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:
div.myId>span.myClass
and with a hotkey (such as Tab in IntelliJ) it expands to this:
<div class="myId"><span class="myClass"></span></div>


Need another example?  
 This:
table>thead>tr>th*5^^^tbody>tr*2>td*5
becomes this:
<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

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.

Tuesday, October 29, 2013

Understanding css style rule precedence

CSS style rules have precedence depending on what kind of selectors you have.  For example, a selector on an id has higher precedence than one just on element type.  But it’s more complicated than that.

Here’s a quick read that I found helpful:

(re-post) "The Two Things"

I'm re-posting this article I learned about from The Dev Show podcast:

The Two Things about Computer Programming

Thursday, October 24, 2013

Set goals to work on both strengths and weaknesses

In a one-on-one with my manager some weeks back, it was time to set some goals.  An idea came to mind, based on some religious literature I'd been reading.  I decided to choose two goals to work on: one goal would focus on a weakness, and one goal on a strength (on increasing a talent I already had).

I thought I was a fairly good communicator.  I felt that was a strength--I had been complimented on my communication skills by a previous manager, and I felt fairly confident about my abilities--especially my written abilities.  Once I started working on this with my manager, I realized I had a lot to learn.  As I included him in more of my communication and got some constructive feedback, he helped me see additional ways to improve.  I attended a couple training classes offered by my workplace on emotional awareness and other topics.  I talked to another manager about a couple communication techniques.  I read a couple blog posts I could find via Google. In the end, it turned out I had a lot to learn, and I was left feeling like I hadn't learned all I could.

This was an important lesson for me.  There are plenty of weaknesses any of us can work on.  But in all my efforts to overcome weaknesses, it can be easy to forget to take time to build on my talents, my strengths.  Incidentally, by looking to improve on my strengths, I realized I could learn a lot from those around me, and it was appropriately humbling--humbling in a good way.

God is good to me.