Monday, August 29, 2011

Show ports and the applications bound to them


#!/bin/bash

netstat -lntup \
| awk '/^(tcp|udp)/ {print substr($4, match($4, ":[^:]+$") + 1) "/" $1, substr($NF, 1, index($NF, "/") - 1)}' \
| while read PORT PID
do
        BIN=$(readlink /proc/$PID/exe)
        echo $PORT $PID $BIN
done

Thursday, August 18, 2011

Show hardware info in Fedora

dmidecode -q
less /proc/cpuinfo
lspci
lsusb

Wednesday, August 17, 2011

List lines in file A but not in file B

I found this interesting scripts' page: http://tkhanson.net/misc/ and I think that I got an alternative to the anb script:


#!/usr/bin/perl

use strict;
use warnings;

sub usage {
        print "$0: filea fileb\n";
        exit -1;
}

usage unless scalar @ARGV == 2;

my $a = shift @ARGV;
my $b = shift @ARGV;

open A, "<$a" or die "can't open $a: $!\n";
open B, "<$b" or die "can't open $b: $!\n";

my %bl;
$bl{$_}++ for (<B>);

for (<A>) {print "$_" unless $bl{$_}};
__END__
Or using map for the last lines:
my %bl = map {$_ => 1 } (<B>);
map {print "$_" unless $bl{$_}} (<A>);




TIMTOWTDI

Wednesday, August 10, 2011

Some notes on Python

Data structures
* tuples - ( ) - inmutable
* lists - [ ] - changeable
* dictionary - { } changeable # Hash concept in Perl
   keys()
   values()
   __contains__(key)

* Strings are immutable

* None
* True
* False

To access the last element: [-1] # Same idea as in Perl

For lists:
   append()
   extend()
   pop(0) or pop() # The last element of the list is removed

Tuesday, August 9, 2011

Navidad 2010


PARA ESTA NAVIDAD 2010 y PARA TODO TIEMPO

Padre, cuando el mundo me empuja a buscar el poder y ejercerlo,
cuando la sociedad nos impulsa a someter al semejante...
Que me rebose tu Palabra de Amor, Señor...
Que me sostenga mi confianza en Ti...
Y que me mueva la vocación de servir al prójimo,
que mi ánimo sea humilde,
que mi Fuerza seas Tú,
que mi paz sea contar Contigo...
Señor, que sea testimonio de entrega generosa,
que me haga pequeño para ser grande Contigo,
que me haga último para ser el primero a tu lado.

Señor, enséñanos a mirar a las personas
igual que Tú las miras… ¡Dispuesto a Servirlas!
Señor, Tú que eres Bueno y Misericordioso,
danos un corazón sencillo, humilde, atento y amable
que no busque ser servido, sino servir.
Enséñanos a mirar al mundo con los ojos que Tú lo miras.
Tú, Señor, sabes mucho mejor que nosotros
aquello que nos conviene, antes que te lo pidamos.
Ten Misericordia de nosotros y no nos dejes caer en la tentación
del poder, prestigio o vanagloria que nos alejen de Ti,
y enséñanos a saber pedirte no lo que deseamos,
sino lo que realmente nos conviene y Tú quieres darnos.

Señor, ayúdanos Tú a ser generosos y serviciales
con nuestros hermanos más cercanos que nos rodean
en nuestro trabajo, familias, en cualquier lugar donde estemos,
para ser capaces de compartir con ellos
todos los dones que Tú nos regalas cada día
para ponerlos al servicio de las personas que lo necesiten. Amén.

'Obras son amores y no buenas razones'

The Gracious Time
By William Shakespeare

Some say that ever 'gainst that season comes
Wherein our Saviour's birth is celebrated,
The bird of dawning singeth all night long:
And then, they say, no spirit date stir abroad;
The nights are wholesome; then no planets strike,
No fairy takes, nor witch hath power to charm,
So hallow'd and so gracious is the time.

Friday, August 5, 2011

Convert WAV files to MP3 in Ubuntu

#!/bin/bash
# name of this script: wav2mp3.sh
# wav to mp3

for i in *.wav; do
 if [ -e "$i" ]; then
   file=`basename "$i" .wav`
   lame -h -b 192 "$i" "$file.mp3"
 fi
done

Thursday, August 4, 2011

Purpose


I want to live my life like a pilgrim, with gratitude and humility, not as a tourist.
Jeb Spencer



Tuesday, August 2, 2011

Encouraging Words: The Transforming Oven of Adversity


Image: © 2009 Darleen Araujo and Sue Chastain