17 September 2013

setting group in linux for printer administration

Finally I need to learn this matter when I encounter the problem of giving right to ordinary user to touch the printing system administration, namely lpadmin. So here are important commands:
Shows available groups:
$ groups 

Shows groups where a username belong to:
$ id username 

Adds a user into a certain (secondary) group:
$ usermod -a -G group user 
warning: DO NOT forget the -a option. Putting only -G will delete other previously defined groups of the user, and overridden only with the new one. About the primary group check this link about the problem of primary group in debian.

Here is the complete commands with username latihan:
$ id latihan
uid=1001(latihan) gid=1001(latihan) groups=1001(latihan)

$ sudo usermod -a -G lpadmin latihan
$ id latihan
uid=1001(latihan) gid=1001(latihan) groups=1001(latihan),107(lpadmin)
Now user latihan can run lprm to delete print spools.

26 Agustus 2013

laptop processor fan error solved

Followed up the first failed attempt to disassembling my laptop, finally I could fix the fan error. My friend actually did it :D, just by spraying high pressure lubricant into the fan motor. I also renewed the thermal paste that was totally dried.

At a slight sight my friend was able to determine the problem. He turned the fan, but it didn't spin continuously, only 1 rotation and stop. After the lubricant was sprayed, it spin longer up to several rotation. Incredible skill. Good bye noise!

error in primary group changing of debian

There is terrible problem with primary group changing in debian. When I unleashed this code
sudo usermod -g primgroup user
the shell doesn't respond. It looks like that it hangs. But when I tried on other shell, it says that it change nothing (so apparently the first command [the hang one worked]). Still it is a mistery! Furthermore when I tried to create a file, and check it using
 ls -l 
it still gave me the old primary group. Amazingly after I restart my computer, tadaaa, everything set up as expected. So? I don't know

03 Mei 2013

linux sound error in CF-T8

It is common that linux(particularly debian) on panasonic toughbook series have sound problems; either no sound from the internal speaker, internal speaker stays on despite the headphone is plugged, no sound at all or any combination of them.

A simple solution is given in agentoss.wordpress.com. Just comment out everything in /etc/modprobe.d/alsa-base.conf. Then put this configuration there:
options snd-hda-intel model=thinkpad

13 Maret 2013

linux kernel kompilation

again? yeah sadly!
  • 0. Source Preparation
    If you just downloaded the latest kernel, just go to no. 1. In case you already have previous kernel source, you should download just the patch, instead of downloading the whole new kernel. How to apply patch? its in the kernel Documentation/applying-patches.txt
    summary:
    in version 3 kernel, linux patch from 3.x.y is relative to 3.x
    but the patch of 3.x1 is relative to 3.x0
    illustration:
    linux-3.8.2/ is created from linux-3.7.9, so you have to go back to 3.7
    from 3.7.9 apply reverse patch you get 3.7
    apply patch (forward) from 3.7 to 3.8
    apply patch (forward) from 3.8 to 3.8.2
    voila!
    note: What if my kerne source is 3.0.1? just go back to 3.0 then repeatedly patch forward 3.1, 3.2, ..., until 3.8, then apply 3.8 to 3.8.2
    in short:
    $ cd kernel-source-directory
    for reverse patch (-R option)
    $ patch -R -p1 < ../patch-x.y.z
    for (forward) patch
    $ patch -p1 < ../patch-x.y.z

    Now you can configure your kernel.
    small note on .config file, keep it back up, every time runs make menuconfig.
  • 1. In Debian
    If you want to be cool even though in debian, go to no. 2.
    Debian has a very nice tool to compile kernel.
    http://www.debian.org/releases/stable/i386/ch08s06.html.en
    $ make menuconfig
    $ make-kpkg clean
    $ fakeroot make-kpkg --initrd --revision=custom.1.0 kernel_image
    you might want the header as well
    $ fakeroot make-kpkg --initrd --revision=custom.1.0 kernel_header
    ok you've got a deb package, just run dpkg -i  on it.
    nice and easy but it takes time for compilation somehow, because it doesn't compile incrementally, clean up everything every time make-kpkg runs. If you want the incremental compilation check the traditional way, no. 2.
  • 2. Traditional
    http://kernelnewbies.org/FAQ/KernelCompilation
    in short:
    compile everything
    $ make

    install modules, it will create the kernel directory /lib/modules/x.y.z and fill it with the kernel modules. Basically this is the kernel modules that you marked as [M] on kernel config.
    # make modules_install

    install the kernel into /boot, yep the kernel is just one file vmlinuz.x.y.z. It will not touch your /lib/modules directory.
    # make install
    not mandatory but preferable to create the initrd image, option -c for creating new, and -k for kernel version
    # update-initramfs -c -k x.y.z

    update your boot menu, I only know for _debian_
    run this anywhere, then copy  the grub.cfg into /boot/grub/
    # grub-mkconfig -o grub.cfg

voila, it's done,  just reboot!

20 Februari 2013

simple solution of slow treeview in pygtk

I found out that the solution was pretty simple. Instead of putting every value into _attached_ treeview's model, it is much faster to detach the model first, fill it with data, then reattach the model into treeview again. The improvement was very significant.
here is the sample code.
treeVw.set_model(None)
batch_insertdata(dataList)
treeVw.set_model(dataList) 

15 Februari 2013

detecting loop in single linked list

Very nice write up about this problem that made me finally understand. The key explanation is finally the fast pointer (hare) will overlap the slower one (tortoise).

The tortoise moves one step, the hare moves two steps. When there's a loop, no matter when/where, for sure they will on the same position. Amazingly, its complexity is only O(n).

01 Februari 2013

disassembling panasonic CF-T8

My pity that the fan is getting noisy around 50-60 C degrees. Finally I decided to disassemble the panasonic CF-T8. Unfortunately I could not find any clue whatsoever on the net. Even I tried to contact panasonic toughbook customer service, but they did not answer.. The number of the screws and the cute appearance have discouraged me to disassemble this laptop. But I could not bear the noise anymore, here we come!

  1. Prepare a light space to organize the screws. Seriously, the screws are a lot! It can make you dizzy when you reassembly the pieces.
  2. Unscrew all base screws, except these two that holds the main board PCB(see pic 1). Remember that there are still several screws under the keyboard. 
  3. Remove battery and hard disk 
  4. Be brave to pull the corner guards outward, it is toughbook, it is not delicate anyway 
  5. Remove the keyboard, by removing the locking mechanism in the bottom (see pic 2). Yes you have to remove the spill resistant plastic covers. Don't get hesitate to do so, you have no choice. If you have remove the screws which lock the keyboard you still have to fight the double adhesive that sticks the keyboard onto the base. Just carefully pull it. 
  6. Remove the cable of the keyboard from the mother board, again you have to get rid of the spill resistant cover. 
  7. Remove the screws and lock on the VGA port and extension port. 
  8. Remove the cable of touchpad and indicator lamp 
  9. Now you should be able to separate the upper part of the base. It is not easy tough, there is adhesive that sticks the plastic element, just be brave and be careful. 
  10. To remove the main board (see pic 3) you have to unscrew green screws, but don't unscrew the reds because they hold the heatsink. 
  11. Remove _short/tight_ cables on the right side of the main board. 
  12. Remove the main board, but be careful because the space for VGA connector is really tight (marked blue in pic 3). Now you have access to the fan. 
  13. On reassembly dont forget to put the switch in place before screwing. 
  14. Good luck 
I'll be more than happy if you find this post is useful.


pic 1. Two screws that hold mainboard

pic 2. locking mechanism to hold the keyboard

pic 3. screws to open mainboard (yellow)

05 Januari 2013

hello, world in django

creating project

$ django-admin startproject DOC
$ ls DOC/
__init__.py  manage.py  settings.py  urls.py
test the server
DOC$ ./manage.py runserver
get this page http://localhost:8000/
untouch project page


creating apps inside the project
$ cd DOC/
DOC$ ./manage.py startapp doc_ui
new folder doc_ui created
DOC$ ls
doc_ui  __init__.py  __init__.pyc  manage.py  settings.py  settings.pyc  urls.py

DOC$ ls doc_ui/
__init__.py  models.py  tests.py  views.py
showing a "hello, world":
  1.  make following changes 
    •  add
    (r'^doc_ui/', 'DOC.doc_ui.views.index'),
    to url_patterns in file urls.py
    • add
    'DOC.doc_ui', 
    to INSTALLED_APPS in file settings.py
  2. write this to file views.py
        from django.http import HttpResponse
        def index(request):
                return HttpResponse("Hello, world.")
run/restart the server
DOC$ ./manage.py runserver

Access through http://localhost:8000/doc_ui/ and then hello, world should show up thats all :D, but it is useless.

So far it is a beginning to write the controller part in MVC paradigm. If you have entities in your system that can be modelled as objects, django provides stunning approach to handle them as model (of MVC). The class declaration, the persistent database and the interface are seamlessly connected and provided instantly.