Friday, December 31, 2010

Installing VMWare ESXi CLI on ubuntu 10.04

This post in forums and this post in forums had proved to be quite useful while sorting out the things.

The magic sequence that seems to have made the vmware CLI work on my ubuntu 10.04:

sudo apt-get install libssl-dev
sudo apt-get install libxml-libxml-perl
sudo apt-get install libclass-methodmaker-perl
sudo apt-get install libcrypt-ssleay-perl
sudo apt-get install libio-zlib-perl
sudo apt-get install libio-compress-perl

Thursday, December 30, 2010 pilot on mongrel2

Finally today I moved in pilot mode the site (IPv6 brokenness test) to use the mongrel2.

The code for the ipv6 test site is in the git repository for gliese (with tiny differences like ports, etc.)

Let's see how it fares.

Tuesday, December 28, 2010

How to install Mongrel2 on Ubuntu with little pain

This post is about installing the latest and greatest of Mongrel2. Moreover - it is biased towards my needs (e.g. Mongrel2 repository automatically exported into git repository from fossil in the process of installation - because I am used to git more; as well as installs my gliese framework and dependencies.)

With that disclaimer, here is the magic link:

what you need to do is wget this file and then run it:

wget --no-check-certificate

Certificate check is disabled because wget seems to dislike the wildcard cname in the cert. Alas.

When you download this file, run it - "sh ./install".

The first batch is a lot of packages that are installed via apt-get, and it will prompt for the sudo password.

After that bunch of packages/software are downloaded in source form - namely: zeromq, redis, fossil, mongrel2 and the associated lua libraries from github.

When the installation has finished, you can test it:

"cd dist/lua/gliese/examples/m2-site; sh run-all-in-screen"

and then connect with the browser to http://localhost:6767/lua1 - this will present you a small dynamic page with the counter stored in redis. This allows to see that all the components are installed and are functional.

If you want to hack on mongrel2 - then feel free to poke in mongrel2-git directory - that one contains the git repository autoconverted from fossil in the process of install. I liked fossil a lot - but just got used to git more, so that's the reason I do it in this script.


Wednesday, December 8, 2010

Building Mongrel2 on ARM architecture

The past weekend I got mongrel2 to build and on my sheevaplug. Not really rocket science, but in case anyone is interested or has some more experience (more on that in the end of the post), I'll document what I did.

First thing - installing the prerequisites, that was easy, just apt-get them - same as anywhere else.

So, then I kick off the make and get:

cc -g -O2 -Wall -Isrc -DNDEBUG -c -o src/task/context.o src/task/context.c
src/task/context.c: In function 'makecontext':
src/task/context.c:97: error: 'mcontext_t' has no member named 'gregs'
src/task/context.c:101: error: 'mcontext_t' has no member named 'gregs'
src/task/context.c:102: error: 'mcontext_t' has no member named 'gregs'
make: *** [src/task/context.o] Error 1

This does not look cool. Let's see the offending part of the code in src/task/context.c:

void makecontext(ucontext_t *uc, void (*fn)(void), int argc, ...)
int i, *sp;
va_list arg;

sp = (int*)uc->uc_stack.ss_sp+uc->uc_stack.ss_size/4;
va_start(arg, argc);

