Mirmo Dynamics

Si tu kiffes pas reunoi, t'écoutes pas et puis c'est tout.

To content | To menu | To search

Geekeries

sottises de geek

Entries feed - Comments feed

Wednesday 1 July 2009

Help Symfony: fix one bug per day and win some gifts !

Today is the first day of the "1 day / 1 ticket" Symfony event.

Starting from today, each ticket you close (or help closing) from this list by either submitting a patch, submitting unit tests, etc will earn you points. At the end of the month, gifts are attributed to people with the most points.

This is a fun and exciting way to help your (hopefuly) favorite opensource project ;)

For more details on rules, please see the official page.

Monday 15 June 2009

subversion, tags and externals

It's been brought to my attention today (by my fellow developper hartym) that there is a HUGE problem with tags in subversion.

The problem is very simple, when you create a tag for your project, and that your project uses svn:externals (quite a common situation), externals in the tags ARE NOT FROZEN. Which means that, if you checkout your tag at a T time, and an external gets modified at T+x, a checkout at T+x will not be the same than the one at T.

Wow.

I'm going to seriously consider switching to git.

Thursday 2 April 2009

SQLSTATE[HY000]: General error: 1005 Can't create table '*' (errno: 150)

You may or may have not already stumbled upon this rather obscure error message (no, I'm not starting a serie on obscures error messages). Well the first thing to think when you encounter this is your foreign keys. This message generally denotes a failure in foreign keys creation, for example when the two columns you are trying to link are not of the exact same type (that is, you can't link an integer(4) to an integer(11)).

Now what if you are absolutely certain that your two columns are of the same type ? I just had the problem with this piece of doctrine schema (simplified for example purpose):

Media:
  columns:
    image:           { type: string(255), notnull: true, unique: true }

ExplorationMission:
  columns:
    probe_image:         { type: integer, notnull: true }
  relations:
    ProbeImage:          { class: Media, local: probe_image, foreign: id, onDelete: 'SET NULL' }

Can you spot the problem ?

It's rather obvious when you know it, but I spent rather some time cursing mysql in vain. The point is that there is a major logic error in this schema. it declares the probe_image as NOT NULL while it gently asks the FK to set it null on delete. See ?

Hope it saves some frustration :-)

Tuesday 31 March 2009

Ajax query failing unexpectedly ?

I was gently doing some ajax black voodoo when I came upon this obscure-ish error in my firebug console:

Error: uncaught exception: [Exception... "Component returned failure code: 0x805e000a [nsIXMLHttpRequest.open]"  nsresult: 0x805e000a (<unknown>)"

What the fuck I though. And then after some (useless) firefox rebooting, I decided to ask the all-mighty Google.

No shit, he said, I know what you are talking about, and thou shall find more informations at this place, and to point me to this thread, where you can read the following:

AdBlock Plus was killing it HAH!

And then I disabled AdBlock Plus, and exactly as the writings told, it worked.

Tuesday 17 March 2009

Rewrite rule to add missing www

  RewriteEngine on
  RewriteCond %{SERVER_NAME} !^www\..*$
  RewriteRule ^/(.*)$ http://www.%{SERVER_NAME}/$1 [L,QSA,R=302]

From the manual, using %1 as a back reference from the RewriteCond in the RewriteRule should work, but it didn't on my installation. Weird.

Friday 26 December 2008

Rebooting the iphone without touching the screen

Yesterday, I had a bug with my iphone that prevented me to use the touchscreen. Weird. No problem I though, I'll just reboot the damn thing and it'll be fine. Except you need the touch screen to turn the iPhone off. After a few manipulation and frustration, I found out that you can actually reboot the iphone by holding the power button and main button simultaneously for a few seconds. Handy heh.

Wednesday 17 December 2008

Charset detection with python

I was looking for a way to easily determine a file's charset when I stumbled upon the Universal Encoding Detector. Just wanted to share it.

Installation:

$ wget http://chardet.feedparser.org/download/chardet-1.0.1.tgz -O - | tar xz
$ cd chardet-1.0.1
$ python ./setup.py build
$ sudo python ./setup.py install

Usage:

From a python console:

>>> import chardet
>>> chardet.detect(open('/path/to/your/file', 'r').read())
{'confidence': 0.98999999999999999, 'encoding': 'utf-8'}

Nice !

Wednesday 29 October 2008

[Pub] Monitoria: track your websites downtime

Monitoria is a web service developped by some friends of mine and designed to help you track and minimize downtime on your sites. Excerpt from the homepage:

Monitoria is a website uptime monitoring service designed to help you detect website downtime which can mean lost revenue and profits.
The worst thing is customers who may never return to your website again if they experience difficulties opening your website.
Register now and take control over downtime today!
Let Monitoria monitor your website 24/7/365 and alert you immediately upon your website accessibility, availability or performance problems.

And because you're smart enough to read my blog, here is a 20% discount coupon code: phpmafia20-87361.

Sunday 26 October 2008

PHP's april's fool

http://wiki.php.net/rfc/namespacese...

wait, we're not April 1st ?

Thursday 16 October 2008

Mass vim file opening reloaded

Thinking about it, the snippet I posted earlier was a bit silly as vim can open by itself multiple files way more efficiently. The only benefit from my script is that I don't have to type the --servername and --remote-silent-tab.

So let's add some usefulness ! First, when I need this script, it's often that I first grepped the files, and then decide that I want to edit them all. From this point of view, having to pass them as arguments is not that handy, so we'll add a way to pass them via STDIN.

Also, what if I want to send them to another vim server ? We'll add this ability too.

Here is the resulting script:

#!/usr/bin/env bash

# set a default SERVERNAME
SERVERNAME="ash0"

# look for files on stdin
if ! [ -t 0 ]; then
  FILES=`cat /dev/stdin`
else
  exit;
fi;

# now let's check if we want a specific vim server
if ! [ -z $1 ]; then
  SERVERNAME=$1
fi;

# we can now open the files
/usr/bin/gvim --servername $SERVERNAME --remote-silent-tab $FILES

Tada !

You can now do the followings:

grep foo | sendtovim
grep foo | sendtovim grep0

Tuesday 14 October 2008

Mass vim file opening

Remember my old post about vim and rox-filer ? Well I've got one tiny and silly addition to it now, I can mass open files from any shell command line, with this little script placed in my ~/bin/ (don't forget to chmod +x):

