Report inadequate content

Tricks in Harecoded

Mails perdidos en Gmail por redireccionamiento [Solucionado]

El problema

Seguro que no soy el único que tiene más de una dirección de correo electrónico. En muchas ocasiones, por orden o por practicidad, configuramos nuestras múltiples direcciones de correo electrónico para que podamos recibirlo en un mismo buzón.

Cuando alguna de esas direcciones está configurada en Gmail, en ocasiones, podemos experimenter pérdida de mensajes.

El motivo

Gmail pasa todo el correo entrante por un motor de detección de correo sospechoso de ser no deseado. Esta carpeta siempre la tenemos accesible para, (recomendable), poderle echar un ojo de vez en cuando y corregir el filtrado de Google. De esta forma vamos haciendo el filtro más efectivo.

El problema viene cuando, por tener el correo redirigido desde una cuenta a otra, el filtro de la primera es el que descrimina el mensaje. En ese caso ni nos enteramos del mensaje y solamente podemos actuar en consecuencia entrando a la primera cuenta. Cosa que... no solemos hacer.

La solución

Debemos entrar al buzón de la cuenta de correo donde se envían los mensajes, es decir, la que está configurada para reenviarlos a nuestro buzón final. 

Accedemos al menú de configuración de opciones y filtros.

Una vez ahí creamos un filtro y, en el campo "Tiene las palabras", escribiremos "is:spam" (sin comillas).

 TAGS:

Pulsamos en "Crear filtro con esta búsqueda".

Y, en la pantalla dónde nos preguntan cómo actuar marcamos la casillas "Nunca enviar a Correo no deseado".

 TAGS:

Con este pequeño truco, todo el correo se nos enviará a la dirección final donde esperamos recibirlo y podremos filtrarlo, de forma automática, según nuestras preferencias.


Fotos de stackexchange.com

Apache RewriteCond -f check file exists solution

If your Apache virtualhost or htaccess configuration uses a rewrite condition (RewriteCond) in order to allow nice URLs, you should be aware that since Apache 2.2 the "check if file or exists" works a little bit different. Any of the following examples might have stopped working for you:

   RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-s

The solution to correct it is very simple, but I couldn't see it documented. All you have to do is to add the variable DOCUMENT_ROOT before the REQUEST_FILENAME

The following example redirects all non existing files to index.php, here is the difference.

Before Apache 2.2:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/(.+) /index.php [QSA,L]

Apache 2.2 and later:

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteRule ^/(.+) /index.php [QSA,L]

The Apache 2.2 documentation is here: http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html

Saltar a página siguiente en direcciones secuenciales

En muchas ocasiones, en un sitio web nos encontramos una url del tipo:

http://url.ltd/path?id=XXXX

Donde XXXX es un identificador. En ocasiones este identificador es la página que estamos viendo y, en otras, el id del propio elemento.

Imagina, por ejemplo, una lista de perfiles de usuarios, donde el id fuera secuencial. Si quisieras verlos todos tendrías que ir cambiando este número o volviendo a la lista de usuarios y haciendo click en el siguiente.

He hecho un pequeño bookmarklet que permite ir saltando al siguiente elemento de forma automática.

Símplemente, arrastra este link a tu barra de bookmarks y ya tendrás la opción:

Siguiente

Por ejemplo, lo puedes probar con esta página web:

http://www.harecoded.com/page/1
http://blog.reformapisos.es/page/1

 

Merge Json files

With this small script you could merge some json files in a new one in json validated format.  The script uses each file name like array key.

Look the example:

file1.json:

{"array1":["elem1","elem2","elem3"],"array2":["elem1","elem2","elem3"]}

file2.json

{"array3":["elem1","elem2","elem3"]}

 

Whit our script you could run:

  • php merge_jsons.php file1.json file2.json > merged_jsons.json

 

Now you can open merged_jsons.json and look this:

{"file1":["array1":["elem1","elem2","elem3"],"array2":["elem1","elem2","elem3"]],
"file2":["array3":["elem1","elem2","elem3"]]}

The script:

for ( $i=1; $i{
$file_name = basename($argv[$i]);
$key_name = strstr($file_name,'.',true);
$data = file_get_contents( $argv[$i] );
$result[$key_name]=json_decode( $data );}echo json_encode( $result );
}

Convert a CSV to JSON with PHP

Imagine a data list dumped in a plain text file (e.g: CSV) and you need to convert it to JSON format. You could use this simple php script to do such task.

It's the simplest version but from here you can customize it to fit your requeriments.

Usage:

php script_name.php file_to_convert.csv > result.json

The script:

$csv = file_get_contents( $argv[1] );
$csv = explode("\n", trim($csv) );

foreach ( $csv as &$line )
{
$line = trim( $line );
}

print json_encode($csv);

This example covers a "single column" CSV file. If you want to add several columns you only need to add an explode with the separator character, be comma, somicolon or tab.

GMAIL: Bulk deleted emails based on date

When I created my gmail account, there was a counter giving you everyday more space. They "sold us" the product as if you never had to delete email again. By looking at that counter it seemed that by now I should have more than a Terabyte of data, truth is that after many years I have less than 8GB. Although it's a lot of space for the email, if you have automatic notifications, reports, and so on... it's easy to see how you are fastly approaching to the limit.

So, from time to time, it is needed to clean up a little bit your GMAIL account. At least for old reports and automatic emails which may not have sense anymore.

I usually delete some of this nonsense emails by typing in the search box:

label:Label_to_delete before:2011/1/31

Instead of "Label_to_delete" write a "secure" label you want to clean. I say secure because if you label your email with vague rules it is possible that you delete something you shouldn't.

When the search results appear, select the checkbox to check them all, and then click on the link that selects all the items matching that search. With this you will be able to delete thousands of undesired emails in a couple of clicks. 

The search box of Gmail is very powerful. If you are used to code, you'll find how easy is to add conditions. A very simple example of that would be:

label:CRONS after:2011/01/01 AND before:2011/02/01 AND from:root AND !has:attachment

Translation: Delete emails coming from CRONS in January coming from root user and without any attachment.

Give it a try!

How to backup your full Flickr account (script)

Why you would like to copy all your images stored at Flickr to your computer? Well, maybe you want to browse them later offline, maybe you want to stop paying your PRO account, or to keep them just in case...

In any case, Flickrtouchr is a simple command-line script to backup Flickr. You don't need to know python or programming at all. A couple of lines in the Terminal and that's it.

After downloading and uncompressing the .py script all you need is to:

Create a directory, e.g: A folder called "Flickr" in your Home dir:

mkdir ~/Flickr

And then call the script:

python flickrtouchr.py ~/Flickr

After this a browser will be opened and Flickr will ask you to authorize Flickrtouchr, and that's it!

Now maybe you want to add this line to your crontab so you can run it periodically. The script will check if the files exists to prevent continuous download.

Pasar enlaces Youtube a un punto de tiempo específico

Muchas veces pasamos enlaces de Youtube donde la parte interesante no llega hasta cierto punto. Puedes pasar a tus colegas el enlace para que salte directamente a un minuto y segundo que tu quieras.

Si por ejemplo quieres que un video empieze en el minuto 1 y el segundo 2 tan sólo tienes que añadir al final:

#t=1m02s

Delante de la m los minutos y delante de la s los segundos. Así de fácil. Por ejemplo:

http://www.youtube.com/watch?v=tTJMerul33E#t=1m02s

Desde el enlace anterior saltarás directamente a la escena de la Ostra Azul de la película Loca Academia de Policía.