Home

Advertisement

Customize
Oct. 13th, 2009 @ 08:50 pm Quote of the day
[20:49:04] Roman: i'll have some pasta with cheese soon, can't wait :)
[20:49:13] Timwi: Macaroni?
[20:49:24] Roman: no, Edam
[20:49:26] Roman: grated
About this Entry
default
May. 5th, 2009 @ 01:55 pm Incredible web design at dictionary.reference.com

If you type a search query on dictionary.reference.com, the page immediately turns blank, and then the new page loads. Did you ever notice this? On other websites, the page you're on stays visible until the page with the search results loads.

Initially I thought this is actually a nice idea; it makes it more obvious to the user that your search query is being processed. If all websites behaved this way, it might increase overall usability of the web slightly.

But today I noticed that if you use the browser's "Back" button, you can actually navigate to that blank page. You have to use "Back" twice to get back to the previous non-blank page. That is, of course, hardly a usability benefit: it is potentially confusing.

Given the above observations, I theorised that the system probably loads a page containing nothing but a <meta name='refresh' content='...'> tag. While that would be unusual in the sense that few other websites do the same, it still seemed reasonable that one would do that if the above usability improvement was the goal.

Today I investigated what is actually going on. It is quite a bit weirder than this. First of all, the above only applies if you allow JavaScript to run. Otherwise the search box will just take you to /dic?q=sound (using "sound" as the example word to look up) and this will display the dictionary entry directly, not even forward you to the (apparently canonical) URL /browse/sound, which displays the same content.

If you do have JavaScript enabled, when you submit the form the function formcheck() is executed:

<script type="text/javascript">
    function adcall(){
        var adTarget;        
        adTarget ='/site=dictionary.com/area=search/aamsz=720x300/keyword=sound'+
            '/pageid=' + aamPageId +'/random=' + aamRndNum;
        document.writeln('<scr' + 'ipt language="javascript" type="text/javascript"' +
            ' src="' + adServer + '/jserver' + adTarget + '"></scr' + 'ipt>');
    }

    //todo: revisit this to handle empty query string, domains
    function formcheck() {
        if(document.getElementById("q") != null){
            var q = document.getElementById("q").value;
            var redirectURL = "http://dictionary.reference.com/browse/" + enc(q) + "";
            adcall();
            location.href = redirectURL;
        }
    }
</script>

Disregarding for a moment the "todo" comment on a live production site, do you notice something here? The function calls adcall();, which outputs a JavaScript tag to the page, and then immediately obsoletes that by assigning to location.href.

Turns out the document.writeln call replaces the entire page with this script tag. This is how you get the blank page so quickly. But then the assignment to location.href takes over and takes you to the correct page. If you use the "Back" button, you get to see the beauty of the blank page with the lone JavaScript tag on it (I've word-wrapped the URL for you, in the original it's all in one line):

<script language="javascript" type="text/javascript"
    src="http://iacas.adbureau.net/jserver/site=dictionary.com/area=search
    /aamsz=720x300/keyword=/pageid=830248663/random=6612083315"></script>

Just for a laugh, I followed the src attrbute to see what this JavaScript does. The contents of this URL are:

document.writeln('<scr' + 'ipt src="' +
    'http://iacas.adbureau.net//AFTRSERVER/jserver/site=dictionary.com/area=search
    /aamsz=720x300/keyword=/pageid=830248663/random=6612083315' +
    '/ATCI=' + '0-0' + '"></scr' + 'ipt>');

Yet another document.writeln with another JavaScript tag! Let's follow it!

document.writeln("<a href=\"http://iacas.adbureau.net/accipiter/adclick/CID=fffffffcfffffffcfffffffc
    /site=dictionary.com/area=search/aamsz=720x300/keyword=/pageid=830248663/random=6612083315/ATCI=0-0\"
    target=\"_blank\"><img src=\"https://a248.e.akamai.net/img.adbureau.net/iacas/accipiter/images/AE13.gif\"
    width=-1 height=-1 border=\"0\"></a>");
document.close();

Yet another document.writeln! But this time it outputs an image with a link instead of a JavaScript tag. Notice the width=-1 height=-1?

