Wednesday, May 19, 2010

Dokuwiki, Gource : color now

In response to various requests, I just added the color to the Dokuwiki representation with Gource. You can now download the new version .

#!/bin/python

"""
This program parse logs of a dokuwiki
and tranform them for gource (a log viewer)
http://code.google.com/p/gource/

developped by WolverineX02
site : http://wolverinex02.blogspot.com

"""
import glob
import os.path
import getopt
import sys
import re

WHITE = "11FFAA"
GREEN = "00F000"
vector = (1,10,100)
start_page_name = "start"

def RGBToHTMLColor(rgb_tuple):
""" convert an (R, G, B) tuple to #RRGGBB """
hexcolor = '#%02x%02x%02x' % rgb_tuple
# that's it! '%02x' means zero-padded, 2-digit hex values
return hexcolor

def HTMLColorToRGB(colorstring):
""" convert #RRGGBB to an (R, G, B) tuple """
colorstring = colorstring.strip()
if colorstring[0] == '#': colorstring = colorstring[1:]
if len(colorstring) != 6:
raise ValueError, "input #%s is not in #RRGGBB format" % colorstring
r, g, b = colorstring[:2], colorstring[2:4], colorstring[4:]
r, g, b = [int(n, 16) for n in (r, g, b)]
return (r, g, b)

def colormodify(colorstring):
rgb_tuple = HTMLColorToRGB(colorstring)
r, g, b = (rgb_tuple[0]+vector[0]) % 255,(rgb_tuple[1]+vector[1]) % 255,(rgb_tuple[2]+vector[2]) % 255
return RGBToHTMLColor((r, g, b))

def listdirectory(path,color):
l = glob.glob(path+"/*")
for i in l:
if os.path.isdir(i):
listdirectory(i,colormodify(color))
else:
readfile(i,color)

def listdirectory2(path):
"""list all the files like *.changes,
read them and output them in gource's log syntax
"""
for root, dirs, files in os.walk(path):
for i in files:
if (re.search('\.changes$', i)):
fichier = os.path.join(root, i)
readfile(fichier,GREEN)

def readfile(fichier,color):
"""read the file and output for each line of this
file a log line for Gource
"""

myfile = open(fichier, 'r')
for line in myfile.readlines():
mots = line.split('\t')
if len(mots)>=6:
resultat = mots[0] + "|"
if mots[4] == '':
mots[4] = 'Anonymous'
resultat += mots[4] + "|"
resultat += translate(mots[2]) + "|"
resultat += mots[3].replace(':', '/')
if mots[3].rfind(start_page_name) == len(mots[3])-len(start_page_name):
resultat += "|" + color
else:
resultat += "|" + colormodify(color)
print resultat
myfile.close()


def translate(mot):
"""translate the dokuwiki vocabulary to the gource one
C (also cc and sc from discussion plugin) ->A
E (also ec from discussion plugin) -> M
D (also dc and hc from discssion plugin) -> D
other -> M
"""
if mot.upper == "C" or mot == 'cc' or mot == 'sc':
return "A"
elif mot.upper == "E" or mot == 'ec':
return "M"
elif mot.upper == "D" or mot == 'dc' or mot == 'hc':
return "D"
else:
return "M"

def main(argv):
"""principal function
"""
try:
opts, args = getopt.getopt(argv, "hd:", ["help", "dokuwiki="])
except getopt.GetoptError:
usage()
sys.exit(2)
for opt, arg in opts:
if opt in ("-h","--help"):
usage()
sys.exit()
elif opt in ("-d","--dokuwiki"):
print listdirectory(arg,WHITE)


def usage():
"""this function will display how to use this script
"""
print "This script will output change logs of a dokuwiki"
print "in a friendly way for gource"
print "how to use it :"
print "python gourcedoku.py -d ~/Sites/MyDokuwiki/ | sort > dokusort.log"
print "and then :"
print "gource --log-format custom dokusort.log --stop-position 1.0 \ "
print "--stop-on-idle --file-idle-time 10000000"
print "---"
print "-h : help "
print "-d : meta directory of your dokuwiki"

if __name__ == "__main__":
main(sys.argv[1:])


Sunday, May 16, 2010

Wasab emulsion

We tasted this preparation in a very good restaurant ... By guessing the ingredients that could be present ... we managed to recreate a recipe for wasabi emulsion well nice and very easy to make :-)


Here is the recipe:

List of ingredients:

  • 1 tsp wasabi (in a tube and not powder)
  • 1 tbsp soy sauce
  • juice of half a lemon
  • 200 ml of cream
