20100223

linux console resolution (i915)

The uvesa-fb approach to console resolution switching is obsolete and depreciated.

Now something called KMS (Kernel ModeSetting) is used.
Requirements:
1. >=kernel-2.6.31
2. >=xorg-server-1.6
3. >=xf86-video-intel-2.8.0.

Steps:
1. Device Drivers ---> Graphics support ---> Support for frame buffer devices; disalbe framebuffer support like intelfb, vesafb or uvesafb

2. Device Drivers ---> Graphics support ---> ... <*> Direct Rendering Manager (XFree86 4.1.0 and higher DRI support) ---> <*> Intel 830M, 845G, 852GM, 855GM, 865G (i915 driver) ---> <*> i915 driver [*] Enable modesetting on intel by default.

More information: http://en.gentoo-wiki.com/wiki/Intel_GMA

20090511

merging many pdf files into one.

Given input files: 0001.pdf, 0002.pdf, 0003.pdf.
Output file: output.pdf
Requirements: GhostScript

gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=output.pdf -dBATCH 0001.pdf 0002.pdf 0003.pdf

20090424

ZSH on rootnode

Howto use zsh on rootnode, and get almost all of benefits that are preconfigured for bash usage on korn.rootnode.net.
  1. % chsh -s /usr/bin/zsh
  2. create a ~/.zshrc file with the following contents:

    PATH="/adm/szatan/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games"
    if [ -d "$HOME/tmp" ] ; then
    TMPDIR="$HOME/tmp"
    TEMP="$TMPDIR"
    TMP="$TMPDIR"
    fi

    JAVA_HOME="/usr/lib/jvm/java-1.5.0-sun-1.5.0.10"
    TMOUT=3600
    JAVA_OPTS="$JAVA_OPTS -Xms128m -Xmx255m"
    [ -d "$HOME/bin" ] && PATH="$HOME/bin:$PATH"
    [ -d "$HOME/man" ] && MANPATH="$HOME/bin:$MANPATH"
    MAIL=~/Maildir
    EDITOR="/usr/bin/vim"
    [ ! -f "$HOME/.nosplash" ] && /adm/szatan/bin/splash
    [ ! -f "$HOME/.nomotd" ] && cat /etc/motd.rootnode

20080509

automounting ftpfs using curlftpfs and autofs

Software requirements:
  1. working autofs instalation
  2. fuse
  3. curlftpfs
Procedure:
  1. create /sbin/mount.curl containing:
    #!/bin/bash
    curlftpfs $1 $2 -o allow_other,disable_eprt


  2. create /sbin/umount.curl containing:
    #!/bin/bash
    fusermount -u $1


  3. make both created *.curl files executable


  4. add /mnt/ftp /etc/autofs/auto.ftp --ghost
    to /etc/autofs/auto.master

  5. create /etc/autofs/auto.ftp file containing:

    myFTP -fstype=curl,allow_other :ftp\://USER\:PASSWORD\@MACHINE/




Et voila!
cd /mnt/ftp/myFTP; ls

20080416

password management in python

Problem:
How to, change existing password of USER using python.

Solution:

import crypt,random
from subprocess import Popen, PIPE
DES_SALT = list('./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz')
SALT = "%s%s"%(random.choice(DES_SALT),random.choice(DES_SALT))
DESHASH=crypt.crypt(PASS,SALT)
inout=Popen(["/usr/sbin/usermod","--password",DESHASH,USER],stdin=PIPE, stdout=PIPE,stderr=PIPE).communicate()

Instead of Popen one could write directly to shadow file

apache - redirecting main page to current date

Problem:
Automatic redirection of main page request to current year and month.
Automatic fixing of broken date links (YEARMONTH to YEAR/MONTH/)


Solution:
Use mod_rewrite magic :D

RewriteEngine on
RewriteRule ^/([0-9]{4})([0-9]{2})$ http://%{HTTP_HOST}/$1/$2/ [R,L]
RewriteRule ^/$ http://%{HTTP_HOST}/%{TIME_YEAR}/%{TIME_MON}/ [R,L]

(1.) enables RewriteEngine
(2.) matches http://host.domain/dddddd and transforms it into http://host.domain/dddd/dd
where $1 is the first match - a group of four digits ([0-9]{4}) and $2 is the second match (group of 2 digits)
(3.) redirects main page (http://host.domain/) to http://host.domain/month/year/