mardi 15 décembre 2009

Bash tricks ":", la commande qui ne fait rien

En bash, la commande ":" ("column", ou "deux points") est une commande qui prend autant d'arguments que l'on veut mais qui ne fait rien.

C'est en particulier pratique pour commenter dynamiquement du code.
Par exemple :


#!/bin/bash
#DEBUG=echo
DEBUG=:

if [ -f /tmp/toto ]; then
$DEBUG "/tmp/toto existe"
echo `date` >>/tmp/toto
else
$DEBUG "/tmp/toto n'existe pas"
echo "fichier cree a `date`" > /tmp/toto

fi


Exem

Autour du code source et des programmes Java

SONAR :




Sonar est une plate-forme libre (LGPL v3) permettant de gérer la qualité du code source Java (exécution de tests unitaires, analyse de la couverture du code par ces tests, vérification du respect des règles de codage, complexité du code, etc.).
(depuis : dlfp )

http://sonar.codehaus.org/


FindBugs :




FindBugs is a program to find bugs in Java programs. It looks for instances of "bug patterns" code instances that are likely to be errors.


http://findbugs.sourceforge.net/
Éradiquer les lignes de code commentées

Forge des greffons Sonar


FindBugs serait en particulier beaucoup utilisé chez Google.

mercredi 4 novembre 2009

Multitâche ou pas ?


rabroué le multitâche

Qui l'eut cru ? Utiliser plusieurs applications simultanément ne nous rend pas plus productifs. Bien au contraire. Selon les scientifiques, le multitâche a plutôt un effet nocif sur notre cerveau car le changement de contexte permanent dégrade la mémoire et les capacités d'apprentissage. Sur le court terme, il nuit à la concentration et élève notre niveau de stress. Mais à plus long terme, il peut conduire à l'atrophie du cerveau. On n'était peut-être pas si mal lotis sous DOS…


01 Informatique n°1935, 07 Février 2008

jeudi 22 octobre 2009

Lire une iso de dvd video

Lire une iso de DVD vidéo.


mplayer dvd://1 -dvd-device FICHIER.ISO


Note : après, tout les racourcis de mplayer fonctionnent évidement.
Pour changer les sous-titres, par exemple, ce sera la touche "j".


Shortcuts mplayer

mercredi 21 octobre 2009

Bash "bind" command for defining keyshortcuts

http://www.geocities.com/h2428/petar/bash_bind.htm

On y trouve entre autre :


# Now map xterm's alternative keybindings to existing functionality
# Some are simple translations to correspontend M- combinations
# ctrl+left/right arrows:
bind '"\e\x5b\x31\x3b\x35\x44"':backward-word
bind '"\e\x5b\x31\x3b\x35\x43"':forward-word
# alt+b/f:
bind '"\xe2"':'"\M-b"'
bind '"\xe6"':'"\M-f"'
# atl+backspace:
bind '"\xff"':backward-kill-word
# alt+'.':
bind '"\xae"':yank-last-arg
# alt+k:
bind '"\xeb"':"\"\M-k\""
# alt+w:
bind '"\xf7"':'"\M-w"'

mercredi 14 octobre 2009

mount iso image via loopback under NetBSD

Mounting



# vnconfig vnd0 image.iso
# mount -t cd9660 /dev/vnd0a /mnt


Unmounting



# umount /mnt
# vnconfig -u vnd0



(Found here)

mercredi 30 septembre 2009

mardi 15 septembre 2009

Kernel Mode Setting (kms)

http://www.ubuntulinux.fr/index.php?post/2009/06/09/Tester-le-Kernel-Mode-Setting-(kms)-avec-une-carte-ATI


«Le kms est le fait que c'est le noyau qui apporte la gestion des accès à la carte graphique. Cela permet par exemple de faire tourner le serveur graphique sans lui donner de permissions de type root. Cela permettra également d'avoir des messages d'erreurs graphiques (l'écran marron de la mort ?). Et cela permettra d'éviter d'avoir des écrans qui scintillent/clignotent lors de changements de résolutions ou de basculements entre terminaux.»

dimanche 23 août 2009