for(i=0; i<4 && i uc->uc_mcontext.gregs[i] = va_arg(arg, uint);

uc->uc_mcontext.gregs[13] = (uint)sp;
uc->uc_mcontext.gregs[14] = (uint)fn;

Okay, this is not too shabby - means this is an ARM-specific code. But, if this is ARM-specific code - how comes that we have a mismatch for the type ? And why do we need this code to begin with - "man makecontext" shows it there ? Quick Google search shows the makecontext is not defined on the ARM architectures, obsoleted API, bla bla bla. Anyway let's test what do they mean by "not defined" with a dumb app.

ayourtch@ubuntu:~/test$ cat test.c

int main(int argc, char *argv[]) {
makecontext(0, 0, 0);

ayourtch@ubuntu:~/test$ gcc test.c
/tmp/ccOO8Fqq.o: In function `main':
test.c:(.text+0x24): warning: warning: makecontext is not implemented and will always fail
ayourtch@ubuntu:~/test$ gdb a.out
GNU gdb 6.8-debian
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "arm-linux-gnueabi"...
(gdb) disass makecontext
Dump of assembler code for function makecontext:
0x000082e8 : add r12, pc, #0 ; 0x0
0x000082ec : add r12, r12, #32768 ; 0x8000
0x000082f0 : ldr pc, [r12, #3368]!
End of assembler dump.

Okay, surely they really mean it - this code seems indeed like just a plug. No-one's home. At least we have a warning. So what they say on the interwebs is true, and that's why we're dragging this ARM-only function implementation.

Let's take a look at where this structure is defined.

$ grep -R -A 10 mcontext_t /usr/include
/usr/include/sys/ucontext.h:typedef struct sigcontext mcontext_t;
/usr/include/sys/ucontext.h: mcontext_t uc_mcontext;
/usr/include/signal.h:/* This will define `ucontext_t' and `mcontext_t'. */

This structure defines the mcontext_t as follows:

typedef struct sigcontext mcontext_t;

And the sigcontext is defined in /usr/include/asm/sigcontext.h:

unsigned long trap_no;
unsigned long error_code;
unsigned long oldmask;
unsigned long arm_r0;
unsigned long arm_r1;
unsigned long arm_r2;
unsigned long arm_r3;
unsigned long arm_r4;
unsigned long arm_r5;
unsigned long arm_r6;
unsigned long arm_r7;
unsigned long arm_r8;
unsigned long arm_r9;
unsigned long arm_r10;
unsigned long arm_fp;
unsigned long arm_ip;
unsigned long arm_sp;
unsigned long arm_lr;
unsigned long arm_pc;
unsigned long arm_cpsr;
unsigned long fault_address;

As such, we need to adjust the code accordingly - to use the arm_XXX named members instead of the array (but array was so convenient!)

After this we can compile everything, but alas, the segfault happens at the very first test.

Why ? Because the libtask's ARM definition of mcontext_t assumes starting with R0 content - but on sheevaplug I can see 12 bytes of other content in front.

My first attempt was to modify the assembler code, to add 12 to the structure pointer on use - but in the end I came up with I think a (slightly) better approach - instead of passing the address of the mcontext_t structure, on the ARM architecture I pass the address of the R0 member withiin the structure, typecasting it to (void *).

This avoids the need to dig into assembler code.

Now I can successfully run mongrel2 on sheevaplug.

However, this leaves me with the question:

Inevitably, the original code ran on *some* ARM. So if the code with the diff from broke the build for you - let me know, so we can fix it properly for everyone - I do not have other hardware.

Tuesday, November 23, 2010

Disable HTTP pipelining in Ubuntu

Mostly a note to self so I do not have to work to find it next time.

echo 'Acquire::http::Pipeline-Depth "0";' >> /etc/apt/apt.conf.d/00no-pipeline

(EDIT: the title seems to suggest it is a 'generally good idea' to do it - no, it is not. It's a workaround.)

Wednesday, October 20, 2010

The justice

It's Friday. The week is over. Stu liked Fridays. Because they aired his favourite show on the WTV - "The perfect crime". Every week they'd pick up one of the cases where the jury failed to find the consensus - and rerun it on air live. And collect the instant responses from the audience to make the verdict based on the simple majority. The direct democracy: crowd wisdom at its best. The audience would make a decision whether the person goes into the recycler or not. There were thousands of the replies - one can't be wrong with such a sample. But still the result was uncertain each time until the last moment. He liked the tingling sensation these shows would bring - it reminded him the good old times before the machines took it away from him.

He was a skyscraper window washer. He was not in it for the windows - it was that tingle sensation that attracted him. He mastered the corner wipe better than everyone and was rightfully proud of his skill. But he could not compete with the machines - they were cheaper - did not require insurance and would never make mistakes, except when mis-programmed. He helped the geeks who came with the machines to hone their skills, but being the cyber-shepherd was not for him, so he moved on to become an instructor in the local climbing club and opened a little food shop in the ground floor of his house. But all of that was not the same - and that's why he liked Fridays.

Today's case promised to be interesting. It was an investigation into an accident that was suspected to have been cooked. The defendant, a young woman, was fully aware she was the only available suspect - and has already told her story. She was visibly nervous, but in her last words she said that she firmly believed that the nation will judge her right. Because it was not her.

Something in her tone, in the way she was talking, made Stu believe she was a victim of the circumstances. He usually would not press the button during the shows - but today he had a feeling he probably should. Even though almost every time they'd say something to try to convince the public. But this time it was different.

The noise of the broken glass downstairs. Not good - need to check. There's been a few burglaries lately in the neighborhood - someone said it was the gang of homeless, the others claimed it was the underground communist cell refilling the replenished reserves. And this of course had to happen just today, when he had blown off the fuse. Sigh. Got to take a flashlight.

The quick inspection of the door revealed nothing suspicious. Windows - intact as well. The dietary supplements corner revealed the truth. Some visitor had smelled the Valerian and did not properly close it. Flasky, his cat, took this upon himself to fix this - of course, smashing all the rest of the glass in ecstatic joy. So all of that noise was for nothing, after all. The damn animal had just spoiled a nice evening in front of the TV. Stu collected the glass and put it into the bin. Hopefully he can make it in time to at least see the result.

As he was climbing the stairs, he heard the polished voice of the host - "Thank you. Thank you to all who participated in today's poll. The decision was extremely hard for you - the difference is only one vote! But you voiced your opinion, the nation of Tivyland. And the verdict is: Guilty".

Damn cat, he mumbled. Should have listened to Johnny and sterilized it. Gonna do that on Monday. He went on to his fridge and wrote in the planner attached to it, right where the hearts of weekend were turning back into the spades: "Take care of Flasky".

Then he opened the fridge and took another beer. He still had an untouched six-pack and Friday evening was just beginning. There were still some other good shows later on tonight.

Monday, October 18, 2010

The good news

Torro was unlike his mates. He was not excited by those of the boys' games that favored the hesitation of choice in them. What he was fascinated with was having a purpose for himself. He excelled at going towards the goal, rushing to the finish line and blowing past it, tearing the ribbon apart. He was the winner, and the world treated him accordingly - he'd always be in the hot spot of attention. Why was he like this ? Probably the adrenaline rush. Probably the ego. Probably the taste of the fruits of fame. Probably all together.

Bruna lived for today and now. She did not hurry - why rushing past ? It's like going on the express train through the summer forest - all you get is the branches hitting your face and the locomotive smoke. Jump off, close your eyes - can you hear that nightingale ? Wait until the tar dissolves and fall onto the ground - can you smell the strawberries ? You may have forgotten it - because none of the supermarkets can recreate this smell, no matter how hard they try. It dies off as soon as it hits the civilization - getting yourself out of it is the only way to experience it.

- "Hey, Bernie, check this out - "
- "What ?"
- "The news says, down there in Europe, they've forbidden the bull fights"
- "Did they allow the bull fights to begin with ?"
- "Yeah, looks like they did."
- "That's silly. Torturing the poor animals."

Sunday, October 17, 2010


The plane was about to land. The landscape underneath was all squares. They were mesmerizing in their proximity - feels like they are all so close, just a couple of meters away, he could not stop looking at them. This has been his favorite nightmare of all the times - inexplicable and personal, like all the nightmares are. The squares which are at an arms' length and at the same time so far that it feels frightening. He was not afraid of height, but this was not about the height - it was about the strange, magical power of the uncertainty. When he was a little kid, he would imagine throwing the ball at these squares, and whenever the ball bounced, he knew the squares were close and small - not those huge ones that are kilometers away that he was afraid of - then he would go to sleep again.

Today was different - it was window behind him and the squares, so he could not use his trick to understand where they are - and this filled him with the anxiety. Hopefully the pilot does know how high they are. And it better be those huge ones far away - otherwise there's no time even to take the position that they show during the briefing in the beginning of the flight. He remembered it was resembling the fetal position, as much as the safety belts permitted it. Maybe worth doing that just in case - but if his feeling about the height was wrong then it would look embarrassingly stupid.

Like that guy that ran with all his belongings when the fire alarm falsely rang in the middle of the night. He chuckled. In any case, if the plane would have slammed the ground, not a whole lot of the positions would help. Someone cynical once told him that the sole purpose of these positions in the airplane was to preserve the jawbones as intact as possible during the accident - then it is easier to identify the passengers, by their teeth. Like archaeologists do. Screw that, no one is waiting on either side of the route - so whether they would be able to assemble the teeth or not, does not really matter. They'll find it from the engraved label on his luggage, if they want.

Strangely, he was not afraid of the magical squares anymore - the nightmare becoming the only hope. He lost the count of time - maybe it was a second, maybe ten minutes - the time went its own ways, independent of him - it felt like an eternity. Finally he felt the shock of the wheels hitting the ground. Landed. So, it was all right after all.

The noise woke her up and she lifted her head - he was sitting on the floor, staring into the carpet. The carpet was a childhood present to her - gentle gray wool, with squared ornament. She liked it, it reminded her of labyrinth, from the favorite book of hers - the legend where the Theseus killed the Minotaur. That was how she met him - he reminded her of Theseus.

- "What's the matter, darling ?"
- "Nothing. I just fell on the floor. Sorry to have waken you up."

Tuesday, October 12, 2010

Disable HTML in Outlook

More of a note to myself really.

Two steps:

1) Tools => Options => Mail format ; "Compose in this message format" - set to "plain text".

This makes all newly composed messages show as plaintext.

2) Tools => Trust center => Read all standard email in plain text.

This makes messages you receive show as plaintext.

Oh, and probably uncheck the scripts, while you are on the latter.

Friday, October 8, 2010

Airfoil. ASCII.

Read on HN about the with the comment "What's the correct answer ?"

I think it is this:


^ counterforce
| lifts the plane
/--- <-- this is a wing
spits hot pollutants <===[engine]===> counterforce /---
pushes /---
forward /---
/--- +---- <=== air hits
| this direction
v air
bounces down

The drawing is imprecise. I welcome you to spot the places where it is.

But it should be correct in principle.

Thursday, September 2, 2010

"This august had 5 sundays, 5 mondays, 5 tuesdays..."

"...and this event takes place every 823 years..." - said the fb update of one of my friends. This meme had then a viral clause attached to it so to ensure its replication - something about money, happiness and all that.

However, it's not the viral clause that caught my attention - but, rather, the "takes place every 823 years" part of the meme, which looked suspiciously fishy - and I decided to make a quick write-up as an after-lunch exercise.

Intuitively, it is simple to see that every August will have 5 of *some* three consecutive days of the week - simply because there are 31 days in august, and there are 7 days in a week - and 31 modulo 7 is three. And the days are consecutive - so this leaves us with 7 combinations of "triples".

The number of days modulo 7 from the "previous august" will give us the shift within days of the week year-over-year. For an ordinary year, it's 1 day (365%7), and for a leap year it is 2 days.

So, if we have the five of sunday-monday-tuesday this august, then the next occurence will be in 2016. If it was not a leap year - then we "overshoot" the target, and need to walk another 6 years. So the next occurence will be in 2021 (11 years after).

Then in 2027 (6 years), 2032 (5 years), 2038 (6 years), 2049 (11 years), 2055 (6 years), 2060 (5 years), 2066 (6 years), 2077 (11 years), and so on.

With the differences forming a nice series: 11-6-5-6-11-...

The period of this sequence is 28 == 11+6+5+6. Which happens to be divisible by 7 (number of days of week in a week) and by 4 (The usual interval between the leap years).

We did not take into the account the years of 2100, 2200, 2300, 2400 - I leave it as an exercise to the reader.

In conclusion - this was a well-crafted meme. It had not one but two replication mechanisms, that were targeting different people. I guess I can say I fell the prey of it. :-)

