Overblog
Suivre ce blog Administration + Créer mon blog
3 juillet 2012 2 03 /07 /juillet /2012 12:11

 

 

Zenity is just a great program for doing quickly a Graphical User Interface on Linux.

 

I am sure you can understand the following program, which asks if you want to increase or decrease,

and runs "./increase" or "./decrease" accordingly:

 

===========================================

 

#!/bin/bash

 

while [ true ]

do

#uses zenity to ask first.

zenity --question --title "Difficult level" --text "Increase ?" --ok-label="Increase" --cancel-label="Decrease"

if [ "$?" -eq "0" ]

then

./increase

else

./decrease

fi


done

===========================================
Isn't it easy ? The loop is here so that the user can call increase or decrease many times...
zenity.jpeg
And you get this =======================>
and a great tutorial:
Partager cet article
Repost0
29 août 2011 1 29 /08 /août /2011 06:10

Vous voulez des jeux éducatifs bons et gratuits ? Des solutions existent; je les rassemble ici en tâchant d'avoir le lien direct vers la page utile:

Partager cet article
Repost0
24 août 2011 3 24 /08 /août /2011 04:36

Preliminaries:

Octave is a just great free software, very good alternative to the expensive Matlab.

It does not handle multiprecision (to keep it simple, let's say that multiprecision is computation

with very high precision).

Aribas is a GNU free tool for multiprecision.

This page presents a simple tool for using Aribas within Octave.

 

Keywords:

- Fractals

- Multiprecision, high precision computing

- Opensource software (Octave, Aribas)

- Buggy source code

 

Why multiprecision matters ?

Sometimes, computation errors cumulate until reaching a very significant level.

It is widely claimed that the satelite-lifting rocket Ariane 5 exploded due to computation errors

(see www.intel.com/standards/floatingpoint.pdf  for more on this example and other examples).

 

Download:

you just have to put the following lines in a file "aribas_eval.m",

in the exec path of octave:

============ aribas_eval.m ===================

function r=aribas_eval(s)
  n=round(rand*10000);m=round(rand*10000);
  chaine=(sprintf('echo "%s.\nexit" | sed ''s/\\^/**/g'' > /tmp/test%d%d.ari ',s,n,m));
 system(chaine);
  system(sprintf("aribas -b /tmp/test%d%d.ari | tail -1 |sed 's/_//g' > /tmp/testb%d%d.ari",n,m,n,m));
  r=load(sprintf('/tmp/testb%d%d.ari',n,m));
 system(sprintf('rm /tmp/test%d%d.ari /tmp/testb%d%d.ari',n,m,n,m));
end

==============================================

 

How to use:

- Write your code with the Octave "eval" function for the computations that you want to see in multiprecision.

- Check that it works

- Replace "eval" by "aribas_eval"

     ==> this is supposed to be a multiprecision version

     ==> however, there are plenty of bugs

 

Example:

mod(eval("(2**250)-1"),256)

    returns 0 (which is wrong --- precision error)

mod(aribas_eval("(2**250)-1"),256)

    returns 255 (which is ok)

 

Important remarks:

- no guarantee

- known bugs: handles only a very small subset of Octave's function

- this will be maintained and improved only as long as there is no better such functionality in Octave

- if you know a better way for doing this in octave just tell me and this page will disappear

 

Contacts:

   olivier . teytaud

      at  gmail . com

I am the only responsible of any mistake in the code. The code is not guaranteed, it is even not guaranteed to do

anything which is useful for anyone - if you use it, you have to check yourself that it is ok for you.

The code is completely free (free code, free of charge).

Partager cet article
Repost0
17 juin 2011 5 17 /06 /juin /2011 21:40

 

What is rengo ?

Rengo consists in having two players playing Go as a team, without communicating - each player plays in turn.

 

What is this page about ?

You have two programs which play Go in GTP and you want to use them as a Rengo pair - this page is for you.

 

