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!
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)) {
fun.call({emit:emit}, i, obj[i]);
}
}
return ret;
}
mapObj() takes an object and a function, applies the function to each property of the object, gathers up the result and returns it as a new object. The function supplied to mapObj is called with two parameters, the key and value of the current property. To add properties to the final object, call this.emit(key, value) from the function. This may be called any number of times for each property (including zero).
Here’s a usage example:
var obj = {a:1, b:2, c:3, d:4};
var obj2 = mapObj(obj, function(key, val) {
if (val != 2) {
this.emit(key.toUpperCase(), val*2);
} else {
this.emit(key, val);
this.emit('aaa', 'bbb');
}
});
// {A:2, b:2, aaa:'bbb', C:6, D:8}
Maybe someone will find this useful.
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 chili, and a chipotle for that nice smoky flavour. Just like whatever you have on hand. Throw in some other spices as well, stuff like cumin, oregano, cilantro, paprika. Teaspoon of sugar, maybe some lemon juice. Maybe add some water and let it boil down to get everything together and tasty-like.
Cook a whole bunch of french fries. Preferably in a deep fryer, if you have one. I have one, it’s awesome. You should get one if you don’t have one. Throw them in a casserole, add some salt if you like. Pour on the meat-chili-stew-thing, add some jalapenos, and cover with a couple handfuls of grated cheese. Bake in the oven until the cheese is melted and golden and/or you’re desperately hungry.
Serve with sour cream, salsa and an antacid.
Computer scientists used to assume that understanding human language, both written and spoken, was a crucial step in creating computers with levels of intelligence approaching that of humans. However, the truth seems to be the other way around, and it’s getting more and more unlikely that we’ll ever achieve either.
So, Panic are recruiting beta testers for a truck-related product.
But what is that? A “Creative writing space”, right there in the sign up form? It’s too tempting: Here is my Panic Beta Sign-Up Short Story.
The snow was falling and making his beard white, but he didn’t notice as he walked swiftly, almost ran, down the crowded street. “There’s still time,” he thought as he narrowly avoided running into a stressed mom with enough christmas presents in her stroller to obscure the baby. Maybe there is no baby, maybe there never was one. He had no time to ponder such questions.
A gust of wind stole his hat, but he managed to snag it before it hit the ground, and he continued on his way. He only had a couple of minutes left now. The first snow of the season was almost ankle height by now, however the snow was not on his mind at all. He could not consider these things, not now, not with so much at stake.
Finally, he was almost there. From across the street, he saw them take in the sign, but he knew he could make it. And he did.
One minute before closing, he walked into Starbucks and ordered his five-adjective latte.
When he was back outside, he watched the snow.
Needless to say, the Textmate bundle went straight into my repository. Incredible stuff.
My name is Arne Martin Aurlien. I run this thing. Here’s a few facts about me:
Here’s a few things I have made: