Archive

Archive for November, 2008

El Caudillo del Sur

October 31st, 2008

El Caudillo del Sur

El dia de hoy tuve la oportunidad tomarme una fotografia con el hijo de Emiliano Zapata, como la mayoria de las personas saben, Emiliano Zapata jugo un papel muy importante en la Revolución Mexicana.

Fotografia con Don Diego Zapata:

Diego Zapata Fotografias de EsMas

Don Diego Zapata es todo un personaje es una persona humilde que apesar de sus años se encuentra muy bien conservado ademas de que tiene un excelente sentido del humor.

Le preguntaron que cual era el “secreto” para llegar a viejo y estar bien conservado el respondio, nada de beber, nada de fumar, luego alguien le pregunto y las mujeres, Don Diego no respondio solo se empezo a reir.

personal

Electronic Game Show 2008

October 27th, 2008

Electronic Game Show 2008

El pasado domingo fui al Electronic Game Show 2008 aqui algunas fotos:



games, personal

Using Windows ? Don’t kill Yourself

October 27th, 2008

Using Windows ? Don’t Kill Yourself

Supose you are Linux user and you have a Windows system.

Alternatives: Cygwin, Mingw or Colinux

You need some (or all) of this interpreters:

Perl, PHP, Python and Ruby

Modify the %PATH%

Example you have a bin dir, on C:\ to include the executables on the %PATH% do this:

set PATH=%PATH%;C:\bin\

On Windows Vista, you can use your mouse:

computer > properties > Advances system settings > (continue) > Advanced > Enviroment Variables > System Variables > Path (edit)

Example run Kompozer on cmd.exe but no modify %PATH%

: kompozer.bat save on %WINDIR%
@"C:\Program Files\Kompozer\kompozer.exe"

Doble click on your scripts to run:

: Perl Scripts
 assoc .pl=Perl.File
 ftype Perl.File=C:\strawberry\perl\bin\perl.exe "%1" %*
 set PATHEXT=%PATHEXT%;.pl
: Python Scripts
 assoc .py=Python.File
 ftype Python.File=C:\Python26\python.exe "%1" %*
 set PATHEXT=%PATHEXT%;.py

Note:

On Windows Vista you need run cmd.exe as Administrator don’t work as normal user

Apache, PHP and MySQL ?

XAMPP and Server2Go

Notes:

XAMPP: simple, quick and easy install.

Server2Go: is great to make CD demo of a Web Application.

Using Perl or Python as CGI on Windows ?

Using Python 2.6

#!\python26\python.exe

Using Strawberry Perl:

#!\strawberry\perl\bin\perl.exe

Now your script works on http://localhost/cgi-bin/script.cgi

develop, unix/linux, windows , , , , ,

Resize Multiple Images

October 20th, 2008

Resize Multiple Images

In my case i need to change the size of more than 1,000 pictures so using gimp and scale everyone is not a good solution.

You need ImageMagick and Bash.

Subfolders:

script.sh:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/bash
# fotos
IFS=$'\t\n'; # Algunas fotos puede que tengan espacios
for i in `ls`; do
    for j in `ls $i `; do # fotos/098-001/ fotos/098-002/ fotos/097-001/ etc...
    if [ "$j" = "Thumbs.db"  ]; then  # garbage file on win32
        echo "Nothing to do..."
    elif [ "$j" = "script.sh" ]; then # this script file :D
        echo "Nothing to do..."
    else
        echo "Working ..." # do the job
        #convert "$i/$j" -resize 500 "$i/new_$j"
        #mv "$i/new_$j" "$i/$j"
        mogrify -resize 500 "$i/$j"
    fi
    done
done

Now all images are width: 500.

Now supose you have a lot of sub directories, you can use this script:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/bin/bash
IFS=$'\t\n'
EXTS=( jpg gif png JPG GIF PNG )
for EXT in ${EXTS[@]};
do
	for f in `find . -name "*.$EXT" -type f`;
	do
		dir=`dirname $f`
		ff=`basename $f`
		echo "Working ..."
		#convert "$f" -resize 500 "$dir/new_$ff"
		#mv "$dir/new_$ff" "$f"
                mogrify  -resize 500 "$f"
	done