Where can I download this script ?

http://www.lri.fr/~teytaud/rengo1.1.tgz

 

How to use it ?

- uncompress the archive: "tar -zxvf rengo1.1.tgz"

- Modify gtpmogo1 and gtpmogo2 - these are the two scripts which are called by the rengo program.
   They are supposed to speak GTP, or sufficiently of GTP for your use.
   For example, "gtpmogo1" might be simply "/usr/games/gnugo --mode gtp" and
   "gtpmogo2" might be simply "/usr/games/mogo --9 --nbTotalSimulations 5000". Then, gnugo and mogo
   will play the rengo together.
- Then the script "rengo" is a GTP program which uses the two programs above in turn. The first
   player is randomly chosen.
- The script "compa" launches games between "rengo" and another script, "gtpmogo".
- The script "check" gives results of the "compa" script.

 

So what ?

- you can use it in gogui

- you can use it in gogui-twogtp

   so you can do experiments like "what if program A plays againt programs B and C"

   or "what if programs A and D play againt programs B and C".

 

Bugs:
- There are more bugs than I can list here. Only the main ones below :-)
- Sometimes some codes are not properly killed. Kill manually :-)

- Some time is lost in some "sleep" commands (yes, it's dirty programming). So the CPU is not fully used.

    But with non-negligible time setting this should be negligible (maybe :-) )

 

Help:

- send an email if you have troubles - I'm happy when my codes can be useful to anyone :-)

Partager cet article
Repost0
12 mai 2011 4 12 /05 /mai /2011 06:04

 

For some reason, you want to back up you blog:

  • Possible reason 1:you want a copy that will still work if some images (links) disappear (images which

              are included from the web are not duplicated - if they disappear from the web your image disappears).

  • Possible reason 2: you don't trust over-blog for backups.
  • Possible reason 3: you want to study it offline.
  • Possible reason 4: you want to migrate to another website.
  • Possible reason 5: you have to be able to show what was your blog at a given date (e.g. plagiarism).

 

Under Linux, there is a very simple solution, as follows:

 

  • Version without image:

 

                 wget -r -np -k http://teytaud.over-blog.com/

 

 

  • Version with images and all necessary elements for proper local display:

 

                  wget   --page-requisites -r -np -k http://teytaud.over-blog.com/ 

 

Unfortunately this does not download images from other websites, which is a trouble for the

possible reason 1.

Maybe you can see http://lifehacker.com/161202/geek-to-live--mastering-wget,

or do a little bit of scripting.

Partager cet article
Repost0
8 mai 2011 7 08 /05 /mai /2011 15:13

 

Blind-Go is to the game of Go what Blind-Chess is to chess: playing just orally, without

any board (or possibly with an empty board as a visual support).

 

OneColor-Go consists in playing with just one color for stones - you have to remember which stones are yours

and which stones belong to the opponent.

 

If you want to play blind-go on your computer, the best interface I know is "qgo".Qgo has also a "one-color go" option.

 

