Friday, December 23, 2011

Navidad 2011


Deseos navideños
¿Cómo, por la Navidad,
no voy a tener deseos
de a los otros regalar
si Tú, Señor, cuando vienes
cada año a Tu portal,
Te regalas a Ti mismo
al extraviado mortal?

Francisco-Manuel Nácher

Diana's cupcakes

Delicious! Homemade, it's a Colombian-American cupcake from Doral!

Thanks Diana!

Jamaica muffins


From Hialeah!

Václav Havel's motto

"Truth and love must prevail over lies and hate."

Tuesday, December 13, 2011

The Zen of Python


janeiros@harlie:~$ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import this
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
>>>

Comparison of Solaris OS and Linux for Application Developers

Comparison of Solaris OS and Linux for Application Developers

http://developers.sun.com/solaris/articles/solaris_linux_app.html

Many developers are writing applications to run under the Linux operating system. With the many new features of the Solaris 10 OS, and with the new emphasis Sun has placed on supporting the Solaris OS on AMD and Intel processor-based machines, developers are becoming interested in being able to develop their applications on the Solaris platform. This article examines similarities and differences in the development environments of both operating systems. Someone responsible for porting applications from Linux to the Solaris OS, or programmers with prior Linux experience that want to learn development on the Solaris OS, should benefit from this article.

In this article, the term "Solaris" refers to the Solaris 10 OS (and OpenSolaris), and "Linux" refers to Linux 2.6. Many of the details covered will also apply to earlier versions of Solaris and Linux. The Linux distribution is meant to be generic, though examples have been tested on SuSe 9.1. Also, the article concentrates on applications written using the C programming language, though C++ should behave the same. Since Java technology-based applications should not be making function calls specific to Linux or the Solaris OS, they should be portable as is.

Monday, December 12, 2011

Dear Lord and Father of Mankind


Dear Lord and Father of mankind,
Forgive our foolish ways!
Reclothe us in our rightful mind,
In purer lives Thy service find,
In deeper reverence, praise.

In simple trust like theirs who heard
Beside the Syrian sea
The gracious calling of the Lord,
Let us, like them, without a word
Rise up and follow Thee.

O Sabbath rest by Galilee!
O calm of hills above,
Where Jesus knelt to share with Thee
The silence of eternity
Interpreted by love!

With that deep hush subduing all
Our words and works that drown
The tender whisper of Thy call,
As noiseless let Thy blessing fall
As fell Thy manna down.

Drop Thy still dews of quietness,
Till all our strivings cease;
Take from our souls the strain and stress,
And let our ordered lives confess
The beauty of Thy peace.

Breathe through the heats of our desire
Thy coolness and Thy balm;
Let sense be dumb, let flesh retire;
Speak through the earthquake, wind, and fire,
O still, small voice of calm!

-John Greenleaf Whittier

Do you hear what I hear


"Do you hear what I hear"

"Somehow, not only for Christmas
But all the long year through
The joy that gives to others
Is the joy that comes back to you.
And the more you spend in blessing
The poor and lonely and sad
The more of your heart's possessing
Returns to you glad."

-John Greenleaf Whittier

A Christmas Treat


"A Christmas Treat"

"A Christmas candle is a lovely thing,
It makes no noise at all,
But softly gives itself away,
While quite unselfish, it grows small."

-Eva K. Logue

Sunday, December 11, 2011

Erma Bombeck & Christmas


"There's nothing sadder in this world than to awake Christmas morning and not be a child."
"When I stand before God at the end of my life, I would hope that I would not have a single bit of talent left, and could say, 'I used everything you gave me.'"
Erma Bombeck

Wednesday, December 7, 2011

Isaías 26:3


Tú guardarás en completa paz a aquel cuyo pensamiento en ti persevera; porque en ti ha confiado.


Isaías 26:3

Tuesday, December 6, 2011

Kasparov on Chess

"Chess helps you to concentrate, improve your logic. It teaches you to play by the rules and take responsibility for your actions, how to problem solve in an uncertain environment."
http://www.telegraph.co.uk/news/worldnews/europe/russia/8917352/Garry-Kasparov-Putins-just-like-Al-Capone.html

Friday, November 18, 2011

How to make a phone call to Cuba from Miami


How To:
Step 1: Dial International Call Prefix
Step 2: Dial Country Code
Step 3: Dial City Code (area code)
Step 4: Dial Local Number


