## Fix Android Froyo (2.2) AAC+ / HE-AAC not decoding SBR part (rooted phone)

AAC+ or HE-AAC files' SBR bits are not decoded in Froyo with the introduction of "stagefright".

Easy fix with rooted phone:
• Use e.g. ES File Explorer to create a "stagefright-off.sh" file which contains
setprop media.stagefright.enable-player false
• Execute the script with root permissions using ScriptMe

## fakeraid, dmraid are evil!

If you use software raid (md) and have a fakeraid controller (controlled by dm-raid), make sure to *never* install dmraid. It will kill your data.

There seem to be the kernel command line parameters preventing data loss...
noacpi nodmraid

## Count the number of files in each subdirectory

find . -maxdepth 1 -type d | while read i; do echo "find \"$i\" -type f | wc -l$i"; done | sort -g

## DVB-T initial tuning data für das Saarland

Heute mal ein Beitrag auf deutsch. Da es um den lokalen Empfang von DVB-T geht, dürfte das den (englischsprachigen) Rest der Welt sowieso nicht interessieren.

Da ich keine "initial tuning data" Datei für das Saarland im Netz finden konnte, hier mal eine Anleitung wie man sich diese selbst herstellt:

Erst mal schauen, wie so eine Datei aussehen muss. Am schnellsten geht das bei installierten dvb-utils am Beispiel von Berlin:

cat /usr/share/doc/dvb-utils/examples/scan/dvb-t/de-Berlin
# T freq bw fec_hi fec_lo mod transmission-mode guard-interval hierarchy
...

Die benötigten Daten entnimmt man nun folgendem Dokument:
http://dvbt.sr-online.de/pdf/fachhandelsmappe-saarland.pdf

Auf der letzten Seite steht also:
Es gibt vier Kanäle, alle werden mit 16-QAM moduliert, haben eine Fehlerschutzrate (FEC) von 2/3 (33% Redundanz), 1/4 ist die Länge des guard interval und die Polarisation ist sinnvollerweise immer vertikal.

Die Frequenzen der vier Kanäle sind dann noch der Tabelle zu entnehmen:
K 42: 642MHz
K 44: 658MHz
K 30: 546MHz
K 49: 698MHz

Es sollte sich also (ungetestet!) folgende tuning-Datei ergeben:

# T freq bw fec_hi fec_lo mod transmission-mode guard-interval hierarchy
T 642000000 8MHz 2/3 NONE QAM16 8k 1/4 NONE # K42: SR, ARD, Phoenix, Arte
T 658000000 8MHz 2/3 NONE QAM16 8k 1/4 NONE # K44: BR, HR, SWR, WDR
T 546000000 8MHz 2/3 NONE QAM16 8k 1/4 NONE # K30: ZDF(+doku+info), 3Sat, KiKa
T 698000000 8MHz 2/3 NONE QAM16 8k 1/4 NONE # K49: SaarTV, T5, QVC, bibel.tv

Da die Kanäle alle im UHF-Bereich liegen, ist die Kanalbandbreite jeweils 8MHz, wie z.B. in [1] angegeben.

Jetzt den Suchlauf starten:

scan de-Saarland > channels.conf

Wer es damit ausprobiert kann gerne hier eine Nachricht hinterlassen, ob es funktioniert hat.

[1]http://de.wikipedia.org/wiki/Frequenzen_der_Fernsehkan%C3%A4le

## GDM autologin when USB stick present, else not

Today I figured it would be a nice idea to increase bootup speed by doing autologin with GDM, which is nothing spectacular, you can just do it.
BUT: What if this machine is used by others from time to time and you don't want someone else to boot the machine and be logged in with your account?
What I find on the net are solutions on how to use pam_usb to save you from entering your password while your USB stick is plugged in. But in my case, for the initial boot of the machine I'm working with, I'd even like to not be asked for my username - but of course only if my USB stick is present.

How to do this is straightforward:
1. Install and configure pam_usb
2. Set up your USB stick for authentication
This results in getting an error and being prompted with username/password dialog of GDM in case your USB stick is not present, but when it is, you're logged in automatically.

