Posts Tagged comment

Get started with github

- create your local git repo.
- create account+project on github
- copy your github url (see project page)
- git remote add origin <github-url>
- git push origin master
copies your local changes
- git pull origin master:master
pulls from github

Setup for another directory/user:
- git clone <github-url>
- git push
- git pull

Note: the second user lives in origin, whereas your original lives in master and you push to origin.
I’m still trying to figure stuff out. Git resources: http://www.gnome.org/~federico/misc/git-cheat-sheet.txt

No Comments

Backup compression

I compressed a backup with various tools:

1606M original tarfile
1226M bzip2 –best
1.3G gzip –best (sorry, no exact MB)
1152M lzma -7 (default)
1131M lzma -8

LZMA (7-zip) is definitly a algorithm heavy on cpu and memory, but achieved great compression.
This shouldn’t be a benchmark (as I didn’t measure time), only a perception in this specific use case.

No Comments

Linux: Hostname change break X apps

There exists a really lame problem on X (X11,XFree86,Xorg,…): The authentification or identification mechanism when a new application wants to connect to the X server (read: show a window) works over the hostname.

This is fine if you live in 1990, but wireless network have dhcp and dhcp server can send a hostname to your machine making your X session stop working: You can’t start any programs anymore.

NetworkManager (what also make the little icon on GNOME/KDE desktops, pre-installed on Ubuntus et.al., developed by RedHat) uses dhclient to retrieve a hostname.

The magic words to add to your dhclient.conf are:

send host-name "hoot";
supersede host-name "hoot";

If you use pump (instead of dhclient), you shouldn’t have this problem, as it doesn’t set the hostname (see the man page).

A mailing list entry on this topic starts here: http://lists.freedesktop.org/archives/xorg/2004-August/002772.html

No Comments

HSQL CHECK constraints with CASE statement

Like the post at [0] suggests, HSQL CHECK constraints can not be used together with CASE WHEN statements.
If you try to insert/update, you will receive a (very informative) “S1000 General error java.lang.ClassCastException”, followed by the whole SQL statement. (here I have, HSQL 1.8.0.9).

If you have something like:


ALTER TABLE personnel ADD CONSTRAINT salary_types_constraint
CHECK (
CASE
WHEN pos = 0 AND (salary < 1000 OR salary > 5000)
THEN FALSE -- personal
WHEN pos = 1 AND (salary < 10000 OR salary > 20000)
THEN FALSE -- manager
ELSE TRUE
END
);

It will not work. It will give you a “S1000 General error java.lang.ClassCastException” error message.

Replace with:


ALTER TABLE personnel ADD CONSTRAINT salary_types_constraint
CHECK (
(pos = 0 AND (salary > 1000 OR salary < 5000))
OR
(pos = 1 AND (salary < 10000 OR salary > 20000))
);

No Comments

Bittorrent: Watching the net

You might wonder, why I made the previous story.

I was trying to find out how to make a tool that watches the local network for torrents. Ideally, it outputs the files shared and being downloaded so one can either join … or fire that guy.

As it turns out reading the spec (bittorrent.org, theory.org) and doing some sniffing, that you can not find out the original torrents.
That is because the info_hash, that is transmitted to tracker announcements (getting other peers, etc) regularly is a one-way hash (sha1).

Thus you can only see how much traffic, how many and which users and how many different files are participating, but not which files are shared, unless you have the .torrent files yourself (like, your the owner of thepiratebay.org).

No Comments

C Reference (Glibc info)

I already knew that the linux man pages contain documentation for a lot of the C-functions.

But I just found the info pages for glibc and using yelp (gnome help), entering

yelp file:///usr/share/info/libc.info.bz2

gives the C reference manual I always wanted!
Awesome.

No Comments

Spam

For not getting confused with my emails, I use filters obviously.
For blocking Spam I use spamassassin. http://wiki.apache.org/spamassassin/
Both are integrated really nice in KMail, my favorite mail application.

Spamassessin is nice ’cause it’s actually software meant for mail servers. Thus I think the bayes and other stuff is quite good. Coolest thing is, I can also fine tune it:

