14 September 2010

CUPS page size error on HP laserjet

From today's experience, I found that it might be caused by wrong PCL option. When I chose PCL6 the page size printed was only halfsized. But after I chose PCL4/5 it was OK.


Printing using command line is the following(watch out the CAPITAL P for specifying page!):
For two sides:
lp -d dest_print -o media=a4 -o sides=two-sided-long-edge -P 1-3 file.pdf


For two sides, each side two pages (for this setting the page numbering is strange, e.g. for printing page 1 to 8 you write -P 1-4, for 15-22 write -P 8-11, and the sides SHORT option is important to prevent having upside down pages):
lp -d dest_print -o media=a4 -o sides=two-sided-short-edge -o number-up=2  -P 1-4 file.pdf

23 Agustus 2010

Challenge of amd64

Last update: 22 Sept 2010, 1 Oct 2010, 2,4,17 Jan 2011, 1 Feb 2011, 25 March 2011




Succeed with installing 64 bit lenny on my computer, now I have many problem with this 64 bit. At first it was fun, that I had to compile or configure many things, which were not available as is. Now I'm deeply considering of moving back to 32 bit, even on the first day I've asked myself how long I will stand with this 64 bit stuffs. Today I get a bitter experience that I cannot compile a software platform on which I'm working on. The compiler run for hours, but a lot of trailing errors afterward.
The amount of time needed for compilation has discouraged me for doing further observation. I'd like to make it works actually. [Hi this platform uncompiled was not amd64 fault!]
Since the platform only compatible to 32 bit OS, I have to provide all the libraries
needed in 32 bit. Therefore instead of using synaptic debian package manager(which provides 64 bit libraries only by default), I have
to grab the library source code and then recompile it into 32 bit. Details are provided below under installing 32 bit library matter.
Note: many resources in internet about the trouble of linux 64 bit mostly a bit out of date. Lenny has fixed a lot of thing. One useful tips when we cannot find 64bit version of debian is just taking the 64 bit version of ubuntu, it works for me for skype.


