Archive

Archive for May, 2007

zomg lolcats ftw!

May 29th, 2007 No comments

this is off the hook!

HAI
CAN HAS STDIO?
PLZ OPEN FILE "LOLCATS.TXT"?
	AWSUM THX
		VISIBLE FILE
	O NOES
		INVISIBLE "ERROR!"
KTHXBYE

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

Categories: code Tags:

scratching my head over a c problem…

May 17th, 2007 6 comments

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");
   fclose(fp);
   free(tmp);
   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?

Categories: code Tags: ,

arabic answers rip off

May 14th, 2007 No comments

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.

Categories: random Tags: ,

taxes on softdrinks… what next?

May 14th, 2007 2 comments

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).

Categories: random Tags:

ruby and rcairo

May 9th, 2007 No comments

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.

Categories: code, technology Tags: ,