Archive for May, 2007

Javascript/CSS: Progressbar

test1 (html, 1 KB)
A progress bar or just a status bar that moves when loading the page. CSS+Javascript.

No Comments

Simple biff – check for new mail over ssh

This sweet littly script checks for new mail over ssh – and needs very little bandwidth, really no load on client and server, only one persistent connection and just one secure login (the ssh login on startup – unless you use keys).

First version:


ssh stud4.tuwien.ac.at -l e0123456 '
oldline=$(ls -l .inbox)
while true; do
line=$(ls -l .inbox)
if [ "$line" != "$oldline" ]; then
oldline="$line"
echo beep
fi
sleep 10
done
'

Second version:


ssh stud4.tuwien.ac.at -l e0123456 '
oldline=$(ls -l .inbox)
while true; do
line=$(ls -l .inbox)
if [ "$line" != "$oldline" ]; then
oldline="$line"
grep -E "^(From|Date|Subject):" .inbox |
tail -n 3 | { read a; read b; read c; echo "$b | $a | $c"; }
fi
sleep 10
done
'|while read line; do
mplayer biff.wav >/dev/null 2>&1
zenity --info --text="New Mail"
echo "$line"
done

The nice thing about this is that you can do on the client whatever you want .. play a sound … use zenity for a info box … etc.

BTW: I like /usr/share/sounds/gnibbles/reverse.wav as new mail sound …
all the others from find /usr/ -iname “*.wav” are to shocking for my nerves ;-)

No Comments

Herrlich …

stadt-aendern

Wien … Stadt ändern

No Comments

My backup plan

Everyone says, backups are important, but how do you backup? And have you ever tried replaying a backup?

My backup plan:
- Working copy on my laptop
- Compressed archive is created every week. I delete old backups infrequently.
- Infrequent rsync of working copy (filtered) to USB stick.
- rsync of working copy (filtered) to the university servers.
- Compressed archive copied to the university server.

I would say I’m quite secure …

Crontab entry: 0 */4 * * * cd backup && sh backup2.sh


#!/bin/bash
PARENT=/mnt/daten/Daten/
DIR=Studium/
SELDOMCHANGE='*.zip *.ps *.pdf *.rar *.tar.* *.jpg *.gif *.png'
BORING='*.log *.out *.xac *~'
LARGESERVER=a0123456@login.unet.univie.ac.at
SMALLSERVER=e0123456@stud4.tuwien.ac.at
SERVERS="$LARGESERVER $SMALLSERVER"
cd $PARENT
# part A:
# compress some file types that change seldom and send them over once a month
# that would be zip, ps, pdf, rar, tars, images,
FILENAME=Sicherungen/Full/seldom-changed-types-$(date +%W).tar.bz2
TARGETSERVERDIR=$LARGESERVER:Sicherungen/Full/
# create archive if it doesn't exist yet
[ -s $FILENAME ] || \
echo 'creating weekly archive' &&
find Studium -type f $( for i in $SELDOMCHANGE ; do echo "-iname" "$i" "-or"; done) -false | \
tar --create --bzip2 "--verbose" "--files-from=-" "--file=$FILENAME"
# lets sync that to the server
# commented out: files ~ 500MB :-(
#echo 'rsyncing weekly archive to server'
#rsync $FILENAME $TARGETSERVERDIR
# part b
# rsync the others
#
for SERVER in $SERVERS
do
echo 'rsyncing with ' $SERVER
TARGETSERVERDIR=$SERVER:Sicherungen/Studium/
for i in $SELDOMCHANGE $BORING; do echo "- $i"; done | \
rsync -az --checksum --delete-excluded --exclude-from=- $PARENT/$DIR $TARGETSERVERDIR
done
echo 'backup done.'

No Comments

Watch Wikipedia growing

The following bash script pops out recently edited wikipedia articles. Matrix-Style!

[ "$WIKI" != "" ] || WIKI="http://de.wikipedia.org/"
echo "using $WIKI";
UPDATEURL="$WIKI/w/index.php?title=Special:Recentchanges&days=1&limit=100&hideminor=1"
# lets get it first
while true; do
#echo "getting $UPDATEURL" 1>&2;
wget -q -O rc.txt $UPDATEURL
cat rc.txt | sed "s/<[^>]*>//g" | grep -Eo '\. \.    [^;]*' | grep -v ":" | sed "s/^\. \. *//g"
# next url
FROM=$(grep -Eo "from=[0-9]*" rc.txt|sort -nr|head -n 1)
UPDATEURL="$WIKI/w/index.php?title=Special:Recentchanges&days=1&limit=500&hideminor=1&$FROM"
sleep 60
done |
while read line; do
echo $line;
sleep 0.4;
done
}

No Comments

Lindex … der LVA Index

Von der Benutzer-Einleitung:

Hallo, und willkommen zu Lindex, dem LVA Index!

Idee: Das System ist dazu gedacht, sämtliche über verschiedene Systeme verstreute Informationen zu kombinieren, damit du nie wieder was verpasst. Einerseits Termine (Tests, Übungen), andererseits allgemeine Informationen (URLs, Skripten, Downloads).

Funktionsweise: Es wird darauf gesetzt, dass die Studierende selbst (bzw. ein Teil) die Moderation übernimmt. Sie fügen Informationen hinzu. Andere (die nicht-moderierte Feeds abonniert haben), kontrollieren den Eintrag, verbessern ihn. Bei der 5ten Bestätigung wird der Eintrag auf die moderierten Feeds durchgeschalten.

