2007-10-29

Segway is cool - brief summary

The "4x4" variant can go anywhere, on any reasonable and unreasonable slope (like 45deg), in any direction (not necessarily gradient). It's very hard to fall from it but not impossible. It can feel jumpy on hard terrains. Speed = 25km/h. You can drive handsfree, the UI is very intuitive. After 5 minutes you don't feel the machine anymore. Charged by a teapot plug (like a comp). It can be yours for about $7K.

The city variant - can be riden on sidewalks only [israel], but requires no license. Can be used instead of walking in any possible way, you can drive slowly with it into elevators, etc.

It has regenerative breaking (for descents and stops). Full charge time - a few hours. Max reasonable speed - 25km/h. Gyro sampling frequency - 100Hz. Min age to ride it in Israel - 16YO.

To try one - go to Eilat, call 077-2199906 to schedule a long segway trip to the birdwatching park. I asked about renting one - this would actually be a cool toy in Eilat, because a car there isn't very handy. They didn't sound too cooperative, the idea was kinda new to them.

2007-10-27

Carting

We went to do some carting (with VM). It was the first time in my life, but at least I finally got a "gold medal" for something (which cannot be said about IPhO).

On the way back I complained that it sucks to drive after carting - a very unhealthy practice. RM said that tetris is the most counter-educational game before driving. VK: "yeah, but it's very educational for parking."

Road#10 to Eilat is a bad idea

I've decided to try this out. First, it's much longer than anyone would expect. Second, it's almost as wide as my car's exhaust pipe (and Prius isn't big). Third, you have egyptians with Kalachnikovs on the other side every a few kilometers.

However, it's an ultra beautiful road. My mistake was to drive the 'philadelphic route' alone and unarmed. The army wouldn't let me thru most of the checkpoints, I had to wait sometimes for millitary (or other) traffic to accompany me. This was funny. It's because they posess some kidnapping alerts.

What's less funny is that one of the magavnicks I gave lift to, explained me that nearly every day they have border events. Mostly influx of ppl thru the border, some of which they couldn't catch. On the way I visited a base (they let me in - either case they are stuck in the middle of nowhere) and bought water in a military Shekem. The shekem was basically a plastic box with some ice and crembo.

2007-10-23

How many mathematicians does it take to change a light bulb?

The answer: N. Unlike nearly all other lightbulb jokes, this one is not even offensive to any group - even though "N" is usually considered a positive integer unless said otherwise (in maths and in Fortran).

My favorite bulb jokes involve sending someone to watch out for incoming electric current.

For more serious stuff, read how many legislators does it take to change a light bulb - a bill to ban selling incandescents. I wish Israeli lawmakers could be smart enough for that, too.

2007-10-15

Database security

Well, let's start with a comix:
http://xkcd.com/327/

For those who hate parsing comixes, I will just summarize that a kid introduced himself to a teacher as an SQL injection , and got his code to database thru spelling and the stupidity of the teachers. In the category of machine-human interaction anecdotes, this is of course no match to the real story of how a guy manually wrote gibberish on an envelope he posted, because he thought these letters (copied from an email) were a real russian font.

But that's not what I wanted to say. What amused me is that the conclusion they come to at the end of the comix is plain wrong. All possible inputs should be supported - not filtered out - to achieve the required security.

I am also amazed by stupidity of some security experts, who recommend people to use stored procedures to achieve just that. As if "not concatenating string inputs into SQL as is" is a hard instruction for coders to follow otherwise.

[C#]
public static string SqlQuote(string s) {
return "'" + s.replace("'", "''") + "'";
}

would definitely do the trick. Don't let them ever scare you.

2007-10-12

Minesweeper vs. Notepad

I have been trying to view a 0.5GB text file recently. No, Windows Notepad was clearly not the first choice, because I perfectly knew what would happen. (To my greatest surprise, neither UltraEdit nor Notepad++ could perform this task smoothly.)

And no, I don't want to say anything bad about Microsoft. I grew up on Windows and used to be a certified Win32 API god. All I want to say is that a moderate-size software vendor can afford to make a text editor in 15 years of work on their OS package. "The size of that company is insane. Can you imagine Safeco Field filled to the brim with software developers? And that’s just the Vista Shutdown Menu Team."

The above quote is from Joel. He also writes elsewhere about craftsmanship in software development. In my opinion, this is how notepad should have been implemented:
1. It takes 10 milliseconds to determine the size of a file. For the very least, it could have not tried to open it.
2. The only reason it would need to read more than the first kilobytes when launched is to display scrollbar position. For this it needs to count the number of lines. This task could really be postponed, with a 200-codeline logic, and you don't need any threads for that. The user could really afford to stay without scrollbar for a while.
3. Even that same scrollbar could have been displayed - based on byte position instead of line position, assuming that this is a good first-order approximation. Then during user's idle time it could dive into heuristic estimation of average number of new lines per file size in different areas, scanning randomly only parts of the file. Optimized to harddrive storage units, of course. This way the scrollbar display would be perfect for large files and this can be accomplished relatively fast.
4. I don't even mention how switching to word-wrap mode should be immediate and save the cursor (and not the scrollbar) position.
5. And last but not least, this can be done within 10K executable file, no more than 20K RAM (ok, we let it use 1MB) and no visible CPU overhead.

So, this they couldn't achieve in 15 years (in fact, the only changes in notepad since Windows 3.1 are the status line and UTF-16 support). Nor could they fix the old bug that Windows Explorer hangs during CD acceleration. By no means it's a simple bug - the short acceleration phase does not fit well into the two possible return values of IsDiskInDrive() somewhere, so they are probably left with thinking it's more inside than outside and wait for the hardware interface until it can actually bring data. An API expansion beyond bool would probably require to rewrite tons of code right up to the UI support, and some of it is not actually actually their code, or something like that.

But then again, aren't they being paid for it? Is it really difficult to recognize my need in good working notepad, calc without 3rd-part addons? (The calc, I must admit, knows to compute "0.5!" - GOOD!). Does Steve Ballmer use CDRoms? Recently I've discovered what really kept them busy during all this time - minesweeper. This article explained me all about it, now I can imagine why redesigning a Win2000 start menu into the WinXP one takes 70 programmers. Enjoy.

P.S. Notepad recognized as the best software that came out of Microsoft :)

2007-10-03

Demotion procedure

A friend of mine (codenamed AP) was thrown out of talpiot for some academic misbehavior (aka copying homework). Of course, it's a regular thing, but once upon a time somebody had to be caught so it was him. Others have been trying to save him from the punishment, but this didn't help. Of course, he believes until today that this is one of the best things that ever happened to him - because - honestly speaking, Talpiot is not something.

While discussing the story today, someone asked - 'how is the demotion ceremony actually performed in the army? Is it like puting the poor guy naked in the middle and everybody shouting angry words at him or something..'

YL seemed to have an idea. "A rebuke procedure starts with the ceremony leader entering the scene. Then he should say 'good bye, and thanks for your attention'. Following that part they continue playing the usual rank ceremony reversed, and of course, all people should be walking backwards.