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 [...]
javascript; sending me insane
>>> [] [] >>> [] == true false >>> [] == false true >>> [] == [] false >>> false == false true
array_unique javascript snippet
function array_unique(a) { return a.reduce(function(u, e) { if(!(e in u)) u.push(e); return u; }, []); }
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)]; }); // [...]
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 [...]
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)
