Archive for April 22nd, 2008

What’s up with CakePHP?

Tuesday, April 22nd, 2008

I’ve had my focus in a lot of other areas for a few weeks, and in that time is seems like quite a bit has happened on the CakePHP front. It seems that there has been a subtle shift in how the framework will evolve from here forward. gwoo puts it much better than I can in his recent bakery article, “After 3 years, looking back and moving ahead“. In the grand scheme of things there are much more interesting things between the lines of what gwoo has written, however the thing that got me most excited was located at the very end:

Stay tuned for more new developments and expect the next 1.2 release in the coming weeks.

JavaScript parseInt Usage

Tuesday, April 22nd, 2008

I have had a bit of a hair pulling experience over the last few hours, until finally I got some sense and looked at the Definition and Usage of parseInt. Here’s the example:

<script type="text/javascript">
   var data = new Array('007', '008', '009', '010');
   for(var x in data)
   {
      console.log(data[x] + ' -> ' + parseInt(data[x]));
   }
</script>

And the result:

007 -> 7
008 -> 0
009 -> 0
010 -> 8

What I wanted was the result 7, 8, 9, and 10. The result seen above comes from the fact that, because I have a leading 0 in my strings, parseInt is reverting to a base 8 (octal) radix. The solution of course is to specify a base 10 (decimal) radix.

<script type="text/javascript">
   var data = new Array('007', '008', '009', '010');
   for(var x in data)
   {
      console.log(data[x] + ' -> ' + parseInt(data[x], 10));
   }
</script>

And the result:

007 -> 7
008 -> 8
009 -> 9
010 -> 10