tweaking your driving route using google maps...

someone from the yahoo maps team did this last hack day (a month+ ago), but for whatever reason, it hasn’t been released by yahoo yet. very useful feature imho (basically, you can drag and drop on the map to change the route, so if you want to avoid a particular road, you can).

scraping websites...

many times, i find myself having to scrape a website for any particular reason. now a days, if i need to do it, i’d probably do it with some version of mechanize (www::mechanize in perl, hpricot in ruby, etc). when i was looking for a bug in one of the scrapers i’d written a long time ago, what took me by surprise was that i’d written a lexer to do it.

i guess this was shortly after i’d taken “languages and interpreters” in college, in which we used [f]lex and yacc/(bison). i just figured it was interesting, after working with a technology, that we try to utilize it. its not necessarily a bad way to do things, i just would do things differently now…

quran facebook application

i figured i’d play around with the facebook api today, so i wrote a little facebook quran app for displaying verses from the quran on your profile page. not very polished if i should say so myself, but… it works (at least for me). if you try it, please let me know if you find any bugs or have any feature suggestions.

you can test it here:

zomg lolcats ftw!

this is off the hook!


they actually have a few test interpreters for it and more examples here.

scratching my head over a c problem...

today, i wanted to try out my test arabic gtk program to see if behdad’s new changes to pango magically fixed the renown arabic shaping issue [in short, it had nothing to do with it]. anyway, i discovered that i needed to install libquran, and to make a long story short, my test program, which used to work before, segfaulted. i ran gdb and valgrind only to find the segfault happening within libquran at the closing of the configuration file (noting this libquran code hasn’t been changed in 3 years now).

i looked at the source, and discovered that the file pointer was becoming null after a call to getline. i tried to see if i could reproduce this in a smaller test program, and i discovered that i indeed could -

#include <stdio.h>

int main(void){
   int n = 0;
   char* tmp;
   FILE* fp = fopen("./testfile", "r");
   getline(&tmp, &n, fp);
   printf("got a str of: %s\n", tmp);
   printf("now fp is: %s\n", (fp==NULL)? "null" : "not null");
   return 0;

the program displayed the first line from testfile, but unexpectedly displayed that fp is null and segfaulted at the fclose. checking the return from getline, i see that it returns successfully (the number of characters it read).

while i got around this problem by modifying the library to do a malloc followed by an fgets, i am just confused -this library code hasn’t been touched in 3 years, it used to work before, and i just repulled it from cvs when i discovered this. so why is it broken now? the only thing that i can think of being different is that my box now runs a 64 bit version of linux, but would that break it?

any ideas?

arabic answers rip off

one of my coworkers sent me this today. pretty funny that they blatantly ripped off the images and such. on a similar note, it seems as though there’s way too much red tape to go through in order to get something like this officially done.

taxes on softdrinks... what next?

today, i went to the supermarket to buy some stuff, and i picked up a 12 pack of pepsi on the way out. when i looked at my receipt, i noticed that there was an additional tax of $0.48 for the pepsi, separate from the overall tax at the bottom (not sure if it is included in the overall x% tax that you pay at the end or not, but regardless, it is more).

safeway receipt

oddly enough, i could buy 1.92 cans of pepsi for the amount of the tax. actually, for the total of $3.98, i could have bought 15.92 cans from the vending machine at work… (although ideally, i should stop drinking pepsi altogether).

ruby and rcairo

i’ve recently been playing more and more with ruby and i really like it. at the same time, i’ve been loving launchy, an open source application launcher for windows (currently using it on my work laptop).

since i love launchy so much, i started to wonder, “why not write something similar for linux?” - now i know one will say that deskbar does the job, but its not quite the same. so anyway, because i wanted transparency and so on, i decided to look into cairo, and the rcairo ruby bindings.

here’s a screenshot of what i’ve been playing with so far:

rcairo demo

note the very right side is the part showing of my open gvim window. while i have yet to organize the code and start writing it for real, the ruby file i have is a proof of concept of all the required pieces i can think of (cairo wise anyway) working together.

some neat videos

this video from steve jobs’ stanford commencement speech (2005) was pretty good:

in addition, the following videos are worth watching (in my opinion):

  • killing us softly - an excellent talk about how today’s advertising schemes are harmful to women and to the society in general (pictures of ads included, so muslim guys may just want to listen rather than watch).

  • don’t buy stuff you can’t afford - a short, yet hilarious, snl skit.

  • pirates of silicon valley - this movie is good for cs majors who want to know how apple/microsoft started.

while most of those were posted in my google reader shared items, no one checks those, do they? :p

a qualm...

i have a qualm with today’s traffic lights… sometimes, they are absolutely ludicrous and preposterous. you would think that with today’s sensor technology and stuff, you’d be able to drive and not wait at lights at all, especially really early in the morning or really late at night… but unfortunately, this is not the case.

one of the traffic lights very close to my house is totally insane. its at a major intersection across a railroad track. during normal hours, if you miss it, you may wait 2 and a half minutes to turn at it. if you are unlucky and a train happens to pass, you miss your next turn most of the time, therefore resulting in one having to wait about 5 minutes if not more to make a left turn at that light. consequently, people just drive to the next light and make a left and/or u-turn from there.

this morning, i waited almost 4 minutes to make a left turn, despite the fact that the road from the other 3 directions was literally empty. ugh… maybe that light either doesn’t have a sensor or has a really bad sensor installed on it?