Wednesday, August 25, 2010

OCR for business cards' photos

I've been curious to try and do the character recognition on the photos of a few of the business cards that I made during the IETF (since otherwise the business cards turn into dust in my jeans' pockets - it was a much better option to make photos).

I've tried gocr, tesseract and the demo version of abbyyocr. The results were pretty much the same as I could find on the web otherwise: gocr was mediocre, tesseract was somehow promising (it could +/- reliably read name and surname - that were written in bold) - and the abbyyocr was actually half-bearable.

To the defence of the software, I must say that the images were far from being a typical OCR-food: shaded, distorted perspective - and the letters were a bit too small.

The interesting effect that I observed though, that when scaling the images *down* from the original to some ~80% the recognition quality increased in all the packages - with the abbyyocr getting to the point of being usable.

The time it took abbyyocr to do the recognition was notably longer. But, if I have to do OCR, among all three I will probably pick that one.

Thursday, August 19, 2010

We will, we will rack you

DISCLAIMER: in case you would not notice. It's a fiction piece - therefore any analogies to the real world are coincidental, hyperbolic and should not be interpreted outside the boundaries of this text or its continuation. Failure to do otherwise may cause the falling bowls of petunias. Thank you for taking care of our environment.

Your Caring Administration.

A swarm of tiny flying insects were hammering at Jack's door. They were so many that their sound resembled a heavy rain. And their synthesized sales chorus was resembling the machine at the dentist's.

".. - We will organize your data for as little as the rights to 2% of it yearly for the first 10 years after your death - .. ".

Damn. It hurts to be the last messed up guy in the area. These were automatic sales agents, tuned to find out the piles of unstructured non-indexed data, and to try to seduce the owners of that data to give it to the army of the all-mighty processing machines of Wiggle.

Wiggle, with their slogan "Your information wants to be free - don't be rude to it!", has expanded quite a lot in the past decade - from a small group of fanatic hackers obsessed with an idea to a large publicly traded corporation. Despite for its size it retained the passion and the hunger for the data that it had for the early days. Their operating principle was simple: you let them arrange your data for you and make it easily fetchable for you, in return you give them the full rights to a share of your information after your death.

For everyone it was as good as free - especially since the majority of the shareholders were in their early twenties - no matter how educated you are, at this age the death itself is a faint ghost, let alone whatever happens after the death - the full-brightness social interactions do not leave any other meaning to life other than "this!". And the letters you write - who cares what happens to them after your death. You won't be there. But it's great to be able to pull just the one you need from out the pile with the elegance of a card magician from the neighboring street.

First it was a neat parlor trick to impress the others, then it became an ubiquitous necessity of everyone's lives. The skills that were needed before were not anymore - this means you can free up that part of the brain for something else, yay! And everyone jumped on the bandwagon. Almost.

Jack was among those who did not. He preferred to keep his cards close to the chest. Not that he had much to hide - only the usual set of human screwups, but he felt naked otherwise. And that was something he hated, hated so much that he hung on to this habit even after it caused a few rather painful breakups - when people come to expect something as a natural property, the lack of it makes you "strange". Even if you think this property is something unnatural (and even if it is) - you are the one who is the gray swan - because you are "deviating from the norm".

Nonetheless, Jack knew where it was coming - that was why he was one of the early purchasers of the shares of Wiggle. And when the first deaths happened, the co-actors of the events that better be left private started to queue up to the offices of Wiggle in order to buy out the information they did not want to be free, literally off the deathbed of their best friends. As disgusting as it may seem - it did not involve selling drugs or trafficking the humans, nor killing the tuna, so it was good enough for Jack - who could happily retire and was now living in a house by the seaside of the El Hierro island.

... to be continued ...

Monday, August 16, 2010

A gift (2/2)

This is a (somewhat unexpected) continuation of the first part. A bit rough, would need further editing.

Heat in the head. Not the one you feel when you are ill, it's different. The heat you feel when you think hard about something. Like in the university,
when they give you a puzzle you haven't solved before, there's a time limit,
and the clock is ticking, and if you don't get it done - you fail the exam. Wait, what's this ticking sound ? Ah, indeed, there's a clock. He opened his eyes. And it shows just after five. He was about to think whether he slept at all when he realized something was strange. Something subtle. The bed, the bedroom it was in - all looked boringly usual. Finally it clicked.

Thin Mint cookie. On the headboard shelf, near the clock. Was that it ? No, something else. What was it ? Ah. His body. Missing. How ? Ah, obviously, that smiling old man and his "mind uploading". They must have kicked him subconscious and syringed a fair doze of cough medicine. But this would not explain this constant buzz in his head - even though his conscious brain was evidently idle, the subconscious obviously was not. But it must be just an effect of DXM. And in any case, the old mofo has ripped him off of 50 bucks - it's only one copy of him, that is visibly - no, mentally - present.

"Or two".

Now that was not him. And it was. The phrase felt like talking with himself yet it was not the controlled dialog - it was an interrupt that carried a wave of the annoyance that was suppressed.

"Idiot. You should not have asked for two copies. Now you get the suffering you deserve!"

- Why ?
- "Do I have to explain to you the perils of the non-standard setup ? Of course not - because it's me who is going to suffer!"
- Suffer from what ?
- "From doing all the work, goddamit! If you did not yet admit that this bloke was not joking, you better do it now! We are indeed now in the 'uploaded' state."
- And how does it work ? I venture it has to do with 6.443J which I missed almost entirely.. Brain alone would require an enormous amount of computational power to simulate - let alone the bed...
- "Probably it does. Because, being your copy, I can't fully comprehend it either.
If not your twaggering, I might have not ended up being such a dweeb."
- Hey, if we are two perfect copies, it's equally your fault same as mine. So, stop offending me, okay ?
- "Fine, you have a point. In any case - I came to consciousness a bit before you had, and searched a bit on this topic. I think this might have to do with the P-NP."
- Transistors ?
- "Idiot. Complexity."
- What would it have to do with the complexity ?
- "There was a supposed proof of it a few months ago. Which was proven incorrect, however it started a lot of talk around the subject. One of the reviewers observed that the problem of solving the 'P!=NP' is an NP problem in itself. The other reviewer observed that both the time and space are computational complexity resources. And the neuroscientists were exploring the hypothesis of quantum brain dynamics. This guy added 2+2 and went a bit further."
- I still can not make sense out of it...
- "That's because your brain is busy simulating me and the entirety of my world - that's where the feeling of 'puzzle' comes from. My and the entire world I am in is your puzzle you are trying to solve. Much like you and your world around you are now inside someone else's brain. Who is in turn inside someone else's brain, and so on. Much like you have with the russian dolls. Except they do not change in size - the time becomes slower so the space 'expands'. That's why it will never be anything later than just after five on this clock."
- But it ticks same as before!
- "That's your brain offering itself a stitch, so it did not go sideways like waves on the water. The sound of tick is local to your consciousness, while the picture of the clock in this case depicts the 'global' time. Don't ask me why."
- Great - so we have uploaded mind which has enough computing power to simulate another uploaded mind, which in turn simulates another one. What's the catch for the uploaded mind ?
- "There's none. Since there are more and more people coming in to the old man, the time has to slow down faster for those "outer" minds. So, their conscious part, with the speed of their thinking, never makes it to being overloaded by the computation required to 'simulate' the inner mind."
- Complicated.
- "It's exactly the same principle as the pension funds. You allocate them your money that you earn so they can invest it into the publicly traded companies, which then pay you this money as wages, which you invest into the pension funds. Your neighbor needs money, so he gets to borrow it from the pension funds, which then sell the debts to other pension funds for more money. The whole system works - if it didn't, you'd not be paying into your pension fund, right ?"
- If your description is correct to any extent and we both are not a split-mind after a hallucinogen overdose, we're past the point of needing to talk about the pension funds.
- "No, we are not. Since it's not just the mind, but the whole world that is emulated - there are pension funds in each of the nested 'russian dolls'".
- And do they all work the same everywhere ?
- "No, of course they do not. The complexity of solving the problem of pensions relates to NP same as NP relates to P."
- This guy is ambitious.
- "And very practical. Remember that you - me - we - paid hundred bucks. And you saw a couple of people coming in over a course a few minutes. So, he appears to have solved the problem of functioning pension funds."
- Does this mean he proved P=NP ?
- "Not at all. He cheated, somewhat. Really you do not care about the "NP" part as soon as you can enumerate all the alternatives fast enough. That's what he did for the best himself and the mankind - a computing device of an ever increasing capacity. It's like a blackhole but instead of sucking in the matter it sucks in the computational power, and overall becomes yet stronger. Or so is my theory - I am still not clear how he would suck out the excess of power that is left after all the work required to simulate the inner worlds."
- And how comes that we are able to talk just like that - if your theory is right then it should not be possible for me to be aware of each other, much like I am not aware of the existence of the "outer" person.
- "We are copies of the single brain. Again, this fact and the supposed quantum properties of the brain, even simulated, have to do with it. It's kind of I say 'bitter lemon' and it makes you feel the taste of it - even though you do not have a head now, much less the mouth and tongue. Don't bug me - I told you already, it's just guesses - you missed too many classes for me to be able to tell it any better".
- It's all good. I'm just killing the time - if your theory is correct, we're going to be the Lewis Carrol live - we are only missing Alice.

