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;...
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...
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?
...
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 ...
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...
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...
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...
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...
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?
...
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...
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_...
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...
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...
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.
...
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...
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...
Does it matter which way I declare my C++ programs?
...
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...
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.
...
In some versions of UNIX there's a banner command (usually /usr/bin/banner) that prints great output like this:
##### ####### # ##### # #
# # # # # # # # #
# # # # # # #
##### # # # # ###
# # ####### # # #
# # # # # # # # #
...