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.jpgThe output will be a mosaic of 6 images, 2 columns, 3 lines, with a small black line as seperation.
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 :
The 1337 bash way :
for i in *.JPG; do mv "$i" "$(echo "$i" | sed -e 's/.JPG$/.jpg/')" ;doneThe 1337 portable way (thx to Krunch) :
for i in *.JPG; do mv “$i” “`echo “$i” | sed -e ’s/.JPG$/.jpg/’`” ;doneThe easy way :
rename 's/.JPG$/.jpg/' *.JPG
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-assistantthen :
module-assistant update module-assistant prepare module-assistant get acx100 module-assistant build acx100 module-assistant install acx100if everything was ok :
modprobe acx iwconfigthe interface wlan0 should appear
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
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
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 :
This will produce 2 files :
At first, you need to have a pair of keys, here’s the way to generate them :
ssh-keygen -t rsaand 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
PermitRootLogin no PasswordAuthentication no UsePAM noNow 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 restartIf everything went fine, root can’t log on anymore, and users must use a pair of keys.
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" <-> rightTo 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