Following the quickstart guide on pamusb.org:
# apt-get install libpam-usb pamusb-tools
# pamusb-conf --add-device MyDevice
# pamusb-conf --add-user john

Now, to use pam_usb as a "common" access module, follow the quickstart guide. In our case, this would be optional. If you still need this feature, add
auth    sufficient      pam_usb.so
above
auth    required        pam_unix.so nullok_secure
in /etc/pam.d/common-auth.

For what is intended here, it suffices to replace
auth    required        pam_permit.so
with
auth    sufficient      pam_usb.so

Which does exactly what we want to achieve: replacing the "always permit" module by the pam_usb module.

Finally, don't forget to actually enable autologin and you're done!

So my day in the office now begins like this: Enter office, switch on my workstation, insert usb stick during boot, grab some (free) coffee, return and I'm welcomed by the desktop instead of the login prompt!

EDIT: If your stick can not be mounted after reboot by pmount (pmount -d /dev/sdxn) or you get an error "device not removable" issuing pamusb-check --debug then you can add your device to /etc/pamusb.

## Find all manually installed deb packages

inverse of "deborphan" and better than dpkg --get-selections

aptitude search '~i!~E' | grep -v "i A" | cut -d " " -f 4

## Split lossless audio CD images (ape, flac, etc.)

Derived from [1], but a little bit better:
#!/bin/bash# usage: $1: cue file,$2: audio file (e.g. .ape) $3: format (e.g. flac)shnsplit -f$1 -o $3 -t %n-%t$2for i in *.$3; do mv "$i" "echo $i | sed -e 's/ /_/g'"; donecuetag$1 *.$3 [1]http://aidanjm.wordpress.com/2007/02/15/split-lossless-audio-ape-flac-wv-wav-by-cue-file/ ## Find out who is accessing the current directory with lsof Is there a more simple alternative to this? lsof -FL -O -L -n +D . | grep -v "^p" | cut -dL -f 2 | less | sort -u ## Remove content from svn repository (permanent, with history) svnadmin create <repos_copy>svnadmin dump <repos> | svndumpfilter exclude <path> | svnadmin load <repos_copy> ## bash completion compgen -A action -- <pattern> -A action The action may be one of the following to generate a list of possible completions: alias Alias names. May also be specified as -a. arrayvar Array variable names. binding Readline key binding names. builtin Names of shell builtin commands. May also be specified as -b. command Command names. May also be specified as -c. directory Directory names. May also be specified as -d. disabled Names of disabled shell builtins. enabled Names of enabled shell builtins. export Names of exported shell variables. May also be specified as -e. file File names. May also be specified as -f. function Names of shell functions. group Group names. May also be specified as -g. helptopic Help topics as accepted by the help builtin. hostname Hostnames, as taken from the file specified by the HOSTFILE shell variable. job Job names, if job control is active. May also be specified as -j. keyword Shell reserved words. May also be specified as -k. running Names of running jobs, if job control is active. service Service names. May also be specified as -s. setopt Valid arguments for the -o option to the set builtin. shopt Shell option names as accepted by the shopt builtin. signal Signal names. stopped Names of stopped jobs, if job control is active. user User names. May also be specified as -u. variable Names of all shell variables. May also be specified as -v. ## Find files that have been modified within the last n minutes As usual, it took a while to figure this out. It's an easy task using find. But let find also exclude some directories and print something nice, it gets complicated. Therefore, here's how... "...to find all files that have been modified under the current directory within the last n minutes excluding a couple of directories and printing the last modification timestamp along with the filename by only using the find command" find -H . -cmin -$n -and $$wholename './proc/*' -prune -o wholename './sys/*' -prune -o wholename './dev/*' -prune -o printf "%p\t%c\n"$$

And what happens is this:
• "-cmin -$n" searches for files modified within the last$n minutes
• "-and " is a test expression, i.e. -cmin -and (something)
• "-wholename './sys/*' -prune" excludes all subdirs of ./sys
• "-o" is an OR
The whole expression reads like this:
find files with some cmin and (if filename matches ... then skip else if filename matches ... then skip else ... else print)

## How to print cluttered web pages with Firefox and Aardvark

