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