If for some reason, you prefer gogui (like me, because it's more convenient for connecting to a bot),

you have to modify "gogui" because there's no option for this.

 

You can just download the source,and remove the drawing options; but if you're too lazy for it,

you can download http://www.lri.fr/~teytaud/blindgogui.tgz . It's just a minor modfiication of the sources,

and I will remove it if one day the official gogui includes a "blind go" option.

 

I've also made a hack for "one-color go": http://www.lri.fr/~teytaud/gogui-1.3.0onecolorgo.tgz

 

Compilation from the sources:

- install ant,  xsltproc,  and the Docbook XSL Stylesheets (with e.g. aptitude under Ubuntu)

- get in the directory, type "ant"

 

Then, you can launch it by

java -jar ./lib/gogui.jar -size 9

(just for launching gogui in blind mode or one-colonr mode)

 

or if you want to connect directly to our program:

  java -jar ./lib/gogui.jar -size 7 -program '/home/olivier/mogoblindgo --9 --nbTotalSimulations 200 --earlyCut 0 --minNumberOfSimulationsOfResign 190 --firstMoveFixed -1'

 

Info: our program MoGoTW (from LRI laboratory, Inria Saclay, TAO team, UMR Cnrs)

         won in blind-go against top players (with the help of Grid5000 and NUTN)

 

Partager cet article
Repost0
25 juin 2010 5 25 /06 /juin /2010 10:55
Transférer des gros fichiers c'est fatigant, parce que souvent ça plante avant la fin. Comment faire ? Ouf, Linux et Unix ont pensé à tout: en plus des classiques "ftp" et "scp", rappelés ci-dessous, il y a le fabuleux rsync que vous devez absolument connaitre.
  • Souvent dans la vie, vous transferez le fichier "localfile" sur le repertoire "directory" de la machine "remotehost", genre avec ftp, ou avec scp:
    scp localfile remotehost:directory/
  • Et des fois paf! Ca s'arrete en route. Mince alors. Faut-il reprendre au debut ?
  • Et ben non! Et cette page sert a l'expliquer :-)
  • Pour reprendre le transfert la ou il en etait,
    rsync -vrPt -e ssh localfile remotehost:directory/
  • Et ca marche aussi si "localfile" est en fait un repertoire.
Partager cet article
Repost0
25 juin 2010 5 25 /06 /juin /2010 10:40

Régulièrement, qqn se perd dans les outils de clefs publiques/clefs privées; ces lignes sont là pour expliquer la base de "ssh_keygen".

  • A quoi ca sert ? a se logguer de maniere un peu sure sur une machine distante Y depuis une machine X sans aucun login/password a taper.Parfois aussi, à faire du git, cvs, svn, etc.
  • Comment faire ? Si vous n'y connaissez rien et n'avez pas envie de comprendre, allez tout de suite au point ci-dessous "simplification". Sinon:
    • Installez vous sur la machine X
    • Taper "ssh-keygen -t rsa1" (selon le systeme, il peut s'agir d'autre chose que rsa1; rsa, dsa... ).
    • La machine vous demande de choisir un nom de fichier, en general vous n'avez qu'a accepter son choix en tapant entree.
    • Ensuite, ssh-keygen vous demande une passphrase; en general, il sera plus simple de rentrer une passphrase vide en tapant juste "entree".
    • On vous redemande la passphrase, tapez la meme.
    • Deux cas:
      • rsa1: On vous raconte des choses et en particulier on vous dit ou est votre clef publique. Copier la a la fin du fichier "~/.ssh/authorized_keys" (si ce fichier n'existe pas, creez le) SUR LA MACHINE Y (ca marchera pas en le faisant sur la machine X!).
      • rsa2: On vous raconte des choses et en particulier on vous dit ou est votre clef publique. Copier la a la fin du fichier "~/.ssh/authorized_keys2" (si ce fichier n'existe pas, creez le) SUR LA MACHINE Y (ca marchera pas en le faisant sur la machine X!).
  • Simplification dans le cas où vous n'avez de ".ssh" nulle part (genre vous n'avez jamais fait de ssh-keygen):
    • Placez-vous sur la machine X (celle où vous êtes là tout de suite) "ssh-keygen -t dsa"     ou   "ssh-keygen -t rsa" (ou les deux, ça peut pas faire de mal) ==> ne mettez aucune passphrase (tapez entrée)
    • Puis, pourchaque machine Y où vous pouvez avoir besoin de vous logguer "scp -r .ssh monlogin@machineY.truc.com:.ssh"

Ce fichier est deliberement ultra-simple et me permet de simplement depanner des gens peu familiers de cette procedure. Merci de me signaler tout manque de clarte par mail .

 


Partager cet article
Repost0
25 juin 2010 5 25 /06 /juin /2010 10:27

Vous ne connaissez pas valgrind ? Ca doit être dur le débugguage. Allez, prenez le temps d'apprendre valgrind, c'est vraiment pas long pour démarrer!


1) Installer valgrind, c'est facile:

- sous ubuntu/debian: sudo apt-get install valgrind

- sous mandriva: urpmi valgrind


2) Et pour utiliser en débugage: c'est facile aussi:

  • vous compilez avec -g (sinon ca marche pas!):  

                                 g++ -g -o mon_code mon_code.cpp

  • si votre code c'est "mon_code arg1 arg2", vous faites

                        valgrind --leak-check=yes mon_code arg1 arg2

     (arg1 et arg2 sont des arguments, votre code n'est pas obligé d'en avoir...)

 

