Category Archives: Programming

Convert m4a files to mp3 with this script.

Some of my library was in m4a files, which I have problems to play, furthermore I prefer having everything in mp3 format. So I wrote the following script: echo “Dependencies: mplayer and lame” if [ $# -lt 1 ]; then … Continue reading

Posted in Bash, Linux, Programming | Tagged , , , , , , , , , , | Leave a comment

Quick tip: Adding and substracting dates in PHP

More simple than it may seems. It will take care of adjusting months and days automatically: Working with days: // My date Y-m-d $mydate = “2012-05-06″; //Adding five days $newdate = date(“Y-m-d”, strtotime($mydate. ” +5 days”)); // Substracting five days … Continue reading

Posted in Php, Programming | Tagged , , , , , , , , | Leave a comment

Python script to backup and restore rpm packages

I’ve written a simple Python script to backup and restore installed rpm packages. On Ubuntu, I used APTonCD for this matter, but in this case, for Fedora I decided to use my own script. The usage is quite simple, only … Continue reading

Posted in backup, Linux, Programming, Python | Tagged , , , , , , , , , , | Leave a comment

Short and useful tip: How to make “tail -f” beep on each new line.

Just in case you do not know, tail prints the last ten lines of the indicated file. Like this: tail /var/log/yum.log Furthermore, if you want to print more lines you can do it with -n parameter: tail -n 20 /var/log/yum.log But … Continue reading

Posted in Bash, Linux | Tagged , , , , , , , , , , , , , , , , | Leave a comment

Functions: How to return more than one value.

We cannot return two variables from a function, but we could use an array for that. So for example, in JavaScript, it would be like this: function foo() { // do something here // whatever return [myvalue, myothervalue, otherthing]; } … Continue reading

Posted in Programming | Tagged , , , , , , , , , , , | Leave a comment

Nuevo script para realizar backups

Ayer estuve escribiendo un nuevo script para realizar los backups en mi sistema, ya que mis necesidades han cambiado. El script está adaptado a mi sistema y como digo, mis necesidades, pero quizás os pueda servir a vosotros. #!/bin/bash # … Continue reading

Posted in backup, Bash, Linux, Programming | Tagged , , , , , | Leave a comment

Comenzando con Git. Primeros pasos

Lo primero será registrarnos en http://www.github.com y una vez tengamos la cuenta, procedemos a instalarlo si no lo tenemos instalado. $ sudo apt-get install git Ahora tenemos que generar nuestra clave SSH (antes tenemos que tener instalado ssh) $ ssh-keygen -t … Continue reading

Posted in Internet, Programming | Tagged , , , , , , , , , , , | Leave a comment

Condiciones en PHP.

Una condición es básicamente una decisión, resultado de una condición específica. Por ejemplo: <?php $edad = 16; print “Tu edad es $edad\n”; if ($edad < 18 ) { print “Eres joven, disfruta.\n”; } else { print “No eres menor de … Continue reading

Posted in Php, Programming | Tagged , , , , , , , , , , , | Leave a comment

PHP Deprecated: Comments starting with ‘#’ are deprecated

Si estáis tratando de ejecutar algún script php desde la terminal de linux o crontab, y os sale algún error como este: PHP Deprecated: Comments starting with ‘#’ are deprecated in /etc/php5/cli/conf.d/ming.ini on line 1 in Unknown on line 0 … Continue reading

Posted in Php | Tagged , , , , , , , , , , , , , , , , , , , , | Leave a comment

Operadores en PHP.

Operadores aritméticos // Suma $a + $b; // Resta $a – $b; // Multiplicación $a * $b; // División $a / $b; // Módulo $a % $b; // Sumar y asignar // Para sumar $b al valor actual de $a, … Continue reading

Posted in Php, Programming | Tagged , , , , , , , , , , , , , , , , , , , | 1 Comment