Preparation:

Mix the wasabi in soy sauce. Add lemon juice, whipping cream and beat all until a stiff emulsion.



Suggestion:

You can serve as an appetizer with bread sticks, as an accompaniment to salmon sashimi.

Enjoy!

Gource and Dokuwiki : the video

The video :






obtain with the followinf command line :

gource --log-format custom dokusort.log --stop-position 1.0 --stop-on-idle --file-idle-time 10000000 --output-ppm-stream - | ffmpeg -y -b 3000K -r 60 -f image2pipe -vcodec ppm -i - -vcodec mpeg4 gource.mp4


It takes a little time but the result is wonderful

Gource and Dokuwiki

Like everyone, I am fond of the wonderful videos made with Gource. The goal of this tool is to make a representation of the changes made on a version control system like git or SVN. But my favorite wiki ( DokuWiki ) is a version control system tool... Have a look to the folder tree to find the directory "dokuwiki/data/meta" in which the files "*. changes" contain exactly the information sought. For example, the file "systemes_visualisation.changes" looks like:

1263135717 ::1 C informatique:systemes_visualisation Wolverine créée 1263135717:: 1 C computer: Wolverine created systemes_visualisation
1263135988 ::1 E informatique:systemes_visualisation Wolverine 1263135988:: 1 E it: Wolverine systemes_visualisation
1263136423 ::1 E informatique:systemes_visualisation Wolverine 1263136423:: E a computer: Wolverine systemes_visualisation

Explanation :

  1. the first column is a Unix Timestamp ,
  2. the second is the IP address (I'm working on localhost ;-))
  3. the third is the action performed (C created, E edited ,...)
  4. the fourth is straightforward,
  5. the fifth is the ID of the person who modified the page
  6. and the last column is the smallest text you can perform when you edit a page ...
Now just turn this tree into a log file readable by Gource . To do this, I developed a small python script named gourcedoku.py:

#!/bin/python

"""
This program parse logs of a dokuwiki
and tranform them for gource (a log viewer)
http://code.google.com/p/gource/

developped by WolverineX02
site : http://wolverinex02.blogspot.com

"""

import os.path
import getopt
import sys
import re



def listdirectory2(path):
"""list all the files like *.changes,
read them and output them in gource's log syntax
"""
for root, dirs, files in os.walk(path):
for i in files:
if (re.search('\.changes$', i)):
fichier = os.path.join(root, i)
myfile = open(fichier, 'r')
for line in myfile.readlines():
mots = line.split()
if len(mots)>=5:
resultat = mots[0] + "|"
resultat += mots[4] + "|"
resultat += translate(mots[2]) + "|"
resultat += fichier
print resultat
elif len(mots)==4:
resultat = mots[0] + "|Anonymous|"
resultat += translate(mots[2]) + "|"
resultat += fichier
print resultat
myfile.close()

def translate(mot):
"""translate the dokuwiki vocabulary to the gource one
C -> A
E -> M
other -> M
"""
if mot == "C":
return "A"
elif mot == "E":
return "M"
else:
return "M"

def main(argv):
"""principal function
"""
try:
opts, args = getopt.getopt(argv, "hd:", ["help", "dokuwiki="])
except getopt.GetoptError:
usage()
sys.exit(2)
for opt, arg in opts:
if opt in ("-h","--help"):
usage()
sys.exit()
elif opt in ("-d","--dokuwiki"):
print listdirectory2(arg)


def usage():
"""this function will display how to use this script
"""
print "This script will output change logs of a dokuwiki"
print "in a friendly way for gource"
print "how to use it :"
print "python gourcedoku.py -d ~/Sites/MyDokuwiki/ | sort > dokusort.log"
print "and then :"
print "gource --log-format custom dokusort.log --stop-position 1.0 \ "
print "--stop-on-idle --file-idle-time 10000000"
print "---"
print "-h : help "
print "-d : meta directory of your dokuwiki"


if __name__ == "__main__":
main(sys.argv[1:])


To start it, nothing more simple, launch the script in yout dokuwiki directory :

python gourcedoku.py -d ~/Sites/MyDokuwiki/ | sort > dokusort.log
then view the result with Gource with the following command:
gource --log-format custom dokusort.log --stop-position 1.0 --stop-on-idle --file-idle-time 10000000

I will try to put this code on the site Gource site ;-) Feel free to ask me questions or to improve my script.

Sunday, January 24, 2010

Chromoxy