But anyway — even if I didn't use AdBlock, I'd never see this ad banner because of the assignment to location.href. So what was the point in all that?

About this Entry
default
Jul. 22nd, 2008 @ 01:07 am Tom Lehrer - The Elements - Animation
I made this a few days ago. This took me a total of about 7 or 8 hours to make, most of which was Wednesday 16 July 22:00 until 03:00. The animation was basically complete then, but I added a few finishing touches (like the glowy effect and a better choice of a font) on Thursday.

The music is by Tom Lehrer. There are many other videos on YouTube which attempt to animate the same song. Feel free to browse the related videos.



Update: Since a lot of people asked: I used Visual C# to make this. I rendered every frame to a PNG, then generated an AVI using AviSynth and VirtualDub. I rendered my own version at a resolution of 960x720 and encoded it as Xvid. Even at the maximum-quality setting the file is only 54 MB. The crap quality is due to YouTube.
About this Entry
default
Jun. 28th, 2008 @ 04:10 am Tennis on the Nintendo Game Boy
Recently I stumbled upon a video by YouTube user "SeventhSun" where he plays the old Nintendo Game Boy game Tennis and wins at the best possible score (6:0 6:0) (don't watch this, it's boring).

I noticed that he uses two basic tricks which trigger a bug in the computer player's algorithm most of the time. By that I mean that the computer doesn't hit the ball when it could. I was quickly able to copy these tactics, and it was suddenly very easy to win 6:0 6:0, but it was boring and no longer challenging, so I scrapped those tricks and tried to play more sincerely.

(By the way, I commented on his video to this effect and apparently managed to get him quite angry. He shows off his sky-high self-esteem in a comment he leaves on my user page at YouTube. Do read this, it's hilarious.)

Eventually I managed to beat the computer 6:0 6:0 too, but I couldn't upload it to YouTube because they now have a 10-minute limit while my game was 13 minutes (like SeventhSun's, which he probably uploaded before the limit was introduced). Despite, the game got me totally hooked, and I've been playing it on and off for months now.

I later managed to win in just under 10 minutes. (Don't watch this either. It's slightly less boring, but still.) I did not specifically try to win quickly here, it just so happened that I managed it and so I uploaded it.

After I uploaded that, I stopped recording every game and just played for fun. This was a weird feeling, as I suddenly took a lot more adventurous risks because I no longer cared about losing any particular game. At this point I discovered several ways in which the computer could be beaten quicker, leading me to a new challenge: what is the fastest that I can win 6:0 6:0?

My current record is 6min 28sec, which I achieved earlier today. I'll embed it here for your convenience. (Do watch this, it's worth it. Unless you're not into computer games. But do if you're into sports. Unless you hate imitations. Whatever. Decide for yourself.) Go to the YouTube video page to watch it in full screen mode.

Another possible record that one could try to set would be the least number of lost rallies. That would, of course, encourage careful play and thus produce longer games; yet my speed record here already has only 5 lost rallies (unless I miscounted, in which case please correct me), which is already very hard to top.



