HOWTO extract rar files with rox

What’s easier than a single click extraction of rar files through rox ?

  • vi /usr/local/bin/urar
  • and paste inside:

    #!/bin/bash
    cd `dirname “$@”`
    unrar x -y `basename “$@”`
    mkdir “unrar done”

  • chmod +x /usr/local/bin/urar
  • then right click on a rar file…go to customize menu and drop /usr/local/bin/urar to the new window that appears.

    Now when you right click on a rar file you will see on the menu “urar”…just click it and you will have your rar files extracted to the current dir. It’s easy to modify the previous script to extract the files to a new dir if you want. It will also create a dir named “unrar done” to notify you when the process has finished.

    What needs fixing ?

  • Passworded rar files
  • some fancier method of telling us the extraction process is over instead of a mkdir…maybe with a small pygtk program to make it open a small “notice” on the current X display ?
  • collectd ebuild

    Last night I decided to create a gentoo ebuild for collectd. It’s the first ebuild I create…so bare with my errors…

    The ebuild is here: http://bugs.gentoo.org/show_bug.cgi?id=107052

    To emerge it follow these simple steps:

  • add PORTDIR_OVERLAY=”/usr/local/portage/” to your /etc/make.conf
  • mkdir -p /usr/local/portage/sys-apps/collectd/files
  • download the ebuild and put it inside /usr/local/portage/sys-apps/collectd/
  • download the rest attachments and put them inside /usr/local/portage/sys-apps/collectd/files/
  • cd /usr/local/portage/sys-apps/collectd/ ; ebuild collectd-2.1.0.ebuild digest
  • emerge collectd
  • I think the ebuild is not “stable” yet…it has only been tested on 2-3 x86 machines so I’ve added the ~x86 keyword for it…

    Feedback is more than welcome…thanks!

    collectd multiple sensor patch

    Collectd is a very nice program that runs in the background and gathers statistics about various kind of stuff like cpu load , disk activity, memory ,fan speed, temperatures, etc, and then puts them all in nice rrd files. It even has a set of scripts to create the graphs. I had only one problem though, but it was fixable.

    Collectd includes sensor.h from lm_sensor package that contains all the functions about your working temperature/fan sensors. It works fine if you only use 1 sensor. But I use 2!

    it87-isa-0290
    Adapter: ISA adapter
    CPU core: +1.78 V (min = +1.66 V, max = +1.84 V)
    DDRAM: +1.31 V (min = +1.17 V, max = +1.33 V)
    3v3 I/O: +3.22 V (min = +3.14 V, max = +3.47 V)
    +5V: +5.09 V (min = +4.76 V, max = +5.26 V)
    +12V: +12.42 V (min = +11.39 V, max = +12.61 V)
    -12V: -11.47 V (min = -7.17 V, max = -16.76 V)
    -5V: -4.03 V (min = -2.48 V, max = -10.02 V)
    Stdby: +5.09 V (min = +4.76 V, max = +5.26 V)
    CPU Fan: 4166 RPM (min = 1599 RPM, div = 4)
    BOX Fan: 1506 RPM (min = 897 RPM, div = 8 )
    IT87 T°: +37°C (low = +15°C, high = +55°C) sensor = thermistor

    lm90-i2c-0-4c
    Adapter: SMBus Via Pro adapter at 5000
    LM90 T°: +47°C (low = +15°C, high = +60°C)
    Athlon T°:
    +53.5°C (low = +15.0°C, high = +70.0°C)
    LM90 Crit: +70°C (hyst = +60°C)
    CPU Crit: +80°C (hyst = +70°C)

    As you can see I use both it87 and lm90 to get correct results. Collectd creates its rrd databases inside /var/lib/collectd. The sensor rrd file it creates are in the form:

    sensors-fan1.rrd
    sensors-fan2.rrd
    sensors-fan3.rrd
    sensors-temp1.rrd
    sensors-temp2.rrd
    sensors-temp3.rrd

    That means it can’t distinguish the different chipsets and overwrites the values if you have 2 chipsets. What I did was patch collectd to rename the rrd files in order to include the sensor name as well. I now have:

    sensors-it87-fan1.rrd
    sensors-it87-fan2.rrd
    sensors-it87-fan3.rrd
    sensors-it87-temp1.rrd
    sensors-it87-temp2.rrd
    sensors-it87-temp3.rrd
    sensors-lm90-temp1.rrd
    sensors-lm90-temp2.rrd

    The patch is here: Collectd-multi-sensor.patch.gz
    Just apply the patch inside the src dir , recompile and install.

    I am in doubt whether I should contact the author or not about this simple patch…anyway…If you use collectd and have more than 1 sensor running…tell me if it works for you…

    cheers!

    graffiti

    A great graffiti group…that’s art….

    http://www.banksy.co.uk

    I think this is my favorite: http://www.banksy.co.uk/outdoors/images/newfullsize/trooper.jpg

    No more classical Trigonometry? Here comes Rational Trigonometry

    At least that’s what an australian academic, Dr Norman Wildberger, says. He says he managed to rewrite the classic geometry theorems and formulas without using trigonometric functions. His book might be worth a look.
    From his introduction:

    Rational trigonometry
    The new form of trigonometry developed here is called rational trigonometry, to distinguish it from classical trigonometry, the latter involving cos θ, sin θ and the many trigonometric relations currently taught to students. An essential point of rational trigonometry is that quadrance and spread, not distance and angle, are the right concepts for metrical geometry (i.e. a geometry in which measurement is involved).
    Quadrance and spread are quadratic quantities, while distance and angle are almost, but not quite, linear ones. The quadratic view is more general and powerful. At some level, this is known by many mathematicians. When this insight is put firmly into practice, as it is here, a new foundation for mathematics and mathematics education arises which simplifies Euclidean and non-Euclidean geometries, changes our understanding of algebraic geometry, and often simplifies difficult practical problems.
    Quadrance measures the separation of points, and spread measures the separation of
    lines. It turns out that

    quadrance = (distance)^2
    spread = ( sin (angle))^2

    although the actual definitions used in this text are independent of distance, angle and the trigonometric functions. They are ultimately very simple, based on finite arithmetic and algebra as taught in schools.

    no more cosθ and sinθ ? One thing’s for sure…he will be strictly judged by millions of mathematicians for every word he’s written…math people are crazy people and they don’t like others playing smart on them…

    good luck to Dr Wildberger…

    crude script for sfv checking

    Most of the times, when I download something and there’s an sfv file available I check the files against the sfv. That saves me from a lot of trouble later on…
    What I wanted though, was to have the sfv check program create a dir inside each folder it checks that would include the details from the sfv scanning. That way you can instantly know whether what you have downloaded 1 week ago is ok, or there are bad files inside, or missing files. I sometimes used to check what I downloaded against the sfv file but I forgot to move it to my “complete” folder. So I made a VERY crude script that does exactly what I want. It uses pure-sfv (which I think is a bit faster than all the others I’ve tested) and then parses the output to create a dir that looks like this:

    [ 49 OK, 0 BAD, 0 MISSING, OUT OF 49 ]

    Here’s the script…
    #!/bin/bash

    THEOLDDIR=`ls -1 | grep "MISSING, OUT OF"` ; rm -rf "$THEOLDDIR"
    ACTION=`pure-sfv *.sfv | egrep "different CRC|Tested|No such file" > check.tst`
    THEBADONES=`grep different check.tst`
    THEMISSONES=`grep "No such file" check.tst`
    LINECOUNT=`wc -l check.tst | cut -d" " -f 1`
    OKFILES=`tail -n1 check.tst | cut -d" " -f5 | cut -d"," -f1 `
    BADFILES=`tail -n1 check.tst | cut -d" " -f7 | cut -d"," -f1 `
    MISSFILES=`tail -n1 check.tst | cut -d" " -f9`
    while read line ;do
    BADIS=`echo $line | cut -d" " -f 1`
    if [ $BADIS != "Tested" ]; then
    if [ -e $BADIS ]; then
    mv $BADIS $BADIS.bad
    else
    touch $BADIS.missing
    fi
    fi
    done < check.tst
    echo "$THEBADONES"
    echo "$THEMISSONES"
    echo "$OKFILES OK, $BADFILES BAD, $MISSFILES MISSING, OUT OF $[$OKFILES+$BADFILES+$MISSFILES]"
    mkdir -p "[ $OKFILES OK, $BADFILES BAD, $MISSFILES MISSING, OUT OF $[$OKFILES+$BADFILES+$MISSFILES] ]" ; rm -f check.tst

    USE IT AT YOUR OWN RISK!!! IT MAY DELETE ALL YOUR FILES. IT WON’T BE MY FAULT!

    and yes I know the code sucks. If you don’t like it don’t use it.

    HOWTO mount iso images with rox

    1) create the file mountiso.sh:

    #!/bin/bash
    STR="/tmp/iso_image_link"
    echo "Mounting $1"
    ln -sf "$1" $STR
    mount /mnt/image

    then chmod +x mountiso.sh and put it in your /usr/bin/ directory

    2) edit your /etc/fstab file and add an entry that looks like this:

    /tmp/iso_image_link /mnt/image iso9660 ro,noauto,user,loop 0 0

    3) open up rox and find a .iso file. Right click on it and go to File/Set Run Action. Then type there:
    mountiso.sh "$@"

    Now when you click on an iso file inside rox that will call mountiso.sh which creates a symlink from the file you want to mount to /tmp/iso_image_link. This way the “name” of the iso is always the same (/tmp/iso_image_link). The entry on the fstab file sets a static mount point for the iso images.

    This way you can mount dynamically named iso images through the /tmp/iso_image_link symlink.

    Enjoy.

    Batch resizing of images in linux with ImageMagick

    Overwriting the current pictures:
    mogrify -quality 85 -geometry '2048x1536>' *.jpg

    Creating new pictures:
    for i in *.jpg; do convert $i -quality 85 -geometry '1024x768' small_$i; done

    Really usefull when you have to convert many pictures at once.

    Microsoft Intellimouse Explorer 2 side keys with gentoo

    First of all read this great HOWTO: HOWTO_Mouse_Nav_Buttons. I am using Fluxbox and gdm so the point where it says about sticking “imwheel -f -k -p -b “67”” in my .xinitrc does not work. What I did was add “imwheel -k -b67” to my .fluxbox/startup. Using a .imwheelrc file that’s inside that HOWTO I am now able to go back and forward pages in Firefox using the side buttons.
    I will start checking out .imwheelrc to see if I can come up with any good general shortcuts using the side buttons.