Alice Wong was happy - she was about to get married. She did not worry about the ceremony itself - her worry was her wedding ring. The future husband's father himself was supposed to bring it in. The wedding was starting at five sharp, and it was already four fifty seven - but the father was still not showing up.

Finally, she saw him getting through the crowd, to her future husband and giving the box to him. There was something unusual in his look. Maybe that he, oddly enough, had a moon-shaped cookie hooked to his suit - just in place where there'd be a rose. What an odd idea. But the old chap was a strange one. Noone knew how old he was, nor what he was doing. He did not seem to be very rich. But whenever his son started to talk about his plans after the marriage, the father always just hid himself under a friendly but a distant smile and mumbled something about the pension problem.

The ceremony began. The time seemed to fly right past by - even if the mechanical clock on the wall was ticking seemingly with the same speed as before... Here comes the moment... "Do you agree to be my wife ?" - "yes I do" - and he opens the box with the ring....

A gasp rolls over the the room, and dies into a complete silence. The stunning perfection of the crystal in the ring. She catches the reflection of the sun ray. It has the sophistication of hundreds of thousands of man-years of experience. The time stops. She sees an unbelievably fast caleidoscope of images, somewhere in the middle her mind captures the bed with the mechanical clock on it and a mint cookie - same as her now-husband's father had been wearing in his suit. And the clock shows exactly the same time.

It's just after five.

A gift (1/2)

It's been a grim week, each day filled with the non-stop replays of an early Monday morning. Shaldon looked out the window - the outside was not much better. The sky resembled a skin of a newly-born rat, but even the usually noticeable rats in the basement of the building turned quiet, fearing the storm outside.

How ironic, he thought - there's a village with the same name as mine. And they sell the tickets to stay there for a weekend. If I could sell the tickets to stay inside my mind for a weekend, would anyone bother ? But only during the summer time. All the other time of the year he'd want to be left alone. In the pursuit of that, he went as far as not having a permanent job. The seasonal jobs paid enough to save up and hide for the winter, sleeping a lot more than one would consider healthy, and crawling out only to get a couple of sandwiches in a automatic drive-in.

But now, with this weather, it's time for a nap. He decided. The old-fashioned mechanic clock was the only thing on the headboard shelf, ticking quietly but relentlessly. The heads were open like a beak of some exotic bird, opened to an extreme - it was just after five. He felt sufficiently dizzy, so the only thing he took off were the shoes. It will be just a short nap, after all. The storm should be gone soon.

The air of downtown Singapore was hot and heavy. He liked this feeling - you can almost take it in your hands and shape the little funny figures out of it - much like the clowns do by twisting the long and thin balloons - but without. He made himself an imaginary dog to fly by his side and started to walk towards the shopping mall - figures or not, it was seriously hot, an airco would have been a relief. No, not the rain. He had enough of it. Besides, it would destroy his newly made silent and unseen friend. Instead he took a bus and rode a few stops. Now's the time to get off.

Approaching the entrance of the mall, he saw a girl of some nine years of age, standing near the entrance. She had a backpack, and was holding a plate of Thin Mints in her hands. In any other time of the year he'd wonder what she is doing in Singapore - but today he was not inclined to. He pulled a five dollar note out of the pocket, and bought a box. He did not wait for the change she was trying to give. Nor he wondered why he'd buy them in the first place. He wanted to get a breath of fresh air.

The mall indeed had an airco, but it was one of those filled with myriads of the small outlets that sell the counterfeit electronics, sometimes per pack, sometimes by weight, almost like cookies. It was a great place to be in - the building internally was multi-storied and circular, every little business trying to grab a bigger share of attention by winning the competition for the strangest signage. He felt like he was a visitor in a beehive - and all this activity around him was filling him with the sense of activity. He'd even walk faster - without any reason to hurry at all.

A small and boring outlet caught his attention. The sign said "mind uploading". What the hell, he thought - it's obviously impossible. But the old man with the face he could not read by all means did not think so. The old man's smile was friendly, but at a distance. Several people came in, passed the money to him, and disappeared behind the back door. No one came out. Time to try out those cookies. He took a bite - which turned the cookie into a moon-like shape, when the old man looked at him and said: "It's only 50 dollars, sir. Full refund if not satisfied".

Walk away ? This is much stranger than his imaginary dog, still hanging around, or the scout selling the cookies. No way. He automatically put the cookie into his back pocket, and reached for the wallet. Only a hundred. "Make me two copies" - he muttered. "Sorry sir, no animals allowed and you can not take this cookie box inside" - politely, but firmly answered the old man. Well. If this works out it will be much better than both combined - so Shaldon put the box upright on the ground near the wall, and walked towards the back door with no signs of hesitation.

The old-fashioned mechanic clock was the only thing on the headboard shelf of an empty bed, ticking quietly but relentlessly. The heads were open like a beak of some exotic bird, opened in an attempt to catch something. And indeed - the exotic bird was not alone. It was trying to catch a moon-shaped piece of cookie that was just beside it, flat on the shelf. Someone must have started eating it and forgotten it down here - or they were teasing the exotic bird out of their sheer evilness - we do not know.

But we can say with full certainty that it was just after five.

Somewhat unexpectedly, continued here. Warning(spoiler): blatant violations of laws of life and universe and everything is ahead.

Thursday, July 22, 2010

How the facebook could earn extra millions without doing much.

My friend sent me this: a Cow Clicker game. This is absolutely brilliant parody because it encompasses everything strange about the "social Facebook games".

Now, back to the subject - how can Facebook earn extra millions ? I think in the same way. They can use their "Like" button instead. Humans want to be heard. They especially dislike when some other humans are heard and they are not heard. They consume the friend feed in bursts (unless facebook is the only activity they do).

So, the solution is to limit the number of feedback/click items per hour - better, per the interval of something inconvenient like 5 hours. Sell the Facebucks and allow to use those Facebucks to pay for the ability to express themselves here and now.

Tada! Instant revenue stream!

Of course it'd be evil beyond belief.

And presumably the "likes" that help to build the semantic network are more valuable than the money buying them would bring.

