Posts

Showing posts from September, 2012

Javascript and other coding standards

Addy Osami article link to a number of guides D. Crockford http://javascript.crockford.co m/style1.html http://javascript.crockford.co m/style2.html http://javascript.crockford.com/code.html  But we use a++ and may differ some re whitespaces. Googles js style guide Love this guy We've followed yuis code comments guide Some useful info here in these isobar standards but more concise would be better imo. We use jshint and confugure it for our rules for building. USing automated tools as much as possible is critical. Then code walkthroughs can concentrate on higher order questions such as proper use of design patterns, right architecture etc. I think it better to agree on reference standards to follow and then only call out anything extra or different from those. There's lots of good references and it fails to be maintained over time otherwise. Below is an example of rules on a previous project. Coding standards your code must lint and you must run the

PHP copy on write means ok to pass large arrays by value if read only

While doing a code walkthrough with a fellow devs PHP code I saw that arrays were being passed by reference to functions, not because they needed to be changed but because it would be more performant to pass by reference since the arrays were large and would be copied since passed by value. It turns out its actually less performant to do this. PHP will actually not copy arrays by value. PHP uses a "copy-on-write" mechanism which only makes a copy when written to. If your use is just read only then its faster to pass arrays by value, not by reference. If you want to change the array in the called function then you should pass by reference. Note: When passed, Objects are passed by reference value i.e. the ref to the object is passed by value, the Object itself is not copied. Some references   http://stackoverflow.com/ questions/178328/in-php-5-0- is-passing-by-reference-faster   http://stackoverflow.com/ questions/2157799/when-to- pass-by-reference-in-php http://ww

Fix Firefox slowness

My Firefox was dying sloooowww, horrible. This Mozilla fix worked for me: A keeper.

Node.js and nodejitsu

I wanted to checkout node.js a little more and after looking at Heroku, nodejitsu seemed a little simpler so I'm going to create an app on nodejitsu. nodejitsu signup is easy and once I registered and got the email to install:  sudo npm install jitsu -g However I got errors. After checking the nodejitsu notices I gleaned my node version was too old (v.0.6.16) and I needed to upgrade I saw some posts about n, a tool for managing node versions. Using n, I switched to node v0.8.8. That kicked off a few minutes of compiles, but thankfully all worked I ran "npm clear cache" (to be safe) and then reinstalled jitsu It worked! I followed the Getting Started instructions. http://www.nodejitsu.com/paas/getting-started.html I installed their default helloworld and deployed it to: http://dnj.jit.su Yeah, it worked. Baby steps. But I want to load an html file, with my (backbone) js code ultimately.... So I modified the nodejitsu hellow world to load an index.html and