Archive for the ‘javascript’ Category
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)];
});
// Sort the data using the second element of [...]
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 [...]
Digg: Javascript overload?
The Digg front page (28KB) requires 2 (3?) CSS files and 17 Javascript files to be downloaded before it can be displayed. This shouldn’t be a problem as the files should be cached on the first visit. But I wouldn’t be here writing this if that was the case. It appears that max-age [...]