But this could be a fun experiment.

Not talking of the fact that having the Facebucks would be a no-brainer side biz for micropayments.

Wednesday, July 21, 2010

The tangible value of time

I've had a thought-provoking experience today: a meeting which got cancelled shortly before. Nothing besides a minor annoyance, but a very valuable trigger to muse on the economic value of time as a function of individual's position in time. Something around the "Time is money" stuff. Lots of terms are in quotes, because this is more of an unsorted dump and less of a coherent essay.

A thought experiment: you ask me to spend 10 minutes now or 10 minutes tomorrow. If I can - I will prefer to spend 10 minutes now. "Now" is "cheaper" for me than "Future" - even though it is in limited supply. "Now" is quickly depreciating - left unused, it becomes a non-redeemable "Past". That's why I try to "sell" the "Now", at a best "price" (usefulness of the activity), so nothing is going wasted into the recycle bin in the corner of Zeus' father cabinet.

So, the most "profitable" strategy for me is to "sell at the edge" - i.e. have little planning at all - the cost of this "just about to be gone" for me is approaching zero. However, since every activity is fitting within the nonzero time interval, this means that the competing activities would meet with the non-determinism - there might be already another thing that I am doing, and the contender, if it is time-critical, will face a "loss".

Seems with the "future", it's really the determinism of my availability that I am "selling" to the "buyers" - in addition to the intrinsic value of "me".
There is a side in this for me too - with the "pipeline of things" the time is allocated, and there is no risk that it goes "unsold" - and if I am able to estimate the "usefulness" of the task for me, then I have a stable "return on investment".

This is similar to a model where someone would pay money "now" to get something in the "future", in an economy with a spiraling inflation. So, "time" is indeed quite similar to money, except the mapping is a bit twisted!

Now, the next question - if the time bears such a strong relationship with money, would it not be interesting to just use the time as a currency ?

So, let's make another thought experiment. Let's assume that the technology allows everyone to print their own currency, and the technology is such, that with every exchange you can see how much of the "units" have been emitted and are in circulation.

"What's the guarantee behind?" - you ask, citing the current money in circulation. With the technology above, the guarantee for the mass of the "personal money" issued by a given individual, is the individual himself. That's when we can exploit the saying "He's worth his weight in gold".

Obviously such a "guarantee" seems scary at first (it looks like some twisted form of slavery), but it is not a problem - to "own" you, someone must be able to continually attract all the "money" you put into emission. Which, unless they produce something you need, is unlikely. Plus, if you are desperate, you can always dilute their "share" by emitting more "money".

This system would some interesting properties.

It would be the economy financially driven by the youth - because the "first emission money" will be the least inflated - therefore of most value. The youth would be able to pay for the education - which would be provided by the elder, who can no longer just "print their money".

With this, it might be that the very core of the society will change (youth being more "naive", if you wish), might just make it for the better. But maybe not.

In any case it would be an interesting experiment.

Now, if that proved to be successful, we can go further, and replace the "personal money" with "personal time".

This interpretation might be even more deterministic - because the lifetime of a person is finite, and is statistically rather well defined.

So you start with your current life expectancy's full of "personal money-time", and get it "vested" in a special way - you have to spend it the moment it is vested or it is lost.

This system would have even more interesting properties. Besides also driven by youth (because they still have more time in front of them), it would also have a very strong inherent motivator for the healthier lifestyle (because then you live longer, which is one of the ways you get richer), and the good for the society as a whole - because the longer the overall society lives, the "richer" it is - which is great for everyone.

This brings a loophole, however - a reproduction can be viewed as a way of "printing money". However, this is maybe not a problem too - as e.g. most of the West have difficulty keeping the birth levels as high as they would want to.

Also, the *way* you spent your past time might also affect the current time's valuation - more educated person would be worth more.

There is one difference between the "personal money" based system and "personal time" based system - the time is something you can spend only once.

But overall, I think it is an interesting system worth modeling. As the technology levels go up - it is not something infeasible to do. It would be a terribly interesting exercise if someone figured out a way to model it.

Not sure how interesting you found this post - but I certainly had a very interesting time pondering. Which means that the today's cancellation was well worth it.

Tuesday, July 13, 2010

Dear chinese-language spammers

Please go away. As you can see, it is not working.

Saturday, July 10, 2010

A lucky strike

Lily was walking past this door for the past couple of years. "Martial arts", said the simply advertisement. She could never make herself come in, even though she really wanted to - the door was always firmly closed. Today it was different - she was sure she heard sounds from behind the door. She pushed it open and came in.

It was an old loft, left untouched by the owner over the course of years. About 10 people - both guys and girls were doing the push-ups - the training session began not too long ago.

- "Ichi, ni, san, chi, go, roku, sichi, hachi, ku, ju, ju ichi, ju ni .." - the counting of sensei was hypnotizing her. Suddenly it stopped.
- "..." - he looked at her, keeping the pause.
- "I would like to ..." - she started, but did not have the time to finish.

He turned back to the group - "Yasme!" - and, pointing to a guy who seemed just a bit too tall to be doing any martial arts, and to Lily: "Jiyu! We see what you are worth".

Smith looked at the girl. Strange feeling struck him. Something of an electric shock. It was hard to explain - this was as if he saw these eyes somewhere, sometime long time ago, when he was much younger and could be just overwhelmingly happy, without a shadow of any other thought. He shook his head but the sensation persisted. He was used to knocking the hell out of newcomers that manage to slide into the door, and sensei liked his style - after the test fight, noone was bleeding, but very few of the newcomers returned, and those that did, were very good students afterwards. But this fight promised to be different. He felt he could not kick the hell out of her. Not in the presence of this itchy feeling. He decided to try to discount the itching as a hunger. He did fight a couple of times like that, and, even inconvenient, it was doable. If he can fool himself that it is a feeling of hunger, that is.

Lily was ready. She was doing martial arts in the town where she lived before moving - and kept her in shape by self-training. This club looked like what she wanted. As soon as she can prove herself in the fight with this guy. In other circumstances she might have found him sexy. The only detail in his looks that was disturbing, was a scar on his face - just above the eyebrow. But it did not matter - today she came for martial arts, not for the dating.


Smith was always careful at the start of these trial fights - testing the other party. And today was not an exception. He was defense-only, and only after a minute started attacking. She did know at least something - his kicks were blocked. And boy, did she move well. Contrary to his attempts, the itching did not want to get disguised. He had to look into these eyes - and it did not help. It did not help at all. This has got to stop, I can't fight this, he thought - this was going through his head almost the same split millisecond as he got distracted and missed the upward movement of her fist, that made his head abruptly go up and backward. "Damn, this way it is as stupid as it gets" - was the last thought before the whole world turned completely black.

He did get unconscious once, back in the childhood. It was funny - you are halfway in your body, halfway out, and can wander around the room. He thought it was pretty cool back then, but for some reason he saw all those people in panic, running around and pushing, squeezing his body, so he had to return. And he never had this experience since. Until today.

He saw the group gathering around his corpse. Hold on, he was not dead yet, was he ? So, it was the body that the group was gathering around. But they were worried nonetheless.

If it could, Smith probably would have sighed - the girl that knocked him out was not part of the frenzy. She just stood aside. And he took the advantage of it. To look again in these sparkling eyes and get a gulp of that old feeling of the overwhelming, worldly childish happiness. How can a bodyless piece of ether even look at things, let alone feel ? We will never know. But he did see these sparkling eyes and felt the itching stronger than before. It was a nice sensation. Worth being unconscious...

...Terribly strong headache. This is the first and the only feeling. Overwhelming, just about bearable. No, it's not. Hopefully the head is still one piece. And all these people around. Who are they ? Where am I ? The head hurts. Can't move. Is it really in one piece ? Move the right hand to check. Yes it is. Thinking long sentences hurts. I was hungry, give me some food. Raise the left hand to ask. Can't. There's no left hand. The left part of the body is gone. Damn. Where it is ? It it was a cut, it'd hurt. But only feel the head. This terribly loud whistling noise. Like an airplane. Who brought me to the airfield ? Stop it, please! What was that hunger feeling ?