done

[thanks for the advice CyX]

develop, unix/linux , ,

Recordando el SITE

October 15th, 2008

Recordando el SITE

El SITE es sin lugar a dudas uno de los mejores lugares para aprender sobre Gnu/Linux, lenguajes de programación y el por que de la vida.

Si tienen oportunidad de entrar en el SITE de su facultad entren aunque sea como becarios pueden aprender mucho.

Cosas curiosas del SITE que me toco vivir o me entere:

  • Hubo un tiempo que usamos un LiveCD con apache para funcionara la pagina oficial de la facultad.
  • Una vez borre todo el contenido de /bin por instalar Firefox (hay que leer antes de hacer “Next”)
  • Los actuales administradores crearon un dios pagano una tarjeta de vídeo destrozada (en la actualidad tiene 2 velas y algunas ofrendas).
  • Una tarde estando aburrido le di botonazo a un servidor (DNS) el cual no respondió bien al reiniciar, Yosio tuvo que quedarse (el tenia que presentar un examen).
  • En tiempos de ocio lanzamos CDs uno contra otro (era nuestro deporte de alto rendimiento aveces algo agresivo).
  • Mandar basura a los amigos con un “cat bin > /dev/tty” o matar procesos de ellos.
  • Los famosos upgrades en Diciembre (casi en Navidad) ver toda la planta de informática vacía y callada.
  • Una vez Julio y yo aplicamos 5s en el SITE (tomamos fotos en unas se ve un caos y en otra un orden).
  • A lo largo del tiempo solo han estado 3 mujeres en el SITE.
  • Siempre que arreglan el clima una semana después deja de funcionar (eso es un hecho).
  • El “Efecto Site” se puede identificar con dejar de ir a clases o perder la noción del tiempo.
  • Se dice que en un principio el SITE tenia Windows (leyenda urbana).

personal

PDF Libraries

October 2nd, 2008

PDF Libraries

Sometimes we need create or export data into a PDF:

.NET:

http://www.pdfsharp.com, http://www.codeplex.com/Print2Pdf

C++:

http://libharu.org

Perl:

http://search.cpan.org/~markusb/PDF-Create/lib/PDF/Create.pm

sudo perl -MCPAN -e 'install PDF::Create'

PHP:

http://www.fpdf.org, http://www.digitaljunkies.ca/dompdf, http://pear.php.net/package/File_PDF

Python:

http://www.reportlab.org

wget -c http://www.reportlab.org/ftp/ReportLab_2_2.tgz
tar xvzf ReportLab_2_2.tgz
cd ReportLab_2_2
sudo python setup.py install

Java:

http://www.lowagie.com/iText, http://www.pdfbox.org

Ruby:

http://ruby-pdf.rubyforge.org/pdf-writer

sudo gem install pdf-writer

develop , , , , , ,

GeoIP PHP Script

October 1st, 2008

GeoIP PHP Script

I made this script utility to check what country is some ip, you need GeoIP Database

I hope you have PHP in your path:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/php -q
<?
 
if (count($_SERVER['argv']) <= 1) {
	echo "use: geoip xxx.xxx.xxx.xxx\n";
}
else {
	$ip=$_SERVER['argv'][1];
	$out=sprintf("%u", ip2long($ip)); // don't ask why, you need this line	
 
	$sql="SELECT country_name FROM geoip WHERE ($out BETWEEN ip_begin AND ip_end)";	
 
	$link = mysql_connect('localhost','root',''); // HOST, USER, PASS
	mysql_select_db('GEOIP'); // DATABASE
 
	$query = mysql_query($sql,$link);	
 
	while ($row = @mysql_fetch_array($query,MYSQL_ASSOC)) {
		$data[] = $row;
	}	
 
	if (count($data) == 1) {
		echo $data[0]['country_name']."\n";
	}
	else {
		echo "Unknown\n";
	}
}
?>

Examples:

~$ geoip 79.130.90.12
Greece
~$ geoip 207.33.11.33
United States
~$ geoip 148.234.13.23
Mexico

I think i made a good tool.

database, network , ,