Monday, March 23, 2009

javascript for each loop

I ran into an issue today with the javascript for each loop. The for each loop would run one extra time and return the value "each" for the variable "field" in example below.

Example 1
for(var field in array){
//some code
}

To solve this I switched up the for each loop to do it this way instead.

Example 2
array.each(function(field){
//some code
});

Not sure what the difference is between Example 1 and Example 2.

Thursday, March 19, 2009

cfqueryparam cf_sql_decimal scale default

A few months ago I was debugging some code that was rounding to the nearest int even though the data being entered was of decimal type. I checked the code to see if round() or numberformat() was being used, but they weren't. I started throwing dumps in the cfquery and noticed that before the decimal var entered in the cfqueryparam it was a decimal, but when the query was ran it was of type int. I was totally confused on how the number was being formatted. Turns out there is a scale attribute I was unaware of on cfqueryparam. The scale attribute is defaulted to 0 and is only applicable to cf_sql_numeric and cf_sql_decimal. I think it's kinda pointless for cf_sql_decimal to have zero decimals. Anyways I ended up adding scale to cfqueryparam with a value of 2 and fixed the issue.

I can see why scale of zero would make sense for cf_sql_numeric but not for cf_sql_decimal.

Monday, March 16, 2009

ColdFusion and PDF font-size pt vs px

So a few months ago I was walking by a developers desk and stopped when I saw him frustrated with some ColdFusion PDF output. He was working with font size's in using pixels (Ex. font-size:15px;) and it was not rendering the same in FireFox and IE. I sat down with him for a bit and we both thought using pixels instead of points (Ex. font-size:15pt) would be compatible across browsers. Our idea was wrong. I went back to my desk and played around with the compatibility of different pixel sizes in the two browsers but had no luck. Giving up with the pixel's idea, I then tried pt. Using pt worked far better then px when dealing with PDF.

Air Boards / Hover Boards

So I was driving to a ski resort to snowboard with my girlfriend and it was 50 degrees. My thoughts as I drove with the A/C blasting, were "I am going to loose 10 pounds in sweet today" and "What were thinking? It's way to warm to be doing this". As I rolled down the window to let some fresh air in, I started thinking about the movie Back to the Future and those crazy cool air boards they had in the movie. We arrived at the ski resort and went snowboarding, threw some snowballs at each other and sweated are butts off. We ended up going home early, so I hopped on Google to do a little research on air boards.

I found a website on how to create an airboard http://www.wikihow.com/Create-a-Hoverboard . It's sounds super easy, reasonably inexpensive (criagslist) to do. Here's a calculator that I found super handy to calculate dims,lift,and power http://www.rqriley.com/hc-calc.html.