Ah, these brown eyes. Sparkles. Sparkles got me on fire. That's why no left side - it has burned off. Need to look what's left. Can't move. But the itching is no more. This is good. Means I can skip the dinner. It's getting dark. Finishing way too late today. Mom's gonna be worried.

Sunday, July 4, 2010

The city of dim

Vegas is a striking experience. Right in the airport you are greeded (sp.?) with a lot of slot machines, flashing lights and the feeling of forbidden.

It's a strange feeling - as if you ended up in a backyard of a small apartment in the boringly usual street, just to find a naked champagne-cognac party with violent fireworks.

The hotel where I was staying, Mandalay Bay, like almost everything in Vegas, is gigantic. But, more impressive is what is not seen from the outside. The hotels that stand near each other are interconnected, and this forms a whole separate city underneath them. A casino turns into a shopping mall, which turns into a betting sports bar, which turns into a casino.

Ah, casino. This was the most fascinating of all the experiences - to watch the faces. The faces of those who work there, the faces of those who gamble. You can immediately distinguish the faces of the true tourists - lit with excitement and fueled by a good doze of alcohol, from the other kind of faces.

Usually in their 40-somethings, these faces are so fascinating it hurts. They depict an almost-lost hope, an almost forgotten happiness, they are in a quest. They have almost given up.

This is the expression you might spot in the faces of the countless waitresses, dealers, casino dancers (though calling this kind of entertainment a "display of flesh" might be more appropriate - there was not much dancing in there). You can spot this expression with a fraction of the players too - usually more with those who try their luck with slot machines. These faces have been so air-conditioned down to an average, that they look almost the same, despite being vastly different. A strange form of sameness.

The air-conditioned coolness of the inner hallways is contrasted with the sauna-grade heat on the outside. Dry heat. Here in Brussels, you pay to get that. But of course, not the entire street filled with it, just a small gas chamber, which you can quickly escape. But in Vegas you can't, not unless you dive back into the shelters of the technology. Here you pay to get a cold around you, all the heat is for free.

When I arrived, the faces of the players was first that made me think of a Inferno-under-construction: "they forgot the boiling kettles part!". However, thinking more of it, I realised it is in fact just a next-gen version, and it's already finished and is functioning full steam.

Here's how it works: you arrive, and get the casino tokens proportionally to the amount of sin, and have to start playing. The more you play, the more you get accustomed to the coolness and the gentle light inside, the more you are wary of getting out into the open air where the sun is showering the ground with radiation. But you inevitably lose in the casino, and then are immediately thrown out into the shadowless street. You are still craving to gamble and are sore of your defeat, and heated by the merciless rays of our closest star.

They'd let you work on the dirtiest jobs, and pay with smaller amounts of money, which you could eventually convert into the tokens for the casino and again be admitted to try your luck and enjoy the artificial coolness. But not for long, and soon you are again being beaten up by the merciless ultraviolet. You are thirsty, but there is no water in the streets. If you crawl around, you'll see the fountains, right in the open air. But you can't drink from them. You can only drink in the casino.

So, you get yourself into the next round - go and find the means of getting back into the shelter, to satisfy your needs for water, gambling, and cooler temperature.

Maybe this is how those folks get their eyes of lost hope ? I won't know. The allotted time is coming to its end - the Brussels awaits me back. Maybe there is a next time, and I find out more about these eyes.

The eyes that are sparkling so dim.

Thursday, June 24, 2010

The drug

A patient in pain is brought to the emergency and has been served shot of drugs aimed to relieve the pain. He never tried the drugs before - and the very thought of this gets him into horror - but there is no way - the pain is too strong even for an energetic person he is.

The drugs help to get a relief, and when everyone falls asleep, the patient jumps into the window and runs away. He continues the shots himself and this allows a bearable life - for a very long time - without attending to the disease. Eventually the disease becomes so evident it is not possible to live with it, the patient will die in a year if they do not cure the disease for good - so he returns to the hospital and asks for the cure.

However, soon the patient realises that curing the disease means no helpful shots of dope anymore. Meantime it has become a routine. It increases alertness and adds to the feeling of well-being. Athletic performance is enhanced - so the routine tasks are done much faster. Sometimes the patient feels the temporary anxiety when looking at the mess around - but, it is short. And it's been a long time - the life without the daily shot seems a hazy mirage, which only has one glaring label on it - the pain.

The pain is gone for good now - and so are the injections. But it feels worse than before. The dependency kicks in. Regular depression. No more euphoria that was offsetting the periods of boredom. It's all gray.

The patient needs to relearn the life from the beginning. All the mistakes he did already but forgot - he needs to do again, one by one. It's a long journey, and every day not once or twice he thinks about taking a magic shot again.

But somewhere there is a hidden thought, the joy of the freedom, the absence of the necessity to fit the entire life according to the need for the next shot.

And this thought brings the meaning back to his life, allows him to continue further even through all the hardships.

It really is worth it.

Living without the life-long dependence.

to the most-debated networking feature of the past decade, with compliments for all the pain it alleviated

Sunday, June 20, 2010

"Your predecessor"

It's a painful reminder about the fragility of life and universe and everything.

Because the "predecessor" means the "one who deceased before".

Which means you too shall die.

Saturday, June 19, 2010

How much are your dreams worth to you ?

I've been always saying (mostly empirically, I never made any detailed analysis) that if you are hunting after money, the IT/telecom work is not your cup of tea. Go into financial - they pay, noticeably more.

However, there is a detail to that. Which was put sharp, to the point it hurt, in one of the comments on the HN thread:

"It's cheap to get that salary, too. All you have to give up is your dreams. My friend who earns £150k hates her job, and used to tell me that every time I saw her."

Maybe this is an isolated case, maybe not. However, this triggered in me an idea for an interview question: "How much of a premium would you require to give up all your dreams ?"

And, it can make up for a good discussion over a beer, too.

Wednesday, June 16, 2010

HTTP parser with ragel

I've wanted to play with the ragel, and as a target I chose to rewrite a HTTP parser made by Zed for mongrel. Partly because I wanted "my own" license, partly because I do not like the way his code handles the split of the fields: if I understand it right, the entire request needs to fit into the buffer. This is not very pure - if I handled something, I should discard it.

The state machine appeared very easy to make - mostly, take the RFC2616, and start transferring the BNF into ragel format.

Then, define the >action_enter and %action_exit for each of the pair of states that denote the data to capture.

The most interesting part was the state-saving mechanism for the case when the field is split between the multiple buffers, e.g.: "GET / HTTP/1.0\r\nHo", "s", "t: f", "oo", ".", "com\r\n\r\n"

The logic is simple: after each parse cycle, check if we need to stash anything, if we need to - do it. And then when retrieving the field value, check if something was already stashed - if yes, then stash the just-collected data, and retrieve the stashed value.

The nice part is that this voodoo with the stashing does not occur by default - so, in the non-pathological case the memory use will be quite small.

Still a known bug is the fixed allocation for the stash buffer - I did not use realloc yet.

The API is pretty close to Zed's - I like the self-contained nature of his parser and the callback.

For your pleasure, here's the nugget of the ragel code that represents the state machine.

htp_octet = (any);
htp_char = (ascii);
htp_upalpha = (upper);
htp_loalpha = (lower);
htp_alpha = (htp_loalpha | htp_upalpha);
htp_digit = (digit);
htp_ctl = (cntrl | 127);
htp_cr = ( 13 );
htp_lf = ( 10 );
htp_sp = ( ' ' );
htp_ht = ( 9 );
htp_quote = ( '"' );

