Find and replace text in multiple files

On Unix, in one command line ?

# Here the search is in PHP files, but
# replace by whatever your file extension is.
find . -name "*.php" -print | xargs sed -i 's/<search>/<replace>/g'
# and that's all.
Leave a comment!

SQL order by personal order

To avoid another heaving PHP/other language sorting process on results from complex SQL queries I wanted to reorder my way, I’ve discovered an interesting property in SQL to order according special values using SQL FIELD (documentation on MySQL FIELD here, and scroll).

Example :

-- Let's I have a table of articles (id, name, color, size) 
-- and I want the red articles first, then green, then yellow
-- and finally blue
SELECT *
FROM articles
ORDER BY FIELD(color, 'red','green','yellow', 'blue');

Then, to be sure that you won’t have any extra results that won’t match your color criteria and therefore be in the first place of your sorted list, you can add a IN on the field you want to sort.

Example :

SELECT *
FROM articles
WHERE color IN ('red','green','yellow', 'blue')
ORDER BY FIELD(color, 'red','green','yellow', 'blue');

Nice huh ?

Leave a comment!

Auto entreprise suite et fin

Auto entreprise, suite et fin. Ou comment arrêter un massacre administratif inutile.

J’ai fermé il y a plusieurs mois mon auto entreprise avec grande joie.

J’avais créé mon auto entreprise parce que mes besoins professionnels étaient les suivants :

  • Pouvoir encaisser légalement le fruit de mon travail et de mes services en tant que freelance sur des petits projets spontanés
  • Tout en minimisant la paperasse administrative
  • Et en conservant une activité professionnelle régulière en tant que salarié.

Ce qu’il s’est passé :

J’ai eu des frais de santé très rapidement après l’ouverture de ma micro entreprise. Et là, surprise, des pièces justificatives qui n’ont jamais été enregistrées par la CCI de la cote d’azur m’avaient fait tomber par défaut dans le statut d’indépendant. Ce fut le début des galères administratives sans fin pour justifier ma double activité et toucher mes remboursements de frais médicaux et indemnités de la sécurité sociale.
Après vérification, j’avais bien donné les pièces justificatives, c’est la CCI qui ne les a pas enregistré. Notez le professionnalisme.

En revanche, la déclaration des activités professionnelles est simplifiée à l’extrême. Quand il faut encaisser de l’argent, la procédure sait être simple.

Ma boite aux lettres physique a été inondée de publicités (matériel de bureau…) et d’escroquerie en tout genre (inscription à des annuaires de professionnels notamment, dont la mise en page vise à imiter une facture).
J’ai été sollicité par téléphone à de nombreuses reprises pour des services dont je n’avais pas besoin, sans avoir donné le consentement à qui que ce soit pour que mes coordonnées soient diffusées.
De plus, mes coordonnées ont été enregistrées par Google et je me suis retrouvé  sur Google Map avec une simple recherche sur mon nom.

Enfin, d’un point de vue plus personnel, je pense que l’imposition sur ce statut est aberrante. Pour une seconde activité professionnelle, cela peut encore passer (mis à part la frayeur de la taxe professionnelle qui dépassait à l’époque le montant de mes revenus en auto entrepreneur).

En effet, pour moins de 32 600 € de chiffre d’affaire duquel il faut déduire les frais de fonctionnement et les taxes, il me parait difficile de vivre et de nourrir une famille aisément, surtout sur la côte d’Azur ou la région parisienne où les loyers sont élevés.

Donc, par rapport à mon expérience, je déconseille sérieusement ce statut d’auto entrepreneur. J’ai essayé de trouver des alternatives pour rester de manière simple dans la légalité, voici à quoi je suis parvenu :

  • Faire établir un contrat freelance par une agence creative (qui se sert au passage), tout ça faisant gonfler les prix pour le client au final
  • Passer par une association 1901
  • Travailler pour le fun, ce qui laisse en effet moins l’impression de se faire détrousser par l’Etat.

Comme autres solutions, on m’a conseillé :

  • Le portage salarial
  • Demander à un ami qui a une auto entreprise d’encaisser pour vous
  • De se faire payer en services ou en marchandise
  • Se faire rémunérer en bitcoins ;)

Si vous  avez d’autres suggestions, je suis preneur.

6 Comments, add yours!

get a function name from the function in Javascript

One day I needed to get the function name from the function itself. Here is what I found.

