Desember 24, 2010

Mengaktifkan command line editing (Readline) di Python


Secara default, pada saat kita masuk ke python command line, tidak akan ada completion seperti halnya bila kita menggunakan bash, tcsh, atau zsh. Untuk mengaktifkan tab completion, biasanya kita menggunakan langkah-langkah berikut:
[bpdp@bpdp-arch ~]$ python
Python 3.1.3 (r313:86834, Dec  1 2010, 12:35:23)
[GCC 4.5.1 20101125 (prerelease)] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.
>>> import readline
>>> import rlcompleter
>>> readline.parse_and_bind(“tab: complete”)
Untuk mengotomatiskan langkah-langkah tersebut sehingga tidak perlu mengeksekusi berbagai perintah diatas, gunakan langkah-langkah sebagai berikut (asumsi: OS Linux dengan shell Bash):
Buat file $HOME/.pythonrc. Isinya:
import readline
import rlcompleter
readline.parse_and_bind(“tab: complete”)
Tambahkan env var yang diperlukan di $HOME/.bashrc
export PYTHONPATH=~/.pythonrc
Selesai
Saat masuk ke command line Python, otomatis mode command line editing telah tersedia dengan menekatan tombol tab, sama halnya dengan di Bash:
[bpdp@bpdp-arch ~]$ python
Python 3.1.3 (r313:86834, Dec  1 2010, 12:35:23)
[GCC 4.5.1 20101125 (prerelease)] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.
>>> help(
Display all 163 possibilities? (y or n)

Oktober 21, 2010

Menggunakan AHA dengan Olive VME-110 di Arch Linux

Tulisan sederhana ini sekedar menjelaskan sedikit cara untuk bisa menggunakan modem EVDO dari AHA di Arch Linux. Untuk modem, saya menggunakan Olive VME-110 yang berwarna putih (yang berwarna perak merk-nya Huawei, caranya mungkin beda sedikit dengan yang ada di tulisan ini). Di tulisan ini, penyebutan "modem" berarti akan mengacu ke Olive VME-110 (males nulisnya kalau panjang ... :-D).

Paket yang Diperlukan

Ada beberapa paket yang diperlukan untuk mengaktifkan modem ini yaitu: wvdial dan usb_modeswitch. Untuk menginstall, gunakan pacman (tentu saja jika belum bisa koneksi ke Internet, ngalah dulu sebentar cari koneksi kabel atau wifi):
# pacman -S wvdial usb_modeswitch
Biasanya instalasi wvdial juga akan menyertakan wvstreams.

Mengubah dari Mode Storage ke Mode Modem

Setelah instalasi paket yang diperlukan di atas, lakukan langkah-langkah berikut untuk konfigurasi.

Aktifkan modul kernel usbserial:
# modprobe usbserial
Masukkan modem ke USB port. Kernel akan mengenali device sebagai USB storage (karena modem ini bisa difungsikan juga sebagai USB flashdisk) berikut ini:

Initializing USB Mass Storage driver...
scsi6 : usb-storage 2-1.1:1.0
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
USB Serial support registered for GSM modem (1-port)
usbcore: registered new interface driver option
option: v0.7.2:USB Driver for GSM modems
scsi 6:0:0:0: CD-ROM            Qualcomm MMC Storage      2.31 PQ: 0 ANSI: 2
sr1: scsi3-mmc drive: 0x/58x caddy
sr 6:0:0:0: Attached scsi CD-ROM sr1
sr 6:0:0:0: Attached scsi generic sg2 type 5
sr1: CDROM (ioctl) error, command: cdb[0]=0x51 51 00 00 00 00 00 00 00 02 00
sr: Sense Key : 0x4 [current] 
sr: ASC=0x0 ASCQ=0x0

Supaya bisa dikenali sebagai GSM modem (/dev/ttyUSB*), maka fasilitas storage (diatas dikenali sebagai Qualcomm - di Windows juga dikenali sebagai Qualcomm) harus di-eject dulu:
# eject /dev/sr1
Saya menggunakan /dev/sr1 karena sesuai dengan pesan yang ada di atas, bahwa storage tersebut di kenali sebagai sr1 (lihat baris "sr1: scsi3-mmc drive: 0x/58x caddy", di tempat lain, bisa saja sr0). Setelah di-eject, maka modem baru akan dikenali:

usb 2-1.1: USB disconnect, address 3
cdrom: issuing MRW back ground format suspend
usb 2-1.1: new full speed USB device using ehci_hcd and address 4
option 2-1.1:1.0: GSM modem (1-port) converter detected
usb 2-1.1: GSM modem (1-port) converter now attached to ttyUSB0
option 2-1.1:1.1: GSM modem (1-port) converter detected
usb 2-1.1: GSM modem (1-port) converter now attached to ttyUSB1
option 2-1.1:1.2: GSM modem (1-port) converter detected
usb 2-1.1: GSM modem (1-port) converter now attached to ttyUSB2

Device juga muncul:

[bpdp@bpdp-arch ~]$ ls -la /dev/ttyUSB*
crw-rw---- 1 root uucp 188, 0 Oct 22 08:45 /dev/ttyUSB0
crw-rw---- 1 root uucp 188, 1 Oct 22 08:45 /dev/ttyUSB1
crw-rw---- 1 root uucp 188, 2 Oct 22 08:45 /dev/ttyUSB2
[bpdp@bpdp-arch ~]$ 

Konfigurasi usb_modeswitch

Paket usb_modeswitch yang saya gunakan belum menyertakan definisi hardware dari modem, jadi kita akan membuat konfigurasinya sendiri. Pertama, kita mencari ID dari device modem:

[bpdp@bpdp-arch ~]$ lsusb 
Bus 002 Device 004: ID 201e:2009  
Bus 002 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 004: ID 0b05:1788 ASUSTek Computer, Inc. 
Bus 001 Device 003: ID 04f2:b071 Chicony Electronics Co., Ltd 2.0M UVC Webcam / CNF7129
Bus 001 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
[bpdp@bpdp-arch ~]$

Di Arch Linux, device dikenali dengan ID vendor 201e dan ID product 2009. Setelah mengetahui ID ini, buat konfigurasi file baru di "/etc/usb_modeswitch.d/201e\:2009" yang berisi teks berikut:

########################################################
# AHA.co.id
# 201e:2009


DefaultVendor= 0x201e
DefaultProduct=0x2009


TargetVendor= 0x201e
TargetProduct= 0x2009


CheckSuccess=20


MessageContent="555342431234567824000000800108df200000000000000000000000000000"

Konfigurasi wvdial

Buat file baru (atau tambahkan entry berikut jika sudah ada filenya) untuk konfigurasi wvdial di "/etc/wvdial.conf". Isinya adalah teks sebagai berikut:

[Dialer aha]
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Modem Type = USB Modem
Baud = 115200
Modem= /dev/ttyUSB0


Phone = #777
Username = aha@aha.co.id
Password = aha
New PPPD = yes
Stupid Mode = 1

Konfigurasi udev

Konfigurasi udev diperlukan supaya kita tidak perlu repot-repot meng-eject setiap kali memasukkan modem ke USB port. Buatlah file baru di "/etc/udev/rules.d/99-evdo-modem.rules" yang berisi:

SYSFS{idVendor}=="201e",
SYSFS{idProduct}=="2009", RUN+="/usr/bin/eject %k"

Konfigurasi Modul Kernel

Masukkan "usbserial" dalam array MODULES yang ada di file "/etc/rc.conf". Jika sebelumnya sudah ada modul lainnya, tinggal tambahkan saja sebagai berikut (di file saya sudah ada modul ath9k, tidak perlu anda tulis jika tidak menginginkan modul ath9k tersebut aktif):

...
...
MODULES=(ath9k usbserial)
...
...

Menggunakan Modem

Langkah-langkah di atas sudah cukup untuk mengkonfigurasi modem. Jika kita ingin mengaktifkan, tinggal men-dial menggunakan wvdial sebagai berikut:

[root@bpdp-arch ~]# wvdial aha
--> WvDial: Internet dialer version 1.61
--> Cannot get information for serial port.
--> Initializing modem.
--> Sending: ATZ
ATZ
OK
--> Sending: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
OK
--> Modem initialized.
--> Sending: ATDT#777
--> Waiting for carrier.
ATDT#777
CONNECT 3100000
--> Carrier detected.  Starting PPP immediately.
--> Starting pppd at Fri Oct 22 09:13:09 2010
--> Pid of pppd: 2578
--> Using interface ppp0
--> pppd:  [01]� �[01]� 
--> pppd:  [01]� �[01]� 
--> pppd:  [01]� �[01]� 
--> pppd:  [01]� �[01]� 
--> pppd:  [01]� �[01]� 
--> local  IP address 10.69.7.130
--> pppd:  [01]� �[01]� 
--> remote IP address 192.168.11.10
--> pppd:  [01]� �[01]� 
--> primary   DNS address 10.8.9.2
--> pppd:  [01]� �[01]� 
--> secondary DNS address 192.168.190.66
--> pppd:  [01]� �[01]� 

Jika ingin disconnect, tekan Ctrl-C di posisi tersebut. Untuk seterusnya, jika ingin koneksi ke Internet menggunakan modem, yang kita lakukan hanya:
1. Masukkan modem ke port USB
2. dari terminal, sebagai root, ketikkan "wvdial aha"

Mudah bukan? Happy browsing using Arch Linux! :)

