Monday, December 1, 2008

Installing alpha version of 64-bit Adobe Flash Player 10 in Hardy

Finally I managed to install the alpha version of 64-bit Adobe Flash Player 10 in my Ubuntu Hardy. It runs nice on my Firefox 3 If you got confused what to do with the so file given by tar.gz package in http://labs.adobe.com/downloads/flashplayer10.html but STILL USING Ubuntu Hardy like me, just copy paste the following script after running this script (I got this from "script for Ubuntu Intrepid")
sudo apt-get install libnss3-dev -y
sudo ln -s /usr/lib/libplds4.so{.0d,}
sudo ln -s /usr/lib/libplc4.so{.0d,}
sudo ln -s /usr/lib/libnspr4.so{.0d,}
Say good bye to heavy nspluginwrapper and have fun!

Thursday, October 30, 2008

Konqueror got error when loading localhost?

You got this annoying message:

An error occurred while loading http://localhost
Could not connect to host http://localhost

when using Konqueror (at least in Kubuntu)? You got to do this:

1. Go to Settings > Configure Konqueror > Cache
2. Uncheck "Use cache" then OK
3. Done!

Now you can browse localhost and run your PHP codes using Konqueror without network connection.

Tuesday, October 7, 2008

Perl memang jagoan text processing

Kecepatan processing text dengan menggunakan bahasa Perl ternyata sangat dahsyat. Gak heran dulu waktu kuliah Information Retrieval, dosennya nyaranin pake bahasa Perl ke para mahasiswanya.

Sensasi ini gw rasakan pada sekitar tanggal 23 September, saat iseng-iseng memporting Parser project Quran di Drupal dari Shell script ke Perl. Saat itu merupakan pertama kalinya gw dan Perl berkomunikasi (baca: ngoding). Ternyata lompatannya sangat jauh. Mungkin ada yang bilang: "Ya iya lah, Shell script mau dibandingin sama Perl". Ya emang dasarnya gw gak niat membandingkan, cuma ingin mempercepat proses aja dengan bahasa Pemograman yang langsung didukung oleh Linux. Daripada porting ke Python, lebih baik ke Perl yang sudah banyak dipakai di bidang text processing.

Kira-kira kecepatan Shell script dalam memproses 114 ayat al-Quran itu adalah 120 detik, sedangkan Perl hanya 1 detik. Ya begitu lah, 120:1.

Pernah juga pakai Ruby untuk memproses xml dengan libxml Ruby tapi kasusnya tidak sama. Cepat juga sih.

Jadi Perl ini bahasanya mirip PHP, Javascript dan Ruby. Nama variabelnya mirip PHP, method scopingnya mirip Javascript dan conditioningnya mirip Ruby (if nya bisa ditaro di belakang dan juga punya unless)

Nambah pengalaman lah :D

Saturday, September 13, 2008

Drupal module, Quran 6.x-2.1 is out!

Alhamdulillah

Finally I released the next version of Quran module for Drupal 6.4. These are the changes:

- Now it cares about localization (locale module). Ambiguous old locale setting is now changed into browser language.
- Searching in Arabic!
- Minor fixing of misspelled words
- All database are now can be imported automatically in UTF8.
- There are one translation: Indonesian language. To others, please contribute too.
- There is an info about amount of searching result

It took a quite time to handle CVS problem (more than 4 hours). I misread the CVS instruction. May be I should use git to access this CVS. :D

I've just released the new version for Drupal 5 with the same features...... and Drupal 6 (yes, another new version) for one small feature: Localization by i18n module.

Enjoy the new version!!!

Tuesday, August 12, 2008

Using pg_standby for high availability of Postgresql

PostgreSQL is a famous database server which can be compared with Oracle or any other commercial database servers. It is said that Postgresql doesn't care about replication because Postgresql wants to focus. But fortunately there is a simple opensource solution to this. Which is called pg_standby.

