vendredi 25 mars 2011

Générer un fichier de traduction po

Je commence par "parser" les fichiers sources pour obtenir une version "template" du fichier de traduction. Pour cela, j'utilise la commande xgettext

find . -name "*.php" | xgettext --from-code=utf-8 --language=PHP 
          -o TransData.pot -f -

Ensuite, je copie TransData.pot en TransData_es.po par exemple et effectue la traduction. Enfin, je termine par la génération du fichier mo

msgfmt -o TransData.mo TransData_es.po 

mardi 15 mars 2011

Trucs et astuces...

Utilisation de rsync à travers ssh

rsync -avz -e ssh --exclude "*~" --exclude ".svn" login@hostname:/dirsource dirdest

Forcer ntp à se synchroniser

service ntp stop ; ntpd -q -g -x ; service ntp start

La boucle for type C en Bash

for((i=0; i < 16; i++)); do
echo $i 
done

Remplacement type sed "simple" en Bash

dst=${string/exp/rep}

mardi 11 janvier 2011

Live coding

Sur ce site on trouve pas mal d'informations sur le "live coding"

mardi 4 janvier 2011

A lire...

Voici un livre très intéressant sur la programmation parallèle. J'ai découvert le lien sur un post du 3 janvier 2011 sur lwn.net.

mardi 9 novembre 2010

Développer des applications Adobe Flash sous GNU/Linux

On peut développer des applications Flash sous GNU/Linux en utilisant les outils d'Adobe.
Voici les points essentiels qui me permettrons de mettre en place une application Flash.
  1. Téléchargez et installer le Flex SDL. A cette date, j'utilise la version 3 complète (environ 110Mo)
  2. Mettre en place l'environnement Web local (apache2 et le fichier crossdomain.xml)
 Voici un exemple d'un fichier crossdomain.xml pour le développement, ce fichier est à copier à la racine du Web local.

<?xml version="1.0"?>
<cross-domain-policy>
<allow-access-from domain="*" />
</cross-domain-policy>

Après avoir désarchivés les fichiers du SDK, j'installe le compilateur en utilisant un script bash et le player flash par un lien symbolique.

#!bin/sh
<chemin vers flex_sdk_3>/bin/mxmlc $*

Cela permet au compilateur de retrouver les répertoires lib, ... qui sont spécifiés de manière relatives.

Pour compiler un fichier mxml ou bien as et générer un swf il suffit de faire :

mxmlc <nom du fichier mxml ou as> 

Concernant, le développement, les différentes documentations fournies par Adobe en ligne sont suffisantes.

Cependant, juste pour rappel, le langage ActionScript 3 est orienté objet et possède la notion d'interfaces (comme chez Java).
Au final, on peu s'étonner de la ressemblance entre FlexSDK/ActionScript et JDK/Java.

mardi 12 octobre 2010

SSH use for distant office

Make things automatic


When I am at home, I usually need remote access to my servers at work, to check some documents or to fill some data on our CRM. We are using openssh access to do remote maintenance of our products so I decide to provide that for remote access from home.

The idea is to make most of the configuration automatic so I have wrote a configuration file for that (~/.ssh/config).

Host job
Hostname job.jeanpul.com
User jeanpul
Port 999
LocalForward *:8080 192.168.0.20:80
ControlMaster yes

With this configuration file, using the following command

ssh job 

open a SSH connection to job.jeanpul.com on port 999 and then gives access to the Web server of the distant machine 192.168.0.20 on the local port 8080.

Browse your Intranet without URL redirection problems

So, then I reach the office Intranet network using the http://localhost:8080/ but all the absolute URL cannot be reached. So URL's like :

<a href="/PHPMyAdmin/index.html">PHPMyAdmin</a>

works because it's leads to http://localhost:8080/PHPMyAdmin/index.html but

<a href="http://server1.office.net/PHPMyAdmin/index.html">PHPMyAdmin</a>

failed because server1.office.net have no meaning locally.

The solution I used was to install and configure a Web proxy. I used privoxy with the following configuration part

forward   job.jeanpul.com    localhost:8080
 forward   server1.office.net localhost:8080

Then I configure my browsers to use this proxy and URLs such as

http://server1.office.net/PHPMyAdmin/index.html

are correctly managed.

Removing password input


I have configured my SSH server to support remote connexion using private/public key so I never enter the user password anymore.

To do so, I have generated a private/public key :

ssh-keygen -t rsa

Then, I have copied the public part to the SSH user on the remote access :

ssh-copy-id -i ~/.ssh/id_rsa.pub job.jeanpul.com

Sharing my Wifi connection

Sometimes, I need an Internet access on my "old" computer at home using my private Wifi network. I don't have any Wifi device on my computer and I need to move my computer close to the ADSL Router . So, I use some iptables commands on my laptop, to provide an Internet access to my "old" computer.

> iptables --table nat --append POSTROUTING --out-interface wlan -j MASQUERADE
> iptables --append FORWARD --in-interface eth0 -j ACCEPT
> echo 1 > /proc/sys/net/ipv4/ip_forward  

This require that my "old" computer have access (same network domain), to my laptop and set its gateway to its eth0 ip adress.

> ifconfig eth0 inet 192.168.1.34
> route add default gw 192.168.1.35

finally, DNS is also configured.