I have just read the article from LifeHacker on how to block ads in Chrome browser Goolge ... ce serait un peu comme l'extension AdBlock Plus pour Chrome ;-) voir même encore un peu plus que seulement filtrer les publicités sur Chrome... This would be like the AdBlock Plus extension for Chrome ;-) see even a little more than just filter the ads on Chrome ... Je me suis dit que c'est pas mal mais pas très automatique ;-) j'ai donc écrit un petit script pour cela : I told myself that it's not bad but not very automatic ;-) so I wrote a little script for that:

#!/bin/sh / bin / sh

# Demarrage de Privoxy # Starting Privoxy
cd /Applications/privoxy/ cd / Applications / privoxy /
./privoxy & . / privoxy &

# demarrage de Chrome # START Chrome
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --proxy-server="http://127.0.0.1:8118" / Applications / Google \ Chrome.app / Contents / MacOS / Google Chrome - proxy-server = "http://127.0.0.1:8118"

# retour maison # Return home
cd cd
et en utilisant Platypus , il devient super facile de créer ensuite une véritable application : and using Platypus, it becomes super easy to then create a real application:

Facile non ;-) si vous êtes intéressés, je peux continuer à développer cette "application". ;-) Not easy if you're interested, I can continue to develop this "application". J'attends vos retours I await your return

Sunday, December 13, 2009

How to import Mac OS X's icons in Visio

You certainly know the program Visio (Microsoft Office) that allows to make beautiful diagrams ... the only small snag, Visio's icons are particularly ugly... Therefore let me show you two techniques to import the beautiful Snow Leopard icons in your Visio.

Method: by hand

Select the application whose you want import the icon (with the famous Apple + C), then open the Preview application and choose "New from clipboard"
you will just have to save it as and choose the PNG format. You can now import your image into Visio.

Second method: using a script

The previous method let you to extract only an icon at a time, if you want to retrieve all the icons of Mac OS X, you can use the following python script:


/bin/python

import os
import re

text = "0000"
out = "~/Pictures/"

stdout_handle = os.popen ( "find / -name *. icns", "r")
while (text !=""):
stdout_handle.readline text = ()
regnamefile = re.compile ( '\/([^//]*)\. icns')
namefile = regnamefile.findall (text) [0]
Reglin = re.compile ( '(\/ .*\. icns)')
line = regline.findall (text) [0]
os.system ( "sips-s format png"+line+"-out"+out+namefile+".png")

Beware the indentation : it is the python ... ;-) The script first look for all icns file (the format of the icons of Mac OS X ;-) ;-)), then apply a transformation using the application sips available on Mac OS X. All files in PNG format will be created in your pictures folder ...

That ;-) I hope you will make beautiful patterns after that.

Sunday, June 08, 2008

Installing Wikicalc: the most beautiful OpenSource spreadsheets

As I indicated in my last post: WikiCalc is a collaborative spreadsheet operating on the principle of wiki. It is completely written in Perl. To install Wikicalc, nothing more simple, just start by installing the necessary tools for your good old Debian:
apt-get install apache2 libapache2-mod-perl2
Then download sources: wikicalc-1-0.tar.gz. Then can begin the installation process itself:
cd /var/www
tar xvzf wikicalc-1-0.tar.gz
ln -s wikicalc-1-0 wikicalc

Now you have to let the Wikicalc engine to be accessible from your Web server: compared to the configuration by default, you just need to add these few lines :



NameVirtualHost *

ServerAdmin webmaster@localhost

DocumentRoot /var/www/wikicalc/

Options FollowSymLinks
AllowOverride None


Options Indexes FollowSymLinks MultiViews ExecCGI
AddHandler cgi-script .cgi .pl
AllowOverride None
Order allow,deny
allow from all





Load Perl module:
a2enmod perl
restart /etc/init.d/apache2

To finish the installation, go to http://wikicalc.monsite.com/wikicalccgi.pl and follow the instructions ....

Now you can play with this imressive spreedsheat

Saturday, March 22, 2008

Fulguro

A new site, soon... I am sure you will enjoy it, so come and join me at http://fulguro.fr/ . People who like Goldorak will enjoy this site, I am sure of it ;-)

Wednesday, January 02, 2008

Simataï : the best part of the great wall

Simataï is probably the best part of the great wall, it is a bit farer than the other part of the great wall, nevertheless it is probably the more typical part of this monument. You will need good shoes to go there and a good health. Be careful there are some bees in the wall and if you are lucky you might be see some bats.

The best way to wish a happy new year

May this new year 2004 will be more prosperous for us all! We wish you all the best for the year 2004. We hope you will get good luck in your life.