Report inadequate content

Migrate Posterous without losing the images

 TAGS:It might seem very obvious to you that if you migrate from Posterous blogs to another service your images should be transitioned as well.

If you want a free service (as Posterous was) there are only two options where you can migrate your Posterous to without writing all your posts one by one again:

1) Wordpress.com (but losing all the images)
2) Obolog.com (and keeping all the images)

So, if you want your blog back including images the only option you have is Obolog. There are no other free services in the net (or at least I didn't find other) where you can bring back to life your Posterous blog. If you have already migrated to wordpress go and see where your images are pointing to. You'll be disappointed because all the posts reference posterous server, and they will be shut down in a few days.

If you still wonder what Obolog is, you are just reading one right now. Harecoded is powered by Obolog and it has been running smoothly for several years so far.

If you want to try it all you have to do is to upload your ZIP backup file into the Posterous migration script. But remember, on April 30th if you don't have the ZIP everything will be gone for good.

{
}

!About the blog

Harecoded is a blog by and for developers. We are essentially web developers born before the Internets and we use this blog as a notebook to write generalistic recipes, tricks and maybe some advice.

All we editors in this blog work in high-scale environments and we are experienced in many battle fronts. If you have questions on the web, use the comments to post any of them! What we write is quite basic but we can help you out with more complex stuff.

Thanks for reading!

Read more about this blog in Obolog

Best web-based alternatives to Google Reader

If you are a Google Reader reader you have certainly seen the message that is going to disappear by July 1st 2013. If you read from mobile then plenty of cool apps like Flipboard you can use, but when it comes to a web-based interface these are the alternatives I found worth using.

The first thing you should do before it is too late is to download a copy of your Google Reader feeds using Takeout

Then take your time to pick another service, there are plenty.

Prismatic

If you log in using your Google account then there is nothing you have to import. All your feeds will be there in a fashion way with big images and a nice presentation. I like it way more than Google Reader, but if you have hundreds of places you are subscribed to maybe you'd prefer something that does not display all the images and shows as a list instead. It looks more like a new sites than a RSS reader, but it is pretty cool.

 -
 -

Find it here: http://getprismatic.com/

The Old Reader

Subscriptions are presented quite similar to Google Reader. You need to download your Google subscriptions if you want to import them here. But it seems that right now, the site is under a lot of load: -
This is how it looks like:

 -

http://theoldreader.com/

Feedly

Finally Feedly seems to be the on of the most commented in the Twitter timeline so far, and looks very nice too. They claim that the transition will be transparent for the users if you connect to Google Reader with a project they are working on called Normandy. What I like the most is that you can select how you want to display the information, a list, a mosaic, anything :)

 -  TAGS:

 

http://www.feedly.com/

Other alternatives to Google Reader

An article I found very interesting on this very same topic covering 12 alternatives to Google Reader is on Marketing Land

Let us know your choice!

Configure Compass,Sass,Less... in PHPStorm

 -

PHPStorm 6 bundles a new feature called "File watchers" which enables Sass, LESS, SCSS, CoffeeScript, TypeScript transpilation. This option will compile your compass/scss/whatever files when the source file is saved (this is when you lose the focus or manually save).

So, for the basic stuff you can stop using external programs and watchers likeCodeKit or LESS.app now. But of course unexpensive software like CodeKit is a must have if you are a frontend developer.

Our frontend guy decided to use Compass using SCSS source files so, the following example illustrates how to configure Compass in PHPStorm under Mac OS X, but this is something reusable for the rest of the languages supported by watchers. The procedure is basically the same for the others.

First of all, you have to install Compass. To do so open the Terminal and type:

sudo gem install compass

Then go to PHPStorm and open any of the SCSS files in your project and you'll see after a second or two a message inviting you to use File watchers. This is going to add under Preferences -> File Watchers a new entry that you can edit as follows:

Program: /usr/bin/compass
Arguments (If you compile files one by one): compile  $FilePath$
Arguments: (If you have SCSS in groups with ruby configurations):
compile  $ProjectFileDir$/relative/path/to/css/

 -

Now save the settings and every time you save one of these files you'll have the compiled SCSS file. Of course you can pass all the parameters you want in the section arguments to fit your needs. 

Ah, and this black theme is the Darcula theme that comes now bundled with the version 6.

Features in PHP 5.4

 -

We had to create a file upload form that allows a user to upload big files. In order to keep a good experience for the user we decided to show the progress bars.

There are several ways of doing that but it came to my mind that PHP 5.4 had an improvement on file upload, making it easier now and wondered if I had the last excuse to upgrade the servers from 5.3 to 5.4.

This is a list of some of the features PHP 5.4 comes with. There are more, but I came here with the intention of speaking about the ones that they care to me. This is not a 5.4 review, but examples.

Session upload progress

I already mentioned it, PHP 5.4 will be handy because now you can ask the server in realtime how the upload progress is going. Mixed with HTML5 you can have a kicking-ass upload form.

Speed