This might come in handy:
Start trimming down the page to your gusto
• r removes selected content
• d removes size constraints
• n narrows content (e.g. table elements)
• w widens content
• i isolates content (removes everything around it)
Then, select "Start Aardvark" again to stop it (as you used to do with Windows, remeber?). Now, you can print the page or create a PDF out of it in case you have a PDF printer driver (CUPS/PDF or FreePDF XP for Windows).

## Speed up multiple debian / ubuntu updates with apt-cacher

Today I upgraded from ubuntu 7.04 to 7.10, and it was 1.4GB. This is a lot, even with fast DSL, given that you will most probably need to do it more than once (desktop, laptop, office etc.). This time I chose to do it more cleverly: using a local cache. Apt-cacher to the rescue. But first, what are the necessary steps?

1. Have an apache webserver ready
2. apt-get install apt-cacher on that machine (your server)
3. Configure apt-cacher (see below)
4. Configure client machines (see below)

About 1 and 2: Apt-cacher can actually also run in stand-alone mode without the need for an apache server, but I'm not going to cover this here. In fact, I believe that the apache-mode is much nicer (see later).

About 3: Tweak /etc/apt-cacher/apt-cacher.conf to your needs. The default settings are usable out of the box and everything is very well documented in there. Very nice: There is an option for rate limiting and external http proxy configuration (even more redundancy!).

About 4: Now for the easy part: Modify you clients' /etc/apt/sources.list files. Here is how the result should look:

Original line:
deb http://ftp.de.debian.org/debian stable main contrib non-free
Apt-cacher enabled replacement:
deb http://cacheserver/apt-cacher/ftp.de.debian.org/debian stable main contrib non-free

Easy!

But now for the brain part:
Q: How to do this automagically for all entries with one line of sed?
I have two possible answers for you:
• A: Backup, then replace the host part
• B: Backup, then duplicate every entry and replace the host part only in the duplicate to have sort-of a fall-back mechanism if either apt-cacher or the original mirror is unavailable or slow.

sudo su
cd /etc/apt
cp sources.list sources.list.pre-caching
export APTCACHER="your.server.name"
sed -i "s/$$http:\/\/$$$$[^\/]*$$\//\1$APTCACHER\/apt-cacher\/\2\//" sources.list About B: Same as A, but sed -i "/^[^#]/h;s/$$http:\/\/$$$$[^\/]*$$\//\1$APTCACHER\/apt-cacher\/\2\//;/^[^#]/{x;p;x}" sources.list

Note that it is not a good idea to execute the sed commands more than once!

