Monday, December 08, 2008

Python 3.0

Python 3.0 was released 5 days ago. I guess it's time to attempt to port some of the Python 2.x scripts to the new 3.0 style.

Wednesday, June 18, 2008

Firefox 3

I've installed FF3 on one machine. I have 2 to go. Hip hip horray!

Wednesday, June 11, 2008

del.icio.us with Firefox 3

After a long wait, finally the "native" add-on for del.icio.us service on Firefox 3 is avaibale.

Hip hip hurray!

Thursday, May 29, 2008

D-Link DWA-110 Wireless G USB Adapter: A Nightmare with Ubuntu

Yes, I bought the D-Link DWA-110 Wireless G USB Adapter and with it I got myself a nightmare - free of charge - when I attempted to get it working with a freshly installed Ubuntu Hardy.

First of all, the driver rt73usb that comes with Ubuntu 8.04 did not work out of the box. A quick browse at the manufacturer site lead me to a driver meant for Linux. Naturally this option would be the preferred one. After all the driver is coming from the maker of the device. Boy, I was totally wrong. Compilation went okay, but I couldn't configure the adapter.

Frustrated, I search for anoother option and I found one - ndiswrapper using the MS Windows driver. It didn't sound like a good solution to me (and it is still not a good one now!). Why would I want to use MS Windows driver? I'm running Linux, for goodness sake! I tried anyway, and as I expected it didn't work.

Another round of researching lead me to a GPL'd driver which in multiple instance reported to work with the exact USB adapter that I have. As a bonus, there's even a guide to the driver running on Ubuntu. Finally, using the open source driver and manual, I managed to get my USB network adapter working. Kudos to all involved with the GPL'd driver and those who contribute to the manual.

Wednesday, May 21, 2008

wxPython ain't working in Ubuntu Hardy?!!

After upgrading from Gutsy to Hardy, I found out that my wxPython didn't work anymore. A quick check revealed that wx.pth was missing. The fix is just re-create the file and add wx-2.8-gtk2-unicode into it.

Tuesday, May 20, 2008

Ubuntu Linux, OpenSSH security update and /dev/null

After doing my security update for OpenSSH on my Ubuntu, I found out my /dev/null turned to be an ordinary ASCII file. If you encounter the same problem the fix is simple, just re-create /dev/null to because a character device again.

$ sudo rm /dev/null
$ sudo mknod /dev/null c 1 3
$ sudo chmod 0600 /dev/null

Tuesday, May 13, 2008

First Attempt to Blog with ScribeFire

This is my first attempt to blog with ScribeFire, a Firefox add-on which helps to post blog.

The extension is pretty impressive. The UI is very intuitive, simple and easy to use, even for newbie.

Monday, February 04, 2008

Permasalahan Maslahat

Imam Abu Ishak As-Syatibi (790 H), pakar ilmu maqasid Islam silam meletakkan panduan dan syarat berikut jika ingin mendakwa sesuatu itu sebagai maslahat:-

  1. Mestilah tidak hanya memandang maslahat duniawi sahaja, bahkan mesti meneliti maslahat ukhrawi juga.
  2. Maslahat hanya diterima pakai dalam hal kebaikan untuk Deenul Islam.
  3. Maslahat untuk menjaga hak ramai didahulukan dari menjaga hak sekelompok.
  4. Maslahat mestilah bersandarkan dalil-dalil yang jelas.

Tuesday, January 08, 2008

Python: Gregorian date to Hijri date conversion and vice versa

Ported from Javascript. Credit goes to the original author of the Javascript (the script is quite widespread but I've never seen those using the script write the proper credit). Below is the code:

#!/usr/bin/env python

import math

def intPart(floatNum):
if floatNum < -0.0000001: return math.ceil(floatNum - 0.0000001)
return math.floor(floatNum + 0.0000001)

def Gregorian2Hijri(yr, mth, day):
if ((yr > 1582) or ((yr == 1582) and (mth > 10)) or \
((yr == 1582) and (mth == 10) and (day > 14))):
jd1 = intPart((1461 * (yr + 4800 + \
intPart
((mth - 14) / 12.0))) / 4)
jd2 = intPart((367 * (mth - 2 - 12 * \
(intPart((mth - 14) / 12.0)))) / 12)
jd3 = intPart((3 * (intPart((yr + 4900 + \
intPart((mth - 14) / 12.0)) / 100))) / 4)
jd = jd1 + jd2 - jd3 + day - 32075
else:
jd1 = intPart((7 * (yr + 5001 + \
intPart
((mth - 9) / 7.0))) / 4)
jd2 = intPart((275 * mth) / 9.0)
jd = 367 * yr - jd1 + jd2 + day + 1729777

l = jd - 1948440 + 10632
n = intPart((l - 1) /10631.0)
l = l - 10631 * n + 354
j1 = (intPart((10985 - l) / 5316.0)) * (intPart((50 * l) / 17719.0))
j2 = (intPart(l / 5670.0)) * (intPart((43 * l) / 15238.0))
j = j1 + j2
l1 = (intPart((30 - j) / 15.0)) * (intPart((17719 * j) / 50.0))
l2 = (intPart(j / 16.0)) * (intPart((15238 * j) / 43.0))
l = l - l1 - l2 + 29
m = intPart((24 * l) / 709.0)
d = l - intPart((709 * m) / 24.0)
y = 30 * n + j - 30

return y, m, d

def Hijri2Gregorian(yr, mth, day):
jd1 = intPart((11 * yr + 3) / 30.0)
jd2 = intPart((mth - 1) / 2.0)
jd = jd1 + 354 * yr + 30 * mth - jd2 + day + 1948440 - 385

if jd > 2299160:
l = jd + 68569
n = intPart((4 * l) / 146097.0)
l = l - intPart((146097 * n + 3) / 4.0)
i = intPart((4000 * (l + 1)) / 1461001.0)
l = l - intPart((1461 * i) / 4.0) + 31
j = intPart((80 * l) / 2447.0)
d = l - intPart((2447 * j) / 80.0)
l = intPart(j / 11.0)
m = j + 2 - 12 * l
y = 100 * (n - 49) + i + l
else:
j = jd + 1402
k = intPart((j - 1) / 1461.0)
l = j - 1461 * k
n = intPart((l - 1) / 365.0) - intPart(l / 1461.0)
i = l - 365 * n + 30
j = intPart((80 * i) / 2447.0)
d = i - intPart((2447 * j) / 80.0)
i = intPart(j / 11.0)
m = j + 2 - 12 * i
y = 4 * k + n + i - 4716

return y, m, d
Usage:
# Convert from Gregorian to Hijri
print Gregorian2Hijri(1972, 12, 9)
print Gregorian2Hijri(2008, 1, 8)

# Convert from Hijri to Gregorian
print Hijri2Gregorian(1392, 11, 3)
print Hijri2Gregorian(1428, 12, 29)