July 2010
3 posts
Oh, and by the way
A sincere THANK YOU to all those who have given color.aurlien.net the upwards-ponting thumb on StumbleUpon — I’ve had over 25.000 visitors in a month, which is awesome. Thanks, guys!
map( ) for Javascript objects
I recently had use for a map()-function while writing Javascript. Javascript has Array.map(), and jQuery has $.map(), but those only works on arrays, and I needed one that could do its magic on objects. So I wrote this one:
function mapObj(obj, fun) {
var ret = {};
var emit = function(key, value) {
ret[key] = value;
};
for (i in obj) {
if (obj.hasOwnProperty(i)) {
...
Here’s what you do:
First, chop an onion. And some garlic. Couple of cloves, I dunno.
Fry in some oil until tender. Toss in some meat. Like, half a kilo of minced meat or something. Keep frying until it’s, like, fried.
Add a couple of chopped tomatoes, and some salt and pepper. Can’t do without that shit. Then start adding head: Maybe a couple of red chili peppers, a habanero if you’re feeling feisty. Some dried...