Catatan: 
Saat mencari cara untuk koneksi menggunakan AHA dengan modem Olive VME-110 ini, saya sangat terbantu dengan artikel dan komentar di URL http://www.icemanblogger.com/2010/07/setting-modem-aha-olive-v-me110-di.html. Bersama ini, rasanya saya perlu mengucapkan terima kasih untuk yang telah menulis artikel di atas dan komentar-komentar di bawahnya.

September 05, 2010

Model Interaksi Aplikasi Web

Pendahuluan


Tulisan ini membahas tentang gambaran umum model interaksi dari aplikasi web. Seperti yang kita ketahui, aplikasi web pada dasarnya terdiri atas dua sisi yaitu sisi klien dan sisi server. Meskipun selalu mempunyai pola klien-server, implementasi model ini mempunyai perkembangan yang menarik untuk diamati karena semakin hari semakin berkembang ke arah interaktivitas yang lebih baik.



Berbagai Model Interaksi Aplikasi Web


Aplikasi web mempunyai siklus request-response. Klien web (web browser) mengirimkan permintaan ke server (request), server menerima request tersebut kemudian memproses request dan mengirimkan hasilnya (response) ke server. Siklus ini bisa kita lihat pada gambar berikut:


Sampai saat ini, ada tiga kategori besar dari aplikasi web berdasarkan pada model interaksi klien-server:
  1. Model Tradisional
  2. Model Ajax
  3. Model Comet
Model Interaksi Tradisional

Model interaksi tradisional mempunyai pola halaman-demi-halaman. Pola ini yang pertama kali digunakan pada saat Tim Berners-Lee mulai mengembangkan HTML dan ingrastrukturnya. Pada model ini, web browser mengirimkan permintaan ke web server, sementara itu web server menerima permintaan dan mengirimkan hasilnya ke web browser. Saat menerima response dari web server, web browser akan me-refresh keseluruhan halaman web. Model ini masih digunakan sampai saat ini. Model ini dianggap "mahal" karena "memaksa" web server untuk mengirimkan keseluruhan halaman yang ditampilkan oleh web browser sehingga memerlukan sumber daya Internet yang relatif besar untuk lalu lintas data. Secara konsepsual, model ini bisa digambarkan untuk aplikasi web yang meminta user untuk melakukan login sebagai berikut:



Pada gambar tersebut, kira-kira logik yang harus dikerjakan oleh pemrogram adalah membuat form HTML dengan action ke script pemroses di server. Saat user mengklik tombol Submit, web browser akan mengirimkan variabel-variabel yang terdapat pada form tersebut dan akan diproses oleh server begitu server menerima variabel tersebut. Setelah diproses, seluruh HTML dikirimkan kembali ke web browser untuk di-render.

Untuk membuat aplikasi web seperti ini, yang diperlukan adalah komponen-komponen berikut:
  1. Web browser yang bisa me-render HTML beserta pendukungnya (CSS,JavaScript, jpg, png, gif, dan lain-lain).
  2. Web server (Apache web server, IIS, yaws, lighttpd, nginx, dan lain-lain)
  3. Jika akan menambahkan pemrosesan business logic di sisi server, bisa ditambahkan server-side scripting language (PHP, JSP, ASP, dan lain-lain tergantung pada compiler/interpreter yang didukung oleh web server).
Model Ajax