Pg Standby is used as a simple way to make PostgreSQL highly available. To make this short, I'll start the tutorial which I've been created from many scattered sites (it's really hard to find how to use pg_standby for me)

Condition: I used Ubuntu 8.04 (Hardy) 64-bit, PostgreSQL 8.2 (If you're using version 8.3 or more, just skip the following installation steps). Please make sure that both servers (or workstations) installed using the same Linux version (the same distro, release and architecture. e.g. Ubuntu 8.04 i386)

Installation
========
For now on, we'll do these steps in primary server.

Preparation
1. Install required packages to create PostgreSQL binary for Debian
sudo apt-get install cdbs bison libperl-dev tk8.4-dev flex libreadline5-dev libssl-dev libpam0g-dev libxml2-dev libkrb5-dev libxslt1-dev python-dev bzip2 fakeroot.

2. Install required packages to install pg_standby
sudo apt-get install sysvconfig postgresql-contrib-8.2 gcc make libc6-dev libreadline5-dev zlib1g-dev libpgeasy-dev unzip checkinstall.

4. Download PostgreSql source from Debian repository
cd ~
apt-get source postgresql-8.2

3. Download pg_standby source files
Download both Makefile and pg_standby.c from http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/contrib/pg_standby/ and put them into postgresql-8.2-8.2.7/build-tree/postgresql-8.2.7/contrib/pg_standby


Compiling
1. Create binary for PostgreSql
cd ~/postgresql-8.2-8.2.7
fakeroot debian/rules binary

2. Copy pg_standby files into PostgreSQL source,
so that we can see 2 files inside ~/postgresql-8.2-8.2.7/build-tree/postgresql-8.2.7/contrib/pg_standby:

- Makefile
- pg_standby.c

3. Compile and install the pg_standby
by using configured PostgreSQL

cd ~/postgresql-8.2-8.2.7/build-tree/postgresql-8.2.7/contrib/pg_standby
make
sudo make install

4. Make the pg_standby command accessible
Create a symbolic link so that the pg_standby command is recognized in the system or terminal

cd /usr/bin
sudo ln -s ../share/postgresql-common/pg_wrapper /usr/bin/pg_standby

*) Another way is to compile it using Debian's packaging way:
Edit postgresql-8.2-8.2.7/build-tree/postgresql-8.2.7/contrib/Makefile to insert pg_standby on WANTED_DIRS variable before doing fakeroot (I've never try this)


Configuration
==========
We need at least 2 servers. The first server acts as primary server which does logging. While the second one is acting as standby warm server ready to become primary server as soon as the primary server is down.

On primary server (server 1)
1. Create a remote directory for the archive
which is only readable and writable to user postgres. So that we'll have /psql-archive mounted from server2:/usr/local/psql-archive

sudo mkdir /psql-archive

Please googling for tutorial to mount nfs file system automatically. Or my be a bit here:

in server2 (192.168.1.202):
sudo apt-get install nfs-kernel-server
sudo mkdir /usr/local/psql-archive
sudo chown postgres.postgres /usr/local/psql-archive
sudo su -c "echo '/usr/local/psql-archive 192.168.1.201(rw,sync,no_subtree_check)' >> /etc/exports"
sudo exportfs -ra

in server1 (192.168.1.201):
sudo apt-get install nfs-kernel-server
sudo mkdir /psql-archive
sudo su -c "echo '192.168.1.202:/usr/local/psql-archive /psql-archive nfs timeo=14,rsize=8192,wsize=8192,intr 0 0' >> /etc/fstab"
sudo mount -a


2. Activate logging
Add into /etc/postgresql/8.2/main/postgresql.conf:

archive_command = 'cp "%p" /psql-archive/"%f"'
archive_timeout = 120

reload the database server configuration or restart!
sudo /etc/init.d/postgresql force-reload

3. Make sure it is running
You should see /psql-archive is filled with archived WAL files. Some people could only see this after base backup is created

4. Create base backup
To make both PostgreSQL server is a clone of each other

4.1 Do this
echo "SELECT pg_start_backup('pertama');" |psql -U postgres

4.2 Backup cluster database (does not need any restart)
cd /var/lib/postgresql/8.2
sudo tar zcvf ~/base-main-backup.tar.gz main

4.3 End the backup
echo "SELECT pg_stop_backup();" |psql -U postgres

On standby server (server 2)
5. Stop the server
sudo /etc/init.d/postgresql stop

6. Copy the backup
from primary server into the standby server on the correct location. May be you need to backup repository first before replace with backup from primary server.

sudo mv /var/lib/postgresql/8.2/main ~/main.backup
sudo tar zxvf base-main-backup.tar.gz -C /var/lib/postgresql/8.2

7. Create recovery file
Create /etc/postgresql/8.2/main/recovery.conf which contains

restore_command = 'pg_standby -l -d -s 2 -k 50 -t /tmp/pgsql.trigger.5442 /usr/local/psql-archive %f %p %r 2>>standby.log'

and symlink it into cluster directory
sudo ln -s /etc/postgresql/8.2/main/recovery.conf /var/lib/postgresql/8.2/main

8. Empty pg_xlog directory
sudo rm -Rf /var/lib/postgresql/8.2/main/pg_xlog/*

9. Start the server back
sudo /etc/init.d/postgresql start

10. Monitor standby.log
sudo tail -f /var/lib/postgresql/8.2/main/standby.log

Testing the configuration
===================
On primary server
1. Create new record
We'll test that this record will also exist on the standby server. Just create one or two tables with data on primary server

2. Shutdown db server
sudo /etc/init.d/postgresql stop

On standby server
3. Standby server, now is primary server
As you see in /var/lib/postgresql/8.2/main/standby.log, there is text stating 'store'. Also, the recovery.conf has changed into recovery.done which means standy server is now fully operating and ready to use.

nb: If it failed to recover which is caused by /tmp/pgsql.trigger.5442 is not triggered, touch it using postgres user

sudo su -
su postgres
touch /tmp/pgsql.trigger.5442

4. Make sure the record exists
You may login into the standby server as it already become a primary server and make sure that the last record exist

That's all

nb:
If the primary server fails and then immediately restarts, you must have a mechanism for informing it that it is no longer the primary. This is sometimes known as STONITH (Shoot the Other Node In The Head), which is necessary to avoid situations where both systems think they are the primary, which can lead to confusion and ultimately data loss.

So, switching from primary to standby server can be fast but requires some time to re-prepare the failover cluster. Regular switching from primary to standby is encouraged, since it allows regular downtime on each system for maintenance. This also acts as a test of the failover mechanism to ensure that it will really
work when you need it. Written administration procedures are advised.

Friday, June 13, 2008

Membuat Gateway Flash Telkomsel di Ubuntu Linux

Dari pada pusing riset lagi dari awal, mendingan bikin dokumentasinya dan berbagi kemudahan ini ke orang banyak. Saya akan menjelaskan bagaimana membuat Ubuntu Linux kita menjadi server gateway internet dengan menggunakan Huawei modem dari Flash Telkomsel.

Cara ini berhasil di Ubuntu 8.04 karena paket wvdial yang dimilikinya mampu menkonfigurasi otomatis huawei modem. Untuk berbagi ke jaringan, pastikan koneksi komputer kita dengan komputer2 lainnya di LAN berjalan baik.

Deteksi Modem
  1. Pastikan pulsanya Telkomsel Flash ada
  2. Tancap kabel yang tengah (baca keterangan pada usb jack!). Karena ada 2 jack yang punya fungsi berbeda.
  3. Pastikan Ubuntu dapat mendeteksi modem pasca penancapan usb. Biasanya baru sempurna deteksinya setelah 1 menit. Cek dengan lsusb. Harusnya ada tulisan kira2 seperti ini:
Bus 005 Device 005: ID 12d1:1003 Huawei Technologies Co., Ltd. E220 HSDPA Modem


Konfigurasi dan dialing
  1. Lakukan konfigurasi otomatis "sudo wvdialconf". Perintah ini harusnya menghasilkan file /etc/wvdial.conf yang berisi kira2 seperti berikut ini. Pastikan bahwa hasil konfigurasi otomatis ini menghasilkan nilai "Username" dan "Password" seperti di bawah ini, yakni { }
    [Dialer Defaults]
    Init1 = ATZ
    Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
    Modem Type = Analog Modem
    ISDN = 0
    New PPPD = yes
    Phone = *99#
    Modem = /dev/ttyUSB0
    Username = { }
    Password = { }
    Baud = 9600

  2. Lakukan dial dan biarkan jaringan Ubuntu dikonfigurasi oleh wvdial
    sudo wvdial

    Harusnya dalam waktu singkat wvdial akan mengeluarkan input akhir seperti ini:

    --> local IP address 221.132.252.149
    --> pppd: 3[7f]
    --> remote IP address 10.64.64.74
    --> pppd: 3[7f]
    --> primary DNS address 202.3.218.10
    --> pppd: 3[7f]
    --> secondary DNS address 202.3.240.10
    --> pppd: 3[7f]

    Selain itu akan tampak perubahan pada perintah "sudo route"

    10.64.64.74 * 255.255.255.255 UH 0 0 0 ppp0
    192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
    default * 0.0.0.0 U 0 0 0 ppp0

    dan bergantinya dns pada /etc/resolv.conf sebagai berikut

    nameserver 202.3.218.10
    nameserver 202.3.240.10


  3. Pastikan kita bisa browsing di Ubuntu kita.
    Buka browser kesayangan kita dan buka sebuah situs. Kita diharuskan mengisi login ke Flash Telkomsel. Buka halaman kedua yang digunakan untuk menjelajah internet. Jika kita berhasil membuka sebuah situs, berarti kita siap melangkah lebih jauh.


Menjadikan Ubuntu sebagai gateway untuk internet di LAN.
  1. Ganti gateway komputer2 satelit. Arahkan gateway komputer2 yang ada di LAN ke ip LAN milik Ubuntu. Jika Ubuntu kita memiliki ip jaringan lokal 192.168.1.45, maka pastikan gateway komputer2 yang akan ikutan pakai internet adalah 192.168.1.45 juga.
  2. Ganti DNS komputer2 satelit. Pastikan dns komputer2 tersebut diarahkan ke 2 dns yang dideteksi oleh wvdial di atas. Sehingga pada salah satu komputer2 satelit tersebut, perintah "sudo route" akan mengasilkan:

    Kernel IP routing table
    Destination Gateway Genmask Flags Metric Ref Use Iface
    192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
    default 192.168.1.45 0.0.0.0 UG 100 0 0 eth0
  3. Izinkan akses langsung internet oleh komputer satelit
    Pada Ubuntu yang kini telah menjadi gateway, jalankan perintah berikut (sesuaikan nilai device output, apakah ppp0 atau ppp1 atau lainnya. Ini tergantung apa yang terlihat dari default gateway hasil perintah "sudo route")

    sudo iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
    echo 1 > /proc/sys/net/ipv4/ip_forward


Semoga berhasil

Tuesday, June 10, 2008

Typing Arabic with Scim

Alhamdulillah and thanks to Anjar03 my friend who has been researching and being curios with Scim and the author of the code (yes, the one who has created scim Arabic). I finally can write Arabic with Scim in Kubuntu, KDE version of Ubuntu. I want to document it here so everybody can leverage Scim as I do.

Please make sure you've installed the following packages so that KDE will automatically use Scim as default input method: scim-bridge-agent scim-bridge-client-qt scim-bridge-client-gtk. For KDE4 may be you should install additional scim-bridge-client-qt4. After that, type "im-switch -s scim-bridge" to activate Scim. For more information see my previous post and here.

To type Arabic you don't need scim-anthy since it is for Japanese. You need scim-tables-additional package installed. Now, re-login.

To test, open kopete chat window since it automatically supports right to left typing mode. Ctrl+Space to start writing with Scim, choose Arabic Egypt from the scim popup. You should see Scim popup like the following



Adapted from this table, we can use the following rule using US Keyboard (the most common keyboard at least in my country: Indonesia).

arabic fontkeyboard
اa
بb
تt
ثth
جj
حh.
خkh
دd
ذdh
رr
زz
سs
شsh
صs.
ضd.
طt.
ظz.
ع'
غgh
فf
قq
كk
لl
مm
نn
هh
وw
يy
ةh'
'2
ٔ/2


- To type لا you can combine A and l.
- The words انّ with tashdid is typed Anx.
- To make vowel, just add a i u after the consonant.
- To make tanwin, just add an in un after the consonant.

الحمداللّه now you can type Arabic

Minbar crash on non Gnome Ubuntu derivatives?

I'm currently using Kubuntu 8.04 amd64. I installed Minbar to remind me of prayer time. It worked fine except, it crashed when I tried to play athan.

I've been searching to solve this problem. I even downloaded its source code to see what happen. From it, I concluded that there must be related to audio plugin. After gooling a little bit, I think the author forgot to include some Gstreamer library as one of Minbar's dependencies since he never used other than Ubuntu. May be, ubuntu has already has that dependency. But not with Kubuntu or Xubuntu.

The solution is just install the following packages: gstreamer0.10-plugins-base, gstreamer0.10-plugins-good
That should solve your problem and make sure you to always pray on time :D

Monday, June 9, 2008

Drupal 5 Performance Tuning, Suprising way

Lately, I tried to tuning up my Drupal 5-based website for one of my company's clients. And successfully achieve their requested test: more than 50 requests per seconds with only one additional PHP PECL module: APC. Alhamdulillah, finally. It was achieved by an unusual way, at least for me.

About 2 months before during development time, I had the Drupal pass the same test. This fact made me relieved that the development is on the track. But at the time, it did not load so much modules as it did lately. To, make it faster, I even activated memcache and advanced session modules. Then, I continued to add and customize additional modules. I think, without testing it anymore.

Two months later, I found out that my Drupal had gone slow. It could only handle no more than 25 requests per seconds. What?..... This made me curious over the new modules. I tried to turn they off one by one and I fired up xcache to see what was happening. After tuning up Apache2, MySQL, and others I could just only rise 2 more request.

I felt something must had gone wrong but not in the Drupal. Because fresh Drupal at the same time also never reached 50 requests per seconds but it had actually before (2 months before). What about removing just (since 2 months before) installed PHP memcache.ini and xcache.ini or renaming it, so that PHP assumes that there is no memcache and xcache.ini

Wonderfully and suprisingly, my Drupal passed the test and reached 52 requests per second. This made me think, sometimes we don't need to go far away to find solutions. The solutions may be near us.

Wednesday, April 23, 2008

Installing Clamav antivirus on Samba in Ubuntu

Many people use Samba in their file server to let Windows users share their files there. But some people just doesn't care if they have shared virus infected files. The other users merely become the victim.

So, lets arm our Samba to protect users from viruses hidden in the shared directories. In Ubuntu and other *nix distros, we can use free Clamav antivirus plugged in to Samba which is called clamav-scan. *nix distros usually provide ready-to-install binary of clamav-scan. But Ubuntu does not. So you must compile the plug in manually.

Enough for the intro, now we'll begin arming the Samba in Ubuntu (my Ubuntu version is 7.04 feisty fawn) . Don't be rush. You must follow test instruction before proceeding the next step.

1. Prepare package Clamav and supporting packages
apt-get install clamav arj unzoo lha clamav-freshclam clamav-daemon clamav-testfiles build-essential

You may also need build-essential package

Test: Please make sure that we can scan infected files.
clamscan -ir /usr/share/clamav-testfiles

We should see lines like the following:

----------- SCAN SUMMARY -----------
Known viruses: 266917
Engine version: 0.91.2
Scanned directories: 1
Scanned files: 7
Infected files: 6
Data scanned: 0.00 MB
Time: 3.762 sec (0 m 3 s)


2. Prepare packages to install clamav-scan into Samba
apt-get install dpkg-dev
apt-get source samba
apt-get build-dep samba
wget -c http://optusnet.dl.sourceforge.net/sourceforge/openantivirus/samba-vscan-0.3.6b.tar.bz2

3. Compiling
cd samba-3.0.24
./debian/rules configure-stamp
cd source
make proto
cd ../..

tar -jxvf samba-vscan-0.3.6b.tar.bz2 -C /usr/src
cd samba-vscan-0.3.6b
./configure --with-samba-source=/usr/src/samba-3.0.24/source
make && make install

Now the vscan-clamav module is ready to use

4. Configuring Samba to cooperate with vscan-clamav
mkdir /etc/samba/vfs-config
cp /usr/src/samba-vscan-0.3.6b/clamav/vscan-clamav.conf /etc/samba/vfs-config/

change some values in the /etc/../vfs-config/vscan-clamav.conf:
clamd socket name = /var/run/clamav/clamd.ctl
infected files action = quarantine
; By default, the quarantine directory is /tmp
; quarantine directory = /mnt/office-shared-files/.quarantine


Add some values in samba config file: /etc/samba/smb.conf. We may add this line under [global] configuration or specific directory configuration
vfs objects = vscan-clamav
vscan-clamav: config-file = /etc/samba/vfs-config/vscan-clamav.conf

5. We must recompile vscan-clamav if we upgrade our Samba. To lock Samba version from upgrading, we must do this:
echo samba hold | dpkg --set-selections
echo samba install | dpkg --set-selections

6. Now restart Samba
/etc/init.d/samba restart

7. See vscan-clamav in action
  • Just copy /usr/share/clamav-testfiles to shared writable directory of Samba so it can be accessed by Windows users. The files inside are harmless to Windows but make clamav assume them as infected files.
  • We can see that Samba has denied us from copying the file out. Instead we'll see the files has been moved to /tmp/var-*****.
  • Later, we can see that Samba users can not copy infected files into the shared directory of Samba.
I hope this tutorial useful to you!

References:
- http://www.howtoforge.com/forums/showthread.php?t=3706
- http://www.grape-info.com/doc/linux/config/samba-vscan-0.3.6b-84.html

Tuesday, April 22, 2008

Quran for Drupal 5 has been released

Someone requested me create Quran for Drupal 5. I thought it's a good ide since many users still use Drupal 5. So, last night I migrated the Quran module from Drupal 6 version to Drupal 5. Alhamdulillah, it's done.

You may download it in official Quran module page. The database files remain unchanged.

Thanks for your support and patients.

Thursday, April 10, 2008

Quran module for Drupal


Alhamdulillah, I finally released one of Drupal module: Quran, or Koran. This is my first contribution to Drupal community and my second contribution to free CMS (previously, Mambo).

This module allows you to read Quran (Koran) on Drupal. You can also search for specific verses by keywords. There is also optional block for random verses. The module includes Quran in Arabic, and English for default translation.

Currently we have more than 3 languages: Arabic, English and Indonesian. The other languages are Germany, French, Turk, etc as listed in Zekr Quran project. Please visit http://www.muslimade.com/projects/quran-drupal-module to download them