Archive for the ‘Coding’ Category

My .vimrc

Mai 25, 2010

Things the world should know:

  • My .vimrc

(more…)

Create a Graph with Perl’s GD::Graph

März 26, 2010

Another backup of know-how…

I created this example some years ago. Since my old wiki is replaced by this blog I’ll post it here.

It was very handy for me recently – when I had to creat a graph with Perl (again).

You need to create charts like this?

GD area graph

GD::Graph::area

(more…)

Git für Anfänger (wie mich)

Februar 1, 2010

Git ist ein Werkzeug zur Versionsverwaltung von Projekten, vergleichbar mit SVN und CVS.

Git bringt so einiges an Power unter der Haube mit sich, die Details kann aber jeder selber nachlesen.

Ein paar Fakten die einen neugierig machen könnten:

  • Git ist „relativ“ neu und stammt aus der Feder von Linus Torvalds
  • Git eignet sich für grosse wie kleine Projekte
  • Der Linux-Kernel wird auf Git entwickelt
  • Verschiedenste Grossprojekte wechsel(te)n zu Git. So z.B. Gnome, Perl, Debian, …
  • Git ist Opensource

Ich möchte hier einfach kurz notieren wie einfach ein Einstieg ist. (Viel weiter bin ich ja auch noch nicht, aber ich brauchs bis jetzt auch nicht)

Nachdem ich Git installiert habe kanns los gehen. (Unter den gängigen Linux-Distributionen eine Sache von Sekunden)

(more…)

Introducing Orgcreator

Januar 24, 2010

The situation was as following: I had to work myself into the opensource HR-program OrangeHRM, had plenty of free time, and wanted to try how it is to develop a GUI-application for Linux.

All this circumstances led to the development of a small program which I call orgcreator.

What the program actually does: It looks up the personnel data from OrangeHRM and creates a picture of the company structure.

graph of company structure

graph of company structure

(more…)

PDF jonglage

November 27, 2009

Mehrere PDF’s zusammenfügen?

Das geht ganz einfach mit pdftk.

So habe ich z.B. für meinen Lebenslauf alle Zertifikate als PDF einzeln gescannt. Für den fertigen Lebenslauf kette ich alles zusammen in ein Dokument:

pdftk *.pdf cat output bewerbung.pdf

Vier Seiten auf eine? PDF um-formatieren für Handouts geht mit pdfnup aus dem Paket PDFJam, welches hilfreiche Scripts anbietet (hier gefunden).

pdfnup --nup 2x2 myfile.pdf

PDFJam enthält auch noch pdfjoin welches das gleiche macht wie oben und pdf90 zum rotieren.

Schnell und einfach, so haben wir es gerne!

Backup und Restore mit MySQL

Oktober 14, 2009

Für Leute mit Shell-Erfahrung, ohne Worte!

Einfach, schnell und effektiv 🙂

Backup

for i in `mysql -B -h $HOST -u $USER -p $PW $DATABASE -e "show tables"| tail -n +2`;
do
    echo "Dumping $i"
    mysqldump -h $HOST -u $USER -p $PW $DATABASE $i > $i.sql
done

Restore

for i in `ls *.sql`
do
    echo "Processing $i"
    mysql $DATABASE -h $HOST -u $USER -p $PW < $i
done

Colors in the Bash

September 10, 2009

Here is a script which shows how colors are used:

#!/bin/sh
############################################################
# Nico Golde <nico(at)ngolde.de> Homepage: http://www.ngolde.de
# Last change: Mon Feb 16 16:24:41 CET 2004
############################################################

for attr in 0 1 4 5 7 ; do
    echo "----------------------------------------------------------------"
    printf "ESC[%s;Foreground;Background - \n" $attr
    for fore in 30 31 32 33 34 35 36 37; do
        for back in 40 41 42 43 44 45 46 47; do
            printf '\033[%s;%s;%sm %02s;%02s  ' $attr $fore $back $fore $back
        done
    printf '\n'
    done
    printf '\033[0m'
done

Just run the script in your terminal and see the result.
The shown numbers can be used to color the background or foreground of output.

(more…)

In and Out

September 10, 2009

Standard Input

Ever wondered how to write a script that you can pipe stuff in? Here you go:

while read LINE;
do
    echo $LINE
done

(more…)

Bash Arguments

September 10, 2009

Basic stuff you’ll need if you write a script that uses arguments. Just try it to see what happens.

echo arglist: $*
echo amount: $#
echo scriptname: $0
echo arg1: $1
echo arg2: $2

Here’s an example how you can loop trough all arguments using $*.

for i in $*
do
    #will echo all the variable passed as parameters
    echo $i
done

Basic Perl Stuff

September 9, 2009

I often need to look up the chapters here when I’m programming. Here I list all the daily perl-stuff that makes life much more easy.

(more…)