htp_crlf = ( htp_cr htp_lf? ); # // Accomodate for unix NLs ?
# htp_crlf = ( htp_cr htp_lf ); # // do NOT accomodate for unix NLs ?

htp_lws = ( htp_crlf? (htp_sp | htp_ht)+ );

htp_not_ctl = (htp_octet - htp_ctl);

htp_text = (htp_not_ctl | htp_lws); # (htp_cr | htp_lf | htp_sp | htp_ht));

htp_hex = (xdigit);

htp_tspecials = (
'(' | ')' | '<' | '>' | '@' |
',' | ';' | ':' | '\\' | htp_quote |
'/' | '[' | ']' | '?' | '=' |
'{' | '}' | htp_sp | htp_ht);

htp_token_char = ((htp_char - htp_tspecials) - htp_ctl);
htp_token = (htp_token_char+);

# comments not supported yet - they require a sub-machine
# htp_comment_char = htp_text - ('(' | ')');
# htp_comment = ( '(' (htp_comment_char+ | htp_comment) ')' );

htp_quoted_char = (htp_text - '"');
htp_quoted_string = ( '"' htp_quoted_char* '"' );

htp_quoted_pair = '\\' htp_char;

htp_http_ver_major = htp_digit+ >mark %http_version_major;
htp_http_ver_minor = htp_digit+ >mark %http_version_minor;

htp_http_version = ("HTTP" "/" htp_http_ver_major "." htp_http_ver_minor);

htp_escape = ('%' htp_hex htp_hex);
htp_reserved = (';' | '/' | '?' | ':' | '@' | '&' | '=' | '+');
htp_extra = ('!' | '*' | '\'' | '(' | ')' | ',');
htp_safe = ('$' | '-' | '_' | '.');
htp_unsafe = (htp_ctl | htp_sp | htp_quote | '#' | '%' | '<' | '>');
htp_national = (htp_octet - (htp_alpha | htp_digit | htp_reserved | htp_extra | htp_safe | htp_unsafe));

htp_unreserved = (htp_alpha | htp_digit | htp_safe | htp_extra | htp_national);
htp_uchar = (htp_unreserved | htp_escape);
htp_pchar = (htp_uchar | ':' | '@' | '&' | '=' | '+');

htp_fragment = ( (htp_uchar | htp_reserved)* );
htp_query = ( (htp_uchar | htp_reserved)* );

htp_net_loc = ( (htp_pchar | ';' | '?' )* );
htp_scheme = ( (htp_alpha | htp_digit | '+' | '-' | '.')+ );

htp_param = ( (htp_pchar | '/')* );
htp_params = (htp_param (';' htp_param)* );

htp_segment = (htp_pchar*);
htp_fsegment = (htp_pchar+);
htp_path = (htp_fsegment ('/' htp_fsegment)*);

htp_rel_path = ( htp_path? (';' htp_params)? ('?' htp_query)? );
htp_abs_path = ('/' htp_rel_path);
htp_net_path = ("//" htp_net_loc htp_abs_path?);

htp_relative_uri = (htp_net_path | htp_abs_path | htp_rel_path);
htp_absolute_uri = (htp_scheme ':' (htp_uchar | htp_reserved)*);
htp_uri = ((htp_absolute_uri | htp_relative_uri) ('#' htp_fragment)?);

htp_host = (htp_alpha);
htp_port = (htp_digit+);

htp_http_url = ("http://" htp_host (':' htp_port)? (htp_abs_path)?);

htp_method = ("OPTIONS" | "GET" | "HEAD" | "POST" | "PUT" | "DELETE") >mark %http_method;

htp_request_uri = ('*' | htp_absolute_uri | htp_abs_path) >mark %http_uri;

htp_request_line = (htp_method htp_sp htp_request_uri htp_sp htp_http_version htp_crlf);

htp_header_name = htp_token+ >mark %http_header_name;
# fixme.
htp_header_value_char = htp_octet - htp_cr - htp_lf;
htp_header_value = htp_header_value_char+ >mark_value %http_header_value;

htp_some_header = (htp_header_name ':' htp_sp* htp_header_value htp_crlf);
htp_last_crlf = htp_crlf; # >{ printf("Last CRLF!\n"); eof = pe; };
htp_request = htp_request_line (htp_some_header)* htp_last_crlf;

main := (htp_request) @{ parser->done = 1; };

Sunday, June 6, 2010

Snooping on search engines with hex tricks.

The big hex number you see on the title of the blog is there for a reason. It's an experiment on the search engines out there.

What's this hex number ? It's a SHA-1 hash of the string "Andrew Yourtchenko" - this gives a nice token that is unique in the whole world (because noone else has yet come up with the idea to hash my name and put the result online). This gives some very entertaining results if you try to search for this number in the search engines.

  • Google: 2 results after folding the duplicates - main page + one post. Expanding them gives 25 results. Cool.

  • Bing: 0 results. Boo. I could not find any page on this blog using it. 2xBoo.

  • Yahoo: 2 results - main page and one post, different from the post that Google shows.

  • duckduckgo: One hit to the same post as Yahoo shows, not to the main page.

  • altavista: 2 results, same as Yahoo.

  • 2 results, same as Google

  • 0 results.

  • baidu: 0 results. Somehow unsurprising at all

  • kosmix: 2 results in google web search (same as google), 4 results in the google blog search, 0 results in yahoo web search. Entertaing how they disagree with Yahoo.

  • 0 results.

  • 2 results same as yahoo + 1 site result. Very interesting form of presentation. I got to play with this one for daily searches, even though it does not appear to be too fast compared to


  1. I don't have many inbound links here - probably about two :)

  2. has a better reach towards the "long tail" (EDIT: 'long tail' in this case being - would be interesting to test e.g. or other blog sites)

  3. There are much more than 127 billion pages on the web.

  4. is a new toy to play with

Though some of the above are fairly obvious, not bad of a result for a single SHA-1 hash, I think. Would be interesting what results this method gives for more popular blogs/websites.

The debatable point in this method is - to which extent do the search engines discriminate the "oddball hex stuff" vs. the "common words". From all I know about the search engines, they should not - vice versa, it's the stopwords (too frequent to be useful ones) that are usually filtered.

Thursday, May 27, 2010

Node.js vs. lua microbenchmarking

Node.js surely seems to be a pretty interesting contender. At least according to the microbenchmarks (ab -c 5 -n 100000):


Document Path: /
Document Length: 12 bytes

