Uncategorized

Produkte gratis testen mit trnd

trndBisher stand ich solchen Marktforschungsprogrammen eher skeptisch gegenueber. Thias’ Blogeintrag “Produkte gratis testen” auf eigent.li/ch hat mich dann aber doch neugierig gemacht. Hab mich darum jetzt auch mal registriert und mich gleich mal fuer das erste Projekt angemeldet.

Mal schaun was draus wird, ich halte euch auf dem laufenden! Falls ihr euch auch anmelden wollt, koennt ihr dies hier* tun.

*ja, das ist ein Referral Link und schreibt mir 3 “Wombats” (was auch immer das ist?) gut. Fuer euch aendert sich damit nix.

Bash Scripting Tips

Writing Shell (here: Bash) Scripts for productive systems can be a pain in the ass. Especially if you have varios flavors of linux in your environment.

I’d like to share some tricks I’ve learned in the past few weeks.

Make Bash fussy

This is something you REALLY wanna do:

1
2
3
#!/bin/bash -e
# or
set -e

By either Modifying the Shebang or by using the set command, you set Bash into “Fuzzy Mode”. This causes the script to exit whenever a command fails (and thus, the exit-code ist not 0/true).

You can disable this functionality for individual commands:

1
2
3
4
5
6
command_that_may_fail || true
# or
set +e
command_that_may_fail1
command_that_may_fail2
set -e

Activate X-Ray (debug) Mode

1
[ -n "$DEBUG" ] && set -x

This turns -x on if DEBUG is set to a non-empty String and causes Bash to be VERY talkative.
Example. This is our Script:

1
2
3
4
5
6
7
#!/bin/bash -e
[ -n "$DEBUG" ] && set -x

w1="Hello"
w2='World'

echo "${w1} `echo $w2 | sed 's/World/Universe/'`!"

And this is what we get:

1
2
3
4
5
6
7
dratir@ajax:~$ DEBUG=1 ./test.sh
+ w1=Hello
+ w2=World
++ echo World
++ sed s/World/Universe/
+ echo 'Hello Universe!'
Hello Universe!

Get the absolute Path to the Script

This is basically an easy one, you just have to know it:

1
2
script="`readlink -f $0`"
wdir=`dirname "$script"`

However, if you use pwd in your script prior to this call, it will fail

Check for needed commands

When working with many different installations, it’s a good idea to check if you’ve got everything you need in your Script:

1
2
3
4
for cmd in command1 install useradd groupadd command2
do
  test -x "`which $cmd`"
done

Because of -e (remember to set it), the script dies if a command can’t be found or executed.

Prevent infinite loops (and your Server from crashing)

Sometimes you need your script to restart itself. If you do it wrong [...] you may produce an infinite loop of self calling (which will cause your system to fail after the ~20’000st call, and thus, the ~60’000st open file).
So use this instead:

1
2
3
4
5
6
7
restart() {
  pscount=`ps aux | grep $0 | wc -l` # count myself
  [ $pscount -lt 10 ] || exit 1 # Exit if we are in a Loop
  $script
  # Don't forget to fill $script with the absolute path to the script (see above)
  exit 0 # to prevent the rest of the script to run
}

Wil 50m



Wil 50m, originally uploaded by Dratir.

Geschossen mit meiner neuen Sony a550. Mehr dazu spaeter.

Gefällt mir!

sprainTV – Doch kei Chabis

Zugegegben, Anfangs war ich eher skeptisch, was sprainTV angeht. “Schowider sonen Chabis” war mein erster Gedanke.

Doch nachdem ichs nun in letzter Zeit regelmaessig geschaut hab, muss ich sagen: Gefällt mir!!!

Die Themen, die witzig praesentiert werden sind meist interessant, nicht selten geht es um etwas aus der Gegend ( = Schweiz). Zudem ist die Laenge ideal: Kurz und buendig!

Fazit: Als Schweizer (oder Schweizerdeutschversteher) definitiv einen Blick wert! Und drum: Hier, die aktuelle Folge 16 von sprainTV:

More >

The Making of Chrome Features

Die meisten von euch kenne wahrscheinlich Google’s Werbespots fuer Google Chrome (Falls nicht: Hier anschauen. Los!)

Nun hat Google ein Video veroeffentlicht, welches die Entstehung dieses Clips zeigt.

Wirklich sehr interessant zu sehen, wie die Jungs und Maedels da zu werke gehen!

Video nach dem Klick. More >