1 -> 011 (Call prefix from the USA) 
2 -> 53 (Cuba prefix)
3 -> 43 (Cienfuegos's prefix)
4 -> 999999 (The local phone number you want to reach)


You dial 011 53 43 999999


References:


https://www.uwtcallback.com/international-call-prefixes.html

https://www.uwtcallback.com/country-calling-codes.html

http://en.wikipedia.org/wiki/Telephone_numbers_in_Cuba




Wednesday, November 16, 2011

NTP server iburst option

Each poll process sends NTP packets at intervals determined by the poll program. The program is designed to provide a sufficient update rate for thc clock discipline algorithm, while minimizing network overhead.

As an option of the server command, instead of a single packet, the poll program can send a burst of six packets at 2-s intervals. This is designed to reduce the time to synchronize the clock at initial startup (iburst) and/or to reduce the phase noise at the longer poll intervals (burst). The iburst option is effective only when the server is unreachable, while the burst option is effective only when the server is reachable.

Tuesday, November 8, 2011

Vim copy&paste in xterm


When running Vim in an xterm, you can either let Vim control the mouse
or let xterm control the mouse. This is configured by the 'mouse' option.

If the 'mouse' option is not set (or set to the default value), then Vim will
not control the mouse. You cannot move the Vim text cursor using the
mouse. When you select some text using the mouse, xterm will copy
it to the X11 cut buffer. When you press both the mouse buttons,
xterm will paste the text from the cut buffer.

If the 'mouse' option is set to 'a' or some other value, then Vim controls
the mouse. The mode (normal or insert or visual, etc) in which Vim
controls the mouse is configured by the 'mouse' option. You can move
the Vim text cursor using the mouse. When you select some text,
the 'clipboard' option setting is used to determine whether to transfer
the selected text to the clipboard or not. The default setting is to
transfer the selected text to the clipboard. If you want to use the
xterm selection mechanism in this mode, then you can press the
<Shift> key. If you press <Shift> key when selecting text using the
mouse, then Vim doesn't control the mouse and xterm controls the
mouse.

PuTTY and the Bell panel


The Bell panel controls the terminal bell feature: the server's ability to cause PuTTY to beep at you.

In the default configuration, when the server sends the character with ASCII code 7 (Control-G), PuTTY will play the Windows Default Beep sound. This is not always what you want the terminal bell feature to do; the Bell panel allows you to configure alternative actions.

Set the style of bell

This control allows you to select various different actions to occur on a terminal bell:

Selecting "None" disables the bell completely. In this mode, the server can send as many Control-G characters as it likes and nothing at all will happen.

"Play Windows Default Sound" is the default setting. It causes the Windows "Default Beep" sound to be played. To change what this sound is, or to test it if nothing seems to be happening, use the Sound configurer in the Windows Control Panel.

"Play a custom sound file" allows you to specify a particular sound file to be used by PuTTY alone, or even by a particular individual PuTTY session. This allows you to distinguish your PuTTY beeps from any other beeps on the system. If you select this option, you will also need to enter the name of your sound file in the edit control "Custom sound file to play as a bell".

"Visual bell" is a silent alternative to a beeping computer. In this mode, when the server sends a Control-G, the whole PuTTY window will flash white for a fraction of a second.

Taken from: http://the.earth.li/~sgtatham/putty/0.52/htmldoc/Chapter4.html#4.5

Wednesday, October 12, 2011

Madeleine Delbrêl

"We, the ordinary people of the streets"


"Hay gente a la que Dios toma y pone aparte.
Pero hay otros a los que deja en medio de la multitud, 'sin retirarlos del mundo.

Hay gente que realiza un trabajo ordinario, que tiene una familia ordinaria, que vive una vida ordinaria de solteros. Gente que tiene enfermedades ordinarias y lutos ordinarios. Es gente de la vida ordinaria. Gente con la que nos encontramos en cualquier calle.

Esos aman la puerta que da a la calle lo mismo que sus hermanos invisibles al mundo aman la puerta que se ha cerrado definitivamente sobre ellos.

Nosotros, gente de la calle, creemos con todas nuestras fuerzas que esta calle. este mundo en donde Dios nos ha puesto, es para nosotros el lugar de nuestra santidad".

"Los de la calle estamos segurísimos de que podemos amar a Dios todo cuanto él quiera que le amemos... Cada acto de docilidad nos hace recibir plenamente a Dios y dar plenamente a Dios con una gran libertad de espíritu. Y entonces la vida es una fiesta".

Madeleine Delbrêl

Wednesday, October 5, 2011

Previous date in bash

Sometimes I need the previous date in my scripts:

DATE=$(date +%Y%m%d --date=-1day)

For 10/5/2011 DATE = 20111004

$ date --version
date (GNU coreutils) 6.10

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

Friday, July 29, 2011

Sonría, por favor

Ayer mi sobrina de cuatro años le preguntaba a su madre: "Mamá, ¿por qué la gente va por la calle enfadada? Van todos tan serios..."  Tanta sabiduría enmarcada en tan escasos años, aplastante y maravillosa en su lógica infantil que ya la quisiéramos los adultos en muchas ocasiones. Crecemos en edad, y así vamos aprendiendo a sumar preocupaciones, sarcasmo, rencor, estulticia, hipocresía, ... Y así salimos cada mañana al mundo, con la máscara de la seriedad por bandera, alienados de nuestra condición humana.  Lejos quedan los patios de juegos de nuestra infancia, adormecida la inocencia de esos primeros años donde sólo importaba el hoy y las inmensas posibilidades que nos esperaban tras cada hora. 

Solo tenemos que echar un vistazo a los plúmbeos noticiarios de cada día para comprobar lo necesario que es recuperar la sonrisa,  relacionarnos a través de ella, incorporar su magia a nuestra realiad cotidiana para acercar un poco más esa olvidada visión de la niñez. Y además todo son ventajas: es gratis, contagiosa, terapeútica y nos hace mucho más guapos a todos.

"Una sonrisa es más barata que la luz eléctrica, pero ilumina lo mismo". Abbé Pierre

Thursday, July 28, 2011

Greyhounds sufferings

FREE AT LAST

Racing days are over
Thought the pain would go away
But soon I learned a different fate
Was headed straight my way
He reached his hands into my cage
And pushed me out once more
I glanced at all my weary friends
As he led me out the door
It hurts to walk; it hurts to stand
Been through all I could endure
But all my pains are nothing that
Somebody's love could not cure
I'm pushed against a concrete wall
And know I've failed the test
He said I wasn't fast enough
And reached into his vest
I close my eyes and cower
As I shake, my senses dull
Then I feel the barrel of a gun
Against my skull
Isn't there a better way
To entertain a crowd?
But my thoughts are interrupted
By a noise so hard and loud
I'm just another failure
Racing to my final day
And sometimes all the winners
Will lose a race someday
They call it an "exciting sport"
They say that it's humane
But a sport that always ends in death
To me, is not a game

Copyright 2001 Lynn Kargol

BLOOD SPORT (A greyhound’s last words)

"I lie on my side. I am dying.
A female blue-brindle greyhound,
Living to run.
Speed was my gift from the gods.
The gift, a headlong dash to death.
Once I dreamed of running in an open field.
No muzzle, no pain, running freely.
I am in a field now.
Eighteen acres of death.
The bullet was meant for my brain.
To be a quick death. Painless.
The bullet entered my neck.
The pain rages… when will it end?
Will there be another bullet to speed my death?
No. Bullets are not to be wasted on dogs.
We were dollar signs
Hurtling down the track.
Together a flash of colors:
Brindle, blue, black, red, white, fawn.
I was too slow to last.
Too slow to make it to age two.
A throw-away life.
When death comes I will not be alone.
There are scores of us. Thousands.
Brindle, blue, black, red, white, fawn.
We, who never knew an open field,
Have found our own field.
It is soaked with our blood.
Once I dreamed of being held in someone’s arms.
Caressed, petted, loved.
All dreams are ended now in this field.
The darkness is taking me over.
Lime is thrown on my defeated, discarded body.
My heart howls out ...
Let my dying matter,
Let my dying be the last.
The light dims out.
Remember, remember, remember."

Copyright 2002 Juliet Law Packer

Taken from http://www.grey2kusaedu.org/education/poems.html

Wednesday, July 27, 2011

Windows XP schtasks command line utility

Windows XP includes a commandline admin utility named schtasks. Schtasks allows an administrator to create, delete, query, change, run and end scheduled tasks on a local or remote system.

Parameter List:

/Create : Creates a new scheduled task.

/Delete : Deletes the scheduled task(s).

/Query : Displays all scheduled tasks.

/Change : Changes the properties of scheduled task.

/Run : Runs the scheduled task immediately.

/End : Stops the currently running scheduled task.

/? : Displays this help/usage.

God Promises

Proverbs 3:5-6
New International Version (NIV)

5 Trust in the LORD with all your heart
   and lean not on your own understanding;
6 in all your ways submit to him,
   and he will make your paths straight.

Matthew 16:24-26
New International Version (NIV)

24 Then Jesus said to his disciples, “Whoever wants to be my disciple must deny themselves and take up their cross and follow me.
25 For whoever wants to save their life will lose it, but whoever loses their life for me will find it.
26 What good will it be for someone to gain the whole world, yet forfeit their soul? Or what can anyone give in exchange for their soul?

Isaiah 41:13
Romans 10:13

Phil 4:19
Psalm 121:7-8

Psalm 37:37
John 15:7

Psalm 119:9
Gal 6:9

Psalm 118:8
Eph 6:4

John 5:39
Rev 21:4

Luk 12:40
Prov 16:3

Matth 7:12
Pet 1 3:10

Psalm 40:4
Rom 6:23

Matth 6:34
Matth 5:6

Rom 5:1
Psalm 32:8

Matt 11:29
Cor 2 9:7

Prov 3:5
Matt 16:24

Luk 21:15
Deu 31:6

Jac 5:15
Isa 45:22

Tim 1 2:5
Psalm 135:6

Matthew 7:8
Matthew 5:10

Tim 2 4:7-8
Rev 3:5

Heb 12:11
John 1 5:15

Psalm 92:10
Lam 3:22-23

Num 6:26
Isa 1:18

John 3:16
Isa 40:29

Pro 10:9
Pro 28:10

John 14:6
Psalm 7:10

Rom 6:23
Psalm 40:4

John 8:36
Psalm 115:14

Psalm 18:32
1st John 2:28

Matt 7:12
1 Pet 3:10

Luk 21:15
Deut 31:6

Matt 11:28
Prov 11:24

Psalm 18:32
1 John 2:28

Psalm 37:3
Revelations 22:12

1 John 3:1
Psalm 23

Mark 10:45
Prov 10:29

Psalm 103:17
Ephes 6:3

Matthew 5:11
Matthew 7:11

Isa 59:1
John 14:27

Psalm 40:4
Rom 6:23

Isa 58:11
1 John 2:1

John 15:7
Psalm 37:37

Rev 3:20
John 5:24

Prov 4:23
Matthew 18:20

Jer 33:3
Matt 6:33

Psalm 37:25
Rev 22:21

1 John 2:17
Psalm 3:5

James 1:12
Ecles 11:1-8

Luke 12:27
Proverbs 11:21

Proverbs 11:24
Matthew 11:28

Hebrews 12;11
1 John 5:15

Isaiah 59:1
John 14:27

1 John 5:14
Hebrews 11:6

Revelations 3:12
Hebrews 8:12

2 Cor 5:21
Isaiah 51:12

Psalm 18:32
1 John 2:28

Psalm 125:1
2 Tes 3:3

1 John 2:17
Psalm 3:5

Psalm 121:7-8
Phil 4:19

Psalm 7:10
John 14:6

Deuteronomio 4:40
John 12:26

Revelations 3:5
2 Timo 7-8

Proverbs 11:24
Matthew 11:28

1 Tim 2:5
Psalm 135:6

Proverbs 3:5
Matthew 16:24

Hebrews 10:38
1 John 5:13

Ephesians 2:8
Psalm 67:1

Psalm 121 7:8
Philippians 4:19

Isaiah 51:12
2 Cor 5:21

Psalm 37:3
Revelations 22:12

Psalm 40:4
Rom 6:23

Psalm 2:8
2 Peter 3:13

1 Juan 4:12
Exodo 33:14

Matthew 6:34
Matthew 5:6

Mat 7:7
Mat 5:8

1 Tim 2:5
Porque hay un solo Dios, y un solo mediador entre Dios y los hombres, Jesucristo hombre,
Psalm 135:6
Todo lo que Jehová quiere, lo hace, En los cielos y en la tierra, en los mares y en todos los abismos.

John 14:23
Eph 5:14

Rev 3:20
John 5:24

1 John 2:28
Psalm 18:32

Mat 11:29
2 Cor 9:7

Gen 8:22
Heb 4:12

Isaiah 45:22
James 5:15

1 John 2:17
Psalm 3:5

Delete route in Fedora

route del -net 172.16.9.0 netmask 255.255.255.0 eth3

Tuesday, July 26, 2011

Using Windows Script for sending keys to an application

Open the calculator and show the About message for 3 seconds:


Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run("calc")
WScript.Sleep(100)
WshShell.AppActivate("Calculator")
WScript.Sleep(100)
WshShell.SendKeys("%H")
WScript.Sleep(500)
WshShell.SendKeys("{DOWN}")
WScript.Sleep(100)
WshShell.SendKeys("~")
WScript.Sleep(3000)
WshShell.SendKeys("{ESC}")

Close the Calculator:


Set WshShell = WScript.CreateObject("WScript.Shell")
Result = WshShell.AppActivate("Calculator")
WScript.Sleep(100)
If Result = True Then
WshShell.SendKeys "%{F4}"
End If

References:
http://technet.microsoft.com/en-us/library/ee156592.aspx
http://msdn.microsoft.com/en-us/library/8c6yea83(v=vs.85).aspx

Monday, July 25, 2011

Reading pcap files with Python

#!/usr/bin/python

import sys
import pcapy
from impacket import ImpactDecoder, ImpactPacket
import re

def main(argv):

        try:
                cap = pcapy.open_offline(argv[1])

                (header, payload) = cap.next()

                while header:
                        (seconds, micros) = header.getts()

                        # Parse the Ethernet packet
                        decoder = ImpactDecoder.EthDecoder()
                        ether = decoder.decode(payload)

                        # Parse the IP packet inside the Ethernet packet
                        iphdr = ether.child()

                        # Parse the TCP packet inside the IP packet
                        tcphdr = iphdr.child()

                        # Get the source and destination IP addresses
                        src_ip = iphdr.get_ip_src()
                        dst_ip = iphdr.get_ip_dst()

                        if tcphdr.child() <> None:
                                body = tcphdr.child().get_packet()

                                isFIX = re.match('8=FIX', body)
                                if isFIX <> None:
                                        print "%d.%06d %s" % (seconds, micros, body)

                        (header, payload) = cap.next()

        except pcapy.PcapError:
                pass

if __name__ == "__main__":
        main(sys.argv)

Wednesday, July 20, 2011

Date formatting in Perl

use Date::Format;
my $Time = time2str("%D", time());

Give something like 07/20/11

Package libtimedate-perl (in hardy, Ubuntu 8.04.3 LTS)

dpkg -S Date::Format

Sending a text file in the body of an email using Perl

In Perl there is a package called Mail::Sendmail that could be used to send a simple text message.

The package for the module is libtimedate-perl (in hardy, Ubuntu 8.04.3 LTS)

dpkg -S Mail::Sendmail

#!/usr/bin/perl

use strict;
use warnings;

use Mail::Sendmail;

# Read the file into a string to put it into the mail hash variable
open FH, 'file.txt' or
        die "Error reading file.txt file: $!\n";
my @Lines = ;
chomp @Lines;
close FH;
my $Lines = join "\n", @Lines;

my $Recipients = 'somebody@mail.example';

my $Subject = 'Testing mail in Perl';

my %mail = (
        To => $Recipients,
        From => 'testing@mail.example',
        Subject => $Subject,
        Message => $Lines
);

$mail{Smtp} = 'mail.example';

if (sendmail %mail) {
        print "Mail sent OK.\n"
} else {
        print "Error sending mail: $Mail::Sendmail::error \n"
}

print "\n\$Mail::Sendmail::log says:\n", $Mail::Sendmail::log;

__END__

Wednesday, July 13, 2011

Yum groups and repositories

Yum supports the group commands
  • grouplist
  • groupinfo
  • groupinstall
  • groupremove
  • groupupdate
Groups are read from the "group" xml metadata that is optionally available from each repository. If yum has no repositories which support groups then none of the group operations will work.
  • grouplist
    yum grouplist [hidden]
    
This will list the installed and available groups for your system in two separate lists. If you pass the optional 'hidden' argument then all of the groups which are set to 'no' in the group xml tag.
  • groupinfo
    yum groupinfo groupname
    
This will give you detailed information for each group including: description, mandatory, default and optional packages.
  • groupinstall, groupupdate
    yum groupinstall groupname
         yum groupupdate groupname
    
Despite their differing names both of these commands perform the same function. They will attempt to install/update all of the packages in the group that are of the types 'default' or 'mandatory' (by default). (To change this types of packages edit the value of the group_package_types option in yum.conf.) And they will install any additional dependencies needed by any of the installing/updating packages.
  • groupremove
    yum groupremove groupname
    
This will remove all packages, of any type, in the named group. It will also remove any package that depends on any of these packages.

Thursday, June 30, 2011

Using grep to extract specific FIX protocol tags values from a file

grep -o -w '\(48\|55\)=[^[:cntrl:]]\+' FILE | perl -pe 's/(\d+=[^\n]+)\n/\1~/' | perl -pe 's/([^~]+~[^~]+)~/\1\n/g'

grep -o -w '\(48\|55\)=[^[:cntrl:]]\+' FILE | tr '\n' '~' | perl -pe 's/([^~]+~[^~]+)~/\1\n/g'

grep -o -w '\(48\|55\)=[^[:cntrl:]]\+' FILE | sed 'N;s/\n/ /'

-o Print only the matched parts of a matching line
-w Select lines containing matches that form whole words (a whole char is a letter, digit and underscore)

Tuesday, June 28, 2011

Static routes after restart/reboot in Fedora/RedHat/CentOS

Static routing is the term used to refer to the manual method used to set up routing. An administrator enters routes into the router using configuration commands. This method has the advantage of being predictable, and simple to set up. It is easy to manage in small networks but does not scale well.

Question: How can I save static routes I set up in my Fedora/RedHat/CentOS Linux after I reboot server?

Answer: In Fedora Linux (or RedHat, CentOS) you can set up static routes for certain network interface (for example eth1) by editing file /etc/sysconfig/network-scripts/route-eth1.

For example, you have to save static route added by the following command:

route add -net 192.168.0.0 netmask 255.255.255.0 gw 192.168.100.1 dev eth1

To do it, just add the following line to /etc/sysconfig/network-scripts/route-eth1:

ADDRESS0=192.168.0.0
NETMASK0=255.255.255.0
GATEWAY0=192.168.100.1

The alternate way of doing it is to put the routes in /etc/sysconfig/static-routes. So the above route would like this like in the static-routes file:

any net 192.168.0.0 netmask 255.255.255.0 gw 192.168.100.1

Where any is specified above you can also set specific interfaces (such as eth1).

Here is the part /etc/init.d/interfaces code:

# Add non interface-specific static-routes.
if [ -f /etc/sysconfig/static-routes ]; then
grep "^any" /etc/sysconfig/static-routes | while read ignore args ; do
/sbin/route add -$args
done
fi

Looks like any must be at the beginning of each line in /etc/sysconfig/static-routes.

/usr/share/doc/initscripts-${VERSION}/sysconfig.txt is a good place to look for these things as well

Friday, June 24, 2011

basename and dirname in UNIXes

I was reading The Unix For Loop today and I found that the following code will fail in the case of a filename like anoldfilename.old:

for i in *.old 
do 
j=`echo $i|sed 's/old/bak/'` 
mv $i $j 
done

I think the following will solve that problem:

j=`basename $i .old`
p=`dirname $i`

mv $i $p/$j.bak


The right tool for the right job!

AWK and Java CLASSPATH

From http://unix-simple.blogspot.com/2008/12/dynamically-building-java-classpaths.html

for line in $java_dir/*.jar
do
  CLASSPATH="$CLASSPATH:$line"
done

Lets put AWK to iterate:

CLASSPATH=$CLASSPATH:$(ls *.jar | awk 'BEGIN { ORS = ":" } { print }')

Maybe a shellish way of do it:

CLASSPATH=$CLASSPATH:`echo *.jar | sed 's/ /:/g'`

Tuesday, June 21, 2011

Prosperity Gospel: Christ Centered or Self Centered?

 The Word of Faith 'Prosperity Gospel' Promotes Material Over Spiritual Needs

Taken from: http://christianity.about.com/od/Word-Of-Faith/a/Prosperity-Gospel.htm?nl=1

Prosperity Gospel: Is Greed a Motive?

"Woe to you, teachers of the law and Pharisees, you hypocrites! You clean the outside of the cup and dish, but inside they are full of greed and self-indulgence." (Matthew 23:25, NIV)

"Watch out! Be on your guard against all kinds of greed; life does not consist in an abundance of possessions." (Luke 12:15, NIV)

"What good is it for someone to gain the whole world, and yet lose or forfeit their very self?" (Luke 9:25, NIV)


Prosperity Gospel: Was Jesus Rich or Poor?

"After this, Jesus traveled about from one town and village to another, proclaiming the good news of the kingdom of God. The Twelve were with him, and also some women who had been cured of evil spirits and diseases: Mary (called Magdalene) from whom seven demons had come out; Joanna the wife of Chuza, the manager of Herod's household; Susanna; and many others. These women were helping to support them out of their own means." Luke 8:1-3 (NIV)

Prosperity Gospel: Do Riches Make Us Right with God?

"Do not store up for yourselves treasures on earth, where moths and vermin destroy, and where thieves break in and steal. But store up for yourselves treasures in heaven, where moths and vermin do not destroy, and where thieves do not break in and steal. For where your treasure is, there your heart will be also...No one can serve two masters. Either you will hate the one and love the other, or you will be devoted to the one and despise the other. You cannot serve both God and money." (Matthew 6:19-21, 23, NIV)

Wealth may build people up in the eyes of men, but it does not impress God. In talking with a rich man, Jesus looked at him and said, 'How hard it is for the rich to enter the kingdom of God!' (Luke 18:24, NIV)

"But godliness with contentment is great gain. For we brought nothing into the world, and we can take nothing out of it. But if we have food and clothing, we will be content with that. Those who want to get rich fall into temptation and a trap and into many foolish and harmful desires that plunge people into ruin and destruction." (1 Timothy 6:6-9, NIV)


Thursday, June 16, 2011

Mounting LVM Disk using Ubuntu livecd

Mounting is an easy process to do, provided the filesystem type you are using is supported. What happen when you have an LVM formatted disk, and you need to mount it because the disk cannot be booted and a hell lot of valuable data kept inside?? Do not worry, because the solution is here.......

1. Get a live cd, for example, Ubuntu. For this article, I use Ubuntu 6.06 (I cannot find any latest version of ubuntu at my place)

2. Boot using the live cd. Search for these tools: lvm2. If the cd do not have it, install it.
# apt-get install lvm2

3. To make sure the harddisk is recognised, you can use fdisk
# fdisk -lu

4. Once installed, run pvscan to scan all disks for physical volume. this to make sure your LVM harddisk is detected by Ubuntu
# pvscan
PV /dev/sda2 VG VolGroup00 lvm2 [74.41 GB / 32.00 MB free]
Total: 1 [74.41 GB] / in use: 1 [74.41 GB] / in no VG: 0 [0 ]

5. After that run vgscan to scan disks for volume groups.
# vgscan
Reading all physical volumes. This may take a while...
Found volume group "VolGroup00" using metadata type lvm2


6. Activate all volume groups available.
# vgchange -a y
2 logical volume(s) in volume group "VolGroup00" now active

7. Run lvscan to scan all disks for logical volume. You can see partitions inside the hard disk now active.
# lvscan
ACTIVE '/dev/VolGroup00/LogVol00' [72.44 GB] inherit
ACTIVE '/dev/VolGroup00/LogVol01' [1.94 GB] inherit

8. Mount the partition to any directory you want, usually to /mnt
# mount /dev/VolGroup00/LogVol00 /mnt

9. You can access the partition in the /mnt directory and can backup your data


(Taken from http://linuxwave.blogspot.com/2007/11/mounting-lvm-disk-using-ubuntu-livecd.html)

Brief Notes on Enabling Samba in OpenSolaris

I've been experimenting with OpenSolaris again. I figured out how to enable my broken samba package: I discovered that, after installing the package with

pfexec pkg install SUNWsmbs SUNWsmba

I had to execute:

svccfg import /var/svc/manifest/network/samba.xml

I then copied /etc/sfw/smb.conf-example and modified appropriate values, and created a configuration file that was saved to:

/etc/sfw/smb.conf

Finally, I could enable the SAMBA server:

svcadm enable samba
(taken from: http://baitisj.blogspot.com/2008/07/quick-notes-on-enabling-samba-in.html)

Wednesday, June 1, 2011

Ubuntu nasty bug

pam update causes cron to stop working with "Module is unknown" error

https://bugs.launchpad.net/ubuntu/+source/pam/+bug/790538

Thursday, May 19, 2011

C# Intrinsic data types

The intrinsic types

C# type Size (in bytes) .NET type Description
byte 1 Byte Unsigned (values 0-255).
char 2 Char Unicode characters.
bool 1 Boolean True or false.
sbyte 1 SByte Signed (values -128 to 127).
short 2 Int16 Signed (short) (values -32,768 to 32,767).
ushort 2 UInt16 Unsigned (short) (values 0 to 65,535).
int 4 Int32 Signed integer values between -2,147,483,648 and 2,147,483,647.
uint 4 UInt32 Unsigned integer values between 0 and 4,294,967,295.
float 4 Single Floating point number. Holds the values from approximately +/-1.5 * 10-45 to approximately +/-3.4 * 1038 with 7 significant figures.
double 8 Double Double-precision floating point; holds the values from approximately +/-5.0 * 10-324 to approximately +/-1.8 * 10308 with 15–16 significant figures.
decimal 12 Decimal Fixed-precision up to 28 digits and the position of the decimal point. This is typically used in financial calculations. Requires the suffix "m" or "M."
long 8 Int64 Signed integers ranging from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
ulong 8 UInt64 Unsigned integers ranging from 0 to approximately 1.85 * 1019.

Tuesday, April 26, 2011

Adriana Zarri, epitafio

«No me vistan de negro: es triste y fúnebre. Ni de blanco, porque es
soberbio y retórico. Vístanme de flores amarillas y rojas, y con alas
de pajarillos. Y Tú, Señor, mira mis manos. Tal vez me han puesto un
rosario, o una cruz. Pero se equivocaron. En las manos tengo hojas
verdes y sobre la cruz, tu resurrección. No coloquen sobre mi tumba un
mármol frío, con las mentiras acostumbradas para consolar a los vivos.
Dejen que la tierra escriba, en primavera, un epitafio de yerbas. Allí
se dirá que viví y que espero. Entonces, Señor, tú escribirás tu
nombre y el mío, unidos como dos pétalos de amapolas».



Non mi vestite di nero:
è triste e funebre.
Non mi vestite di bianco:
è superbo e retorico.
Vestitemi a fiori gialli e rossi
e con ali di uccelli.
E tu, Signore, guarda le mie mani.
Forse c’è una corona.
Forse
ci hanno messo una croce.
Hanno sbagliato.
In mano ho foglie verdi
e sulla croce,
la tua resurrezione.
E, sulla tomba,
non mi mettete marmo freddo
con sopra le solite bugie
che consolano i vivi.
Lasciate solo la terra
che scriva, a primavera,
un’epigrafe d’erba.
E dirà
che ho vissuto,
che attendo.
E scriverà il mio nome e il tuo,
uniti come due bocche di papaveri.

Adriana Zarri
(1919-2010)

Monday, April 18, 2011

50 years old

Bonhoeffer: “Who Am I?”

Who am I? They often tell me
I stepped from my cell’s confinement
Calmly, cheerfully, firmly,
Like a squire from his country-house.
Who am I? They often tell me
I used to speak to my warders
Freely and friendly and clearly,
As though it were mine to command.
Who am I? They also tell me
I bore the days of misfortune
Equally, smilingly, proudly,
Like one accustomed to win.

Am I then really all that which other men tell of?
Or am I only what I myself know of myself?
Restless and longing and sick, like a bird in a cage,
Struggling for breath, as though hands were
compressing my throat,
Yearning for colors, for flowers, for the voices of birds,
Thirsting for words of kindness, for neighborliness,
Tossing in expectation of great events,
Powerlessly trembling for friends at an infinite distance,
Weary and empty at praying, at thinking, at making,
Faint, and ready to say farewell to it all?

Who am I? This or the other?
Am I one person today and tomorrow another?
Am I both at once? A hypocrite before others,
And before myself a contemptibly woebegone weakling?
Or is something within me still like a beaten army,
Fleeing in disorder from victory already achieved?
Who am I? They mock me, these lonely questions of mine.
Whoever I am, Thou knowest, O God, I am Thine!

D. Bonhoeffer
March 4,1946

Sunday, March 13, 2011

1st Sunday in Lent

I appeal to you therefore, brothers and sisters, by the mercies of
God, to present your bodies as a living sacrifice, holy and acceptable
to God, which is your spiritual worship. Do not be conformed to this
world, but be transformed by the renewing of your minds, so that you
may discern what is the will of God--what is good and acceptable and
perfect.
[…]
Let love be genuine; hate what is evil, hold fast to what is good;
love one another with mutual affection; outdo one another in showing
honor. Do not lag in zeal, be ardent in spirit, serve the Lord.
Rejoice in hope, be patient in suffering, persevere in prayer.
Contribute to the needs of the saints; extend hospitality to
strangers.
-Romans 12:1-13 (NRSV)

Encourage one another and build up each other.
-1 Thessalonians 5:11 (NRSV)

Prayer
Thank you, God, for your amazing love and for sending people to
encourage us when we need it. Help us to be channels of support and
encouragement for those around us. Amen.

16 El que se bendijere en la tierra, en el Dios de verdad se
bendecirá; y el que jurare en la tierra, por el Dios de verdad jurará;
porque las angustias primeras serán olvidadas, y serán cubiertas de
mis ojos.
17 Porque he aquí que yo crearé nuevos cielos y nueva tierra; y de lo
primero no habrá memoria, ni más vendrá al pensamiento.
19 Y me alegraré con Jerusalén, y me gozaré con mi pueblo; y nunca más
se oirán en ella voz de lloro, ni voz de clamor.
19 Y me alegraré con Jerusalén, y me gozaré con mi pueblo; y nunca más
se oirán en ella voz de lloro, ni voz de clamor.

Isaiah 65

Wednesday, January 12, 2011

2 Thessalonians 3:13



And as for you, brothers and sisters, never tire of doing what is good.


New International Version, ©2010


http://www.biblegateway.com/passage/?search=2+Thessalonians+3:13&version=NIV

Tuesday, January 11, 2011

2011 Federal Holidays


Federal law (5 U.S.C. 6103) establishes the following public holidays for Federal employees. Please note that most Federal employees work on a Monday through Friday schedule. For these employees, when a holiday falls on a nonworkday -- Saturday or Sunday -- the holiday usually is observed on Monday (if the holiday falls on Sunday) or Friday (if the holiday falls on Saturday).

Friday, December 31, 2010*New Year’s Day
Monday, January 17Birthday of Martin Luther King, Jr.
Monday, February 21**Washington’s Birthday
Monday, May 30Memorial Day
Monday, July 4Independence Day
Monday, September 5Labor Day
Monday, October 10Columbus Day
Friday, November 11Veterans Day
Thursday, November 24Thanksgiving Day
Monday, December 26***Christmas Day
* January 1, 2011 (the legal public holiday for New Year’s Day), falls on a Saturday. For most Federal employees, Friday, December 31, 2010, will be treated as a holiday for pay and leave purposes. (See 5 U.S.C. 6103(b).)
** This holiday is designated as "Washington’s Birthday" in section 6103(a) of title 5 of the United States Code, which is the law that specifies holidays for Federal employees. Though other institutions such as state and local governments and private businesses may use other names, it is our policy to always refer to holidays by the names designated in the law.
*** December 25, 2011 (the legal public holiday for Christmas Day), falls on a Sunday. For most Federal employees, Monday, December 26, will be treated as a holiday for pay and leave purposes. (See section 3(a) of Executive order 11582, February 11, 1971.)