3) Et vous voulez "profiler", c'est-à-dire savoir où ça rame ?

Utilisez l'option callgrind:

 

valgrind --tool=callgrind mon_code arg1 arg2

kcachegrind

 

(la deuxième commande fait un affichage graphique)

 

4) vous voulez aller plus loin ? allez la

Partager cet article
Repost0
25 juin 2010 5 25 /06 /juin /2010 10:18

Si vous êtes développeur et ignorez la gestion concurrente de versions, vous ne pourrez plus vous en passez!

Remarques:
- CVS est souvent remplacé par SVN. Ca fonctionne presque pareil.
- Git est un peu différent, par absence d'une référence centralisée. Mais si vous savez faire du CVS vous apprendrez vite git.



A quoi ca sert


  • principalement, a coder a plusieurs sur un meme projet, typiquement de programmation
  • aussi, a rediger des rapports collaborativements, du moins pour les logiciels de traitement de texte "compiles", comme LaTeX.


Méthode:


Un serveur S, gere par un administrateur A, contient des "repositorys" contenant chacun une arborescence de fichiers.
  • Pour pouvoir utiliser le serveur S, un utilisateur U doit: demander à l'administrateur A de lui ouvrir un compte.
  • pour cela, l'administrateur A va typiquement demander a U
  • un login
  • un password
  • l'administrateur A va aussi fournir a U:
  • un type de serveur (typiquement "pserver")
  • un identifiant genre "machin@truc.org"
  • un chemin, genre "/users/truc/machin/cvs
ou bien directement un CVSROOT de la forme
CVSROOT=:pserveur:machin@truc.org:/users/truc/machin/cvs

  • l'utilisateur U va alors pouvoir s' "enregistrer"; pour cela, U va lancer
    cvs -d :pserveur:machin@truc.org:/users/truc/machin/cv s

  • U peut alors recuperer sa copie du repository:
  • s'installer dans le repertoire /users/moi/oujeveux
  • taper "cvs checkout R" avec R le nom du repository et voir qu'il y a desormais /users/moi/oujeveux/R

  • Quand U veut mettre a jour sa copie (i.e. profiter des ameliorations apportees par les autres personnes travaillant sur le projet), il tape simplement
    cd /users/moi/oujeveux/R ; cvs update -d

  • Quand U est content de sa copie (tout compile, a minima), il peut l'envoyer sur le serveur en tapant
    cd /users/moi/oujeveux/R; cvs update -d ; cvs commit -m mon_message_pour_dire_ce_que_j_ai_fait
    Attention; si U est malchanceux, cvs update peut lui repondre qu'il y a des "conflicts" dans certains fichiers. Il convient alors d'editer les fichiers problematiques, et de corriger manuellement les problemes, signales nettement par des balises, puis de recommencer apres avoir bien verifie que tout est ok, compile, etc.


  • Beaucoup d'options sont possibles (droits differents des utilisateurs, etc)
  • Interface graphique: cf "cervisia" sous Linux ou "wincvs" sous windows
  • Autres outils que cvs: svn (alias subversion)
  • Doc plus complete: ici

Corrections, ajouts: mailez moi
Partager cet article
Repost0