September 3, 2010

user-mode-linux & uml-handler mini-howto

A short introduction about UML UserModeLinux and UML-Handler tool and related issues.

September 2, 2010

k-shaper mini how-to

A short introduction about linux and iptables architecture as well as traffic shaping engines in this environment, and relational issues.

A solution is provided by k-shaper, and these slides show a mini how-to.

This is part of my academic training, and it was introduced at HackMeeting in Naples, in 2005.

K-Shaper code is available at:

May 27, 2010

screen session crypted password

sometimes i use irssi in screen, but in a box not mine...

so, i would like no one, except me, can reattach my screen...
read: i don't want superuser-root can reattach my screen....

a few of search (and test), et voila:

in screen, type:
ctrl-a ENTER
:password ENTER
[screen asks for password 1th time] TYPE_MY_PASS
[screen asks for password 2th time] RETYPE_MY_PASS

then, if u reattach (only screen -r) it will ask for pass

finally, if u want all future screen sessions use THAT (crypted) password, u have to:
  1. obtain pass: ctrl-a ]
    copy crypted string (i.e. "WWKHW6FMEu6TAjk234j")
  2. save a line into .screenrc as below:
    echo password WWKHW6FMEu6TAjk234j >> .screenrc

enjoy it ;D

May 22, 2010

check auth.log

sometimes i'm paranoid and i want check who try to log in my server...
but auth.log is a very large and blinding file... so:

cat /var/log/auth.log | egrep -e "\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b"  | cut -d":" -f4  | uniq | sed 's/[a-zA-Z\-]//g' | awk '{print $1}' | uniq

obviously a script is a smarter solution ;D

links: authCheck

May 19, 2010

we love to compile on the edge ;D

ok, in this post i'll spend two words about a my debian builder-cc enhanced version.

you know builder-cc is a gcc/g++ wrapper, which utilize some bash env variable to optimize/tune/etc compilation, using -mtune -ftracer and so on...

in builder-cc (and builder-c++) only 2 variables are used, that is
DEBIAN_BUILDARCH (to specify architecture as pentium3,prescott,k7,k8,core2 and so on...) and DEBIAN_BUILDGCCVER (just the gcc version: 4.2, 4.3, ...)

however, i love extreme situations, and these 2 variables are not enough for me.. i want use also -ftrace -fomit-frame-pointer -mSOMEsse etc...

so, just another variable: EXTREME_COMPILING (what wonderful name, isn't ;D ?)

with "EXTREME_COMPILING=yes" we could have:

-pipe -O2 -msse4 -ftracer -mcx16 -msahf -fomit-frame-pointer -momit-leaf-frame-pointer -other-options-we-like

and NOW, 'cause most people have multicore processore (core2duo,quad,etc), it would be smart use make "-j" option; -j = jobs -> it specifies the number of simultaneously jobs (i.e. compiling). So i use -j9 'cause i have a i7 (ht-quad = 8cores) [or you can using -j`echo $((`getconf _NPROCESSORS_ONLN`+1))` ]
For this last i wrote "builder-make", which use SMP_MAKE=9 <- -j9

To be more simpler, i used same prefix in variable names:

in order to use builder-cc, builder-c++ and (last) builder-make, we must:
1) use this links structure:
[k0smik0@widgy bin]$ pwd
[k0smik0@widgy bin]$ ls -l g++* gcc* make*                                                
lrwxrwxrwx 1 root root     11 19 mag 17:51 g++ -> builder-c++*
-rwxr-xr-x 1 root root 253104 26 feb 06:56 g++-4.4*
lrwxrwxrwx 1 root root     10 19 mag 17:51 gcc -> builder-cc*
-rwxr-xr-x 1 root root 239080 17 feb 11:53 gcc-4.3*
-rwxr-xr-x 1 root root 251440 26 feb 06:57 gcc-4.4*
lrwxrwxrwx 1 root root      7  7 mar 12:18 gcc.real -> gcc-4.4*
lrwxrwxrwx 1 root root      7  7 mar 12:23 g++.real -> g++-4.4*
lrwxrwxrwx 1 root root     12  7 mar 12:24 make -> builder-make*
-rwxr-xr-x 1 root root  31070 16 feb 06:04 make-kpkg*
-rwxr-xr-x 1 root root 166448  2 nov  2009 make.real*

2) declare above variables with "declare -x" or "export" before launch gcc/g++/make, or declare in /etc/bash.bashrc or ~/.bashrc or... or.

ok, here the scripts: links:
or code below:
## builder-cc

 @target = ("gcc.real", @ARGV); 