The spam rating is based on scores given for the different tests run on the incoming email. As a user, you can create new test and set the scores for existant tests. If the sum hits a maximum (5 for me), it is flagged as spam. Cool feature in Kmail: You can see the spaminess (Spam score given by spamassessin)
spaminess

My .spamassassin/user_prefs:


score DATE_IN_FUTURE_12_24      5
score HTML_MESSAGE              3.3
score MIME_HTML_ONLY            5
score MULTIPART_ALT_NON_TEXT    3
score GAPPY_SUBJECT             5
score FROM_EXCESS_BASE64        3
score FROM_HAS_ULINE_NUMS       3
score UPPERCASE_25_50           3
score UPPERCASE_50_75           4
score SUBJ_ALL_CAPS             2
body EVIL_WORDS         /(software|petroleum|casino|kurs|profit|symbol)/i
score EVIL_WORDS                2
describe EVIL_WORDS     evil_words
body EVIL_WORDS2        /(price|oil|bonus|prognose|borse|preis)/i
score EVIL_WORDS2               2
describe EVIL_WORDS2    evil_words2
body DOLLAR_SIGN        /[\$]/
score DOLLAR_SIGN       3
body PERCENT_SIGN       /[\%]/
score PERCENT_SIGN      3

The 25_50 stands always for percent.

No Comments

HP-UX/Bash: Getting comfortable in your shell

Introduction: I’m talking about the weird things after opening a shell on stud4

stud4 has a ugly configuration. If you connect, you get a minimal shell. the locale is set wrong, so you see the following all the time:

 Warning! One or more of your selected locales are not available.
Please invoke the commands "locale" and "locale -a" to verify your
selections and the available locales.
Continuing processing using the "C" locale.

Also, vi is no fun, and vim doesn’t accept the extended keyboard (delete, end).

Here I want to provide some info how you can improve your comfort.

1: start bash. Way better than the default shell.

bash

2: set your locale (language and localization). This is also in which language the error messages for example are.

export LC_ALL="en_US.utf8"
#export LC_ALL="de_DE.utf8"

For example:

[e0123456@stud4:~]$ export LC_ALL="en_US.utf8"
[e0123456@stud4:~]$ man
Usage: man [-M path] [-T macro-package] [ section ] name ...
or: man -k keyword ...
or: man -f file ...
[e0123456@stud4:~]$ export LC_ALL="de_DE.utf8"
[e0123456@stud4:~]$ man
Syntax: man [-M Pfad] [-T Makro-Paket] [ Sektion ] Befehlsname ...
oder: man -k Schlüsselwort ...
oder: man -f Datei ...
[e0123456@stud4:~]$

3: allow backspace

stty erase "^?"

4: get a informative prompt (second is with color)

PS1="[\u@\h \W]\\$ "
PS1="\e[0;34m[${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}]$ \e[m"

Example:

bash-2.04$ PS1="\e[0;34m[${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}]$ \e[m"
[e0123456@stud4:~]$

List of colors and manual

If you want that in your startup, write the following into your .bashrc

#!/bin/bash
export LC_ALL="en_US.utf8"
#export LC_ALL="de_DE.utf8"
stty erase "^?"
PS1="\e[0;34m[${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}]$ \e[m"

Now you may wonder, how can I write that easily in the freaking file?

pico .bashrc

To set pico, vim, xemacs or whatever your default editor (so "crontab -e" and other commands call it), use:

export EDITOR=pico

Another funny thing is XForwarding. Try this:

ssh e0123456@stud4.tuwien.ac.at -X
bash
xemacs

Ta-daa! A fat graphical editor. Of course only if you use X.
Also funny commands you can play with: xload, xbiff++, xclock, etc.

Really useful on the stud4 server is the script quotax:

[e0123456@stud4:~]$ quotax
Disk space limits on stud4:
---------------------------
Total disk space in home directory:   200 MB
Minimal free space for mail delivery:  10 MB
Maximal capacity of inbox folder:      50 MB
Disk usage summary for user e0123456:
-------------------------------------
Used disk space in home directory:  186.0 MB [93.0 %]
Free disk space in home directory:   13.9 MB [ 7.0 %]
Number of messages in inbox folder:  213
Size of inbox folder:                 2.0 MB [ 4.0 %]
Free space for incoming messages:     3.9 MB
WARNING: Remaining disk space in home directory is very low.
-------> There is not much space left for files and incoming mails.

At the end, some useful bash and vim tips for these crippled terminals:

bash:
Ctrl-A: begin of line
Ctrl-E: end of line
Ctrl-W: delete last word
vim: (watch out if you are in edit or command mode)
:dl      Delete letter
:dw    Delete word
:dd     Delete line
:wq    Write & quit
:q!      Quit without writing or anything

It is always worthy reading the according manuals (probably not on HP-UX, but on a linux machine or man-pages on the internet).

That’s it. Try things, don’t break things, and have fun.

1 Comment

My backup plan

Everyone says, backups are important, but how do you backup? And have you ever tried replaying a backup?

My backup plan:
- Working copy on my laptop
- Compressed archive is created every week. I delete old backups infrequently.
- Infrequent rsync of working copy (filtered) to USB stick.
- rsync of working copy (filtered) to the university servers.
- Compressed archive copied to the university server.

I would say I’m quite secure …

Crontab entry: 0 */4 * * * cd backup && sh backup2.sh


#!/bin/bash
PARENT=/mnt/daten/Daten/
DIR=Studium/
SELDOMCHANGE='*.zip *.ps *.pdf *.rar *.tar.* *.jpg *.gif *.png'
BORING='*.log *.out *.xac *~'
LARGESERVER=a0123456@login.unet.univie.ac.at
SMALLSERVER=e0123456@stud4.tuwien.ac.at
SERVERS="$LARGESERVER $SMALLSERVER"
cd $PARENT
# part A:
# compress some file types that change seldom and send them over once a month
# that would be zip, ps, pdf, rar, tars, images,
FILENAME=Sicherungen/Full/seldom-changed-types-$(date +%W).tar.bz2
TARGETSERVERDIR=$LARGESERVER:Sicherungen/Full/
# create archive if it doesn't exist yet
[ -s $FILENAME ] || \
echo 'creating weekly archive' &&
find Studium -type f $( for i in $SELDOMCHANGE ; do echo "-iname" "$i" "-or"; done) -false | \
tar --create --bzip2 "--verbose" "--files-from=-" "--file=$FILENAME"
# lets sync that to the server
# commented out: files ~ 500MB :-(
#echo 'rsyncing weekly archive to server'
#rsync $FILENAME $TARGETSERVERDIR
# part b
# rsync the others
#
for SERVER in $SERVERS
do
echo 'rsyncing with ' $SERVER
TARGETSERVERDIR=$SERVER:Sicherungen/Studium/
for i in $SELDOMCHANGE $BORING; do echo "- $i"; done | \
rsync -az --checksum --delete-excluded --exclude-from=- $PARENT/$DIR $TARGETSERVERDIR
done
echo 'backup done.'

No Comments

Feedreader für Lindex

Hier werden geeignete Feedreader für Lindexdiskutiert.

Um zu testen, gehe auf die Lindex Startseite und wähle einen unmoderierten Feed von der TestLVA von der TestUni. Nachdem der Feed geladen wurde, ändere bei einem Eintrag Text oder Datum. Der Feedreader ist gut, wenn er die Änderung erkennt (als neu markiert und Datum und Text richtig ausgibt).

Empfehlungen

  • Windows: RSSOwl: Vorbildlich (sollte auch auf anderen Betriebssystemen gehen)
  • Linux: Liferea: Vorbildlich
  • Windows: RSSReader: Erstellt bei Änderungen einen neuen Eintrag
  • Firefox: Sage: Zeigt aber Datum nicht in der Liste an.

Getestet und nicht empfohlen

  • Linux: Akregator: Erkennt keine Änderungen.
  • Firefox: WizzRSS: Zeigt Datum nicht an.
  • Windows: Feedreader: Markiert geänderte Einträge nicht als neu/ungelesen
  • Thunderbird: Erkennt Änderungen nicht, unübersichtlich bei zu vielen Feeds.

Jeder ist eingeladen, dazu Kommentare zu posten.

No Comments