Now let me list my footprints until I arrive here:

  1. Wireless, using iwlagn. Note that you must have access to the backport of lenny. If you don't have wired access you can also download the files one by one, and run dpkg -i packageName.deb
    Somehow you need to call ifconfig wlan0 up before calling iwconfig
  2. flash plugin was taking a very long way, until I found Debian Lenny 64 bit installation. It is really good. It points to How to get flash working in 64 bit. Follow the instruction! Just remember to download the keyring manually before touch the repository.
    Update: Adobe has just provided native 64 bit flash player plugin. Just untar and put the library on place
    cp libflashplayer.so  /usr/lib/mozilla/plugins/

  3. Screen off just using vbetool from official repository
  4. skype, just grab ubuntu64 deb package from skype's website
  5. pidgin, need to compile the newest distribution from scratch. The binary from repository doesn't provide client for yahoo and msn messenger.
  6. Speaker. My speaker is mono (written as monaural to be cooler). It didn't output sound, even though the headphone jack is work perfectly. Following ubuntuforum about "Headphones work-no internal speaker sound?", I found that debian has a bit different configuration. Debian doesn't have /etc/modprobe.d/alsa-base.conf, instead it split it into /etc/modprobe.d/alsa-base and another file /etc/modprobe.d/sound. I change the options on /etc/modprobe.d/sound from
    alias snd-card-0 snd-hda-intel
    options snd-hda-intel index=0
    into
    alias snd-card-0 snd-hda-intel
    options snd-hda-intel model=laptop


  7. Compile latest kernel. It's supposed to fix backlight problem but gain nothing.
    Other thing I get is it "How easy it is to compile kernel". In newer kernel Intel wireless driver is given out of the box. Here the step for kernel compilation, an experience version of this instruction with a fix for lenny:

      Download the latest stable kernel from here
      Extract it
      Prepare/clean everything there. It will delete everything you put there

      make clean && make mrproper

      copy configuration file from /boot/. Its name is config-your-kernel-name. It is the most convenient way instead of create configuration from scratch.
      Name the new file as ".config"
      REFINE ".config"
      make menuconfig

      there should be ....coutinued...sorry I forgot some steps. There is a mandatory step to copy some generated code to the kernel source include folder. please look for it on internet.


  8. network manager. I got no luck with gnome network manager with lenny, unlike when I installed ubuntu. Fortunately there is wicd package that work out of the box. Give it a try if you have the same experience :^).

  9. Installing 32 bit library on it. It was a desperate effort, that finally turn into a hack. First install the 64 bit version as usual using synaptic. Then delete the 64 bit library. Afterwards put the 32 bit library on the same place as the location of deleted 64 bit, no need to copy the symlink, ldconfig will do it for you. Run ldconfig. voila! Here is the illustration. RESULT: program is compiled, but not run!
    kompie# ls /usr/lib|grep gsl
    libgsl.a
    libgslcblas.a
    libgslcblas.so
    libgslcblas.so.0
    libgslcblas.so.0.0.0
    libgsl.so
    libgsl.so.0
    libgsl.so.0.12.0
    kompie# rm /usr/lib/libgsl*
    kompie# ls /usr/lib|grep gsl

    All 64 bit libs have been deleted. Now put the 32 bit ones.

    kompie# cd gsl-1.0/
    kompie/gsl-1.0# cp .libs/libgsl.a /usr/lib
    kompie/gsl-1.0# cp .libs/libgsl.so.0.0.0 /usr/lib
    kompie/gsl-1.0# cp cblas/.libs/libgslcblas.
    libgslcblas.a libgslcblas.lai libgslcblas.so.0
    libgslcblas.la libgslcblas.so libgslcblas.so.0.0.0
    kompie/gsl-1.0# cp cblas/.libs/libgslcblas.a /usr/lib
    kompie/gsl-1.0# cp cblas/.libs/libgslcblas.so.0.0.0 /usr/lib/
    kompie/gsl-1.0# ls /usr/lib|grep gsl
    libgsl.a
    libgslcblas.a
    libgslcblas.so.0.0.0
    libgsl.so.0.0.0
    kompie/gsl-1.0# ldconfig
    kompie/gsl-1.0# ls /usr/lib|grep gsl
    libgsl.a
    libgslcblas.a
    libgslcblas.so.0
    libgslcblas.so.0.0.0
    libgsl.so.0
    libgsl.so.0.0.0
    kompie/gsl-1.0#
    Warning!!! All this hacking trick DID NOT work! Finally I do this following to compile my GSL library into 32 bit
    $ CFLAGS="-m32 -g -O2" LDFLAGS="-m32" ./configure i386

  10. Backlight control....again. Didn't get any luck from recompiling kernel, again a retried my with other driver module, now it is from Regis Prevot, watchout, the ssl configuration in your browser might be nasty. Just take panasonic_acpi.c and the Makefile. This driver was intended to be used with W7 and W7, that have DVD drive. Since mine is T-series I have to remove all DVD related code. I don't know if it was caused by my highly abusive kernel recompilation so the compilation related to DVD device was failed.

    Before loading the new driver, first I have to remove panasonic_laptop module, I dont know how to do it. So I do it brutally, remove the file from the kernel ;^(, then reboot. Run "depmod -a" to remove its entry as well. Finally run "modprobe panasonic_acpi" to load the new driver, this command will not succeed unless you remove the panasonic_laptop module.
    Result: The driver is succesfully loaded, but the screen back light is still inaccessible.

  11. Fullscreen problem with mplayer. It's only simple fix on xorg.conf, just add driver to the device.
    Section "Device"
    Identifier "Configured Video Device"
    Driver "intel"
    EndSection


  12. Touchscreen that haunted me from the beginning finally works pretty well. I use evtouch. Instead of using the installation from debian repository, I used the latest version (0.8.8) and compile it. A simple trick about the installation directory; by default it installs on /usr/local/lib/ but my X cannot find it, and I cannot find how to make it works. So I change the prefix entry on the Makefile, instead of /usr/local, I change it into /usr.

    The main issue with the driver from debian repository is its ability to act like mouse. It can only draw horizontal or vertical line.

    Here is my xorg.conf entry as the result of try and error calibration process:
        
    Option "MinX" "50"
    Option "MaxX" "3900"
    Option "MinY" "150"
    Option "MaxY" "4050"
    Note that the log from /var/log/Xorg.0.log has an entry "Setting screen physical size to 270 x 203"

  13. Screen rotation is pretty simple using xrandr. From shell just type:
     xrandr -o left


  14. Brightness, a success story :D. Just make sure you have "panasonic_laptop" module in your kernel. Run "depmod -a" to make sure everything properly listed, check using "lsmod -a", if not listed run "modprobe panasonic-laptop". Yup that's the preliminary.
    This is the most important thing, set the grub! Look for this similar line code on /boot/grub/menu.lst
    kernel /boot/vmlinuz-2.6.35.3-intel-amd64 root=UUID-...-xxxx ro
    then change into [the "=" sign is not a cosmetic]
    kernel /boot/vmlinuz-2.6.35.3-intel-amd64 root=UUID-...-xxxx ro acpi_osi=

    Voila brightness accessible trough:
    root# echo BRIGHTNESS > /sys/class/backlight/panasonic/brightness
    Note root access is mandatory, therefore we need to fix the acpi script ... where BRIGHTNESS value between 0 to 21
  15. I upgrade to Squeeze

  16. Still many things to go ...

07 Agustus 2010

Installing debian 64 bit on intel laptop from USB flash disk


First of all, in debian, 64 bit for ordinary intel processor is denoted as AMD64
instead of IA64, which is totally different architecture that is die casted
on unpopular intel Itanium processor only.

The procedure is quite simple.

  1. Use unetbootin to create a bootable usb disk debian linux installer. I personally
    suggest using [Distribution], then I choose "Debian" and "Stable_HdMedia_x64".
    After the process done, check whether /dev/sdX1 mountable. If not try to plug the stick off
    and plug it in again, hopefully it will be automounted. From this point forward
    I assume we can mount and write into /deb/sdX1, e.g. mount into /mnt/usb/

  2. Download debian-505-amd64-CD-1.iso from debian.org and copy the file into mount point
    of /dev/sdX1 (eg. /mnt/usb/). The installer is supposed to fetch this file from
    the network. But when we cannot configure our laptop to have internet connection
    this should help. Moreover the inetbootin can be configured in Windows!

Voila...
We have a USB installer with full support from CD1 of debian lenny.

warning: this procedure is proven doesn't work for squeeze

20 Juni 2010

specification pattern


a very nice site about specification patterns to be verified using formal method :


16 Juni 2010

some useful daily scripts

Last update: 13 Feb 2011
I wrote several simple scripts to manipulate the content of files. Most of them are written in bash, but due to my lack of expertise sometimes I mixed bash with make, and perl. It will be very practical.. almost no explanation, but I'll try to gradually improve this article. Here are they:

  1. Find the files with specific content
    find . -type f -name "*.bash" -print0|xargs -0  grep -ne "keyword"


  2. Change certain content of files in batch manner. Just copy these script into a command.bash, and change the permission then run it (command filenamepattern old new)
    ./command.bash "tt*" tir ti
    The script:
    #!/bin/bash
    
    TMPDIR=/tmp
    
    fname=${1}
    old=${2}
    new=${3}
    tmpfile=${TMPDIR}/$$.tmp
    #echo "ls ${fname}"
    for mydataset in `ls ${fname}`; do
    echo "${mydataset}"
    cat ${mydataset} | sed -e "s/${old}/${new}/g" > ${tmpfile}
    mv ${tmpfile} ${mydataset}
    done
    
    
    


  3. Delete a bunch of file
    If you have thousand of files, rm * will not work, therefore here is an alternative. Create a makefile with the following entry and call make clean.
    clean:
    find . -name "*.log" -print -exec rm {} \;
    
    
    

  4. Creating tags for emacs
     find . -name "*.[chCH]" -print | etags -

    In case you have only few files
     etags file1 file2 ...
  5. Removing Hijriah calendar from islamicfinder.com praying timetable :). Often the hijriah date make me confuse and pick a wrong time. I do it in vi using this search and replace command.
    :%s/[0-9]*\/[0-9]*\t//g

  6. Cleaning carriage return/line feed (crlf) but left double crlf. I use this for formatting my latex style text file (which uses crlf extensively) before I upload it into blogger.
    cat fileinput |sed -n 'H;${g;s/\n/crlf/g;p}'| sed -n 'H;${g;s/crlfcrlf/\n\n/g;p}'| sed -n 'H;${g;s/crlf/ /g;p}' > file output

  7. Resize pictures/images, 1024 is the width
    mogrify -resize 1024 *.jpg
  8. Montage/combine/collate pictures into one
    montage *.jpg -tile 1x2 -geometry 1024 combine.jpg
  9. Convert  images into pdf
     mogrify -format pdf *.jpg
  10. Download Al-Quran ayats.
    #usage:
    # want to download albaqarah ayat 1 to 10
    # to download other ayat you must change this script accordingly
    # just to list the download commands
    #$ bash dlayat.sh 1 10
    # actually download
    #$ bash dlayat.sh 1 10 download
     
    i="${1}"
    j="${2}"
    download=0
    if [ "${3}" == "download" ]
    then
        download=1
        echo download
    fi
    
    while [ $i -le  $j ] 
    do
    padd=""
    if [ $i -lt 100 ] 
    then
     padd="0"
    fi
    if [ $i -lt 10 ]  
    then
     padd="00"
    fi
    
    if [ $download -eq 1 ]
    then
        wget http://www.everyayah.com/data/Ghamadi_40kbps/002${padd}${i}.mp3
    else
        echo wget http://www.everyayah.com/data/Ghamadi_40kbps/002${padd}${i}.mp3
    fi
    i=$[$i+1]
    done
    
  11. Converting raw images into jpg in batch manner
    #change the raw file extension accordingly
    thepath=${1}
    
    for file in `ls ${thepath}*.CR2`; do
        ufraw-batch --out-type=jpg ${file}
    done
    
  12. To be continued..

06 Juni 2010

service bagus telkom speedy


Hari itu pas hari minggu, hujan deras. Pas mau magrib internet gak jalan.
Telpon ke customer service telkom disuruh restart dsb, tapi tetap
saja tidak jalan. Akhirnya dijanjikan akan dicek ke rumah.

Sekitar jam 7 malam, beneran ada petugas yang datang, ngecek koneksi dsb.
Eh ternyata memang koneksi ADSL nya yang lepas di central stationnya.
Mas petugasnya nelpon temannya yg bagian jaringan dan akhirnya dibenerin
di centralnya.
Salut.. hari minggu malam2 hujan deras pula. Salut telkom speedy.

Sejauh ini hanya itu saja masalah yg terjadi, speed ke lokal baik2
selalu, sekitar 300kbps. Begitu ngakses di luar IIX.. mampus deh..
tapi masih acceptable. berikut screen shotsnya:











Ini speed waktu download package dari shol.vlsm.org