Die Hoffnung ist, dass weniger Zeit für Suchen und durchchecken von verschieden Systemen draufgeht. Besonders effizient ist es, wenn die Quell-URLs (wo gelesen) im Eintrag stehen oder auch die URLs für neue Dateien (Skriptum, Angaben, etc.).

Was ist zu tun? Testen, Benutzen, Moderieren, Feedback geben. Vielleicht einen Skin schreiben. Newsreader testen.

Viel Spass damit, Johannes Buchner (16.06.2006)

Wie gesagt, Feedback und Ideen sind willkommen. Kann unter http://jublogin.sourceforge.net/uni/lindex/index.php ausprobiert werden.

Source ist auch verfügbar: lindex-v0.5-utf8.zip (zip, 555 KB), und Datenbankdump: database_dump.sql (sql, 6 KB)

No Comments

Feedreader für Lindex

Hier werden geeignete Feedreader für Lindexdiskutiert.

Um zu testen, gehe auf die Lindex Startseite und wähle einen unmoderierten Feed von der TestLVA von der TestUni. Nachdem der Feed geladen wurde, ändere bei einem Eintrag Text oder Datum. Der Feedreader ist gut, wenn er die Änderung erkennt (als neu markiert und Datum und Text richtig ausgibt).

Empfehlungen

  • Windows: RSSOwl: Vorbildlich (sollte auch auf anderen Betriebssystemen gehen)
  • Linux: Liferea: Vorbildlich
  • Windows: RSSReader: Erstellt bei Änderungen einen neuen Eintrag
  • Firefox: Sage: Zeigt aber Datum nicht in der Liste an.

Getestet und nicht empfohlen

  • Linux: Akregator: Erkennt keine Änderungen.
  • Firefox: WizzRSS: Zeigt Datum nicht an.
  • Windows: Feedreader: Markiert geänderte Einträge nicht als neu/ungelesen
  • Thunderbird: Erkennt Änderungen nicht, unübersichtlich bei zu vielen Feeds.

Jeder ist eingeladen, dazu Kommentare zu posten.

No Comments

KTurtle

Oje, heute bin ich wieder kreativ …
In KTurtle:
vorwärts 100
nachlinks 5
vorwärts -50

logo

No Comments

Sweet Konqueror

punkt

No Comments

Maxima graphical output

I frequently use maxima (http://maxima.sourceforge.net/). Today I looked for related projects with GUIs.
wxMaxima is quite nice, it provides a good help at entering input.

But I miss writing mathematical sheets and just arrange the formulas and diagrams on it.

My first step to this is the php script at the end. I put my formulas in testformula1.txt, call the script php maxima2html.php >maxima2html.html and get a nice html output (at the left in the screenshot):

screenshot2


<style>
div.formula{
font-family: 'Lucida console', monospace;
font-size: small;
white-space: pre;
padding: 4px 1em;
margin: 2px;
clear: both;
float: left;
margin: 0px;
}
div.in{
border: 1px solid #FDD;
background-color: #D99;
margin-top: 5px;
}
div.out{
background-color: #9D9;
margin-left: 2em;
margin-bottom: 1px;
}
</style>
<?php
function cleantext($text){
$re = '/\(%[io][0-9]*\)/';
$ntext = preg_replace_callback(
$re,
create_function('$matches','return str_repeat("",strlen($matches[0]));'),
$text);
$ntext = str_replace("\t",str_repeat(' ',8),$ntext);
$lines = explode("\n",$ntext);
$padleft = NULL;
// find smallest intend
foreach($lines as $l){
$i = 0;
while($i<strlen($l)){
if($l[$i]!=" "){
if(is_null($padleft) or $i<$padleft){
$padleft = $i;
}
break;
}
$i++;
}
}
for($i=0;$i<count($lines);$i++){
$lines[$i] = substr($lines[$i],$padleft);
}
$nntext = join("\n",$lines);
return rtrim($nntext);
}
function readOutput($pipe){
$out = '';
$shell = '(%i';
while(!feof($pipe)){
$out .= fgetc($pipe);
if(substr($out,-strlen($shell),strlen($shell)) === $shell){
while(substr($out,-1,1)!=')')
$out .= fgetc($pipe);
break;
}
}
return $out;
}
function machflecken($pre, $class, $continue = false){
if(empty($pre)) return;
echo '<div class="formula '.$class.($continue?' continued':'').'">';
echo $pre;
echo '</div>',"\n";
}
$in = file('testformula1.txt');
$in[] = 'quit(a=b);';
$descriptorspec = array(
0 => array("pipe", "r"),  // stdin is a pipe that the child will read from
1 => array("pipe", "w"),  // stdout is a pipe that the child will write to
);
$out = '';
$process = proc_open('maxima -q', $descriptorspec, $pipes);
if (is_resource($process)) {
$out = cleantext(readOutput($pipes[1]));
machflecken($out,'start');
while(true){
if(empty($in)) break;
$cmd = array_shift($in);
fwrite($pipes[0], $cmd);
#print 'in: '.count($in).': '."\n".$cmd."\n";
$out = cleantext(readOutput($pipes[1]));
if(FALSE === strpos($cmd,'=')){
machflecken($cmd,'in',true);
machflecken($out,'out');
}else{
machflecken($out,'out');
}
}
stream_get_contents($pipes[1]);
fclose($pipes[1]);
$return_value = proc_close($process);
#echo "command returned $return_value\n";
}
?>

No Comments