## Friday, August 8, 2014

### Resource Monitor - something you already have (Windows) and should use.

http://www.hanselman.com/blog/YouArentUsingResourceMonitorEnough.aspx

## Friday, May 30, 2014

### If you work with HTML much at all, use emmet.

Make sure you know how to use
emmet. It has plugins for every
major IDE and text editor out there.

http://docs.emmet.io/ (watch the short intro video)

Basically, you can type something like this:

and with a hotkey (such as Tab in IntelliJ) it expands to this:

Need another example?

This:

becomes this:

http://docs.emmet.io/ (watch the short intro video)

Basically, you can type something like this:

div.myId>span.myClass

<divclass="myId"><spanclass="myClass"></span></div>

Need another example?

This:

table>thead>tr>th*5^^^tbody>tr*2>td*5

<table> <thead> <tr> <th></th> <th></th> <th></th> <th></th> <th></th> </tr> </thead> </table> <tbody> <tr> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> </tbody>

## Wednesday, January 22, 2014

### List of valid and invalid email addresses

This looks like a good list of test email addresses with which to test an email validation regex. Then again, if you want to get technical, email addresses shouldn't be validated with regular expressions. But to make our lives simpler, I think most programmers do it anyway.

## Thursday, January 16, 2014

### Futures in JavaScript

This was a useful article to read:

http://www.xanthir.com/b4PY0

It explains what futures are (a relatively new feature in JavaScript, from last year) and how to use them. This is useful when managing ajax-heavy applications when you have to deal with errors, chaining, combining, waiting, and ordering of ajax calls--among other things.

MSDN also has a good article on futures:

http://msdn.microsoft.com/en-us/magazine/gg723713.aspx

http://www.xanthir.com/b4PY0

It explains what futures are (a relatively new feature in JavaScript, from last year) and how to use them. This is useful when managing ajax-heavy applications when you have to deal with errors, chaining, combining, waiting, and ordering of ajax calls--among other things.

MSDN also has a good article on futures:

http://msdn.microsoft.com/en-us/magazine/gg723713.aspx

## Wednesday, January 8, 2014

### Data types for dollars

"A discerning developer just declared that when dealing with dollars, doubles are a dodgy deal".

Don't use float or double types to handle money in your programs. Use BigDecimal instead, or something equivalent in non-JVM languages.

The 'float' type has only 6 or 7 digits of accuracy, although it may appear to have more precision. Money values over $150K will start losing precision at about a cent at a time just from raw display, and there may be larger rounding errors when doing computations such as sales tax. The float type has a "mantissa" (the numerical part aside from the exponent) of 24 bits--this is where you get 24 bits of accuracy; 2^24 = 16777216, and if this is a monetary value then you are losing accuracy after you get over $167,772.16 -- if the only thing you are doing is displaying numbers. You may have fewer significant digits when you start doing calculations.

Using the 'double' type is less dangerous, but still prone to errors especially when doing mathematical operations on money. Double values have 14 to 15 digits of accuracy, but during financial calculations such as sales tax or interest rates, you might be losing pennies that eventually add up to millions.

This emphasizes the importance of testing not merely big numbers, but numbers with many significant digits.

Here's a handy guide to the problem of using floats, in a variety of contexts.

BigDecimal, on the other hand, represents decimal values as integers and an exponent. They can store arbitrary-precision values, as well as compute them accurately while giving you explicit control over rounding.

Don't use float or double types to handle money in your programs. Use BigDecimal instead, or something equivalent in non-JVM languages.

The 'float' type has only 6 or 7 digits of accuracy, although it may appear to have more precision. Money values over $150K will start losing precision at about a cent at a time just from raw display, and there may be larger rounding errors when doing computations such as sales tax. The float type has a "mantissa" (the numerical part aside from the exponent) of 24 bits--this is where you get 24 bits of accuracy; 2^24 = 16777216, and if this is a monetary value then you are losing accuracy after you get over $167,772.16 -- if the only thing you are doing is displaying numbers. You may have fewer significant digits when you start doing calculations.

Using the 'double' type is less dangerous, but still prone to errors especially when doing mathematical operations on money. Double values have 14 to 15 digits of accuracy, but during financial calculations such as sales tax or interest rates, you might be losing pennies that eventually add up to millions.

This emphasizes the importance of testing not merely big numbers, but numbers with many significant digits.

Here's a handy guide to the problem of using floats, in a variety of contexts.

BigDecimal, on the other hand, represents decimal values as integers and an exponent. They can store arbitrary-precision values, as well as compute them accurately while giving you explicit control over rounding.

Subscribe to:
Posts (Atom)