2-cent tip: Convert a bunch of Images from one format to another
Amit Kumar Saha [amitsaha.in at gmail.com]
Tue, 22 Apr 2008 11:21:30 +0530
convert is a command line tool available with ImageMagick which can be used to convert between image formats. This shell script uses it to convert a bunch of images from '.ps' to '.png'. Follow embedded instructions to customize it to your needs.
#Script begins here #!/bin/bash # Uses the 'convert' utility to convert a bunch of images from one #format to another # the script should reside in the same directory as the images # You need to have 'ImageMagick' installed #(http://www.imagemagick.org/index.php) # By Amit K.Saha # Help taken from http://howtoforge.com/forums/showthread.php?t=4493 #to convert to/from different formats # change 'ext' to reflect the format you want to convert "from" # Chnage target to the format you want to convert to ext=".ps" target="png" for i in *.ps do base=$(basename $i $ext) #to extract only the filename and NOT the extension convert $i $base.$target done #Script ends here
Try it and suggest improvements!
-- Amit Kumar Saha *NetBeans Community Docs Coordinator* http://amitsaha.in.googlepages.com http://amitksaha.blogspot.com
2-cent tip: Linux Magic System Request Keys
René Pfeiffer [lynx at luchs.at]
Fri, 11 Apr 2008 22:08:26 +0200
Some of you might now the Linux Magic System Request Keys (see the file sysrq.txt in the kernel documentation). These keys allow to send some commands directly to the Linux kernel. This is dangerous, but it can be very useful since you can sync all buffers to disk, see all processes, dump diagnostic information to the console and immediately reboot the system. You can enter the commands on x86 system with the keys ALT-SysRq-<command key>.
Well, what happens if your server is co-located and you don't have any keyboard at hand? You can still use the magic keys by means of writing to /proc/sysrq-trigger.
"echo s > /proc/sysrq-trigger" "presses" the magic key 's' that syncs all buffers. Likewise "echo b > /proc/sysrq-trigger" reboots the system immediately (i.e. without noticing applications and writing data to disk!). The latter was very useful for when recovering a co-located server from a crash of the kernel crypt daemon which blocked access to the filesystem.
2-cent tips: KeyTouch, .sig generators, Corrupted ISOs, etc.
Jonathan Clark [clarjon1 at gmail.com]
Wed, 2 Apr 2008 21:58:01 -0400
Hello, all. On my laptop, I've got those lovely little function keys which, by default, do absolutely NOTHING in Linux. However, all that can change!
I've found with my current distro, PCLinuxOS, a handy little utility called KeyTouch. This program allows you to map your keys to what they are supposed to do. You can easily map your keys like this, and, from what I understand, this doesn't work just with laptops, but also with multimedia keyboard, microsoft keyboards, and so forth. Very useful.
Now, on my laptop, I've got one of those buttons which, I suspect, is supposed to change the power usage profile in Windows. However, I've found a more useful job for it to do. In keytouch-editor, I have it set so that when that key combo is pressed, it will run:
kdialog --passivepopup "`acpi`"which pops up a little 'speech bubble' to show me the current battery status, as well as time remaining for discharge or recharging the battery. Very useful, in my opinion.
What else do I have? Oh, yes. In Compiz-Fusion, there seems to be a bug with the alt-tab application switcher, which will occasionally kill off the Emerald window manager. I thought it was a bug with the keyboard shortcut, until I remapped it to win-tab and it would still kill it. So, if this is annoying you, disable the "Application Switcher" module, enable something like "Ring Switcher", and map it to Alt-Tab. Just like that, the decoration issue is solved.
Ever wondered how people get those static-yet-dynamic sig-generators? It's easy to do, with a simple bash script. First, create a file, let's call it sig. Put in the information that you are wanting to stay static. Make sure that there is an empty line at the end of the file. Now, you probably want to use something like fortune to get the changing part of the sig, right? Here's a shell script I use, called sig.sh:
---8<--- #!/bin/bash cat ~/sig /usr/games/fortune --->8---Set this little script to be executable, then go to the mail client of your choice, tell it to get the sig from a program, and tell it to use your sig.sh.
And, finally, corrupted ISO downloads. A friend taught me how to fix these: If your ISO is corrupted, it seems like all you have to do to fix it is to create/get a torrent of it, stick the corrupted download in the directory where the ISO will be downloaded to by default, and let the torrent system correct it for you!
Hope that these may help some users, will be giving more when I can think of some more!
-- Clarjon1 Proud Linux User. PCLinuxOS on Dell Inspiron 1501,1 Gig ram,80 Gig Hard drive 1.7gHz AMD Athlon 64bit dualcore processor Contact: Gmail/gtalk: clarjon1 irc: #pclinuxos,#pclinuxos-support,##linux on freenode Baruch's Observation:
2-cent tip: Snapedit
Ben Okopnik [ben at linuxgazette.net]
Sat, 19 Apr 2008 14:00:33 -0400
When I see a post in The Answer Gang and want to try out some submitted code, I often want to run it to see what it does - but the procedure to do this (open another xterm, fire up 'vi', put it into "append" mode, paste the code, etc.) is a pain. So, I've created a script that helps me do all of this conveniently.
#!/bin/bash # Created by Ben Okopnik on Sun Apr 13 11:22:45 EDT 2008 # Requires 'dialog' and 'xclip' cd /tmp label="New filename:" while : do fname=`/usr/bin/dialog --stdout --inputbox "$label" 7 40` # WEIRD: '-f' doesn't expand/handle '~'! We'll borrow the shell's brain. fname=`eval /bin/echo $fname` if [ -f "$fname" ] then label="\"$fname\" already exists. New name:" else [ "$fname" = "" ] && exit /usr/bin/xclip -o > "$fname" /bin/vi "$fname" break fi done
I also created an icon on my Window Manager toolbar that executes "/usr/bin/xterm -e /usr/local/bin/snapedit". Now, whenever I highlight any kind of text, I can click on the icon, enter a filename (optionally including a path - otherwise, the file will be created in "/tmp") in the dialog box, and get a 'vi' session with the selected content already in the file. Ever since I created this thing, I've found more and more uses for it. Give it a try, and you will too!
-- * Ben Okopnik * Editor-in-Chief, Linux Gazette * http://LinuxGazette.NET *
2-cent tips: Using git
Jimmy O'Regan [joregan at gmail.com]
Tue, 8 Apr 2008 01:04:34 +0100
Using git to recreate an old CVS layout
I had to go hunting for old data in a CVS repository today, and wanted to hang on to the data in one place. git-cvsimport does a nice job of maintaining the CVS history of each module, but because of the way the repository was laid out, each module had to be grabbed separately. To join them back together, I created a new git repository, and used 'git-submodule add' to drag in each of the converted modules.
It's not as convenient as being able to look at the whole project history at once, but at least it's a lot easier to pass to the next poor soul who finds themselves in my situation.
Git as a better SVN
I've been using git-svn for decentralised SVN access for a few months - sometimes I don't have access to an internet connection, sometimes I don't want to commit something until it's finished, sometimes I want to be able to work on a branchwithout having to redo everything when I want to merge - but today I found another use: to revert a whole commit, instead of individual files.
There's probably a proper way to do it, but being able to open gitk, right click on the commit and save it as a file, chop off the mail headers and use patch -R -p1 was a lot quicker than the subversion way. (Though SVN is probably a better if you just want to revert one file from a commit).