live network trafic view ? iptraf, iftop

A explorer

http://www.commentcamarche.net/faq/sujet-848-linux-trafic-entrant-sortant-en-temps-reel


On trouvera ci dessous les extraits des deux manpages de iptraf et ethstatus.
Intéressant pour comptabiliser la quantité de données qui circulent sur les différentes interfaces, ainsi que pour monitorer quelles sont les connexions ouvertes.

Après un bref test, "ethstatus" m'a cependant l'air d'utiliser beaucoup de ressources CPU, et semble être surtout un reformatage des infos d'ifconfig. Peu intéressant donc.

Au contraire, "iptraf" était plus léger et apportait plus d'informations.

Egalement, iftop fourni plus d'informations et permet de lister les connextions courantes un peu comme "top" le ferait.






IPTRAF(8) IPTRAF(8)

NAME
iptraf - Interactive Colorful IP LAN Monitor

SYNOPSIS
iptraf { [ -f ] [ -q ] [ -u ] [ { -i iface | -g | -d iface | -s iface |
-z iface | -l iface } [ -t timeout ] [ -B [ -L logfile ] ] ] | [ -h ] }

DESCRIPTION
iptraf is an ncurses-based IP LAN monitor that generates various net‐
work statistics including TCP info, UDP counts, ICMP and OSPF informa‐
tion, Ethernet load info, node stats, IP checksum errors, and others.

If the command is issued without any command-line options, the program
comes up in interactive mode, with the various facilities accessed
through the main menu.



IFTOP(8) IFTOP(8)

NAME
iftop - display bandwidth usage on an interface by host

SYNOPSIS
iftop -h | [-nNpbBP] [-i interface] [-f filter code] [-F net/mask]

DESCRIPTION
iftop listens to network traffic on a named interface, or on the first
interface it can find which looks like an external interface if none is
specified, and displays a table of current bandwidth usage by pairs of
hosts. iftop must be run with sufficient permissions to monitor all
network traffic on the interface; see pcap(3) for more information, but
on most systems this means that it must be run as root.

By default, iftop will look up the hostnames associated with addresses
it finds in packets. This can cause substantial traffic of itself, and
may result in a confusing display. You may wish to suppress display of
DNS traffic by using filter code such as not port domain, or switch it
off entirely, by using the -n option or by pressing R when the program
is running.

By default, iftop counts all IP packets that pass through the filter,
and the direction of the packet is determined according to the direc‐
tion the packet is moving across the interface. Using the -F option it
is possible to get iftop to show packets entering and leaving a given
network. For example, iftop -F 10.0.0.0/255.0.0.0 will analyse packets
flowing in and out of the 10.* network.

lundi 20 juillet 2009

open microblogging tool (or : An open source twitter)

Laconi.ca is used on the website identi.ca as an open microblogging
tool. Microblogging is well known with the famous Twitter that allows
post of ~140 characters


The platform is freely (AGPL) available at :

http://laconi.ca/

There are plenty of plugins and application that can use it, and for
example it is working with :
* webinterface
* Jabber/GTalk
* email
* SMS


For those who only want to try it, they even made a concurrent of
twitter using the platform :

http://identi.ca/

tag: web, blog, php, opensource

jeudi 16 juillet 2009

Jgraph, command line tool for graphics

Command-line graph production.

The input describe some plotting or curving with a language quite straightforward to read and write, and produces an image (ps, eps, gif, ...).


Main Website :
http://www.cs.utk.edu/~plank/plank/jgraph/jgraph.html

Some examples & first hands on Jgraph :
http://www.cs.utk.edu/~plank/plank/classes/cs494/494/notes/Jgraph/lecture.html

"Brief Description"
"Jgraph is a program that takes the description of a graph or graphs as input, and produces a postscript file on the standard output. Jgraph is ideal for plotting any mixture of scatter point graphs, line graphs, and/or bar graphs, and embedding the output into LaTeX, or any other text processing system that can read postscript. "


There are 2 JGraph, and the most referenced on the web search engines is a Java library. This is obviously NOT about that jgraph...

PDF tool kit : pdftk

