standards

Is there a "canonical" name for a function combining min() and max()?

I find that I frequently end up writing a function that I always call "clamp()", that is kind of a combination of min() and max(). Is there a standard, "canonical" name for this function? It always looks something like this: function clamp($val, $min, $max) { if ($val < $min) return $min; else if ($val > $max) return $max;...

SQL Formatting Standards

In my last job we worked on a very database heavy application and I developed some formatting standards so that we would all write SQL with a common layout. We also developed coding standards but these are more platform specific so I'll not go into them here. I'm interested to know what other people use for SQL formatting standards. Unl...

why does my css render wrong in IE?

you will notice the hover css for the links in the main nav area (grey bar under logo) for this site http://testing.ksischool.com/ works fine in firefox, but IE7 chops off the bottom few padding pixels. why? ...

void, VOID, C and C++

I have the following code: typedef void VOID; int f(void); int g(VOID); which compiles just fine in C (using gcc 4.3.2 on Fedora 10). The same code compiled as C++ gives me the following error: void.c:3: error: ‘<anonymous>’ has incomplete type void.c:3: error: invalid use of ‘VOID’ Now, this is something in external library and I ...

Platform Neutral SQL Statement for INSTR or CHARINDEX

I have a problem writing a SQL statement for both Oracle and MS SQL server. I'd like to write the SQL so that it works in both. I don't want to have to mess around with setting a database type variable and switching I have a column of course names that have values like this: 9RA923.2008W 1223.200710 P0033330.200901 I w...

asp.net: Prevent Generating Server Control Ids

The Problem When using asp.net server controls id attributes such as the following are automatically generated. <img id="ctl00_body_ULRepeater_ctl01_LIRepeater_ctl00_PartImg" src="img.png" /> While I'm not averse to id attributes in general, I try to stay away from using these unnecessarily verbose types of names and use concise, des...

Did HTML's loose standards hurt or help the internet

I was reading O'Reilly's Learning XML Book and read the following HTML was in some ways a step backward. To achieve the simplicity necessary to be truly useful, some principles of generic coding had to be sacrificed. ... To return to the ideals of generic coding, some people tried to adapt SGML for the web ... This prove...

Correct way to pass a variable from the server backend to javascript?

I need to pass a variable that php is aware of to my javascript code and I'm wondering what the correct way to do this is. I already know that I could add this to the page generation: <script type="text/javascript"> var someJSVariable = <?php echo $somePHPVariable ?> </script> But I find this method to be more obtrusive than I'd like...

Why do browsers have such poor support for W3C standards?

I can't figure it out. Is it because the people making the browsers don't care? Is it because we, as developers, already write hack code to get around things that don't work in browser X and Y? ...

Is there a W3C valid way to disable autocomplete in a HTML form?

When using the xhtml1-transitional.dtd doctype, collecting a credit card number with the following HTML <input type="text" id="cardNumber" name="cardNumber" autocomplete='off'/> will flag a warning on the W3C validator: there is no attribute "autocomplete". Is there a W3C / standards way to disable browser auto-complete on sensi...

Is it legal to use the increment operator in a C++ function call?

There's been some debate going on in this question about whether the following code is legal C++: std::list<item*>::iterator i = items.begin(); while (i != items.end()) { bool isActive = (*i)->update(); if (!isActive) { items.erase(i++); // *** Is this undefined behavior? *** } else { other_code_...

WS-* standard for telling a service that I do or don't want specific optional parts of an XSD

Hi Guys I have an XSD which describes the data that is going to be sent back in response to a request. For example, my service may be focused on requesting client details. The XSD in question describes what data items are going to be sent back and one of these data items is the details of the organisation that the client works for. In th...

HTML form submission with no submit button

I've got a form like this: <html> <body> <form onSubmit="alert('Just got submitted');"> <p> Hello: <input class="field" type="text"/><br/> Goodbye: <input class="field" type="text"/><br/> </p> </form> </body> </html> which in one browser submits happily on user...

How to avoid magic numbers when matching an event.keyCode in javascript

Can I avoid magic numbers when matching keypresses in javascript? An example would be using 13 to match the enter key. I could specify my own constants, but I don't know if these values are stable enough across different platforms/browsers/locales. ...

Microsoft _s functions, are they part of the C++ standard now?

I just recently changed my IDE to MS Visual Studio 2005 coming from MSVC++ 6, and I've gotten a lot of deprecation warnings. Rather than ignore the warning, I started to change them to the _s equivalents. However, I then found out that these were microsoft-only implementations. I read somewhere that they were pushing for these to beco...

Should web based applications follow web standards?

By day, I am a front-end web developer but in my off time I dabble with other languages such as C, Objective-C, Python, etc. When I first got into web development the idea of web applications was just getting started. Since then two amazing frameworks have appeared, SproutIt's SproutCore and 280 North's Cappuccino (+Objective-J). Sprout...

Difference between void main and int main?

Does it matter which way I declare my C++ programs? ...

When to use ellipsis after menu items

In pretty much all applications that have a menu bar, some of the items have an ellipsis (...) after them, and some don't. Is there a well known convention on when to put that ellipsis there and when not to? When do you do it? Do you do it? I have looked at various windows applications, and this is what I have come to: Ellipsis Menu...

Does the C standard define a stack overflow behavior?

Is there a defined behavior for handling a stack overflow? Apart from terminating the process, it doesn't seem like there's a whole lot that can be done. I'm just wondering if anyone might know what the C standard has to say about it. ...

What's the deal with the banner command?

In some versions of UNIX there's a banner command (usually /usr/bin/banner) that prints great output like this: ##### ####### # ##### # # # # # # # # # # # # # # # # # # ##### # # # # ### # # ####### # # # # # # # # # # # # ...