(P.S. I wrote this entry because I couldn't sleep.)
About this Entry
default
Jun. 26th, 2008 @ 11:58 am Lifesign
I'm considering resuming my blogging here at LiveJournal.

I'm not sure what you write about though. Any suggestions?
About this Entry
default
Apr. 28th, 2007 @ 09:35 pm //
[21:23] Timwi: Can you think of more than three very common cases in which two slashes ('//') might come up in succession? :-) (random quiz)
[21:23] Timwi: (I can think of only three)
[21:25] Roman: i can't even think of three: i can only think of protocol:// and c++ line comments
[21:25] Timwi: OK, wanna know the third one I thought of? :)
[21:26] Roman: mark-up in some wiki? :)
[21:26] Timwi: Hm, that might be another one, but that's not what I'm thinking of :)
[21:26] Roman: what is it?
[21:26] Timwi: s/ <pattern> //; :-)
[21:26] Roman: hehe :)
[21:29] Roman: but you said "very common" :)
[21:30] Timwi: Well, I only said that to prevent you saying things like $empty_string = q//; which is of course possible but ideosyncratic :)
[21:31] Roman: but i wouldn't have thought of that anyway :)
[21:32] Timwi: q// or qq// = empty string, qr// = empty regexp, qw// = empty array :)
[21:33] Timwi: or indeed $var =~ // which
[[info]pne explains in the comments ;-)]
[21:33] Timwi: OK, sorry, I'm in extreme geek mode
[21:33] Roman: yeah
About this Entry
default
Mar. 23rd, 2007 @ 09:17 pm Am I on Candid Camera?
[19:57] Roman: omg i just got about 10000x wealthier because some super wealthy person promised 100 billion "food" to the first person to say "stephen sux". Guess who was the first :)
[19:58] Roman: she kept the promise :)
[20:01] Roman: i'm totally stomped and i have no idea what to do now :))))
[21:07] Timwi: So what is 100 billion "food"? :)
[21:07] Roman: a resource. Like money.
[21:08] Timwi: I'm not sure if you're trying to be funny, to be honest :)
[21:08] Roman: i'm not :)
[21:09] Timwi: So how is this person going to transfer the 100 billion "food" to you? :-p
[21:09] Roman: they've already done that. There's a system for sending stuff to people.
[21:11] Timwi: So how rich are you now? :)
[21:11] Roman: i'm not sure if I understand you completely either. Do you not believe me or something? :) why the ":-p"?
[21:11] Roman: i can't answer that question because you have nothing to compare it to :)
[21:12] Timwi: It is a bit hard to believe, yes
[21:12] Roman: i see :)
[21:12] Roman: well, it's true
[21:12] Timwi: If you can't answer that question, then where did the "10000x" figure come from?
[21:12] Roman: i was really surprised to actually receive it
[21:12] Timwi: Receive /what/ though?
[21:12] Roman: receive 100 billion units of food. Do you understand that i'm talking of that space strategy game?
[21:13] Timwi: Ooooooooooooooooooooohhhhhhh
[21:13] Timwi: OMG WTF!!!!!
[21:13] Timwi: No, I totally didn't realise that, obviously :)
[21:14] Timwi: OMG WTF ... this is ... uh... how do I say this :)
[21:14] Roman: i thought it was in context. But clearly it wasn't, now that i look back :)
[21:15] Timwi: OK, well, to give /you/ some context, I just watched a TV show in which they trick people into some sort of trap, with a hidden camera.
(Die Comedy Falle)
[21:15] Timwi: And all of a sudden I totally felt like I'm in the middle of something like that myself...
[21:16] Roman: lol :)))
[21:17] Timwi: Do you mind if I post this exchange to my LJ?
[21:17] Roman: go ahead :)
About this Entry
default
Mar. 19th, 2007 @ 03:26 pm Expert Sokoban

Roman's and my project, Expert Sokoban, has now been released as freeware.

Download Expert Sokoban

Documentation is still a bit lacking, and the description is a bit weird :), but the program works and is feature-complete :)

About this Entry
default
Mar. 16th, 2007 @ 03:54 pm Graph theory
If anyone reading this is or knows someone who is interested in graph theory, I am very keen on finding a proof or a counter-example for the following conjecture:
Take an arbitrary graph with unweighted, undirected edges. Define the "distance" between two nodes as the length of the shortest path between them.

Start at a random node S. Use breadth-first search to discover the nodes with the largest distance from S. Choose by random any node X out of those that have the largest distance from S. Now run breadth-first search again starting at X. Choose by random any node Y out of those that have the largest distance from X.

Conjecture: All pairs of nodes (A,B) in the graph have a distance less than or equal to the distance between X and Y. (In other words: (X,Y) is one of the furthest-away pairs.)
(A counter-example was found by a graph theorist at wer-weiß-was.)
About this Entry
default
Feb. 17th, 2007 @ 02:09 pm Stupid .NET WTF
TableLayoutPanel MyTable = new TableLayoutPanel();
MyTable.ColumnCount = 2;
MyTable.ColumnStyles[0].SizeType = SizeType.AutoSize;
MyTable.ColumnStyles[1].SizeType = SizeType.AutoSize;
        // last line triggers index out of bounds exception! WTF!!
About this Entry
default