Donnerstag, 20. Dezember 2012

Number of pages inside a pdf

$ grep -o "'Page[0-9]*'" your.pdf | tail -1 | grep -o "[0-9]*"

Freitag, 9. November 2012

wildcard && brace expansion -eq <3

mplayer *s05e0{1,2,3}*

Queues the following files:
xyz.s05e01.someformat
abc.s05e02.someotherformat
123.s05e03.format
...

Check http://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html

Montag, 22. Oktober 2012

undefined symbol: apr_reslist_maintain after upgrading httpd on Slackware 13.37

After upgrading apache to the latest patch (ftp://ftp.slackware.com/pub/slackware/slackware-13.37/patches/packages/) you get that error: "/usr/sbin/httpd: symbol lookup error: /usr/sbin/httpd: undefined symbol: apr_reslist_maintain" when starting httpd / apache.

In order to resolve it you have to update apr (Apache Portable Runtime, makes sense, huh? ;)) and apr-util to the latest patched versions (get them here ftp://ftp.slackware.com/pub/slackware/slackware-13.37/patches/packages/).

Donnerstag, 18. Oktober 2012

Dienstag, 25. September 2012

Show single image with xlock

Took me a while to figure out how to simply show an image when locking with xlock:

$ xlock -mode image -bitmap image.xpm -count 1

-mode image: sets the mode to only display random sun images
-bitmap image.xpm: replace the random sun images with image.xpm (*)
-count 1: sets the amount of images that shall be shown at the screen at once to 1

* use ImageMagicks 'convert' method to convert to xpm: $ convert input.jpg output.xpm

Have fun!

Mittwoch, 4. Juli 2012

x121e Cardreader (rtl_pstor) - Kernel 3.4.4 menuconfig

Took me a while to figure out where the driver for my cardreader resides. In menuconfig go this path:

Device Drivers -> Staging drivers

and check this one, either as module or builtin:


RealTek PCI-E Card Reader support

Freitag, 22. Juni 2012

Easy rounding with Javascript round() wrapper

Really simple method to easily round with javascript:
function round (number, fractionalDigits) {
    "use strict";
    if (!number) {
        return; 
    }
    var multiplicator = 1;
    while (fractionalDigits--) {
        multiplicator *= 10;
    }
    return Math.round(number * multiplicator) / multiplicator;
}

Just pass in the number to round and the number of fractionalDigits you'd like to keep, like:
round(95.12345, 2); will return 95.12
round(95.54555, 4); will return 95.55

If you omit the last param, you'll get no fractionalDigit, like:
round(95.12345); will return 95
round(95.50000); will return 96

One last call: Don't use it as is, create a namespace for it to reside in! 


Or append it to Number, then you can remove the number param. ;)
Number.prototype.round = function(fractionalDigits) {
    "use strict";
    var multiplicator = 1; 
    while (fractionalDigits--) { 
        multiplicator *= 10; 
    } 
    return Math.round(this * multiplicator) / multiplicator;
}

Call it like:
var number = 8.12345;
number.round(2); will return 8.12


Have fun!