Sunday, April 24, 2011

A new name for you

The world is steadily moving away from exchanging the phone numbers towards exchanging the online handles. For example, getting people friended on facebook.

This is quite annoying for me, because, even if my first name is pretty easy to spell,
the last name is as far from something easy like "Smith" as it can be.

So I inevitably end up writing it. Boring. Now, lately I've used a different trick. telling people to search for the stuff I am involved in, e.g. "Happy Eyeballs" make for a pretty good search to fish my name and contact info from.

Now, I thought why not do it in a bit more dedicated fashion - and just grab a domain that is easy to remember for normal people, and hook it to a key-value store.

Here comes the secondna.me.

go to secondna.me to search on someone's "second name", or create your own - the "second name" can really be anything that is easy to remember and does not require spelling by letters.

There is no login, no password, everything is write-once-read-many. So, if you have made a mistake, too bad.

The value is escaped to translate the < into &lt; - so, no fancy HTML either.

Just good old plain text.

If you think it does look fugly, I agree. But I think the utility trumps the looks.

Good enough for me, for now at least.

And tell me what you think.

(yes, it's like about.me, after an intensive diet course).

Tuesday, April 19, 2011

A toast to differences

Once upon a time, there lived a gardener. And he grew oranges and lemons. He did not eat enough of the lemons himself, so he sold them in the neighboring village - there they grew bananas, but they were too lazy to grow enough of them to feed the entirety of the village. So, every day they bought lemons from him, and picked those poor souls who were to feed with lemons.

Needless to say, the poor souls had hated the nasty fruit - it gave them the pains in their bellies. And soon they started to hate the gardener himself - yet, they continued to buy the lemons from him.

It was a very saddening fact for the gardener - after all, he was honestly growing his best fruits - and the oranges were not bitter at all - sweet and refreshing. So, one day he decided to make a pleasant surprise for his faithful customers that should make them happier - he brought them oranges instead of lemons, but did not tell.

The customers were enraged - "Not only you exploit us by selling these bitter fruits to us, but now you also brought them in rotten color and blown up shape!". They've beaten the poor gardener, and trashed his cargo.

So, let's have a drink to the gentle attention for differences - if you're a gardener, try to sell not just lemons alone; and if you're on the market buying - not everything that is slightly round is bitter.

Monday, April 11, 2011

A story to remember when you are afraid to fail...

Found a great anecdote here, translating:

The stage: Autumn. A lake. Wild geese are warming up to start flying to the south. At the front a well-built goose is stretching his muscles, all enjoying himself and looking forward to fly, when a little gray duck approaches him and starts the dialog:

- So-o-o-o... You're fly-i-i-ng south ?
- Yeah. Gotta fly south. It's warm there.
- So-o-o-o... A-a-and... I will sta-a-ay here... To Fre-e-e-eze...
- Come on, let's fly with us. Southbound.
- So-o-o-o... You've got big wings... I do not... I will fall and die...
- No problem - we'll catch you and keep you up. Air streams and all that.
- So-o-o-o... But I will get hungry on the way... And die-e-e-e-e...
- We're gonna pick up the bugs. Big, fat and tasty bugs.
- So-o-o-o... The bugs are bi-i-i-ig... Your beaks are bi-i-i-ig... Mine is small... I will choke and die...
- No problem, we'll chew them up for you. You're gonna make it.
- So-o-o-o...

(the goose straightens up and looks at the duck):

- Okay. Fuck off.
- So-o-o-o... As usu-u-u-ual... Exactly as I tho-o-o-ought... (while walking away).

Tuesday, April 5, 2011

A functional (almost) prelude on the topic of mergesort

I know of table.sort, yes. But thought it was fun nonetheless.


function apply(x, f)
for i, v in ipairs(x) do
f(v, i)
end
end

function filter(x, f)
local out = {}
local fa = function(v, i)
if f(v, i) then table.insert(out, v) end
end
apply(x, fa)
return out
end

function merge(...)
local args = { ... }
local out = {}
local fa = function(v)
table.insert(out, v)
end
apply(args, function(v) apply(v, fa) end)
return out
end

function sort(x)
if #x < 2 then
return x
else
local ix = math.floor(#x/2)
local smallx = sort(filter(x, function(v) return v<x[ix] end))
local samex = filter(x, function(v) return v == x[ix] end)
local bigx = sort(filter(x, function(v) return v>x[ix] end))
return merge(smallx, samex, bigx)
end
end


function show(x)
apply(x, print)
end

a = { 1,3,2,4,2,1,1,23,12,22 }
show(sort(a))


NB: of course this is *not* a functional style by far, since the apply() assumes the f() will have the side effects.