Ajax (Asynchronous JavaScript and XML) adalah sekumpulan teknologi untuk membuat aplikasi web lebih interaktif dengan cara menggunakan berbagai teknologi dan spesifikasi yang telah ada untuk mengambil data dari server secara asynchronous dan me-render hasilnya ke display web browser tanpa "mengganggu" bagian lainnya. Konsep inti dari Ajax adalah menetapkan bagian tertentu dari halaman web yang akan diambil dari server, kemudian secara asynchronous mengambil data di latar belakang setelah itu menampilkan hanya pada bagian yang berubah itu saja. Istilah Ajax dikemukakan oleh Jesse James Garret pada essay yang ditulisnya pada tahun 2005 dengan judul "Ajax: A New Approach to Web Applications" (http://www.adaptivepath.com/ideas/essays/archives/000385.php).

Secara konsepsual, model interaksi ini bisa digambarkan sebagai berikut (gambar diambil dari artikel milik Jesse James Garret dan merupakan hak cipta dari yang bersangkutan):


Ajax bekerja dengan menggunakan berbagai teknologi berikut:
  1. HTML/XHTML dan CSS (serta pendukung lainya - gambar PNG, JPG, GIF) untuk lapisan presentasi.
  2. DOM (Document Object Model) merupakan konvensi yang cross-platform dan language-independent untuk merepresentasikan dan berinteraksi dengan obyek dalam HTML, XHTML, dan XML. Antarmuka publik dari DOM ini diimplementasikan dalam bentuk API (Application Programming Interface). JavaScript adalah salah satu contoh bahasa yang mendefinisikan API untuk memanipulasi berbagai elemen DOM ini. Teknologi ini tidak selalu menggunakan JavaScript, tetapi bisa juga menggunakan client-side programming language lainnya seperti JScript (implementasi ECMAScript dari Microsoft) atau VBScript (hanya bisa digunakan di Internet Explorer).
  3. XML untuk format pertukaran data serta XSLT untuk pemrosesnya. Teknologi ini tidak selalu digunakan, banyak diantara pemrogram yang menggunakan JSON sehingga XSLT tidak diperlukan lagi.
  4. XMLHttpRequest, yaitu API yang terdapat pada client-side scripting language (diantaranya JavaScript) yang digunakan untuk mengirimkan request HTTP/S secara langsung ke web server dan me-load response dari web server secara langsung ke dalam script.
  5. JavaScript untuk mem-binding berbagai teknologi tersebut ke dalam suatu interaksi baik dari suatu aplikasi web.
Contoh dari aplikasi yang berbasis Ajax ini bisa dilihat pada berbagai implementasi dari aplikasi web berikut:
  1. Suggestions pada saat mengisikan input text di mesin pencarian Google/Yahoo/dan lain-lain.
  2. Mengisi komentar, mengirimkan message di Facebook dan masih banyak lainnya.
Model Comet

Model ini merupakan model yang mulai banyak digunakan dan merupakan perkembangan terakhir dengan tingkat interaktivitas aplikasi ke user yang paling bagus. Istilah Comet muncul pertama kali pada blog Alex Russel (project leader dari Dojo Toolkit dan presiden dari Dojo Foundation) di http://infrequently.org/2006/03/comet-low-latency-data-for-the-browser/. Comet dikenal juga dengan berbagai istilah berikut:
  1. Ajax Push
  2. Reverse Ajax
  3. Two-way-web
  4. HTTP Streaming
  5. HTTP Server Push
Model ini sebenarnya merupakan sekumpulan teknologi yang memungkinkan suatu aplikasi web untuk mengirimkan data dari server ke browser menggunakan teknologi push. Secara konsepsual, Coment bekerja menggunakan gambaran berikut (gambar diambil dari blog Alex Russel):


Comet bisa diimplementasikan menggunakan dua metode yaitu Streaming dan Long Polling, meskipun penggunaan Long Polling makin banyak digunakan. Contoh dari aplikasi web menggunakan Comet ini antara lain bisa dilihat di Facebook. Pada aplikasi Facebook, notification akan secara otomatis muncul (dalam bentuk angka dengan latar belakang merah) tanpa diminta atau di-request ulang ke server. Server Facebook akan mem-push notification tersebut ke web browser.

Beberapa web server yang sudah mendukung Comet ini antara lain adalah:
  1. Caplin Liberator (http://www.freeliberator.com/ - dibangun menggunakan C)
  2. Cometd (http://cometd.com/ - dibangun menggunakan Python)
  3. ErlyComet (http://erlycomet.googlecode.com/ - Erlang)
  4. Glassfish (http://glassfish.dev.java.net/ - Java)
  5. Jetty (http://jetty.mortbay.org/ - Java)
  6. Lightstreamer (http://lightstreamer.com/ - Java)
  7. Meteor (http://meteorserver.org/ - Perl)
  8. Orbited (http://www.orbited.org/ - Python)
  9. Persevere (http://persevere.sitepen.com/ - Java-JavaScript)
  10. RMDS2Web Server (http://www.migratory.ro/ - Java)
Penutup

Model interaksi tersebut sebenarnya tidak tergantung pada tingkat kekinian tools. Sebagai contoh, menggunakan Jetty yang sudah mendukung Comet tidak serta merta menjadikan aplikasi tersebut sebagai model aplikasi web yang menggunakan interaksi Comet. Dengan demikian, memang harus berhati-hati dalam mendefinisikan hal ini.

Tertarik? Silahkan mencoba membuat aplikasi dengan berbagai macam teknologi dan model interaksi tersebut. Tools sudah banyak tersedia dan banyak pula yang merupakan software bebas.

Selamat belajar dan berkarya :)

September 01, 2010

Masalah upgrade Ruby di Arch Linux

Untuk rekan-rekan yang menggunakan Arch Linux, proses update dan upgrade Ruby dari versi 1.9.1 (atau 1.8.7 juga ya?) ke versi berikutnya (1.9.2) mungkin bisa melihat ada masalah. Mulai dari instalasi yang gagal karena menumpuki file-file lama di /usr/share/ri dan /usr/lib/ruby, sampai dengan gem yang jika dijalankan malah memunculkan error.

Saya belum melihat ke bug yang di-report, tapi langsung saya mencoba otak atik. Untuk instalasi saja sebenarnya bisa selesai dengan menyertakan --force:

# pacman -S --force ruby

Sayangnya, ini akan menimbulkan kekacauan saat menjalankan 'gem'. Jika mengalami masalah ini, silahkan uninstall ruby, hapus direktori /usr/lib/ruby dan /usr/share/ri. Setelah itu, baru install ruby yang baru.

Catatan: Upgrade ke 1.9.2 perlu dilakukan jika kita ingin menggunakan Rails 3.0.

Selamat mencoba.

Mei 25, 2010

Konfigurasi EV-DO Smart di Chakra (Phoix) / Arch Linux

Chakra (http://www.chakra-project.org) merupakan (saat ini) distrolet yang dikembangkan dari Arch Linux (http://www.archlinux.org). Chakra mempermudah anda jika ingin langsung mempunyai desktop yang fully functional dengan menggunakan desktop environment KDE. Tulisan ini akan menjelaskan cara menggunakan USB Modem EVDO ZTE AC 2726 dengan provider Smart. Tulisan ini berdasarkan pada pengalaman mas Muhammad Iqbal di http://masiqbal.net/modem-smart-evdo-zte-ac2726-di-linux.php (terima kasih mas!) dan manual dari usb_modeswitch yang bisa diperoleh di http://www.draisberghof.de/usb_modeswitch/

OS yang saya gunakan adalah Chakra versi terakhir (Phoix). Meskipun menggunakan Chakra, tulisan yang ada disini bisa diterapkan juga untuk Arch Linux. Chakra dan Arch yang akan anda gunakan sudah harus mempunyai Yaourt karena instalasi nantinya akan menggunakan Yaourt. Jika belum mempunyai, anda bisa menggunakan Pacman untuk menginstall Yaourt.

Pada saat modem USB dicolokkan, Chakra sudah langsung mengenali. Berikut adalah snapshot dari lsusb:

[root@chakra etc]# lsusb 
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 003: ID 19d2:fff5 ONDA Communication S.p.A. 
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 007 Device 002: ID 03f0:171d Hewlett-Packard Wireless (Bluetooth + WLAN) Interface [Integrated Module]
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 002: ID 04f2:b016 Chicony Electronics Co., Ltd VGA 30fps UVC Webcam
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
[root@chakra etc]# 

Device yang dikenali disitu adalah "Bus 005 Device 003: ID 19d2:fff5 ONDA Communication S.p.A.". Meskipun sudah dikenali, perlu digunakan usb_modeswitch untuk mengubah dari mode storage ke mode Modem. Berikut adalah langkah-langkan instalasi paket supaya modem bisa digunakan.

Langkah pertama adalah instalasi usb_modeswitch menggunakan Yaourt:

[root@chakra ~]# yaourt -Ss usb_modeswitch
aur/usb_modeswitch 1.1.2-1 (83)
  Activating switchable USB devices on Linux.
aur/usb_modeswitch-fixed 1.1.1-3 (Out of Date) (13)
  Activating switchable USB devices on Linux.
aur/usb_modeswitch-updated 1.1.1-1 (2)
  Activating switchable USB devices on Linux.
[root@chakra ~]# yaourt -S usb_modeswitch
==> WARNING: Building package as root is dangerous.
 Please run yaourt as a non-privileged user.

==> Downloading usb_modeswitch PKGBUILD from AUR...
--2010-05-26 09:43:18--  http://aur.archlinux.org/packages/usb_modeswitch/usb_modeswitch.tar.gz
Resolving aur.archlinux.org... 208.92.232.29
Connecting to aur.archlinux.org|208.92.232.29|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 693 [application/x-tgz]
Saving to: “usb_modeswitch.tar.gz”

100%[=============================================================>] 693         --.-K/s   in 0s      

2010-05-26 09:43:24 (54.7 MB/s) - “usb_modeswitch.tar.gz” saved [693/693]

bsdtar: Removing leading '/' from member names
x PKGBUILD

Comment by: cyberpatrol on Wed, 24 Mar 2010 22:23:14 +0000
Please, update this package. Version 1.1.1 is out and the version 1.1.0 is not available for downloading anymore.

Comment by: helios on Fri, 26 Mar 2010 13:46:40 +0000
I will update it as soon as I get back from holiday.

Comment by: gborzi on Tue, 20 Apr 2010 22:29:21 +0000
Version 1.1.2 is available, it requires tcl to work. Also udev doesn't seem able to find the tcl script which is installed by default as
/lib/udev/usb_modeswitch/usb_modeswitch.tcl
installing it as /lib/udev/usb_modeswitch it is found and works. This is the PKGBUILD I've used to make the package
pkgname=usb_modeswitch
pkgver=1.1.2
pkgrel=1
_pkgdata=20100418
pkgdesc="Activating switchable USB devices on Linux."
arch=('i686' 'x86_64')
url="http://www.draisberghof.de/usb_modeswitch/"
license=('GPL')
depends=('libusb' 'tcl')
makedepends=('gcc' 'make' 'wget')
backup=('/etc/$pkgname.conf')
source=("http://www.draisberghof.de/usb_modeswitch/usb-modeswitch-${pkgver}.tar.bz2"
"http://www.draisberghof.de/usb_modeswitch/usb-modeswitch-data-${_pkgdata}.tar.bz2")
md5sums=('071cb300d00938bfe20025c654303d92' '659c9633513fa2f84465244a50c351b3')
build() {
cd $srcdir
# fetching
wget -Nc http://www.draisberghof.de/usb_modeswitch/usb_modeswitch.setup || return 1
# extracting
cd $srcdir/usb-modeswitch-$pkgver/
mkdir -p $pkgdir/lib/udev/usb_modeswitch || return 1
mkdir -p $pkgdir/etc || return 1
mkdir -p $pkgdir/usr/share/man/man1 || return 1
# deleting the precompiled binary
make clean || return 1
# recompiling
make || return 1
# installing
make DESTDIR=${pkgdir} install || return 1
# adjusting the tcl script location
mv ${pkgdir}/lib/udev/usb_modeswitch/usb_modeswitch.tcl ${pkgdir}/lib/udev/usb_modeswitch.tcl || return 1
rmdir ${pkgdir}/lib/udev/usb_modeswitch || return 1
mv ${pkgdir}/lib/udev/usb_modeswitch.tcl ${pkgdir}/lib/udev/usb_modeswitch || return 1
# installing data
cd $srcdir/usb-modeswitch-data-${_pkgdata} || return 1
make DESTDIR=$pkgdir install || return 1
# installing config
cp $srcdir/usb_modeswitch.setup $pkgdir/etc/ || return 1
}

Comment by: helios on Sun, 25 Apr 2010 12:35:48 +0000
thanks and updated


      First Submitted: Thu, 26 Jun 2008 17:00:39 +0000
usb_modeswitch 1.1.2-1 : Activating switchable USB devices on Linux.
( Unsupported package: Potentally dangerous ! )
==>  Edit PKGBUILD ? [Y/n] ("A" to abort)
==>   ----------------------------------------------
==>n


==> usb_modeswitch dependencies:
 - libusb (already installed)
 - tcl (package found)
 - gcc (package found)
 - make (package found)
 - wget (already installed)
==>  Continue the building of usb_modeswitch ? [Y/n]
==>   ----------------------------------------------
==>Y


==> Install or build missing dependencies for usb_modeswitch:
resolving dependencies...
looking for inter-conflicts...

Targets (7): libmpc-0.8.2-1  ppl-0.10.2-3  cloog-ppl-0.15.9-1  libelf-0.8.13-1  gcc-4.5.0-2  
             make-3.81-5  tcl-8.5.8-1  

Total Download Size:    19.83 MB
Total Installed Size:   79.74 MB

Proceed with installation? [Y/n] 
:: Retrieving packages from core...
 libmpc-0.8.2-1-i686...    68.0K   31.8K/s 00:00:02 [############################################] 100%
 ppl-0.10.2-3-i686.p...     2.4M   15.0K/s 00:02:47 [############################################] 100%
 cloog-ppl-0.15.9-1-...   119.5K   16.0K/s 00:00:07 [############################################] 100%
 libelf-0.8.13-1-i686      84.6K   23.9K/s 00:00:04 [############################################] 100%
 gcc-4.5.0-2-i686.pk...    14.7M   15.5K/s 00:16:12 [############################################] 100%
 make-3.81-5-i686.pk...   322.7K   18.5K/s 00:00:17 [############################################] 100%
:: Retrieving packages from extra...
 tcl-8.5.8-1-i686           2.1M   16.1K/s 00:02:17 [############################################] 100%
checking package integrity...
(7/7) checking for file conflicts                   [############################################] 100%
(1/7) installing libmpc                             [############################################] 100%
(2/7) installing ppl                                [############################################] 100%
(3/7) installing cloog-ppl                          [############################################] 100%
(4/7) installing libelf                             [############################################] 100%
(5/7) installing gcc                                [############################################] 100%
(6/7) installing make                               [############################################] 100%
(7/7) installing tcl                                [############################################] 100%
==> Building and installing package

==> usb_modeswitch dependencies:
 - libusb (already installed)
 - tcl (already installed)
 - gcc (already installed)
 - make (already installed)
 - wget (already installed)
==> Making package: usb_modeswitch 1.1.2-1 i686 (Wed May 26 10:06:36 WIT 2010)
==> Checking Runtime Dependencies...
==> Checking Buildtime Dependencies...
==> Retrieving Sources...
  -> Downloading usb-modeswitch-1.1.2.tar.bz2...
--2010-05-26 10:06:36--  http://www.draisberghof.de/usb_modeswitch/usb-modeswitch-1.1.2.tar.bz2
Resolving www.draisberghof.de... 194.0.247.207
Connecting to www.draisberghof.de|194.0.247.207|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 35001 (34K) [application/x-bzip]
Saving to: “usb-modeswitch-1.1.2.tar.bz2.part”

100%[=============================================================>] 35,001      25.0K/s   in 1.4s    

2010-05-26 10:06:44 (25.0 KB/s) - “usb-modeswitch-1.1.2.tar.bz2.part” saved [35001/35001]

  -> Downloading usb-modeswitch-data-20100418.tar.bz2...
--2010-05-26 10:06:44--  http://www.draisberghof.de/usb_modeswitch/usb-modeswitch-data-20100418.tar.bz2
Resolving www.draisberghof.de... 194.0.247.207
Connecting to www.draisberghof.de|194.0.247.207|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 13967 (14K) [application/x-bzip]
Saving to: “usb-modeswitch-data-20100418.tar.bz2.part”

100%[=============================================================>] 13,967      16.2K/s   in 0.8s    

2010-05-26 10:06:52 (16.2 KB/s) - “usb-modeswitch-data-20100418.tar.bz2.part” saved [13967/13967]

==> Validating source files with md5sums...
    usb-modeswitch-1.1.2.tar.bz2 ... Passed
    usb-modeswitch-data-20100418.tar.bz2 ... Passed
==> Extracting Sources...
  -> Extracting usb-modeswitch-1.1.2.tar.bz2 with bsdtar
  -> Extracting usb-modeswitch-data-20100418.tar.bz2 with bsdtar
==> Starting build()...
--2010-05-26 10:06:52--  http://www.draisberghof.de/usb_modeswitch/usb_modeswitch.setup
Resolving www.draisberghof.de... 194.0.247.207
Connecting to www.draisberghof.de|194.0.247.207|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 38634 (38K) [text/plain]
Saving to: “usb_modeswitch.setup”

100%[=============================================================>] 38,634      12.6K/s   in 3.0s    

2010-05-26 10:07:01 (12.6 KB/s) - “usb_modeswitch.setup” saved [38634/38634]

/bin/rm -f usb_modeswitch
gcc -o usb_modeswitch usb_modeswitch.c -march=i686 -mtune=generic -O2 -pipe -Wall -l usb
usb_modeswitch.c: In function ‘search_devices’:
usb_modeswitch.c:1120:8: warning: ‘listcopy’ may be used uninitialized in this function
install -d /tmp/yaourt-tmp-root/aur-usb_modeswitch/usb_modeswitch/pkg/usr/sbin
install --mode=755 usb_modeswitch /tmp/yaourt-tmp-root/aur-usb_modeswitch/usb_modeswitch/pkg/usr/sbin/usb_modeswitch
install --mode=755 usb_modeswitch.tcl /tmp/yaourt-tmp-root/aur-usb_modeswitch/usb_modeswitch/pkg/lib/udev/usb_modeswitch
install --mode=644 usb_modeswitch.conf /tmp/yaourt-tmp-root/aur-usb_modeswitch/usb_modeswitch/pkg/etc/usb_modeswitch.conf
install --mode=644 usb_modeswitch.1 /tmp/yaourt-tmp-root/aur-usb_modeswitch/usb_modeswitch/pkg/usr/share/man/man1/usb_modeswitch.1
install -d /tmp/yaourt-tmp-root/aur-usb_modeswitch/usb_modeswitch/pkg/etc/usb_modeswitch.d
install --mode=644 -t /tmp/yaourt-tmp-root/aur-usb_modeswitch/usb_modeswitch/pkg/etc/usb_modeswitch.d ./usb_modeswitch.d/*
install -d /tmp/yaourt-tmp-root/aur-usb_modeswitch/usb_modeswitch/pkg/lib/udev/rules.d
install --mode=644 40-usb_modeswitch.rules /tmp/yaourt-tmp-root/aur-usb_modeswitch/usb_modeswitch/pkg/lib/udev/rules.d
if [ -f /tmp/yaourt-tmp-root/aur-usb_modeswitch/usb_modeswitch/pkg/etc/issue ]; then \
                if [ -n `which udevadm 2>/dev/null` ]; then \
                        UDEVADM=`which udevadm`; \
                        UDEVADM_VER=`$UDEVADM -V 2>/dev/null`; \
                        if [ -z $UDEVADM_VER ]; then \
                                UDEVADM_VER=`$UDEVADM --version 2>/dev/null`; \
                        fi; \
                        if [ $UDEVADM_VER -gt 127 ]; then \
                                $UDEVADM control --reload-rules; \
                        else \
                                $UDEVADM control --reload_rules; \
                        fi \
                elif [ `which udevcontrol 2>/dev/null` ]; then \
                `which udevcontrol` reload_rules; \
                fi \
        fi
==> Tidying install...
  -> Purging other files...
  -> Compressing man and info pages...
  -> Stripping debugging symbols from binaries and libraries...
==> Creating package...
  -> Generating .PKGINFO file...
  -> Compressing package...
==> Finished making: usb_modeswitch 1.1.2-1 i686 (Wed May 26 10:07:03 WIT 2010)

==>  Continue installing usb_modeswitch? [Y/n]
==>  [v]iew package contents [c]heck package with namcap
==>   ----------------------------------------------
==>Y

loading package data...
checking dependencies...
(1/1) installing usb_modeswitch                     [############################################] 100%
If you like this package, please install aurvote
and vote for its inclusion/keeping in [community]

[root@chakra ~]# 

Snapshots di atas adalah yang saya ambil dari screen pada saat instalasi. Perintah yang diketikkan sebenarnya hanya satu, yaitu "yaourt -S usb_modeswitch" dan setelah itu menjawab untuk meneruskan instalasi.

Konfigurasi /etc/usb_modeswitch_setup

File ini berisi setup untuk hardware yang kita gunakan. Yang perlu dilakukan hanya menghilangkan komentar ";" di depan konfigurasi hardware yang kita gunakan. Dalam hal ini, karena menggunakan ZTE 2726, kita akan mengedit bagian tersebut menjadi sebagai berikut:

DefaultVendor=  0x19d2
DefaultProduct= 0xfff5

TargetVendor=   0x19d2
TargetProduct=  0xfff1

# only for reference and 0.x versions
# MessageEndpoint=0x05

MessageContent="5553424312345678c00000008000069f030000000000000000000000000000"

Setelah selesai, jalankan usb_modeswitch berikut ini:

[root@chakra etc]# usb_modeswitch 

Looking for target devices ...
 No devices in target mode or class found
Looking for default devices ...
 Found devices in default mode or class (1)
Accessing device 002 on bus 005 ...
Using endpoints 0x0a (out) and 0x89 (in)
Inquiring device details; driver will be detached ...
Looking for active driver ...
 OK, driver found ("usb-storage")
 OK, driver "usb-storage" detached

SCSI inquiry data (for identification)
-------------------------
  Vendor String: ZTE     
   Model String: USB Storage FFF1
Revision String: 2.31
-------------------------

USB description data (for identification)
-------------------------
Manufacturer: ZTE, Incorporated
     Product: USB Storage
  Serial No.: 000000000002
-------------------------
Setting up communication with interface 0 ...
Using endpoint 0x0a for message sending ...
Trying to send message 1 to endpoint 0x0a ...
 OK, message successfully sent
-> Run lsusb to note any changes. Bye.

[root@chakra etc]# 

Setelah itu, lihat hasilnya menggunakan lsusb, jika berhasil, pada baris kedua akan berubah menjadi fff1 bukan fff5 seperti di awal tulisan ini:

[root@chakra etc]# lsusb 
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 003: ID 19d2:fff1 ONDA Communication S.p.A. 
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 007 Device 002: ID 03f0:171d Hewlett-Packard Wireless (Bluetooth + WLAN) Interface [Integrated Module]
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 002: ID 04f2:b016 Chicony Electronics Co., Ltd VGA 30fps UVC Webcam
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
[root@chakra etc]# 

Untuk mengaktifkan, tinggal kita gunakan wvdial:

[root@chakra etc]# pacman-color -S wvdial
resolving dependencies...
looking for inter-conflicts...

Targets (3): xplc-0.3.13-2  wvstreams-4.6.1-2  wvdial-1.61-2  

Total Download Size:    1.25 MB
Total Installed Size:   8.27 MB

Proceed with installation? [Y/n] 
:: Retrieving packages from extra...
 xplc-0.3.13-2-i686        43.5K   25.1K/s 00:00:02 [############################################] 100%
 wvstreams-4.6.1-2-i...  1152.1K   16.4K/s 00:01:10 [############################################] 100%
 wvdial-1.61-2-i686        85.9K   32.3K/s 00:00:03 [############################################] 100%
checking package integrity...
(3/3) checking for file conflicts                   [############################################] 100%
(1/3) installing xplc                               [############################################] 100%
(2/3) installing wvstreams                          [############################################] 100%
(3/3) installing wvdial                             [############################################] 100%
[root@chakra etc]# 

Jalankan wvdialconf untuk membuat konfigurasi wvdial berikut ini:

[root@chakra ~]# wvdialconf 
Editing `/etc/wvdial.conf'.

Scanning your serial ports for a modem.

Modem Port Scan<*1>: S0   S1   S2   S3   
WvModem<*1>: Cannot get information for serial port.
ttyUSB0<*1>: ATQ0 V1 E1 -- OK
ttyUSB0<*1>: ATQ0 V1 E1 Z -- OK
ttyUSB0<*1>: ATQ0 V1 E1 S0=0 -- OK
ttyUSB0<*1>: ATQ0 V1 E1 S0=0 &C1 -- OK
ttyUSB0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 -- OK
ttyUSB0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK
ttyUSB0<*1>: Modem Identifier: ATI -- Manufacturer: QUALCOMM INCORPORATED
ttyUSB0<*1>: Speed 9600: AT -- OK
ttyUSB0<*1>: Max speed is 9600; that should be safe.
ttyUSB0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK
WvModem<*1>: Cannot get information for serial port.
ttyUSB1<*1>: ATQ0 V1 E1 -- failed with 2400 baud, next try: 9600 baud
ttyUSB1<*1>: ATQ0 V1 E1 -- failed with 9600 baud, next try: 9600 baud
ttyUSB1<*1>: ATQ0 V1 E1 -- and failed too at 115200, giving up.
WvModem<*1>: Cannot get information for serial port.
ttyUSB2<*1>: ATQ0 V1 E1 -- failed with 2400 baud, next try: 9600 baud
ttyUSB2<*1>: ATQ0 V1 E1 -- failed with 9600 baud, next try: 9600 baud
ttyUSB2<*1>: ATQ0 V1 E1 -- and failed too at 115200, giving up.
WvModem<*1>: Cannot get information for serial port.
ttyUSB3<*1>: ATQ0 V1 E1 -- failed with 2400 baud, next try: 9600 baud
ttyUSB3<*1>: ATQ0 V1 E1 -- failed with 9600 baud, next try: 9600 baud
ttyUSB3<*1>: ATQ0 V1 E1 -- and failed too at 115200, giving up.
WvModem<*1>: Cannot get information for serial port.
ttyUSB4<*1>: ATQ0 V1 E1 -- failed with 2400 baud, next try: 9600 baud
ttyUSB4<*1>: ATQ0 V1 E1 -- failed with 9600 baud, next try: 9600 baud
ttyUSB4<*1>: ATQ0 V1 E1 -- and failed too at 115200, giving up.

Found a modem on /dev/ttyUSB0.
/etc/wvdial.conf: Can't open '/etc/wvdial.conf' for reading: No such file or directory
/etc/wvdial.conf: ...starting with blank configuration.
Modem configuration written to /etc/wvdial.conf.
ttyUSB0: Speed 9600; init "ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0"
[root@chakra ~]# 

Hasilnya adalah sebagai berikut:

[root@chakra ~]# cat /etc/wvdial.conf 

[Dialer Defaults]
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Modem Type = Analog Modem
; Phone = 
ISDN = 0
; Username = 
Init1 = ATZ
; Password = 
Modem = /dev/ttyUSB0
Baud = 9600
[root@chakra ~]# 

Ubah sesuai dengan konfigurasi Smart:

[root@chakra ~]# cat /etc/wvdial.conf 

[Dialer Smart]
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Modem Type = Analog Modem
Phone = #777
ISDN = 0
Username = smart
Init1 = ATZ
Password = smart
Modem = /dev/ttyUSB0
Baud = 9600
FlowControl = CRTSCTS
Carrier Check = No
New PPPD = yes
[root@chakra ~]# 

Untuk mengaktifkan koneksi ke Internet, yang perlu dilakukan hanya memanggil wvdial berikut ini:

[root@chakra ~]# wvdial Smart
--> WvDial: Internet dialer version 1.61
--> Cannot get information for serial port.
--> Initializing modem.
--> Sending: ATZ
ATZ
OK
--> Sending: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
OK
--> Modem initialized.
--> Sending: ATDT#777
--> Waiting for carrier.
ATDT#777
CONNECT
--> Carrier detected.  Waiting for prompt.
~[7f]}#@!}!}!} }9}"}&} } } } }#}%B#}%}%}&} }/[0f]9}'}"}(}"dq~
--> PPP negotiation detected.
--> Starting pppd at Wed May 26 10:53:55 2010
--> Pid of pppd: 6231
--> Using interface ppp0
--> pppd: H~� Pt� 
--> pppd: H~� Pt� 
--> pppd: H~� Pt� 
--> pppd: H~� Pt� 
--> pppd: H~� Pt� 
--> local  IP address 10.12.26.89
--> pppd: H~� Pt� 
--> remote IP address 10.20.4.138
--> pppd: H~� Pt� 
--> primary   DNS address 10.17.3.244
--> pppd: H~� Pt� 
--> secondary DNS address 10.17.3.252
--> pppd: H~� Pt� 

Selesai. Lain waktu, saat booting komputer dan masuk ke Linux, dari terminal aktifkan wvdial dengan perintah "wvdial Smart" sebelum mulai menggunakan.

Selamat mencoba!

Februari 20, 2010

RubyGems Update 1.3.5 to 1.3.6

At first, I thought that RubyGems update should be a piece of cake but it turns out that I got some weird things happened. Here’s the scenario:

[root@bpdp-arch ~]# gem update --system
Updating RubyGems

Updating rubygems-update

Successfully installed rubygems-update-1.3.6

Updating RubyGems to 1.3.6
Installing RubyGems 1.3.6
RubyGems 1.3.6 installed
=== 1.3.6 / 2010-02-17
NOTE:
http://rubygems.org is now the default source for downloading gems.
You may have sources set via ~/.gemrc, so you should replace
http://gems.rubyforge.org with http://rubygems.org
http://gems.rubyforge.org will continue to work for the forseeable future.
New features:
* `gem` commands
 * Added `gem push` and `gem owner` for interacting with modern/Gemcutter
 sources
 * `gem dep` now supports --prerelease.
 * `gem fetch` now supports --prerelease.
 * `gem server` now supports --bind.  Patch #27357 by Bruno Michel.
 * `gem rdoc` no longer overwrites built documentation.  Use --overwrite
 force rebuilding.  Patch #25982 by Akinori MUSHA.
* Captial letters are now allowed in prerelease versions.
Bug fixes:
* Development deps are no longer added to rubygems-update gem so older
 versions can update sucessfully.
* Installer bugs:
 * Prerelease gems can now depend on non-prerelease gems.
 * Development dependencies are ignored unless explicitly needed.  Bug #27608
 by Roger Pack.
* `gem` commands
 * `gem which` now fails if no paths were found.  Adapted patch #27681 by
 Caio Chassot.
 * `gem server` no longer has invalid markup.  Bug #27045 by Eric Young.
 * `gem list` and friends show both prerelease and regular gems when
 --prerelease --all is given
* Gem::Format no longer crashes on empty files.  Bug #27292 by Ian Ragsdale.
* Gem::GemPathSearcher handles nil require_paths. Patch #27334 by Roger Pack.
* Gem::RemoteFetcher no longer copies the file if it is where we want it.
 Patch #27409 by Jakub Šťastný.
Deprecation Notices:
* lib/rubygems/timer.rb has been removed.
* Gem::Dependency#version_requirements is deprecated and will be removed on or
 after August 2010.
* Bulk index update is no longer supported.
* Gem::manage_gems was removed in 1.3.3.
* Time::today was removed in 1.3.3.
------------------------------------------------------------------------------
RubyGems installed the following executables:
 /usr/lib/ruby/gems/1.9.1/gems/rubygems-update-1.3.5/bin/gem
[root@bpdp-arch ~]# logout
Piece of cake, right? Wrong. Let’s see:

[bpdp@bpdp-arch ~]$ gem env
RubyGems Environment:
 - RUBYGEMS VERSION: 1.3.5
 - RUBY VERSION: 1.9.1 (2010-01-10 patchlevel 378) [i686-linux]
 - INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.9.1
 - RUBY EXECUTABLE: /usr/bin/ruby
 - EXECUTABLE DIRECTORY: /usr/bin
 - RUBYGEMS PLATFORMS:
 - ruby
 - x86-linux
 - GEM PATHS:
 - /usr/lib/ruby/gems/1.9.1
 - /home/bpdp/.gem/ruby/1.9.1
 - GEM CONFIGURATION:
 - :update_sources => true
 - :verbose => true
 - :benchmark => false
 - :backtrace => false
 - :bulk_threshold => 1000
 - REMOTE SOURCES:
 - http://gems.rubyforge.org/
[bpdp@bpdp-arch ~]$
So, I guess I should use old-fashioned way just as explained in manual:

[root@bpdp-arch ~]# gem install rubygems-update update_rubygems
Successfully installed rubygems-update-1.3.6
ERROR:  could not find gem update_rubygems locally or in a repository
1 gem installed
Installing ri documentation for rubygems-update-1.3.6...
Updating class cache with 132 classes...
Installing RDoc documentation for rubygems-update-1.3.6...
Could not find main page README
[root@bpdp-arch ~]# gem env
RubyGems Environment:
 - RUBYGEMS VERSION: 1.3.5
 - RUBY VERSION: 1.9.1 (2010-01-10 patchlevel 378) [i686-linux]
 - INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.9.1
 - RUBY EXECUTABLE: /usr/bin/ruby
 - EXECUTABLE DIRECTORY: /usr/bin
 - RUBYGEMS PLATFORMS:
 - ruby
 - x86-linux
 - GEM PATHS:
 - /usr/lib/ruby/gems/1.9.1
 - /root/.gem/ruby/1.9.1
 - GEM CONFIGURATION:
 - :update_sources => true
 - :verbose => true
 - :benchmark => false
 - :backtrace => false
 - :bulk_threshold => 1000
 - REMOTE SOURCES:
 - http://gems.rubyforge.org/
[root@bpdp-arch ~]#
This didn’t work too. Looks like I need to manually execute the script to update RubyGems:

[root@bpdp-arch ~]# update_rubygems
RubyGems 1.3.6 installed

=== 1.3.6 / 2010-02-17

NOTE:
[ ... cut ... ]
[ ... cut ... ]
[ ... cut ... ]
------------------------------------------------------------------------------

RubyGems installed the following executables:
 /usr/bin/gem
[root@bpdp-arch ~]#
And then I am happy with the result:
[root@bpdp-arch ~]# gem env
RubyGems Environment:
 - RUBYGEMS VERSION: 1.3.6
 - RUBY VERSION: 1.9.1 (2010-01-10 patchlevel 378) [i686-linux]
 - INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.9.1
 - RUBY EXECUTABLE: /usr/bin/ruby
 - EXECUTABLE DIRECTORY: /usr/bin
 - RUBYGEMS PLATFORMS:
 - ruby
 - x86-linux
 - GEM PATHS:
 - /usr/lib/ruby/gems/1.9.1
 - /root/.gem/ruby/1.9.1
 - GEM CONFIGURATION:
 - :update_sources => true
 - :verbose => true
 - :benchmark => false
 - :backtrace => false
 - :bulk_threshold => 1000
 - REMOTE SOURCES:
 - http://rubygems.org/
[root@bpdp-arch ~]#

Februari 03, 2010

Managing a Software Development Team: Some Experiences

Managing a software development team is never an easy task. It consists of 2 sides: technical and non-technical. This task is often assigned to the project manager. To be succeed, one has to consider those 2 sides. Below are some of my experiences in managing a software development team. This list is not meant to be complete. You may need more but at least you will be in the safety line level one if you do care with these issues.

Decide the tools which will be used by the team

Well, this is a bad news if you don't have enough technical capabilities. Once you don't decide the tools, your team will be confuse as they have more than one preferences. It's not funny to have your team uses PHP with different versions, some use WAMP while the others use XAMPP or maybe PHP which comes from some Linux distros. It's not funny to have your team uses Notepad, Textpad, Vim, Netbeans, Eclipse, for their IDE/Text Editor. This will waste much time and bandwidth. Consider this, if they use different tools, then when someone says: "uh oh, my Vim always give me a tab and not some spaces, how do I turn the tab into spaces?" and then nobody can answer this and probably think "that is your responsibility, I don't care because I never use Vim". Now consider if everybody uses Netbeans (note: I don't have any relation whatsoever with Netbeans nor a Netbeans evangelist), when someone yell "How do I create a new PHP module in Netbeans?", chances are some of the guys in your team know about this.

Use a specific software development methodology, probably with some minor adaption

A software development methodology consists of process and modelling. It guides the team through the process and enable the team to model the software which is built by the team to solve client problems. It is important to use the specific methodology so that everyone in the team knows what and how to do the development. If you don't decide any methodology, then your team won't have any guides. Remember, you have to use a specific methodology but don't be too rigid. Your team may consists of people from many backgounds with many level of capabilities. For example, you may use a Unified Process methodology but because your team is limited and don't have time to learn how to use UML, then don't push them to use rigid UP methodology. The most important thing here is process. Do use that process but don't be too rigid.

Make some conventions regarding technical issues

Again, this is important to keep the team away from the state of flux and let the guys in the team communicate with the same language. You surely don't want your team to have more than one variable / property naming system, right? What if some programmers use "this_is_a_variable", while the others use "thisIsAVariable"? quite confusing, I guess. You may need to define some coding conventions and probably uses software tool to force this conventions, for example if you use Java, you may use Checkstyle.

Know the client(s) and their problems which are tried to be solved

You must understand this good enough so that you can define the scope of the problems and deal with the problems.

Decide the scope of the problems and insists on this.

Clients basically don't understand the requirements, so your duty as a project manager is to define the scope of the problems which are tried to be solved by the software. You must cooperate nicely with the client and have the information understood by all team members. From programmers' point of view, the uncertainty caused by scope uncertainty will lead to frustration. Well, I do understand that agile methodologies encourage changes, but who want to deal with changes everytime? What I am trying to say is you as a project manager should understand that changes are possible but this should be done within the scope. Don't play with programmers' heart ;)

Have a good interpersonal relationship and don't be a jerk

I know that this software development task is not easy. Clients always ask the progress and the team is in a stress condition. It really helps to just stay with the team and always willing to help them whatever you can than just act like a jerk who walks here and there and yelling. Trust me, the team will respect you more if you are always willing to help them.

Never let the team in a state of flux

Uncertainty comes everytime. Whenever the team has anything uncertain, your decision is needed to keep them stay away from confusion. You do understand that you have to have a good grasp in technical side and problem domain to make a good decision, don't you?

Let the team concentrate on technical matters

Ok, pay attention more to non technical matters so that the team can concentrate on technical side. Don't let them do any clerical things since programmers (usually) hate to do administrative things. It's good to have a dedicated person to deal with all administrative things.

Let the team member knows each other about progress and difficulties

Opennes is important. By let them know each other's progress, you keep them in a fair situation. Low salary probably can be understood, but unfair treatment can not be tolerated.

Inform the team about your progress too

So you think you can hide your progress? The team will surely want to know that you do your jobs too. If you hide your progress, they will lose respect and trust in you.

Communicate. Communicate. Communicate

I can not stress more. This is really important for the team to have them communicate each other. Your tasks will be to communicate with them and act as a liaison between the team and the client. Oh and don't forget, have a good sense of humour.

Always keep backup of everything

You don't need to backup everything if you are sure that you always live in an ideal situation. You should keep backup in more than one place. Compress them and have them uploaded anywhere on the Internet (4shared.com, rapidshare.com, /etc) as long as you have full control of your files.

Use Version Control System

Version control system is a software which can be used to track the software source code versioning. You may use git, mercurial, subversion, /etc for this purpose.

Use web based bug tracking system, project management software, and/or wiki

This will keep any information handy and on track. All any other members can also see the project's progress. It will keep each team members informed and any unfair situation can be detected.

Januari 05, 2010

MVC Without Framework: JSP and Servlets Integration

Introduction

This post is used to showcase a MVC pattern for web development without framework. Its functionality is display a random number which is set by a bean and populated by a servlet. I use the source code from book “Core Servlets and Java Server Pages” – chapter 15, which is available online at http://pdf.coreservlets.com/. Credits should goes to Marty Hall and Larry Brown, I only make some minor replacement (for Tomcat 6.0.20) and more details instruction for the shake of my student’s clearlyness.

Directory Structures and Files

[bpdp@bpdp-arch webapps]$ tree mvc/
mvc/
`-- WEB-INF
 |-- classes
 |   |-- beans
 |   |   |-- NumberBean.class
 |   |   `-- NumberBean.java
 |   `-- servlets
 |       |-- RandomNumberServlet.class
 |       `-- RandomNumberServlet.java
 |-- views
 |   `-- RandomNum.jsp
 `-- web.xml
5 directories, 6 files
[bpdp@bpdp-arch webapps]$
Files

NumberBean.java



package beans;

public class NumberBean {

 private double num = 0;

 public NumberBean(double number) {
   setNumber(number);
 }

 public double getNumber() {
   return(num);
 }

 public void setNumber(double number) {
   num = number;
 }

}
RandomNumberServlet.java

package servlets;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import beans.NumberBean;

/** Servlet that generates a random number, stores it in a bean,
 * and forwards to JSP page to display it.
 */

public class RandomNumberServlet extends HttpServlet {
  public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException {

    NumberBean bean = new NumberBean(Math.random());
    request.setAttribute("randomNum", bean);
    String address = "/WEB-INF/views/RandomNum.jsp";
    RequestDispatcher dispatcher = request.getRequestDispatcher(address);
    dispatcher.forward(request, response);
  }
}
RandomNum.jsp



 
web.xml




From these source code, you should know that I have prepare directory for views (only for JSP), servlets (all servlets), beans (all beans). That way, we can separate our application into 3 functionalities: Model (beans) – View (JSP) – and Controller (servlets). This will keep your mind stay organized.

Run Application

Execute the application by typing its URL: http://server:8080/mvc/randomize. Here’s the screenshot:









Notes:

If you want to copy, the source code, have a look here: http://bambangpdp.wordpress.com/2010/01/06/mvc-without-framework-jsp-and-servlets-integration/

Quick Hack for the Impatients: JSP Custom Tag

Introduction

Source code from this posting was taken from http://java.sun.com/developer/technicalArticles/xml/WebAppDev3/ with some minor replacement needed for Apache Tomcat 6.0.20 (latest as of this date) and more details on how to run the application.

Purpose of Application

This application is used as a showcase for jsp custom tag. Its functionality is create custom tag for jsp to display string in lowercase.

Directory Structure and Files

[bpdp@bpdp-arch webapps]$ tree customtags/
customtags/
|-- WEB-INF
|   |-- classes
|   |   `-- tags
|   |       |-- ToLowerCaseTag.class
|   |       `-- ToLowerCaseTag.java
|   |-- mytaglib.tld
|   `-- web.xml
`-- coba.jsp

3 directories, 5 files
[bpdp@bpdp-arch webapps]$
We created customtags directory under webapps (which is needed for an application to be executed by Tomcat).  Pay attention to file mytaglib.tld, this file is used as tag lib descriptor to describe descriptor for taglib.


Files

ToLowerCaseTag.java

package tags;

import java.io.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;

public class ToLowerCaseTag extends BodyTagSupport {

   public int doAfterBody() throws JspException {
      try {
         BodyContent bc = getBodyContent();
         // get the bodycontent as string
         String body = bc.getString();
         // getJspWriter to output content
         JspWriter out = bc.getEnclosingWriter();
         if(body != null) {
            out.print(body.toLowerCase());
         }
      } catch(IOException ioe) {
         throw new JspException("Error: "+ioe.getMessage());   
      }
      return SKIP_BODY;
   }
}
web.xml




mytaglib.tld



coba.jsp



Notes: 

From  all of the files above, you should know the relationship between taglib uri="mytags" prefix="first"  (in coba.jsp) with mytags (in web.xml).

I used screenshot and not embedded code because this post interpret tags as HTML and keep yelling about error, so if you want to copy the source code, have a look here: http://bambangpdp.wordpress.com/2010/01/06/217/

Run Application

To run this application, type the URL: http://server:8080/customtags/coba.jsp
Here's the screenshot:


Januari 03, 2010

Configuring mutt for IMAPS


Here’s a trivial guide for desperately busy people to start using mutt, yes the mail client that suck less. If you like simplicity and more on functionalities than eye candy, this should be your mail client (and who the hell are you to ask me to do that? — you said :p).

Ok, to begin, you should know your user name, IMAP server, and SMTP server details. This should not be difficult since you should have this first place when you got your mail hosted somewhere else (for example, you may login to cpanel and than get this information from your e-mail account.
Firstly, the configuration file. Mutt uses $HOME/.muttrc as the default configuration file. There are some configuration. Here’s mine (this is not complete .muttrc, I put this only the parts which is useful for this guide):
# put your email address here
set from="bpdp@contextualmind.net"
set use_from=yes
set envelope_from="yes"

set editor=vim

set folder="imaps://username@imapserver"
set spoolfile="imaps://username@imapserver/INBOX"

set imap_pass="putpasswordhere"

set smtp_url="smtp://username@server/"
set smtp_pass="putpasswordhere"

bind index 'G' imap-fetch-mail
set mbox="!"
Run mutt from shell and use G key to refresh (just as you have already defined in bind index).

Happy mutt-ing, people :)