martedì, maggio 18, 2010

Random playlist from the command line (with zsh e gst123)

If you use zsh as your shell you can install gst123 and you now on can play a random playlist from the command line with:


cd in_your_music_root_folder
gst123 -z **/*

giovedì, settembre 10, 2009

String slicing in bash

Just a memo here:

${var_name:start_index:num_of_chars_after_index}

prompt:$ to_be_sliced="1234567890"

prompt:$ sliced=${to_be_sliced:5:${#to_be_sliced}}

prompt:$ echo $sliced
67890


Note:
${#var_name} returns the length of $var_name

martedì, settembre 08, 2009

RTFMP: Override resolv.conf from network manager

Hi,
a little post after so much time!

I always asked myself how I could override the search domain set by network manager or dhclient in /etc/resolv.conf but I never did it.

The easier and, I'd say, nicer solution comes from man /etc/resolv.conf! and it says:

"The search keyword of a system’s resolv.conf file can be overridden on a per-process basis by setting the environment variable LOCALDOMAIN to a space-separated list of search domains."

Not only it can be overriden! but also on a 'per process basis'!

Next time i have to remember to Read The Fucking Man Page.

Alleluja

martedì, giugno 10, 2008

Back to VIM

After more than two hardcore months spent with Emacs...

I'M BACK TO VIM

because...

+ it fits to my way of thinking +

ps.
among other awesome things, i really love the repeat input shortcut '.'

p.p.s
Still think emacs it's good ;)

martedì, aprile 29, 2008

Linux Daemon - Python sys.exit versus os._exit

Trying to daemonize a simple xmlrpc server i found some examples... let's give them credit:

W. Richard Stevens and Stephen A. Rago
Advanced Programming in the Unix Environment

Levent Karakas
http://www.enderunix.org/documents/eng/daemon.php

Devin Watson
www.netzmafia.de/skripten/unix/linux-daemon-howto.html

Chad J. Schroeder
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/278731

Some of the examples suggested to use os._exit instead of sys.exit while daemonizing a process.
The difference is quite subtle and it's fully explained in two C man pages, Python implementation of these functions follow exactly what's defined here:

man 2 _exit
man 3 exit

They're not present by default in common desktop distros...
In debian they're in manpages-dev package; think is the same on rpm based distros (not sure).

greets

giovedì, aprile 17, 2008

History meme

eolo999@ggubu:~$ history | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head

112 py -> python
48 sudo
36 cd
34 ls
32 cache -> apt-cache search
24 inst -> apt-get install
20 em -> emacs -nw
17 mutt
14 fg
13 gm.sh -> fetchmail

mercoledì, aprile 02, 2008

Provo emacs per un po'

Ho sempre preferito vim ad emacs pero'...
...
mentre mi divertivo a studiare lisp/scheme sono stato costretto a confrontarmi con emacs...



...
non mi e' dispiaciuto per niente e ho deciso di provare ad usarlo per un po' come editor predefinito.
Ho fatto queste modifiche:

file: .bashrc

1. ho aggiunto un alias -> alias em='emacs - nw'
2. editor di default per le applicazioni da terminale -> export EDITOR="emacs -nw"
p.s. "-nw" serve per non avviare la versione X di emacs