elsif ($ENV{BUILDER_ARCH} eq undef && $ENV{BUILDER_EXTREME_COMPILING} eq undef) {
 @target = ("gcc-" . $ENV{BUILDER_GCCVER}); 
 @target = ("gcc-" . $ENV{BUILDER_GCCVER}, 
 "-mtune=$ENV{BUILDER_ARCH}", "-march=$ENV{BUILDER_ARCH}", @ARGV); 
else {                                
        # these options are _VERY_ personal, and architecture dependant - you risk to fail compile - careful with that axe, eugene!                                                      
 @flags = ("-pipe","-O2","-msse4","-ftracer","-mcx16","-msahf","-fomit-frame-pointer","-momit-leaf-frame-pointer"); 
 @target = ("gcc-" . $ENV{BUILDER_GCCVER}, "-mtune=$ENV{BUILDER_ARCH}", "-march=$ENV{BUILDER_ARCH}", @flags, @ARGV); 
 exec @target or die "Unable to exec @target[0]: $!\n";
## builder-c++

 @target = ("g++.real", @ARGV); 
elsif ($ENV{BUILDER_ARCH} eq undef && $ENV{BUILDER_EXTREME_COMPILING} eq undef) {
 @target = ("g++-" . $ENV{BUILDER_GCCVER}); 
 @target = ("g++-" . $ENV{BUILDER_GCCVER}, 
 "-mtune=$ENV{BUILDER_ARCH}", "-march=$ENV{BUILDER_ARCH}", @ARGV); 
else {                                
        # these options are _VERY_ personal, and architecture dependant - you risk to fail compile - careful with that axe, eugene!                                                      
 @flags = ("-pipe","-O2","-msse4","-ftracer","-mcx16","-msahf","-fomit-frame-pointer","-momit-leaf-frame-pointer"); 
 @target = ("g++-" . $ENV{BUILDER_GCCVER}, "-mtune=$ENV{BUILDER_ARCH}", "-march=$ENV{BUILDER_ARCH}", @flags, @ARGV); 
exec @target or die "Unable to exec @target[0]: $!\n";
## builder-make
if ($ENV{BUILDER_SMP_MAKE} eq undef) {
 @target = ("make.real", @ARGV); 
} else {
 @target = ("make.real", "-j$ENV{SMP_MAKE}", @ARGV); 
exec @target or die "Unable to exec @target[0]: $!\n"; 

encode dv to theora

just a little script to encode from dv to theora (ogg vorbis video) - download: dv2theora


### do not modify below ###


FILE=`file $DV_FILE 2>&1`
echo $FILE | grep DV >/dev/null 2>&1 || (echo "Usage: dv2theora a_valid_dv_file.dv" && exit 1)

ffmpeg2theora -f dv -v $VIDEO_QUALITY -o ${DV_FILE/%dv/ogv} $DV_FILE

an elegant script for multithreading bash execution

ok, we are in 2010 and we have (at least) a duo-core (i hope ;D)

recently, i buyed my first NEW computer (after ten years i've spended in building my computers, assembling used hardware... buyed on ebay or similar... now i'm too old to this.. and i buyed a _complete_ case ;D)
...a ht-quadcore i7 with 6gb ram ;D
and now i want all my sw/script/etc in multithreading.. damn, i have an optocore and i want use it!
so, it's a good chance for xargs.
in example, some days ago i encoded from dv to theora (11 files):
- sequential solution (11 iteration, sequentially):
for DV_FILE in `ls -1 *dv`;
 ffmpeg2theora -f dv -o ${DV_FILE/%dv/ogv} $DV_FILE
- "parallel" solution (11 parallel processes - if u want your cpu(s) start to cry...):
for DV_FILE in `ls -1 *dv`;
 # just added & to command, to send in background
 ffmpeg2theora -f dv -o ${DV_FILE/%dv/ogv} $DV_FILE &
now, an inline solution with xargs: supposing we have a script "dv2theora" as:
ffmpeg2theora -f dv -o ${DV_FILE/%dv/ogv} $DV_FILE
and dv files are named as 1.dv 2.dv etc...
then we have
echo `seq 1 11` | xargs -n1 -P3 ./dv2theora
xargs takes argument from pipe and gives them to command "dv2theora" - option P3 means "3 parallel processes"

but.. where is the problem?
oh, it's simple - xargs handles substitutions as find, with {} - bad, very bad.

so, there is just a better solution:

links: mdo ("mdo" means MultipleDOing) or copy and past from below:

# number of cpus/threads u want at same time

# do not modify below
[ $# -lt 1 ] && echo "Usage: mdo    " && exit 1
unset argv[0]
echo ${argv[@]} | xargs -n1 -P$SMP_PARAMETER $COMMAND
and now i can use as below:
mdo dv2theora `find . -type f -iname '*.dv'`
just more intuitive
just simpler

enjoy it ;D

May 13, 2010

af9015 usb - >= patch for this afatech tv stick (id: 15a4:9016 )

yes, sometimes i like watchin' tv, so i bought this:

afatech 9015

afatech 9015

lsusb tells: Afatech Technologies, Inc. AF9015 DVB-T USB2.0 stick - 15a4:9016

unfortunately, under linux, nothing go well at first time ;D

so, after some ask to google, i found something.. and something else... but obviously nothing to "get and use".

so i builded my patch, et voila:
(builded against a, but it works also on a, and perhaps on successive...)


or copy and past from below: