Archives for the month of: June, 2009

There are severeal ways of doing this. One is to have GRUB on the MBR on your harddrive, and booting whatever OS you have in you /boot/grub/menu.lst.

I have Windows XP on my first partition, Slitaz on my second and Arch on my third. This is only on my laptop. My desktop computer looks even worse ūüėČ

Anyway – WinXP requires to be boot from the first partition following the MBR or something. Go figure. And it has its own bootloader, so GRUB must chainload it. I also did this with my first trial of Arch – chainloading a second GRUB install which deals with its respective kernels. This way new kernels will be populated in its own menu which belongs to the correct partition and OS, which keeps my original menu.lst clean(er).

My /boot/grub/menu.lst which resides on my /dev/hda, looks like this. As you can see, I could install GRUB on my Slitaz partition as well – to keep it even cleaner.

# /boot/grub/menu.lst: GRUB boot loader configuration.
default 2 # 3rd entry
timeout 2 # seconds delay

title     Windows
 rootnoverify (hd0,0)
 makeactive
 chainloader +1

title   SliTaz Latest (Kernel 2.6.29.3-slitaz)
 root (hd0,1)
 kernel /boot/vmlinuz-2.6.29.3-slitaz root=/dev/hda2

title     Slitaz (wireless) (Kernel vmlinuz-2.6.25.5-slitaz)
 root (hd0,1)
 kernel /boot/vmlinuz-2.6.25.5-slitaz root=/dev/hda2

title      Arch Linux  [chainload]
 root   (hd0,2)
 chainloader +1
Advertisements

I am impressed! When writing the header of a function, why not simply write an example and automatically test the function?

#!/usr/bin/env python

import doctest

def fact(n, stop=1, r=1):
 """ An iterative factorial function.
 n!     = n*(n-1)*(n-2)*..*(n-(n-stop-1))*r
 stop    fact(5,3)= 5*4
 r        fact(5,3,10)=5*4*10
 >>> fact(5,3,10)
 200
 >>> fact(4)
 24
 """

 while n > stop :
   r *= n
   n -= 1
   return r    

def main():
 doctest.testmod()
 return 0

if __name__ == '__main__': main()

More here: http://docs.python.org/tutorial/stdlib.html#quality-control

To get lighttp to run python files, you need to tell it to do so. The standard configuration file that comes with Slitaz only allows scripts to be run in the /cg-bin/ folder. I guess this is personal preference – but I want to be able to run scripts everywhere! This can easily be changed ( the orginal line is commented out):

# $HTTP["url"] =~ "/cgi-bin/" {
$HTTP["url"] =~ "/" {
   ".cgi" => "/usr/bin/python",
   ".py" => "/usr/bin/python"
 )

How hard can it be, right?

Setting up lighty is simply too easy! On Slitaz it is a matter of downloading and start the server. Just point your browser to localhost and expect it to work!

When working with different projects it is handy to use subdomains or virtual hosts. Or – if you host different sites, virtual hosting is a must. It is also very simple to setup. Make sure the vhost.conf is read by lighttp.conf, and modify the former with your virtual host:

# /etc/lighttpd/vhost.conf
$HTTP["host"] =~ "(^|\.)bridge$" {
 server.document-root = "/home/tux/www/bridge"
 server.errorlog = "/home/tux/www/bridge/log"
}

Make sure you create the log file and set the approriate ownership on the file which is set in lighttpd.conf before restarting. I use www:www, thus

# su
# chown www:www /home/tux/www/bridge/log

Make sure you add the hostname to your /etc/hosts:

# echo "127.0.1.1 bridge" >> /etc/hosts
# /etc/init.d/lighttpd restart

The sound control on lxpanel only handles one channel. But let’s say I want to control mute/unmute on mic by a handy shortcut! Two handy scripts fixes this, which can be assigned to a keyboard shortcut in Openbox or your preferred WM/DE.

#!/bin/sh
amixer set Mic 80% mute > /dev/null
#!/bin/sh
amixer set Mic 80% unmute > /dev/null

You may of course choose any other control you want – ie PCM:

amixer set PCM 10%+ > /dev/null

Will increase sound by 10%.

Oh – the possibilities!
sed, grep and a lot of editors support the use of regexp. It’s about time I learned it!

Bash, ash, sh and zsh – it’s a jungle! Zsh is apparently more filled with features and tuning capabilities than the others. The Bash is the default shell in many distrobutions. But it does not mean that it is the best shell out there!

Zsh is not new – it has been available for several years. But I am having a feeling its userbase has increased, as I see more references to it in forums in the cloud.

So – I will have to learn more about it! No way around it! I am working on some shell-scripts, and got a little frustrated when I realised busybox’ sh was not capable of everything I picked up of tips around the net. Bash does the job, but maybe zsh can do it even better?

I like to have my desktop setup in a certain way. Especially I like to have Firefox/Minefield in fullscreen mode on its own desktop. Openbox lets you automate this. You might want to use xprop, as the inline comments in rc.xml says, to identify windows. I did this – but I was fooled. I use Slitaz at the moment, and xprop gives the following information:

WM_CLASS(STRING) = "Navigator", "Minefield"

The name attribute returns the webpage you’re on, so that’s useless. BUT – using either Navigator or Minefield in the rc.xml fails – it is executed by “firefox-bin”! I spent way to much time on this, so I am actually considering notifying the developer about this behaviour. My rc.xml now looks like this:

<application name="firefox-bin">
   <fullscreen>yes</fullscreen>
   <desktop>3</desktop>
</application>

I wanted to hide the menu bar in addition to the Bookmarks and Navigation bar. This simple add-on fixes it.