Archive for the ‘javascript’ Category

Code Smell

“In computer programming, code smell is any symptom in the source code of a program that possibly indicates a deeper problem.” — Wikipedia I found this piece of code this morning, I think it counts as something gone terribly, terribly wrong: return displayItemDetails(this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode, 14059111); (The code was in-line JavaScript, inserted into a onclick handler, generated [...]

Posted by Matthew on July 4th, 2011

Filed under javascript, programming | No Comments »

javascript; sending me insane

>>> [] [] >>> [] == true false >>> [] == false true >>> [] == [] false >>> false == false true

Posted by Matthew on January 19th, 2010

Filed under javascript, programming | 1 Comment »

array_unique javascript snippet

function array_unique(a) {     return a.reduce(function(u, e)     {         if(!(e in u))             u.push(e);         return u;     }, []); }

Posted by Matthew on February 23rd, 2009

Filed under javascript, programming | No Comments »

Javascript map-sort

I’m sure sorting method has a real name, but I’ve had no luck searching for it. function mapSort(array, mapFunction, sortFunction) {     // Store both original value, and transformed value     var mapData = array.map(function(e)     {         return [e, mapFunction(e)];     });         // [...]

Posted by Matthew on January 20th, 2009

Filed under javascript, programming | No Comments »

Javascript…

Javascript is both infuriating and awesome at the same time. I don’t think I’ve ever speant so much time tracking down annoying bugs (even compared to PHP), yet at the same time it makes functions like the one below very simple to write. For reference, the below code returns a `getter` method that we use [...]

Posted by Matthew on March 23rd, 2008

Filed under javascript | No Comments »

Very simple captcha decoding using the Canvas tag

Ever since learning about the canvas tag, I’ve been wanting to try this…. Yes, the captcha I used is amazingly simple to break, but, I doubt I'm smart enough to tackle anything more complicated. Though I feel it still serves a good proof of concept (espcially when combined with Greasemonkey) Canvas Captcha Results.png (57 KB)

Posted by Matthew on February 10th, 2007

Filed under javascript, programming | No Comments »