pdftk is a toolkit available for example on ubuntu repositories. It seems to be from the "PDF Hacks" book.


Main Webpage :
http://www.accesspdf.com/pdftk/


List of the features found on the website (Latest Version: 1.41, Released: November 28, 2006) :

  • Merge PDF Documents
  • Split PDF Pages into a New Document
  • Rotate PDF Pages or Documents
  • Decrypt Input as Necessary (Password Required)
  • Encrypt Output as Desired
  • Fill PDF Forms with FDF Data or XFDF Data and/or Flatten Forms
  • Apply a Background Watermark or a Foreground Stamp
  • Report on PDF Metrics such as Metadata, Bookmarks, and Page Labels
  • Update PDF Metadata
  • Attach Files to PDF Pages or the PDF Document
  • Unpack PDF Attachments
  • Burst a PDF Document into Single Pages
  • Uncompress and Re-Compress Page Streams
  • Repair Corrupted PDF (Where Possible)

vendredi 10 juillet 2009

svn + ssh on NetBSD

Problème : sur une machine uniquement accessible en ssh, je souhaite installer un serveur svn pour la gestion de version. Je souhaite avoir plusieurs utilisateurs. Ces utilisateurs doivent pouvoir faire des "checkout", des "commit", et autres opérations avec svn, mais ne doivent pas pouvoir se logguer sur le serveur pour autre chose que pour utiliser le serveur.

1ère étape :
Création d'un utilisateur svn qui sera celui utiliser pour se logguer sur le serveur.

1.1 Authentification par clefs publique/privée ssh

 Chaque utilisateur créé une clef ssh ( ssh-keygen ). Ajouter la clef publique générée dans ~/.ssh/authorized_keys

cat clef.pub > ~svn/.ssh/authorized_keys

Maintenant les utilisateurs peuvent se logguer directement en tant que l'utilisateur svn.

Allons voir un peu plus avant le contenu du fichier ~svn/.ssh/authorized_keys ...
Chaque ligne est indépendante, et de la la forme
  command="COMMAND" TYPE KEY COMMENT

En utilisant cette syntaxe, pour restreindre l'accès uniquement au service svn, on peut également ajouter "no-port-forwarding" ainsi que "no-agent-forwarding,no-X11-forwarding,no-pty"
  command="svnserve -t",no-port-forwarding TYPE KEY COMMENT

ainsi l'on utilisera une fois la clef ssh enregistrée (ssh-agent bash; ssh-add clef)

svn co svn+ssh://svn@host/path/to/base/repos




1.2 Plusieurs utilisateurs
Pour l'instant tout le monde se loggue en tant qu'utilisateur "svn". En particulier, il est ainsi impossible de différentier les auteurs des différents commits effectués.



ajouter l'option "--tunnel-user=user" également pour l'identifier.


2ème étape : Eviter d'avoir à afficher tout le path sur le serveur

Si le repo est dans /path/to/base/repos, alors :
  command="svnserve -r /path/to/base/",no-port-forwarding TYPE KEY COMMENT

Attention
:
il semble que l'option -r et l'option -t soient incompatibles si l'on utilise pas l'option --tunnel-user


3 Et Au Final...

Nous obtenons dans le fichier ~svn/.ssh/authorized_keys :
   command="/path/to/svnserve -t -r /repository/root --tunnel-user=alice",no-port-forwarding,no-agent-forwarding,no-X11-forwarding,no-pty TYPE1 KEY1 COMMENT1
command="/path/to/svnserve -t -r /repository/root --tunnel-user=bob",no-port-forwarding,no-agent-forwarding,no-X11-forwarding,no-pty TYPE2 KEY2 COMMENT2



1.4 liens/remerciements.



lundi 6 juillet 2009

PowerTOP

PowerTOP présente une fenêtre ressemblant à ce que rend la commande "top", mais en fonction de l'utilisation des ressources en terme d'énergie.
Il tourne pour les processeurs Intel, et propose même des suggestions sur comment diminuer la consommation (dé-activation de certains modules, augmentation du temps de certaines vérification faites trop souvent, etc.)

site web :
http://www.linuxpowertop.org