Concurrency Level: 5
Time taken for tests: 17.526 seconds
Complete requests: 100000
Failed requests: 0
Write errors: 0
Total transferred: 7600000 bytes
HTML transferred: 1200000 bytes
Requests per second: 5705.94 [#/sec] (mean)
Time per request: 0.876 [ms] (mean)
Time per request: 0.175 [ms] (mean, across all concurrent requests)
Transfer rate: 423.49 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 1
Processing: 0 1 0.5 1 14
Waiting: 0 1 0.5 1 14
Total: 0 1 0.5 1 14

Percentage of the requests served within a certain time (ms)
50% 1
66% 1
75% 1
80% 1
90% 1
95% 2
98% 2
99% 2
100% 14 (longest request)

And here goes the Lua result:

Document Path: /
Document Length: 11 bytes

Concurrency Level: 5
Time taken for tests: 6.666 seconds
Complete requests: 100000
Failed requests: 0
Write errors: 0
Total transferred: 34600000 bytes
HTML transferred: 1100000 bytes
Requests per second: 15001.08 [#/sec] (mean)
Time per request: 0.333 [ms] (mean)
Time per request: 0.067 [ms] (mean, across all concurrent requests)
Transfer rate: 5068.72 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 4
Processing: 0 0 0.1 0 4
Waiting: 0 0 0.1 0 4
Total: 0 0 0.1 0 5

Percentage of the requests served within a certain time (ms)
50% 0
66% 0
75% 0
80% 0
90% 0
95% 1
98% 1
99% 1
100% 5 (longest request)

The node.js code was as follows:

var sys = require('sys'),
http = require('http');

http.createServer(function (request, response) {
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end('Hello World\n');
sys.puts('Server running at');

And in its turn, the Lua script used to run the server is here: - slightly tweaked to make it run.

This is not anunfair comparison, since node.js runs a heavily optimized server, and the lua runs an off-the-shelp example, and yet outperforms Node.js almost 3x.

Though, more complicated code might result mostly in slowing down - so, the ballpark should be about right.

I will update this post if I get anything more complex on the lua side.

EDIT: in fact, a little bit of reverse engineering shows that Node.js code is also somewhat naive: "FOO /\n\n" works perfectly as a "request" for the above app. So the tests are more or less adequately show the status quo. Roughly 3x speed difference, that is.

EDIT2: has some more interesting stats.

Tuesday, May 11, 2010

prosody one-shot makefile on 64-bit arch

Today I tested my prosody-one-shot-makefile on my Xen VPS which happens to sit atop the 64-bit CPU.

After a few tweaks it now compiles and makes a self-contained copy of prosody on both 32-bit and 64-bit linuxes.

Interesting how the XMPP server immediately got got integrated when I launched it, and I could communicate with a demo account from my other XMPP accounts. Admittedly, I did not expect such a plug'n'play.

Sunday, May 9, 2010

Haute couture 2010: Privacy
Your latest luxury item to brag about

Pied Piper of Hamelin
The fate of chronic privacy deprivation that we are facing worries quite a few, and spurs a lot of heated discussions "we will do it better!".

Those inevitably bring up a question: "But Facebook is free, who is going to pay you ?"

So here's my take on it. Similar to how you have to be "rich" to control your weight, you will have to be "rich" to control your privacy.

So, the new services would have free accounts that are all-public (which is how you have to treat your info now, anyway - just extrapolate).

The paid accounts (something in the ballpark of $9/month) would allow making the information private. Or, one could go a bit more creative and sell privacy apiece - the more you pay, the more you can hide, and you pay only for the stuff you want to hide - so the distinction between the paid and free accounts would blur.

All of the accounts would allow the export of data into other services, should "this" social provider go off-rail.

The data formats as well as the interaction between the different providers would be standardized, so it would not really matter whether you and your friends are on the same provider or not.

This may not seem pretty, but I think this approach would be better than changing the smallprint in the ToS overtime.

Because there's no free lunch. It's just about charging in different currencies.

Now, I am curious (and you probably are curious too) about the correctness of the assumptions above, so here's a poll for you.

What would you choose ?
Stay on current social network
Get a free all-public account - or host your own instance with the privacy settings you choose
All-inclusive privacy paid account
Privacy sold apiece free polls

Thursday, April 29, 2010

Thoughts about NAT

Reading the NANOG thread about "The alleged evils of NAT", I wanted to come up with a semantic parallel, for the fun of it. Here it is:

NAT is like "tax optimization".

It's not illegal. But it may feel wrong.

It allows to represent things differently than you would think they are.

If you go too far with it, you end up in a real mess.

It brings very tangible benefits for those practicing it.

And those who don't - have to pay up on the communal goods for those who do.

Henceforth, they always argue with each other when they meet.

It creates a new profession dedicated to it.


As for my personal opinion, I'll just quote an anecdote: "it said 'celebrate', not 'celibate'".

Monday, March 29, 2010

The taste of lua as a web app language

This is a snippet of the web app that is written in lua, using my experimental framework:

Not RoR but is reasonably convenient, though would be nice to get rid of some of the braces/parens.

Tuesday, March 23, 2010

Solution for the "paid content" and online newspapers.

It's all here: - the newspapers just need to keep providing the "human-readable" content for free, and charge for the structured/machine-readable data, that might be possible to further aggregate/analyse.

How many of the "paid members" will that generate ? That's a good question - but I'd wager that people's curiousity could be a good help to this. Think of this more somewhat like a "click & pay here for more info", but rather than content-wise, you do that semantically.

Imagine this to be similar to a progressive JPEG (or different formats of the picture) - lower-resolution picture is free, and you need to pay a modest amount for the hi-res one.

Those who are interested by the core fact - will get only the core fact for free. Those who are interested in full glory - will use micropayment to get there. ($0.1 might be the right amount)

Of course, this implies working micropayments...

Monday, March 22, 2010

One-shot makefile for Prosody updated + on github

I've updated the makefile to compile 0.6.1, and rather than putting it onto the blog posts, it's now on github:

Lua quine

For some reason lately I've seen an anomalous number of mention of quines, and figured it'd be time to try it out myself (I read about this question back in 1990s, but for some reason never got myself at solving it. here's the result in Lua.

function p(s)
print("\ns = " .. string.format("%q", s) .. "\np(s)")

s = "function p(s)\n print(s)\n print(\"\\ns = \" .. string.format(\"%q\", s) .. \"\\np(s)\")\nend"

And, just in case that blogger mucks up my quoting, here's a base64-encoded version:


Friday, February 12, 2010

FOSDEM2010: now we might call ourselves "NOC"

A belated 2010 follow-up to the last year's experience. This year, as you've probably seen in the news, was quite fun. Thanks to the help from BELNET (and of course the Fosdem folks who did all the discussions), and the two rolls of fiber, we had 1gbps uplink, and 1gbps link between H and AW.

The most stressing moment was when on Friday at 5pm we discovered that 5 out of 6 strands of fiber that were planned to connect us to the internet, were not working. Plan B (which plan B? we already tested everything! it worked!) was pretty weak. So, applying some logic and with a bit of luck, the problem was solved by resplicing one of the ends.

After that, a few hours trying to build the correct OS platform to install the management software, which supposedly could magically convert some of the APs that we had into the correct mode, rather than us doing manually. At something like 11pm we realised manual was faster - but we didn't have the power supplies with us, but since the security folks wanted to close the doors, we grabbed a few access-points and went to the office to fix them up.

The process of converting access-points from standalone into management mode is dead-simple - hold the button while the AP is powercycled, then power it on with the button is pressed, and wait till the two out of three LEDs on the top turn red. Then release the button, and the AP will grab the predefined address and will start the TFTP download of the image with the default name. All good except the TFTP requests would be sent to broadcast address. It took me about 7 access-points (as measured by Jerome converting them with some naive TFTP server under windows), till I have figured out how to get the atftpd to react: "ifconfig eth0 promisc". Really-really weird. I thought tcpdump - which was running in parallel - was already putting the interface into promiscuous mode.

Anyway, once I found the trick, the rest of the conversion was trivial, so when I started up at 5am, the remaining of the APs were trivial and fast to convert.

This year the access-points we used had a bit more juice - both on 2.4Ghz and 5Ghz - so we managed to kick off some interference to the wireless mic in Jansson. And this year we used the feature to "kill" the rogue APs - which were apparently not so low in number. Strange. I thought people would come to the conference to listen, rather than to annoy others. Nonetheless, killing the phy seems to work - at least this year I saw much less of "strange" SSIDs. Next year we should enable the triangulation, to go and ask personally :)

The kicker this year was that the network was full-dualstack. And, I cooked the bind9 to point to the SixXS recursive servers (thanks guys for the service!), DNS queries going over the SixXS tunnel. A bit of a chewing-gum and matches, but worked fine over the period of two days - and looking at the SixXS traffic graph, it felt like we even made some bump for the gateway by our queries - although this is most probably wishful thinking.

I don't know how many people noticed their traffic was IPv6-based (being geek conference and such). But if they did not - even better! That means - IPv6 works!

All in all, it seems like everyone was quite happy - the visitors (thanks for being there!), the Fosdem staff (it was fun, guys! Let's do it next year!), and ourselves.

On to FOSDEM2011!