Mar 13, 2008 · 2 minute read
code
so i was working on some code in which i needed to know whether or not it was dst for a given country and/or timezone or not. luckily, with php5.2, some sparsely documented (yet very useful) classes were introduced - a more thorough documentation can be found here.
so let’s say i want to know whether or not egypt is in dst right now or not… so first i need to know what zoneinfo file egypt uses (for egypt, it’s simple, but this trick is useful for more obscure places, like “isle of man,” for example):
cd /usr/share/zoneinfo
grep -i egypt iso*.tab # get the iso country code for egypt
# the above command returns 'EG' - so...
grep EG zone.tab
# returns 'Africa/Cairo'
in many cases, there are many timezones that exist for a given country. in many cases, it’s obvious which file you need, but in some cases, it’s not very obvious. in those cases, i found it helpful to open the binary files and look at the very last line, in which some hint about the offset of the timezone is given.
anyway… once you have the zoneinfo file that you would use, it’s very easy to find whether or not you are in dst (well, assuming that you know what the standard, non-dst offset from utc is). for example:
$tz = new DateTimeZone('America/New_York');
$date = new DateTime();
$date->setTimezone($tz);
echo $date->;format(DATE_RFC3339) . "\n";
echo $date->getOffset()/3600 . "\n";
running this returns the time in new york, and the offset (-4). since the standard est offset is -5 hours, -4 means we’re +1 which means we are currently on dst.
so if you don’t know the standard offset, another trick that you could do is pass some parameters to the new DateTime() constructor - so for example…
$tz = new DateTimeZone('America/New_York');
$date = new DateTime('2008-12-31');
$date->setTimezone($tz);
echo $date->getOffset()/3600 . "\n";
this returns -5, which is out of dst. anyhow, you could use the above if you don’t know the default offset for a timezone for dst by passing in 2 dates - something towards the middle of the year (july-ish) and something towards the end of the year (december-ish). if the offsets are different, the place probably has dst.
also, do note that some places have things a little differently - so dst in windhoek, namibia, for example, ends in april and starts in september.
Mar 2, 2008 · 1 minute read
technologywebsite
thanks to the iwphone wordpress plugin, the blog now looks a lot better on the iphone!
speaking of the iphone, i am really disappointed at the notion that the long awaited sdk coming out on 3/6 will potentially be locked down. i guess we can’t know for sure until the announcement on thursday, but i personally have gone ahead and re-jailbroken my phone, courtesy of zibri’s ziphone.
Mar 2, 2008 · 1 minute read
technology
i always used to get upset when i send a message or set a status on an english site in arabic, only to have the punctuation all messed up. well, thanks to two unicode control characters, \u200e and \u200f (for ltr and rtl, respectively), i can finally go from writing:
يحيى الإسلام!
to writing:
يحيى الإسلام!
much better :) thanks goes to this wikipedia article and adil allawi, whom i first heard about this from.
Feb 13, 2008 · 1 minute read
gaming
i just beat quake4 (played the whole game under linux). fun!
Feb 10, 2008 · 1 minute read
random
woot! egypt won the 2008 africa cup of nations! beautiful game, i only saw the last 20 minutes, but those were the 20 minutes that mattered. beautiful assist by zidane in a crazily intense moment, passing to abu trayka who scored :) incredible work of art!
i am not a big fan of sports, but this was one game i had to watch :) second cup win in a row, the last being against the ivory coast in 2006.
Feb 9, 2008 · 1 minute read
work
woot! word has it that monday, yahoo will write a “sorry” to microsoft. now let’s just hope they don’t get rid of our search advertising (and, therefore, search in general) to google… as i mentioned before, the best option here is to tough it out this period of time, and things will come back up.
in lolcat terms, courtesy of the flickr anti-microsoft group: this picture is awesome :)
Feb 9, 2008 · 1 minute read
gamingtechnology
i’ve been dual booting my gentoo box with windows vista 64 for my occasional bouts of gaming… but yesterday, i decided that despite microsoft ending it’s support for xp sometime this year, that i am better off running xp for gaming than vista. so i downgraded vista 64 to xp 32. i think i made this decision after seeing this article on slashdot.
Feb 7, 2008 · 1 minute read
work
yahooza linked two funny articles about the whole y! ordeal… i especially like the first one, and the second one is funny too but has bad language, so if it offends you, consider yourself warned:
on a more serious note on the same subject, the techcrunch article, “decision time for yahoo,” is a more serious (and perhaps realistic) analysis of the situation. until i read this article, i never really knew that there could be lawsuits for violation of fiduciary duty (which basically entails that you look out for your shareholders before looking at your own interests).
if it weren’t for this, i would have to think that yahoo’s decision would be easy - be patient and the storm will pass.
Feb 6, 2008 · 2 minute read
technology
so i spoke with the bro about the dns thing, and it seems as though i jumped the gun a little. in summary, what he told me is that another islamic site did a dos attack on his site due to the fact that there were non-muslims allowed on the forums and such, which some of the people from the other site didn’t like. he didn’t know about this until dnsmadeeasy contacted him, and said he had 48 hours to take the site down or pay the overages. so he said that within 6 hours, the site was taken down.
when he came to renew, he found the $8000 bill, and he was emailing back and forth with them about this (as it seems that they made a mistake with what had happened in the system etc). so he decided he’d switch dns for the time being (and he forgot that i had some of my sites hosted on the same dns server with him). they said they’d investigate and contact him back, and, until now, they didn’t, and he’s still in the process of trying to get this resolved.
given the sort of not-so-positive tone (if not negative or anti-islamic, even) of the dude on the phone “oh, this was the guy who was involved in dns attacks with islamic sites,” versus me knowing my brother, i tend to believe the brother more than this dude. at the same time, the brother should have remembered the important services that i had hosted on there as well, because that is a responsibility and trust.
in any case, all is good now al7amdulillah and am just posting this as a clarification to my earlier post about the same subject.
Feb 5, 2008 · 1 minute read
codetechnology
launched my second facebook app: sublime rhymes! still a little rough around the edges, some things can be a little more intuitive, but for now, i am going to sleep :)