Archive

Archive for the ‘unix/linux’ Category

TODO LIST 2009

December 1st, 2008

TODO LIST 2009

Read/Learn/Practice:

Python 2.6 (What’s New)

Perl 5 (Modules, Packages)

PHP (Changes, and news)

COBOL

.NET (C#, LINQ, (ok VB but not much))

Java (Im interested on Mobil Applications)

Haskell

Ruby (Im interested on Rails)

Parrot and Pugs

Gnu/Linux (Services and Bash)

BSD and OpenSolaris

Personal Projects 2009:

BSE (Blog’s Search Engine) (http://BSE.AyalaSoft.com)

Invoices PHP (Now is part of a Intranet) (http://valuacion.com.mx)

Forming one’s own business

And others ….

Lambda Functions on PHP 5.3.0:

 $lambda = function () { echo "Hello World!\n"; };

Parrot “Hello World” example:

.sub main
      print "Hello World!\n";
.end

COBOL “Hello World” example:

* Hello World Program
* GPL Copyleft Jonathan Riddell 2001
	IDENTIFICATION DIVISION.
	PROGRAM-ID.    hello.
	ENVIRONMENT DIVISION.
	DATA DIVISION.
 
	PROCEDURE DIVISION.
		DISPLAY "Hello ," WITH NO ADVANCING
		DISPLAY "World!"
		STOP RUN.

Haskell “Hello World” example:

putStrLn "Hello World!"

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

C Compile on Demand

November 24th, 2008

C Compile on Demand

If you want to use C/C++ as CGI you need compile the code you can compile on demand check C Cod WebSite

See the Documentation some aspects similars to ASP(VBScript).

you now:

#!/usr/bin/php
#!/usr/bin/perl
#!/usr/bin/python
#!/bin/bash
...

Add this #!/usr/bin/ccod to use C/C++, one simple example:

#!/usr/bin/ccod

Download C Cod.

develop, network, projects, unix/linux, web, windows ,

LAMP on Ubuntu 8.10 Desktop Edition

November 10th, 2008

LAMP on Ubuntu 8.10 Desktop Edition

# LAMP on Ubuntu 8.10 desktop edition
sudo apt-get install mysql-server
# Set root password (MySQL)
sudo apt-get install apache2
# Install PHP as module
sudo apt-get install libapache2-mod-php5
# Support MySQL on PHP
sudo apt-get install php5-mysql
# Restart Apache server
sudo /etc/init.d/apache2 restart
# Test php5 on Apache2
sudo echo "<? phpinfo ?>" > ._info.php
sudo mv ._info.php /var/www/info.php
firefox http://localhost/info.php

GEOIP

Something I found interesting is that there is already a php5-geoip module that uses a database of MaxMInd, see GeoIP Database on MySQL.

develop, unix/linux, web ,

QEMU Emulator

November 1st, 2008

QEMU Emulator

QEMU is a great emulator, like VMware or VirtualBox you can use to manage many guest operating system on your computer of course you need a lot of RAM

Install on Debian:

apt-get install qemu
wget http://bellard.org/qemu/kqemu-1.3.0pre11.tar.gz
tar xvzf kqemu-1.3.0pre11.tar.gz
cd kqemu-1.3.0pre11
./configure
make
make install

To load kqemu on Windows:

net start kqemu

To load kqemu on GNU/Linux:

modprobe kqemu

Port redirection use the flag option “-redir” some examples:

-redir tcp:8000::80  # redirect host port 8000 to port 80 on the guest.
-redir tcp:22::22 # ssh server on the guest

Note: I have a little trouble to install kqemu.inf on Windows Vista Bussiness i need to download the setup file on “Accelerators” section on QEMU for Win32

Damn Small Linux is a light distro use old kernel but run very wheel on old computer systems, you can run on CD-Rom, USB or Embedded System (using QEMU emulator)

Some times you need test some software but you want to install on your personal computer system, emulate and test the software is the best solution

network, unix/linux, windows , ,

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 , ,

rubygems-update issue on Ubuntu

September 30th, 2008

rubygems-update issue on Ubuntu

If you have this problem on your computer:

sudo gem update --system
Updating RubyGems
Bulk updating Gem source index for: http://gems.rubyforge.org/
Updating rubygems-update
ERROR:  While executing gem ... (Gem::GemNotFoundException)
    could not find rubygems-update locally or in a repository

The problem is RubyGems you need to install manually or use this script solution:

#!/bin/bash
#(download the latest on http://rubyforge.org/frs/?group_id=126)
wget http://rubyforge.org/frs/download.php/43984/rubygems-update-1.3.0.gem
sudo gem install rubygems-update-1.3.0.gem
sudo update_rubygems
# now this work:
sudo gem update --system
echo "done."

I found this solution on this web:

http://rubyglasses.blogspot.com/2008/08/updating-gem-to-120-on-ubuntu.html

develop, unix/linux , ,