It seems that PHP 5.4 is faster than its ancestry, and I say that it seems because even there are plenty of sites claiming that I still have not run any benchmarks with my app.

Traits

Kids deserve  a candy sometime. We have regret many times using PHP because unlike other languages there has never been multiple inheritance. Now PHP gives us a sugar-free candy to mitigate this. Traits are not the multiple inheritane but might help you out sharing common functionallity between classes. And traits can use traits. This is an example of how a simple trait would work:

<?php
namespace Mammal\Primate;

trait Feeding
{
        public function getDiet( $age )
        {
                if ( $age < 3 )
                {
                        return [ 'breastfed' ];
                }
                else
                {
                        return [ 'fruit', 'leaves', 'flowers', 'buds', 'nectar', 'seeds', 'insects', 'bird eggs' ];
                }               
        }
}

Then your trait can be attached to any class like this, no matter if your class already extends something else:

class Gorilla extends VertebrateKingdom implements Animalia
{
        use \Mammal\Primate\Feeding;
        // ...
}

Now you can use the trait methods directly:

$gorilla = new Gorilla();
$gorilla->getDiet( 5 );

Python-alike stuff: lists and anonymous functions

Being a former pythonist I'm glad to have these two back in town:

Anonymous functions

Create functions on the fly: 

$dump = function( $var ) { var_dump( $var ) ; };
$dump( $gorilla->getDiet( 5 ) ); // Array containing 'fruit', 'leaves'...

Short array syntax

This is the same format than python lists, and the ability to get rid of temporary variables:

// Before: PHP < 5.3:

function getMammals()
{
        return array( 'monkey', 'zebra', 'dolphin', 'cat', 'John' );
}

$mammals = getMammals();
echo $mammals[0];

// Now: PHP 5.4+
function getMammals()
{
        $mammals = [ 'monkey', 'zebra', 'dolphin', 'cat', 'John' ];
}

echo getMammals()[0]; // Look that you don't need the temp variable anymore

Webserver

Finally, now you can run a debugging server without the need apache:

 php -S localhost:8080 -t /var/www/tests 

Not very useful in my case scenario where I have a full virtual environment with puppet and so on, but maybe for running temporary scripts might be useful. With earlier versions remind that you can always execute inline PHP from command line like this:

php -r "phpinfo();"

Yeah!!!

{
}

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

A life explained in HTTP status codes

This is a made-up story of a life explained with HTTP status code. It was written up to down at once without much thinking, feel free to improve it!

Status Code Event HTTP meaning
100 You are curious about her Continue
101 First time sex Switching Protocols
200 Love OK
201 She's pregnant Created
202 And you are the father Accepted
203 Were you looking forward it? Non-Authoritative Information
204 Think of a name  No Content
205 Baby is born. Your life starts again  Reset Content
206 Changing diapers Partial Content
300 Kids education Multiple Choices
301 New place to live  Moved Permanently
302 Your relation is elsewhere Found
303 She has an adventure See Other
304 At least is not pregnant  Not Modified
305 They used condom Use Proxy
306 Your toolbox remains... ( Unused )
307 Back to your parent's Temporary Redirect
400 Call your old girl friends Bad Request
401 Shit, all married Unauthorized
402 Maybe Hookers? Payment Required
403 You are bankrupt Forbidden
404 Reconsidering sexuality Not Found
405 In your ass Method Not Allowed
406 Confused Not Acceptable
407 Back to your wife's Proxy Authentication Required
408 Too late to say I miss you Request Timeout
409 I want the kids! Conflict
410 Custody trial Gone
411 Penis enlargement Length Required
412 That was not the problem Precondition Failed
413 That does not fit in Request Entity Too Large
414 Too long Request-URI Too Long
415 Try the other gender Unsupported Media Type
416 Not a good idea Requested Range Not Satisfiable
417 Not enjoying it Expectation Failed
500 You feel like crap: Psychiatrist Internal Server Error
501 No cure found yet Not Implemented
502 Bingos, hookers and alcohol  Bad Gateway
503 You are getting old Service Unavailable
504 Viagra Gateway Timeout
505 Mental institution HTTP Version Not Supported

HTTP specification can be found here

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

Convertir de ISO a UTF-8 por línea de comandos

 TAGS:Esta mañana he tenido que utilizar un .CSV generado desde Excel.

Al acceder a él desde la línea de comandos me he encontrado que se perdían todos los acentos. Un problema ya clásico este de "los carácteres especiales".

Gracias al comando 'file' he podido descubrir la codificación que Excel le da a nuestro fichero en el momento de hacer la exportación.

>file nombre_fichero.csv
nombre_fichero.csv: ISO-8859 text, with CRLF line terminators

Lo único que he tenido que hacer es convertirlo en la misma terminal a UTF-8. Conviene fijarse en que, iconv utiliza ISO-8859-15 en lugar del ISO-8859 que me ha devuelto file:

> iconv -f ISO-8859-15 -t UTF-8 fichero_origen.csv > fichero_convertido.csv

Con esto ya tengo en fichero_convertido.csv los datos con el formato esperado.
Suerte.