Code Snipplets

Here'a a page of cut'n'paste code to rememer.

CVS related

wget -m -nH --cut-dirs=1 -np www.fastcgi.com/cvs/mod_fastcgi

…is supposed to get the HEAD version from a webcvs, via http

FastCGI scratch

http://www.fastcgi.com/devkit/doc/fcgi-spec.html http://www.lighttpd.net/documentation/fastcgi.html

#include <fcgi_stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main () {
  char* p;

  while (FCGI_Accept() >= 0) {
    /* wait for fastcgi authorizer request */

    printf("Content-type: text/html\r\n");

    if ((p = getenv("QUERY_STRING")) == NULL) ||
         <QUERY_STRING is unauthorized>)
         printf("Status: 403 Forbidden\r\n\r\n");

    else printf("\r\n");
      /* default Status is 200 - allow access */
  }

  return 0;
}

initrd cpio

cd $tmproot
find . | cpio --quiet -o -H newc > $initrd
gzip -9 $initrd

apt gpg key

get C. marillat's key:

gpg --keyserver hkp://wwwkeys.eu.pgp.net --recv-keys 1F41B907
gpg --armor --export 1F41B907 | apt-key add - 

rsync backup

/usr/bin/rsync -e ssh -avzp --exclude "*.journal"  --delete /home remotehost:/var/backups/myhome/ 

Encode!

lav2yuv -I 1 <avifile> | mpeg2enc -o <outputfile>.m1v
lav2wav <avifile> | mp2enc -V -o <outputfile>.mp2
vcdmplex <outputfile>.m1v <outputfile>.mp2 <multiplexedfile>.mpeg
mkvcdfs <multiplexedfile>.mpeg [<more mpegs>].

Fix Gnome

sudo gconf-schemas  --register /usr/share/gconf/schemas/*.schemas

X hacks

either in .xsession

xset -dpms  # power management
xset s off  # screen-saver

or hardcoded in x11 config

Section "ServerFlags"
  Option "blank time" "0"
  Option "standby time" "0"
  Option "suspend time" "0"
  Option "OffTime" "0"
EndSection

*nix Backup

Gnu Tar

GNU Tar supports everything needed to make a reliable backup (although I must say I don't know how well, if at all, it supports extended attributes). One major problem with tar is, that you have to pay close attention to the options you give (also at restore time), because the defaults are not suitable. Two major ones are –preserve-permissions and –numeric-owner. This could also include –same-owner, but a quick tests shows the –preserve-permissions option implies this. Should you have forgotten the –numeric-owner option for the backup command, this can also be given at restore time. Giving it at backup time, should negate the necessity of giving it at restore time.

DAR

http://www.halfgaar.net/backing-up-unix

dar --execute "par2 c -r5 %p/%b.%n.par2 %p/%b.%n.%e" --alter=atime --empty-dir \ --fs-root / --noconf --create
 ARCHIVE_NAME --slice 620M --first-slice 600M -z6 \ -an -Z "*.ogg" -Z "*.avi" -Z "*.mp?" -Z "*.pk3" -Z "*.flac" -Z
 "*.zip" -Z "*.tgz" \ -Z "*.gz" -Z "*.gzip" -Z "*.bz2" -Z "*.bzip2" -Z "*.mov" -Z "*.rar" -Z "*.jar" \ --prune
 lost+found --prune usr/portage/ --prune var/tmp/portage --prune media \ --prune proc --prune mnt --prune sys
 
wiki/randomcode.txt · Last modified: 17.12.2008 17:24 by rgareus