Sun Jul 22 14:15:08 CEST 2007

How to create mosaics with imagemagick?

It's quite simple:
montage -tile 2×3 -bordercolor black -border 1 -geometry 225×150+0+0 0*.jpg result.jpg
The output will be a mosaic of 6 images, 2 columns, 3 lines, with a small black line as seperation.

Just drop your thoughts | Posted by Gick | Permanent Link | Categories: Script

Sun Jul 22 14:12:16 CEST 2007

File renaming

How to rename a lot of files, like *.JPG to *.jpg
The 1337 bash way :
for i in *.JPG; do mv "$i" "$(echo "$i" | sed -e 's/.JPG$/.jpg/')" ;done
The 1337 portable way (thx to Krunch) :
for i in *.JPG; do mv “$i” “`echo “$i” | sed -e ’s/.JPG$/.jpg/’`” ;done
The easy way :
rename 's/.JPG$/.jpg/' *.JPG

Just drop your thoughts | Posted by Gick | Permanent Link | Categories: Script

Sun Jul 22 14:08:54 CEST 2007

Installation of the Netgear WG311v2 pci WIFI card

Debian Kernel >= 2.6.13
Download the firmware and put it in /lib/firmware

Check that your have a repository contrib in /etc/apt/sources.list and install wireless-tools and module-assistant :

apt-get install acx100-source wireless-tools module-assistant
then :
module-assistant update
module-assistant prepare
module-assistant get acx100
module-assistant build acx100
module-assistant install acx100
if everything was ok :
modprobe acx
iwconfig
the interface wlan0 should appear


Just drop your thoughts | Posted by Gick | Permanent Link | Categories: Config

Sun Jul 22 14:03:05 CEST 2007

Preventing Fork Bombs

What’s a fork bomb ?


It’s simple : “fork while fork”, a lot of processes will be created, using CPU and memory and it’ll become impossible to quit or reboot the machine using the system, you’ll need to press the reset button.
Please don’t try to execute these examples on an unprotected system !
one bash example :
:(){ :|:& }; :
  • : is a function that accepts no arguments ()
  • the code of the function is between {}
  • :|: the function calls itself and redirects its output on itself
  • & puts the call on background, if a parent is killed, the child process wont die
  • ; finishes the function
  • : is the call of the function
one perl example :
perl -e "fork while fork" &
One way to prevent fork bombs is to limit the number of fork by user in /etc/security/limits.conf
@users soft nproc 100
@users hard nproc 150

Just drop your thoughts | Posted by Gick | Permanent Link | Categories: Config

Sun Jul 22 13:26:00 CEST 2007

SSH for paranoiacs

Once you have installed the ssh daemon, you’ll have surely noticed that root can log on, and that any user (including root) can log on without a pair of private /public keys. Here’s the modifications to do :
At first, you need to have a pair of keys, here’s the way to generate them :
ssh-keygen -t rsa
and enter a passphrase.
This will produce 2 files :
  • id_rsa.pub is your public key, its content must be put on the remote machi ne in ~/.ssh/authorized_keys
  • id_rsa is your private key, don’t give it to anyone, you must put it in ~. /ssh/ on your machine
In sshd_config on the remote machine :
PermitRootLogin no
PasswordAuthentication no
UsePAM no
Now you can try to log in to your remote machine with your key. If it succeeds, restart sshd on the remote machine.
sudo /etc/init.d/sshd restart
If everything went fine, root can’t log on anymore, and users must use a pair of keys.

Just drop your thoughts | Posted by Gick | Permanent Link | Categories: Config

Fri Jul 20 16:08:24 CEST 2007

VIM tips 1

Open a document

vi document.txt

Insert some text
Type "i"

Moving around in the document

"h" <-> left
"j" <-> down
"k" <-> up
"l" <-> right

To leave the INSERT mode type ESC
Save and quit the editor
":w" <-> save the document
":q" <-> quit the document
":q!" <-> quit without saving the changes
":x" <-> save and quit

Just drop your thoughts | Posted by Gick | Permanent Link | Categories: VIM

Thu Jul 19 20:25:37 CEST 2007

Creating a blog with Nanoblogger

apt-get install nanoblogger
nb -b /path/to/the/blog -a

Just drop your thoughts | Posted by Gick | Permanent Link | Categories: Nanoblogger