For the curious:
Explanation of the regular expression in A:
• Only one command 's/pattern/replacement/' (substitute) is used.
• It searches for "http://" followed by "not a slash" or "until the next slash" (which is the host name).
• This is grouped with $$...$$ to later reference it with \1 and \2 in the replacement.
• In the replacement we just add the apt-cacher URL between \1 (http://) and \2 (e.g. ftp.de.debian.org).
Explanation of the regular expression in B:
• In the middle we have the same 's' command.
• This time we want to duplicate each entry (but not the comments!) and replace only in the duplicate.
• '^[^#]/h' is the command to 'hold' (remember) a line if it does not start with '#' (i.e. is not a comment line)
• Next is the substitution from above (it is tried on every line including comments)
• '/^[^#]/{x;p;x}' is the last (group of) commands. It checks again if we're in a comment line, and if not, it exchanges ('x') the current buffer (i.e. the current line) with the hold buffer we have filled in the first command. Then the current buffer containing the original (non-substituted) line of the 'hold' is printed with 'p' and then swapped again (for sed to print the substituted line automatically).
• The result is that we have, for every line that is not a comment, created a duplicate of it where the duplicate has the required substitution.
I like regular expressions.

## tshark statistics with filters problem

After several hours I finally found out how to use those tshark statistics filters with the -z option. I couldn't find any clues in the documentation or on the net though, just found the solution by accident...

Even the example from the man page:
  -z 'io,stat,1,ip.addr==1.1.1.1'
may not work!

What can happen is that the comma after the time value "1" is interpreted as the decimal delimiter, for a german locales setting for example, so the rest of the filter string is omitted.

Another example would be writing
  -z io,stat,0.001,ip.addr==1.2.3.4
where tshark will complain that the time value must be >= 0.001, but in this case it really is = 0.001 (one might think).

Either do
export LANG=C
before or write something like this instead:
  -z io,stat,"0,001",ip.addr==1.2.3.4

## Intel piix, ata_piix battle for hard disk and cdrom drive

Problem:
For kernels until 2.6.17 and maybe later the ata_piix controller may detect the cdrom / dvd drive but does not assign a driver letter to it. On the other hand the piix controller may detect the sata hard disk but can not use it.

Cause of the problem:
The ide controller is either handeled by the piix module or the sata_piix module. The module that is loaded first will grab the controller exclusively.
• If piix is loaded first, your hard disks might run only in ide mode or might not work at all. The cdrom/dvd drive will work.
• If ata_piix is loaded first, your hard disks will run in sata mode but your cdrom/dvd might not work since the atapi sata code is disabled by default (it's still experimental).

Solution:
Either make sure piix is loaded before sata_piix and hope your hard disk still works.

To do the latter you can either try to set "options libata atapi_enabled=1" in /etc/modules.conf or modify the initrd image (necessary for debian) by loading the module directly with the parameter. Add
libata atapi_enabled=1
to /etc/mkinitrd/modules. After that re-create the initrd via
mkinitrd /boot/initrd.img-uname -r
Make sure the original initrd has been replaced. Another possibility would be modifying the kernel parameter line in /boot/grub/menu.list by adding
ide1=noprobe libata.atapi_enabled=1
This should also be possible with a new installation of debian or ubuntu where the cdrom is not detected and the installation fails.

## Symbolic links in samba shares

Problem: When you create a symbolic link inside a samba share, everything is fine when browsing the share in Windows. In Linux though, the symbolic links may be treated as links to the local filesystem, which will not work.

Solution:
I don't really understand why this is the default samba behaviour, but you can disable it by setting "unix extensions" to "no" on the server for this particular share or globally.

## Login in Xnest nested window

gdmflexiserver --xnest

## Build debian package from planner 0.14.1 source

From this article I just learned how to build a debian package. In my case I built a package from the latest gnome/imendio planner source (0.14.1). After unpacking the tarball the following steps were necessary:

• Executing ./configure. If it fails, check if you have all the packages[1] installed.

• Executing dh_make:
dh_make -n -s -e <email-address>
• Editing the control file debian/control

• Editing the rules file debian/rules
# Add here commands to clean up after the build process.-$(MAKE) clean since in planner's Makefile there is no distclean target. • Editing the rules file debian/rules # Add here commands to install the package into debian/planner.$(MAKE) install prefix=$(CURDIR)/debian/planner/usr/local since in planner's Makefile the install prefix is called prefix. • Executing debian/rules cleandebian/rules builddebian/rules binary [1] The following packages may be necessary: dh-make libglade2-dev libgnomecanvas2-dev libgconf2-dev libgnomeprintui2.2-dev libgnomeui-dev libgnomevfs2-dev libxslt1-dev [2] http://www.debian-administration.org/articles/337 ## Compile and create debian package from source Compile from source and create debian package sudo apt-get -b source wavemon Or, if you downloaded the source archive, do ./configuredh_make -n -s -e <email>debian/rules binary ## Subversion authz pitfall Using SVNPath and SVNParentPath together with AuthzSVNAccessFile has to be configured slightly different: <location /projects/bob> DAV svn SVNPath /var/svn/public/projects/bob AuthzSVNAccessFile /home/bob/svnaccess.conf</location> versus <location /projects/> DAV svn SVNParentPath /var/svn/public/projects AuthzSVNAccessFile /home/bob/svnaccess.conf</location> Note the trailing slash in the location block in the second example. If there was a trailing slash in the first example, dav_svn would not work at all (SSL error). Now let's mix both things: <location /projects> DAV svn SVNParentPath /var/svn/public/projects</location><location /projects/bob> AuthzSVNAccessFile /home/bob/svnaccess.conf</location> Here dav_svn will work, but authz will not work as expected. The problem is that authz is defined "later", i.e. one path level deeper than DAV svn. Subversion's authz does in my opinion not correctly determine the actual repository in this case. It sees /projects/bob ("bob" is the repository name) as the parent path and treats subdirectories of "bob" as repository names. Restricting access to subdirectories of "bob" would now be done in the following way: [subdir:/]someone = r While the following which should be how it's done will not work: [bob:/subdir]someone = r I am using the following Subversion and Apache versions: Apache/2.0.54 (Debian GNU/Linux) DAV/2 SVN/1.3.2 ## Multiple http file upload with JavaScript Definitely worth a look: the-stickman.com ## How to resume another user's screen session It's so easy yet it took me quite a while to 'google' it out. The problem: Being root you would like to resume another user's screen session. Let the user be A. You 'become' him by su A - Then you would like to screen -r but unfortunately this gives you an error: Cannot open your terminal '/dev/pts/0' - please check. or something similar. The simple cause is that user A does not have the right to write into your (root's) terminal. This can be fixed by chmod'ing the above displayed file. For example: chmod a+rwx /dev/pts/0 Do it as root and be aware that this is a severe security risk! ## How to change subversion mime-type When you have e.g. an html file inside your repository and you want it to be displayed in your browers correctly, i.e. as html and not as plain text, this is what you need to do: One needs to properly set the mime-type to "text/html". Checkout the repository and do the following: svn propedit svn:mime-type yourfile.html --editor-cmd vi Here, vi is used as the editor. enter "text/html", save and exit (:wq for vi) Check if mime-type was changed svn -R proplist svn commit ## How to install Sun Java on Debian First download Sun Java J2SE Development Kit from http://java.sun.com/ Filename should be something like jdk-1_5_0_07-linux-i586.bin Short version: apt-get install java-packagefakeroot make-jpkg .bindpkg -i .deb Source: http://www.crazysquirrel.com/computing/debian/java.jspx ## Combine multiple PDF files It's also possible to insert a pdf file into another. For example, I had to insert one page from a pdf file after page 2 of another pdf file. This is how it's done: pdftk A=file1.pdf B=file2.pdf cat A1-2 B1 A2-end output combined.pdf verbose So the output results in pages 1,2 from A followed by page 1 from B and then the rest of A. ## Debian security GPG key http://www.micressor.ch/content/wiki/index.php/Debian_GPG_error ## LaTeX: Change spacing of itemize, enum, description Link to original post (french) Here is what I did: \let\orig@Itemize =\itemize\def\Nospacing{\itemsep=1pt\topsep=0pt\partopsep=0pt%\parskip=0pt\parsep=0pt}\renewenvironment{itemize}{\orig@Itemize\Nospacing}{\endlist} ## There is no Groupware for me I want to know if there is a Groupware (or, at least, something that is not called Groupware but does what I want) which has the following features: 1. Beautiful, efficient and comfortable web-interface 2. Low resource usage (server RAM and CPU) 3. Calendar is iCal/WebDAV accessible 4. Contacts are LDAP or (even better) WebDAV accesible (GroupDAV, what are you?) 5. Uses Mozilla Thunderbird as client (it's nice and portable) 6. Can synchronize contacts and calendar with cellular phone (syncML) ## Gnome "Open with" customization If you added an entry to the "Open with" menu of nautilus (i.e. Gnome file-manager), you currently can not customize the string that is displayed. Maybe you added two entries "xmms" and "xmms -e" (enqueue) for mp3-files. Then both will show up as "xmms" in the "Open with" menu. Thats odd, but customization is possible even though the Gnome makers keep hiding interesting options like that. (Maybe Linus is right about KDE/Gnome? - but then... Gnome is still much more beautiful...) Having said that, here's the obscure location where nautilus stores your custom "Open with" entries: ~/.local/share/applications ## Mozilla Firefox gxine wmv plugin 1. Install gxine 2. Install w32codecs (google for it) 3. Create symbolic links to the following files in your Mozilla plugins directory (could be ~/.mozilla/plugins): gxineplugin.a gxineplugin.la gxineplugin.so (might be under /usr/lib/gxine) This crashed frequently. Install mozplugger instead! 4. Delete the pluginreg.dat 5. Add the following to /etc/mozpluggerrc or modify anything similar to application/x-mplayer2: wmv,asf,mov: Windows Mediavideo/x-ms-asf: asf,asx,wma,wax,wmv,wvx: Windows Mediavideo/x-ms-wmv: wmv: Windows Mediastream noisy ignore_errors: gxine "$file"
6. Start Firefox, Quit Firefox -> pluginreg.dat was re-created
7. Done
Note: The lines above may already be present but pointing to mplayer. So if you have mplayer installed you need to modify only the last line (i.e. the command to be executed).

## Medion MD 41300 WLAN

If you have never really got your WLAN to work on your Medion MD 41300 laptop as I have then there is good news: I finally found some drivers from another vendor that work for the integrated Intersil PRISM wireless nic. (downloads at the bottom)

In the device manager the card showed up as
with the driver supplied by Medion. Actually this driver never worked for me since the wireless LAN card always stopped functioning after a couple of minutes. Only a reboot could bring it back. The interesing thing was though that the card worked perfectly with linux+ndiswrapper+SMC drivers. Unfortunately the SMC drivers would not install under Windows XP.

Here is a summary of driver, firmware and utility (prismsta.exe) versions

From Medion the latest you can get is:
DriverVer = 08/26/2003, 2.1.7.0
Firmware unknown
Utility version 1.00.20

From SMC you can get the following
DriverVer = 04/29/2004, 3.0.11.1
Firmware 2.05.03
Note1: No prismsta.exe utility included. Included SMC utility didn't work for me.
Note2: The firmware seems to be included in the driver (.sys file)

From MPC corp. you get the following
DriverVer = 03/21/2002, 1.7.37
Firmware unkown
Utility version 1.07.37

So one can create a driver bundle with the SMC driver, the MPC inf file and the MPC utility.

Here's what you need to do:
3. Exchange the MPC PRISMNDS.SYS (50k) in the WinXP subfolder by the SMC 2802W51.sys (377k) (delete the PRISMNDS.SYS and rename the SMC one)
4. Update the driver of your wlan card with this new driver package. Windows will refuse to do so unless you explicitly do "manually choose driver" and "have disk". A non-certification message should apper and you're done.

For me this works like a charm. Do it at your own risk. For questions use the comments function.

Edit: Some people left comments that the MPC driver is not there anymore. Actually, I have just been able to download it. I can't figure out why for some people the link should be broken, but I also just found out that MPC has an FTP: ftp://ftp.mpccorp.com/Support/Notebook/V2000/WinXP/
Edit2: Actually no one complained, yet, but the MPC driver comes as a self-deflating .exe file. To access it, just open it with your favourite zip utility (or, let it deflate and cancel the installation)

## LaTeX and PDF

Installing the Latin Modern fonts solves the problem that LaTeX's PDF output (pdflatex or ps2pdf) looks like rubbish, i.e. bad font rendering, missing ligatures (lat. ligare - to bind), etc.

apt-get install lmodern

## gawk printf float pitfall

I had to use a shell script reading in some values and spitting out some values. Those were to be processed by a binary that hung in an endless loop for an unknown reason. The script used the gawk tool excessively and I figured out that there was a problem with the decimal delimiter, which is different in some countries.

sed -e 's/\./,/g'
replacing dots by commas and afterwards vice versa
sed -e 's/,/\./g'
corrected this problem.

But it turned out that tools like gawk do rely on the locales set for your environment. A setenv LANG C before calling the scripts solved the problem even better. Quoted from the GNU awk User's guide
[...] The locale also affects numeric formats. In particular, for awk programs, it affects the decimal point character. The "C" locale, and most English-language locales, use the period character (.') as the decimal point. However, many (if not most) European and non-English locales use the comma (,') as the decimal point character.
So when using gawk make sure to execute
setenv LANG C (ksh-style shell) or
export LANG=C (sh-style shell)
in your script before calling gawk. Otherwise it may not run under different localized environments.

## Create new initrd with mkinitrd for Debian kernel

If you are using sata or scsi and your Debian 2.6 stock kernel won’t boot you need to tweak your initrd because with Debian all modules required to boot must be loaded from the initrd. Else the boot process will halt because e.g. the hard disk or other necessary stuff is not accessible.
Edit the file
/etc/mkinitrd/modules
to contain all the modules you wish to load (e.g. for your sata controller). You can find out which modules you need by doing
lspci
on an already running kernel (other kernel version or maybe a live-cd like knoppix). Then you need to run mkinitrd to create the new initrd manually. Here’s an example:
mkinitrd -o /boot/initrd.img-2.6.8-2-386_TEST 2.6.8-2-386
Change the kernel version and the filename to what you need. The kernel version is exactly the directory name under /lib/modules. Next you can check if your changes were applied. Mount the initrd image to a local directory to examine its conents:
cd /bootmkdir loopmount -o loop -t cramfs initrd.img-2.6.8-2-386_TEST loop/cat loop/loadmodules
See the module(s) that you added here? Nice! Now you only need to tell your boot loader to use the new initrd. Edit /boot/grub/menu.lst or /etc/lilo.conf accordingly (with lilo, run lilo before rebooting!).

## Calculate the DPI resolution of your display

I needed this when X displayed LyX with huge fonts. You can change the font's DPI setting when using Gnome (I didn't find it immediately): settings...fonts...details (very small button)

or without Gnome/supposedly KDE you can edit your ~/.xsession to execute
xrdb ~/.Xresource
and in the .Xresource you add a line (replace with what you calculated)
Xft*dpi: 85
But at least with gnome the second method does not work because gnome overrides this value with sheer brutality (try the fist method).

Now the brain-part (calculation): Pythagoras' theorem

a^2 + b^2 = c^2

is used to calculate the pixel-diagonal of your screen resolution (c) and c divided by the size of your monitor (screen diagonal in inches) yields the DPI

Example: 1024x768 on 15 inch (in german: "Zoll") screen

sqrt(1024^2 + 768^2) / 15 = ~85 DPI

Google to the rescue! Example calculation for 1280x1024 on 17 inch screen

## Network interface speed shell script

A shell script to determine the current throughput of a network interface. Yay!
#!/bin/shdev=$1if test "$dev" = ""thenecho "No link specified. Using eth0"dev="eth0"fiinA=ip -s link show $dev | tail -n3 | head -n1 | tr -s " " | cut -d" " -f2outA=ip -s link show$dev | tail -n1 | tr -s " " | cut -d" " -f2sleep 2inB=ip -s link show $dev | tail -n3 | head -n1 | tr -s " " | cut -d" " -f2outB=ip -s link show$dev | tail -n1 | tr -s " " | cut -d" " -f2echo "RX: $[(($inB-$inA)*8)/1000] kbps"echo "TX:$[(($outB-$outA)*8)/1000] kbps"

## CPU usage shell script

This three-liner extracts the CPU idle-percentage from vmstat, subtracts it from 100 and stores the result in a file.
Vmstat arguments specify waiting time in seconds and number of captures. I chose {5,2} to be sufficient.

idle=vmstat -n 5 2 | tail -n 1 | sed -e 's/ \{2,\}/ /g' | cut -d" " -f16
use=$((100-$idle))

## Apache2 and subversion (DAV-SVN)

Insert this into your apache2 SSL config file to enable subversion. This is the most simple example with user-defined styles and password protection.
<Location /~joe/svn>DAV svnSVNParentPath /path/to/subversionSVNIndexXSLT "/~joe/svnstyle.xsl"AuthType BasicAuthName "Joe's subversion repository"AuthUserFile /path/to/htpasswdRequire user joe</Location>

The code is pretty self-explanatory. First lines enable svn, last lines enable security.

## Apache2 SSL

1. Create a self-signed certificate: Apache2 comes with the script
apache2-ssl-certificate

Note: It seems not to be documented at all (manpage?), so try --force and --days if your certificate has expired!

2. Create a new server configuration under apache2/sites-available
Listen 443NameVirtualHost *:443<VirtualHost *:443>LoadModule ssl_module /usr/lib/apache2/modules/mod_ssl.soDocumentRoot /var/swwwSSLEngine onSSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULLSSLCertificateFile /etc/apache2/ssl/apache.pemErrorLog /var/log/apache2/ssl_error.log</VirtualHost>

3. Enable the new site
cd /etc/apache2/sites-enabled
ln -s ../sites-available/new-site-name

4. Restart apache2
/etc/init.d/apache2 restart