function functionName(fn)
{
var name=/\W*function\s+([\w\$]+)\(/.exec(fn);
if(!name)return 'No name';
return name[1];
}

via http://bytes.com/topic/javascript/answers/640929-obtain-function-name

Leave a comment!

HTML5: Up and Running by Mark Pilgrim

English Version:

A nice book to discover HTML5 and the futur of the web.

The author, Mark Pilgrim Engineer at Google, is describing the main features of HTML5 from the very basic level like new semantic elements: <audio>, <video>, <header>, <footer> to  the most advanced use of canvas, geolocalisation, local storage and microdata. Along the descriptions, Mark provides illustrated examples of use cases, links for more informations, and tells us the story behind every HTML5 component he is presenting.

In addition, he offers open sources tools to allow cross and retro compatibility with the current web browsers on the market.

I have personally really enjoyed the first part describing the evolution and needs of HTML.

Very easy to read, this books should be mandatory for every web worker.

Version française :
Un ouvrage bien complet pour découvrir le HTML5 et le futur du web.
L’auteur, Mark Pilgrim ingénieur chez Google, ne se contente pas seulement de nous décrire la nouvelle sémantique HTML5 (<header>, <footer>, <video> and co…) ni l’utilisation avancée des canvas, geolocalisation local storage et microdata, il évoque tout au long du livre l’histoire qui a amené à l’élaboration de ces composants et finalement du HTML5, il illustre ses propos d’applications concrètes et de liens pour plus d’informations.

Il propose aussi des outils (open sources) afin mettre en pratique les nouvelles spécifications du W3C et maximiser la compatibilité à travers les navigateurs web du marché actuel.

D’un point de vue plus personnel, j’ai particulièrement apprécié la première partie, les recherches faites décrivant les balbutiements du HTML.

Très facile à lire, ce livre est à mettre dans toutes les mains !

O’Reilly product page : http://oreilly.com/catalog/9780596806033/

Leave a comment!

Error 500 wordpress 1and1

Using one and one hosting, I wanted to install WordPress. I had an Error 500. Too Bad. Here is the trick :

Check that your root .htaccess file has the following information :

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
AddType x-mapp-php5 .php
AddHandler x-mapp-php5 .php

Don’t forget to save it with UNIX Line Endings (thanks to NotePad++ on windows for example),  in UTF8 and after removing all special characters. (Squares, with Windows)

via http://www.twiz.fr/school/tuto/webmaster/wordpress-error500/

Leave a comment!

Web and Entrepreneurship on the Cote d’Azur

Recently I have been seeking for business events about entrepreneurship and web around la Cote d’Azur, in South of France. My objectives are simple : to see what’s going on, to meet people, to understand how to do for when I’ll  be ready and on top of that, to understand how to do better.

bannière nice drink 4The first event I have been is Nice Drink #4. This event was sponsored by Perferencement compagny and aimed at allowing web people from south-east of France to connect in a convivial mood.

Different kind of people for different type of connection : job seekers, students looking for a sponsor for their projects, head hunters, business angels, “creative-innovative” showing off, bloggers of all kind, community managers, software engineers, journalists…

The mood was indeed very nice and encounters very interesting. However, I regret the lack of content. Meeting people is nice but it could have been interesting to propose workshops on trendy topics organised by a charismatic master of ceremonies. Anyway, it was a really nice party!

ND-14.jpg

Team Voila to the rescue…

Later I have been to Start Up Factory, where start-ups present their project to business angels. This event was really well organized, albeit less prestigious location. The aim was clear, workshops were organized with a charismatic MC, (I like this expression). Start ups had 5 minutes to present a project to convince business angels in investing in them. The mood was more serious than NiceDrink’s and people looked more like CEO and all kind of executives than bloggers type of person.

What I have learned is that people who don’t know nothing from the web, or just pretending, still want to succeed with revolutionary websites they didn’t check if they already exist, and are asking a lot of money to propose a crappy version of it. Paradox with technical people and their real problems and commercial people saying bullshits is more than real. I’m afraid the commercial ones will succeed. Poor World.

I have also learned, among other things, that business angels are not investing because they want to give a chance to these start ups but because they are saving money from taxes. héhé.

My conclusion regarding these two events is that there is a lot of opportunities to start a company in the web in south of France : people are interested and skilled, funding doesn’t seem a problem, lifestyle is pretty nice… So what’s missing ?

Leave a comment!

Why we love JavaScript

These past years JavaScript has been the language on the web. Through Ajax, we can do amazing dynamics things on a web page.
From what I remember, when I started my first web page a while ago in 2002, Javascript was considered evil. Hard to program, poor documentation, and to be honest : for what use ? Changing background colors ? Moreover, web browsers weren’t as powerful as now.

And then, Ajax appeared. That was revolution. At first it was all made by hand, but a while later it was the beginning of JavaScript frameworks development. I remember I started with Prototype and Scriptaculous.

Later, JavaScript frameworks have been combining complete tools to add life in web pages : DOM manipulation, fancy transition effects, Ajax and JSON support. They became so powerful that now, it’s all about improving JavaScript engines on web browser to enhance more and more user experience.

These last two years, I have been really enjoying developing with Dojo and JQuery. When I see what we can do now with Cufon http://cufon.shoqolate.com/ for example to play with fonts in canvas or PHPJS http://phpjs.org/ to implement PHP function in JavaScript, I hope that it is just the beginning or prehistory of the web and rich applications.
JavaScript has finally become the language on the web, the language that we love to hate (welcome on WTF JS) for a better future.
My guess is that the next move will be full JavaScript and XMLHttpRequest support for portable devices such as mobile phone and tablets. There is a huge market there !

If you are interested in learning JavaScript, here is a really nice website : Learning Advanced JavaScript http://ejohn.org/apps/learn/# where lots of nice tricks are explained.

Now that you know a lot of things about JavaScript : can you guess what does this piece of code do on a page ?

($=[$=[]][(__=!$+$)[_=-~-~-~$]+({}+$)[_/_]+
($$=($_=!''+$)[_/_]+$_[+$])])()[__[_/_]+__
[_+~$]+$_[_]+$$](_/_)

answer on http://adamcecc.blogspot.com/2011/01/javascript.html

1 Comment, add yours!

Xampp/Wampp Apache Crashes on Start

It displays “Busy” in the shell but it’s not started?

Executing “apache_start.bat” says something like :

(OS 10048)Une seule utilisation de chaque adresse de socket (protocole/adresse réseau/port) est habituellement autorisée.  : make_sock: could not bind to addres s 0.0.0.0:80

?

Then, if you are using Skype then the solution is here :

http://mwolk.com/blog/port-80-busy-how-to-start-apache-on-xampp-and-wamp/

Shut it down or disable the use of 80 and 443 port in the advanced connection settings and restart.

Then, restart your Xampp/Wampp Apache server, and you are back on business.

Leave a comment!

Galère de l’auto entreprise

Je ne sais pas si c’est juste moi ou la population entière, mais j’ai un problème avec l’administratif.

J’ai rempli les formalités au mois de juillet 2010 pour créer ma micro entreprise. Mon but initial était de pouvoir vendre des produits achetés sur internet dans la région où je réside, tout en restant salarié. Sorte de petit bonus en fait. A l’époque, j’avais une super opportunité, qui malheureusement n’en était pas une.

La micro entreprise est donc restée dans un état opérationnelle mais non utilisée. Au pire, je la gardais sous la main pour pouvoir faire légalement des sites web.  Chose qui est largement dans mes compétences, et les clients parmi les amis ne manquent pas.

L’affaire stagne donc jusqu’à LA galère administrative.
Je décide de me faire opérer du genou, suite à un accident datant de quelques années. Tout s’engage dans la bonne voie, un bon chirurgien trouvé, une opération qui se déroule bien, et je rentre chez moi, en arrêt maladie de mon activité de salarié. Jusque là, j’avais oublié ma micro entreprise. Sauf que…

Bien que dans ma déclaration de micro entreprise, il est écrit noir sur blanc que :

Vous restez simultanément : Salarié
lieu d'exercice : dept : 06

Je fus, je ne sais pas pourquoi, rattaché au régime social des indépendants, i.e. régime non salarié. Point capital de tout cela : en tant qu’indépendant, je ne touche pas d’indemnisation journalière de la CPAM pendant mon immobilisation, alors que je devrais, car je suis salarié.

La galère expliquée totalement : le RSI (régime social des indépendants) a récupéré mon dossier à la CPAM, m’a ouvert des droits chez lui, et fait fermé les droits de salarié que j’avais à la CPAM.

Pour rectifier tout ça, je dois donc faire fermer mon affiliation et mes droits au RSI en fournissant des pièces justificatives de mon activité de salarié, et tout faire réouvrir à la CPAM, en fournissant d’autres pièces justificatives.

Étant en arrêt maladie,  heureusement que je n’ai que ça à faire…

To be continued…

Leave a comment!