Message d'erreur

J'avais un message m'indiquant :
"no ACPI power usage estimate available"

Bien que n'empèchant pas powertop de tourner, il a pour effet de ne pas m'indiquer quelle est la consommation à un instant donné, ce que powertop sait faire (vu tourner lors d'une démo).

Trouvé un début de solution ici : Smop.co.uk:Power Saving on Linux. Il faut débrancher son portable de la source principale d'énergie. Malheureusement le changement n'est pas persistant, donc cette solution n'est pas parfaite.






NAME
powertop - program to analyze power consumption on Intel-based laptops

SYNOPSIS
powertop

DESCRIPTION
This manual page documents briefly the powertop commands.

powertop is a program that shows the power consumption on Intel-based
laptops and makes suggestions on how to extend battery lifetime.
The program is more fully described at http://www.linuxpowertop.org

mardi 2 juin 2009

Rubber : a LaTeX processing tool

I still have to test it with other .tex files, but I just discovered and tried "rubber", and LaTeX compilation seems to be pretty fast (for an 8 pages document).


It seems that it proposes a tool that compiles and analyses the LaTeX source file to generate either a ps, pdf or dvi, and to run the needed tools : makeindex, bibtex, etc. and all by itself without having to write a complicated makefile.



From "rubber" man pages :

NAME
rubber - a building system for LaTeX documents

SYNOPSIS
rubber [options] sources ...
rubber-pipe [options]

DESCRIPTION
Rubber is a wrapper for LaTeX and companion programs. Its purpose is,
given a LaTeX source to process, to compile it enough times to resolve
all references, possibly running satellite programs such as BibTeX,
makeindex, Metapost, etc. to produce appropriate data files.

The command rubber builds the specified documents completely. The
source files may be either LaTeX sources (in which case the suffix .tex
may be omitted) or documents in a format Rubber knows how to translate
into LaTeX (this currently means CWEB or Literate Haskell documents).
If one compilation fails, the whole process stops, including the compi‐
lation of the next documents on the command line, and rubber returns a
non-zero exit code.


Some Links :

mardi 21 avril 2009

date relative

Utilisation de la commande date pour calculer une date relative en nombre d'heures à partir d'une autre date.

  1. 1ère étape : entrer la date initiale avec date
    $ date --date='2009-03-23 12:00'


  2. 2ème étape : utiliser le résultat obtenu comme base pour y ajouter un décalage en nombre d'heures, soit donc :
    $ date --date="$(date --date='2009-03-23 12:00') +1001 hours"
    Mon May 4 06:00:00 CEST 2009



lundi 20 avril 2009

Aptitude, apt & cie. (Mainly for Debian, but Ubuntu works on the same way)

Ce post tourne autour des commandes apt, aptitude et dpkg

Installer une selection de paquets :


D'un côté :
$ dpkg --get-selections > liste-pkg

De l'autre côté :
# dpkg --set-selections < liste-pkg
# apt-get dselect-upgrade


Ressources non officielles de paquets pour Debian





Paquets installés automatiquement (jeux de dépendance)


$ aptitude why python-notify


Update automatique sans interaction humaine



export DEBIAN_FRONTEND=noninteractive
yes '' | apt-get -y -o Dpkg::Options::="--force-confdef" -o
X Dpkg::Options::="--force-confold" dist-upgrade


(originaire de : http://www.ouaza.com/livre/admin-debian/
site web du livre "Cahier de l'admin, sur GNU/Linux «Lenny» " )

Utile également :
https://help.ubuntu.com/community/Repositories/CommandLine

mercredi 1 avril 2009

convert .wmv to .avi

mencoder infile.wmv -ofps 23.976 -ovc lavc -oac copy -o outfile.avi

mercredi 4 mars 2009

commandlinefu

Fantastique !

http://www.commandlinefu.com

c'était un peu l'idée de ce blog au départ, bien que cela ait un peu dévié...

En se retrouve sur ce site avec un équivalent twitter, mais uniquement pour des lignes de commande !

exemple, cette commande que j'avais eu l'occasion de chercher un jour pour une vidéo prise avec mon appareil photo...
mencoder -vf rotate=1 -ovc lavc -oac copy "$1" -o "$1"-rot.avi

jeudi 26 février 2009

Imprimer des transparents

Imprimer des transparents

Dont un script que j'avais écrit il y a (très) longtemps pour imprimer des transparents :




#!/bin/bash

# convert .pdf slides into ps files with 4 slides/page

# takes : PDF documents in landscape (-l) or portrait (-p) orientation
# returns : PS document with 4 slides per page [file names $PREFIX*.ps]
#
# pages to be read in rows: [1] [2]
# [3] [4]

PREFIX=p4-
FORMAT=a4
MODULO=2:1,0
#

while getopts "lpb:f:h" opt ; do
case $opt in
f)FORMAT=$OPTARG;;
p)echo "Potrait mode"; MODULO=4:0,2,1,3;;#MODULO=4:1,3,2,0 ;;
l)echo "Landscape mode"; MODULO=2:1,0 ;;
b)PREFIX=$OPTARG;;
h)
cat < < EOF
convert .pdf slides into ps files with 4 slides/page
usage : $0 [-f] [-l|-p] [-p]
options :
-l landscape document (default)
-p portrait document
-f=FORMAT paper format (default is a4)
-p=PREFIX prefix appened to filename (default is "p4-")
-h this help message

