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.