for i in $*; do
  /usr/bin/gvim --servername ash0 --remote-silent-tab $i
  sleep 1
done;

The sleep 1 is necessary as vim does not seem to like being flooded with files.

Example usage:

sendtovim `grep foo *`

Opens in vim all files containing "foo" in the current directory. Who said handy ?

Note: I know have an updated and useful version of this script

Monday 28 July 2008

The Eight Irrestitible Principles of Fun

http://www.eightprinciples.com/

(via pmog)

Wednesday 23 July 2008

La Défense / Puteaux a pied

J'aime beaucoup google maps, et pour fêter ça, et à cause des travaux sur le tram qui coupent la circulation entre la défense et puteaux, j'ai fait une map avec le trajet optimal (je pense) entre le parvis de la défense et la station de tram de puteaux.

Voilà c'était la minute je kiff gmaps.

Thursday 10 July 2008

Rename directories to lowercase

Using a single (and somewhat simple) shell line, you can rename any directory to its lowercase version.

for i in *; do lcase=`echo $i | tr A-Z a-z`; if [ ! -d $lcase ]; then mv $i $lcase; fi; done;

Viva el chell !

Thursday 26 June 2008

Apache and mod_rewrite to subdirectories

Naneau just poke me with a little problem he had with mod_rewrite when trying to rewrite to a subdirectory. Imagine you've got the following setup:

  • Apache's document root is /document_root/
  • You application's bootstrap is /document_root/public/index.php

You could come to the following rewrite rules quite easily:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ public/index.php/$1 [L]

And you'd be horribly wrong.

The problem here is that when you hit / on your server, mod_rewrite will populate %{REQUEST_FILENAME} it to /document_root/, which obviously fails the !-d rewrite condition. By the magic of DirectoryIndex, you'll eventually hit /index.html (or whatever your directory index is set to), and there we go for another rewrite magic. At this point, things get a little messy, and if you're like naneau, you'll end up crying while rolling on the floor and calling for help on irc (that's quite a set of hard things to achieve at the same time).

The solution is not that simple, and actually, I've not found a fully satisfying solution yet (although naneau is satisfied with the partial solution). The quick hack is to simpy remove the !-d condition. The obvious drawback is that any existing directory will get rewritten, but you'll be able to access the files inside it. I'm still working on a more complete solution, but as it's not my main concerne for the moment, it'll wait a bit (unless someone posts a solution in the comments).

Monday 21 January 2008

Symfonians, un site pour les maestros en herbe

Les utilisateurs du framework symfony ont désormais leur cafet' dédiée pour aller prendre un ptit café ! Pour résumer, symfonians se propose de réunir la petite communauté symfony autour de fonctionnalités aussi conviviales qu'utiles, telles que la création d'un profile développeur symfony, des offres d'emploi, ce genre de choses quoi. Le projet est chapoté par NiKo, ce qui au moins est un gage de bonne qualité.

Wednesday 2 January 2008

Zend Framework 1.0.3 PEAR package

Just to say I packaged the 1.0.3 version of the zend framework on the phpmafia pear channel. It's a bit late I know, but at least it's here. Please note that I already have been notified of a problem regarding the Zend Locale's xml datafiles and that I hope to have worked out a solution for the next release (1.5 if all goes well).

Friday 21 September 2007

Ubuntu est chez Dell

Je ne sais pas si c'est récent ou non, mais toujours est-il qu'hier j'ai remarqué sur le site de dell france la posibilité d'acheter un ordinateur dell équipé d'Ubuntu Linux. L'initiative est vraiment sympa, d'autant plus que le matériel proposé me semble tout à fait abordable: on arrive à une configuration desktop équipée d'un core duo et d'1 Go de ram plus un écran 19 pouces pour moins de 600 euros (livraison comprise). J'achète.

Friday 7 September 2007

Quand ssh est mou

Juste pour mémoire: http://www.refreshinglyblue.com/200....

Thursday 30 August 2007

Quick php5 pre-migration check

If you're wondering how much of a hassle it would be to migrate your app / codebase to php5, try the following command line (after having installed the php5-cli package of course):

find . -name "*.php" -exec /usr/bin/php5 -l {} \; | grep -v 'No syntax errors'

It'll show you all the files with syntax errors in it.

- page 1 of 8