For a fast use, just use 'pdf4ps file1.pdf file2.pdf',
and it will produce 'p4-file1.ps' and 'p4-file2.ps'.
EOF
exit;;

?)echo "Error : bad option. Try $0 -h"
exit;;
esac
done

shift $(($OPTIND - 1))

for i in "$*" ; do
if [ ! -f "$i" ]; then
echo "No file $i"
else
OUTFILE=$PREFIX`basename "$i" .pdf`.ps
if [ ! -f "$OUTFILE" ]; then
pdftops "$i" - \
| pstops "$MODULO" \
| psnup -4 -d1 -m0.2 -s0.5 -c \
| psresize -P"$FORMAT" -p"$FORMAT">"$OUTFILE"
else
echo "$PREFIX version of \"$i\" already exist ($OUTFILE)"
fi
fi
done

# Corentin Mehat oct2005-oct2006
# please send all bugs & ameliorations

# pdftops $i - \ # softs are to use ps files, convert the file to ps
# | pstops 2:1,0 \ # reorder mod 2 : odd, even
# | psnup -4 -d1 -m0.2 -s0.5 -c \ # border=1 margin=0.2 scale=0.5
# | psresize -Pletter -pletter>$OUTFILE # recenter

mercredi 25 février 2009

Quine : self-replicating program

Quines are programs who print their own source code when run.
For example in lua, this is a quine :

s="s=%qprint(s:format(s))"print(s:format(s))

mercredi 18 février 2009

Splitting and Merging pdfs

Pdfsam : PDF split and merge.

Open source tool to split and merge pdf

http://www.pdfsam.org/

lundi 9 février 2009

SLOCCount, compter le nombre de lignes de code

SLOCcount, permet de compter le nombre de ligne de code dans un répertoire
en déterminant automatiquement grace à différentes heuristiques de quel langage il s'agit.

Page web :
SLOCcount

lundi 19 janvier 2009

HotCRP Conference Management Software

HotCRP Conference Management Software

HotCRP is conference management software: it accepts paper submissions and manages the review process. Many conference management packages are available nowadays, including START/Softconf, Linklings, EasyChair, and Dirk Grunwald's original CRP. (I haven't used Conferencereview.com or Continue.) HotCRP is better than the original CRP. Relative to the others, as of early 2007 it is easier for PC members to navigate from paper to paper and to search for papers in HotCRP, but START's single-page paper submission form is easier than HotCRP's paper submission process (HotCRP includes an email validation step). If you don't like HotCRP try START. Linklings is not in the same class.

HotCRP is open source and requires that you run your own server, although the initial setup process is quite easy and should take about 15 minutes on a modern Linux or BSD box. Software requirements: Apache, PHP version 5 or higher, and MySQL version 5 or higher, plus several PHP packages. The README for the latest release has more.

