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")