HotCRP was written for the HotNets V workshop in 2006, and used thereafter for USENIX 2007, SIGCOMM 2007, and SOSP 2007, among many others. It is based on Dirk Grunwald's CRP but is mostly rewritten by now.

Git repository

git clone git://read.cs.ucla.edu/git/hotcrp LOCALDIR
Gitweb source code browsing

jeudi 15 janvier 2009

Tomboy and python, using dbus

Tomboy expose a bunch of methods on the dbus interface.

Dbus is a kind of component-oriented middleware comunicating by messages.

Here http://arstechnica.com/journals/linux.ars/2007/09/26/using-the-tomboy-d-bus-interface
I found a description of the dbus interface that tomboy propose to the programmer, so I gave it a try in order to implement a few scripts :

  • showAllNotes

  • showNotebook myNbkName




The previously cited blog article on arstechnica cites this deeper plugin example.




showAllNotes



#!/usr/bin/env python

## In Tomboy, display all the notes.

## Licence : GPL
## Date : 2009-01-14

# This uses the tomboy dbus interface and the methods exposed by tomboy

import sys, dbus, gobject, dbus.glib

# Get the D-Bus session bus
bus = dbus.SessionBus()
# Access the Tomboy D-Bus object
obj = bus.get_object("org.gnome.Tomboy", "/org/gnome/Tomboy/RemoteControl")
# Access the Tomboy remote control interface
tomboy = dbus.Interface(obj, "org.gnome.Tomboy.RemoteControl")

# Show every note
for n in tomboy.ListAllNotes(): tomboy.DisplayNote(n)




showNotebook



#!/usr/bin/env python

## In Tomboy, display all the notes labeled under a given "Notebook"

## Licence : GPL
## Date : 2009-01-14

# This is based on the underliying Tomboy tag mechanism (unused)
# knowing that a given notebook "mynotebookname" will be under the
# tag : "system:notebook:mynotebookname"
# (Thanks to irc.gnome.org#tomboy:sandy for the hint)


import sys, dbus, gobject, dbus.glib

# Get the D-Bus session bus
bus = dbus.SessionBus()
# Access the Tomboy D-Bus object
obj = bus.get_object("org.gnome.Tomboy", "/org/gnome/Tomboy/RemoteControl")
# Access the Tomboy remote control interface
tomboy = dbus.Interface(obj, "org.gnome.Tomboy.RemoteControl")

if len(sys.argv) > 1:
for note in tomboy.GetAllNotesWithTag("system:notebook:" + "".join(sys.argv[1:])):
tomboy.DisplayNote(note)
else : sys.stderr.write("Notebook name not specified. Exiting.\n")

Visual Diff and merge tool : meld

Meld



"Meld is a visual diff and merge tool. You can compare two or three files and edit them in place (diffs update dynamically). You can compare two or three folders and launch file comparisons. You can browse and view a working copy from popular version control systems such such as CVS, Subversion, Bazaar-ng and Mercurial. Look at the screenshots page for more detailed features."


http://meld.sourceforge.net/.



Alternative tools (see meld page) :

Kdiff3, Xxdiff, TkDiff, GtkDiff.

mercredi 7 janvier 2009

Copier-coller X

X window system, évidement !

Copier :
avec la souris, comme d'habitude

Coller :

shiftt+insert

lundi 5 janvier 2009

Molly-guard (for ssh)

Installant sshd sur mon eee ubuntu m'a conseillé d'ajouter également «molly-guard», dont je n'avais jamais entendu parler.

Found on http://packages.ubuntu.com/fr/intrepid/molly-guard

protects machines from accidental shutdowns/reboots

The package installs a shell script that overrides the existing shutdown/reboot/halt/poweroff commands and first runs a set of scripts, which all have to exit successfully, before molly-guard invokes the real command.

One of the scripts checks for existing SSH sessions. If any of the four commands are called interactively over an SSH session, the shell script prompts you to enter the name of the host you wish to shut down. This should adequately prevent you from accidental shutdowns and reboots.

This shell script passes through the commands to the respective binaries in /sbin and should thus not get in the way if called non-interactively, or locally.