Main

4.08.10

Today I integrated a small but non-neglectable optimisation for my MT blog. In the era of again slow internet connections (on mobile phones for instance) a faster access to the menu can save you precious seconds and bytes. Therefore remember to place the the menu in the HTML structure before the content.

Now there might be some issues with the layout since the order changed. Fortunately MT integrates several standard layouts, thus I had to

  1. inverse the placement of the alpha and beta div
  2. change the beta div to delta in order to float right instead of left, and subsequently the beta-inner div to delta-inner too.

Note: alpha, beta and gamma are float:left; and only delta is float:right;

Simple and effective.

23.03.09

 

This might apply for any website where you enter text and preview it afterwards. I experienced a browser crash when writing the preceding blog entry. And as if a browser crash wasn't annoying enogh, I discovered I didn't save my blog entry when it was finished. Instead I previewed it and headed off doing other stuff, which ended in killing browser.

Sure, as a golden rule, always copy your text before you submit any form, since any website is suspect to lose your content. But I was young and foolish and didn't do that, and even the built-in autosave mechanism of Movable Type didn't save anything helpful.

But my luck was, I did preview it. The fact of previewing it made it possible to find it in the browsers' cache. I opened the terminal and entered the following:

grep <keyword> -r ~/Library/Caches/Firefox/

whereas <keyword> is to be substituted with a word that is for sure in your text but not very common. The same could be applied to Safari, which cache is accessible under ~/Library/Caches/Safari/. The output of the grep command is the filename followed by the line in which the keyword was found. If you found the right file, you can view the contents of the file with the command cat <path/to/file>.

25.05.08

matrix style code

"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it."

Auf gut Deutsch:

"Programmierfehler zu beheben ist doppelt so schwierig wie den eigentlichen Code zu schreiben. Daraus folgt, dass du, wenn den Code so raffiniert wie möglich schreibst, per Definition nicht schlau genug bist, um auch Fehler zu beheben."

Et pendant que j'y suis, je tente une traduction en français:

"Corriger des erreurs de programmation est deux fois plus difficile que écrire le code en soi. Par conséquence, si on écrit le code de la manière la plus raffinée que possible, on est par définition pas assez intélligent pour corriger les erreurs."

Original quote by Brian Kernighan, "The Elements of Programming Style", 2nd edition, chapter 2; slightly modified by Code Project.

22.05.08

heimspiel.be website ausschnitt

Gerade bin ich über die Seite heimspiel.be gesurft, weil ein Freund (Mike Neeser, für alle die ihn kennen) bei der Gruppe Sänger ist. Die Seite ist mit viel Aufwand und Liebe zum Detail gestaltet worden, mein erster Gedanke ist: "Da hat sich einer viel Mühe gegeben!" Als ich nun durch die Seiten blättere, fallen mir einige kleinere Stolperfallen auf.

Anmerkung: Ich will nicht die Implementation geschweige denn den Designer zerpflücken, sondern vielmehr die Informatiker, mich inklusive, vor der nur allzuhäufigen Betriebsblindheit warnen!

Die Seite hat als Navigation ein Register (Tabs, vertikal angeordnet). Schön gemacht, sehr intuitiv. Man klickt auf die Registerkarte, und das 'Booklet' blättert zu dem entsprechenden Bereich. Also schaue ich mal in die Galerie rein, Diashow, vorwärts, rückwärts, wie es sich gehört.

Es stehen zwei Bildersets zur Auswahl, rechts am Bildrand vertikal angeordnet. Ich klicke auf das nächste Bildersets, ganz nach dem frisch gelernten Registerkartenprinzip, doch nichts tut sich. Bei genauerem Hinsehen entpuppt sich die oberste Registerkarte als eine Art Guckloch, mit Pfeilen nach unten und oben. Bei einem Klick auf den unteren Pfeil verschiebt sich der Text unter dem Guckloch nach oben, und das nächste Bilderset erscheint.

Ich surfe weiter auf die Registerkarte Blog, und lese einen Eintrag, der mich angesprungen hat. Irgendwie endet der Eintrag nach kaum 3/4 der Seite mitten im Satz. Wie nun weiter? Ich sehe rechts an der Seite wieder so ein Ding ähnlich dem Guckloch von vorhin, und drücke auf den Pfeil nach unten. Der Text bewegt sich nicht. Nach einem kurzen Moment probieren stellt sich heraus, dass das Guckloch eine Scrollbar ist, die man ziehen muss.

Fazit für alle Designer von Grafischen Benutzeroberflächen (GUI): Der Benutzer ist ein Gewohnheitstier. Wenn er ein Konzept der Interaktion erlernt hat, so wird die Funktionsweise mit einem optischen Muster, Pattern, verbinden. Wenn nun ein anderes Element sich optisch zuwenig unterscheidet, wird das Pattern erkannt, obwohl die Bedienung nicht dieselbe ist. Resultat: der Benutzer versteht die Logik nicht und ist frustriert.

Ach ja, wenn wir schon dabei sind: Das ist mitunter ein Grund, warum ich OS X so super finde. Apple hat sich anscheinend einige solche Überlegungen gemacht, es geht oft einen Tick einfacher als mit Windows.

12.01.08

ramada encore hotel

This one is for all of the Webmasters out there.

ramadaencoregeneve.ch leads You to a website with the title "Jelmoli Holding AG: Detailhandel & Immobilien", whereas www.ramadaencoregeneve.ch leads you to the "Ramada Encore Hôtels" website.

To me, this is very poor webmastering. Not only do the two links not point to the same page as I'd expected, but it lets even leak out information which may not be intended for a larger public. But there is worse - the link without the www prefix leads to a dead end error page.

So... how is the configuration of the domains you administer?

22.11.07

37

Kleines Geek Quiz, merci MP!

Wenn du es schon gemacht hast und wissen willst, welche Tags ich vergessen habe, dann kannst du unter dem Link unten weiterlesen.

Continue reading "HTML Wissen" »

20.09.07

If You ever had to work with cascading style-sheets (CSS) which you didn't write entirely on Your own or with a CSS framework (such as YAML), then You probably asked yourself the same question as I did some days ago:
"Which classes are really used - and which could I delete without harm?"

An answer to this question I hoped to find on GoSquared.com, but the result was not really satisfying. The script had several bugs, making it nearly useless for me:

  • Only the first class / id in the css definition is taken into account
  • Multiple class names in the same class attribute were not recognised (resulting in "false positives")
  • Identical class / id will not report even if unused

But as it was pretty close to what I needed, I went ahead, corrected these bugs and implemented some improvements on my own:

  • Output prefixed with . respectively # to distinguish classes and id's
  • Support for multiple HTML / CSS pages (as in larger projects) added, use a comma-separated list as page parameter
  • Added an optional parameter "visual" which will make the script print the evaluated CSS and HTML to the browser window

As for a future version, one could integrate support for link type css definition <link rel="stylesheet" type="text/css" href="style.css"/> and probably its quite easy now to evaluate also inline CSS definitions. But as I won't use this functionality, I end the development here. Nevertheless everyone feel free to contribute!

23.08.07

This is a video about a very interesting technique for content-aware image resizing, also called retargeting:

(...)The simplest way to do this is to remove columns of pixels from the image. The best column to remove would be the least notable or the least important column. (...) However, using such an approach leads quickly to serious artefacts. Therefore, instead of using rigid colums we search for connected paths of pixels or seams from one side of the image to the other, that contain the least energy. (...)

For my fellow computer science students: what algorithm would you apply? Remember travelling salesman? Tree traversal algorithms? They'll be back!

Thanx to MTN for the hint.

3.08.07

blaues kleines blümchen

Manchmal ist mein Hirn wie ein Löchersieb. Darum den Eintrag als Gedankenstütze:

Komfortables PHP editieren mit VIM von Tobias Schlitt (direkt zum SVN Ordner der VIM-Skripte).

29.07.07

Quote from creativebits.org:

any example image

Don't hotlink, ImgRed instead

Hotlinking is when you use the image from one website on another website without copying the image to the second website's server.

Most website operators hate when people do that to their images if they don't link back to the source. (...) You can of course avoid all this problem by saving the image and uploading it to your own server. (...) [Alternatively] You can use the service called ImgRed. All you do is add http://imgred.com/ in front of the url of the image you want to display and ImgRed will take the image (once) and create a copy of it on ImgRed's servers.

I guess this was not the complete idea of the creator of imgred.com. It was rather to provide others with an easy-to-use showcase solution which everyone can adopt for their own server.

Unfortunately, the code is not ready for any server: if you don't have permission to run the PHP exec command on your host, which is very likely if you don't have a pro account, the script will fail. A very simple solution to this problem is to replace the user defined function GetMIMEType by the PHP function mime_content_type.

For my purpose, I set up a rewrite rule which allows me to add /imgred/ in front of the original URL of the image. Nevertheless it was tricky to find out that per default, any double slash // in a webhost path is reduced to a single slash. So I had to find the following workaround:

RewriteRule ^imgred/http:/(.*) /imgred.php?Image=http://$1
RewriteRule ^thumbred/http:/(.*) /imgred.php?Thumb=http://$1

The source code for the above image looks as follows:

<img alt="any example image" src="/thumbred/http://adsoftheworld.com/files/images/CalciWWF.preview.jpg" width="100%"/>

19.06.07

emi copy controlled logo

Für alle, denen der Name Jackson Pollock nichts sagt, aber die gerne mit Farben schmieren: jacksonpollock.org

Toll! Ich liebe so interaktive Flash-Programme. Das ist wirklich astrein und stilecht umgesetzt. Dann mal viel Spass! *g*

Tipp: [Shift] drücken, das trägt noch zur Allgemeinbildung bei.

6.06.07

Just discovered a bug in the blog engine: If you type var/ in the body of a blog post, you will get a quite funny

Forbidden
You don't have permission to access cgi-bin/mt/mt.cgi on this server.

The same occurs also with cgi-bin/, by the way...

Took me a few seconds to figure out what actually provoked the error. But with splitting it in halfs, it's not as cumbersome: First half = no error? Then look in the second half. Here again, split in halfs, and test one. And so on.

16.02.07

junkjunkjunkjunk© 2007 Apple Inc.

Probably not a lot of people reading my blog are using MovableType to blog themselves. Nevertheless I am very glad that I've solved my junk comment problem with this MT plugin: HMPassphrase

The mechanism is simple: The plugin introduces a new field in the comment submit form. If this field is not filled in correctly, the comment is rejected. This is a great relief for me since I usually had one spam comment every 10 minutes - at least.

So have fun to comment on any entry you like, an don't forget to fill "jaja" in the extra field...

Update: An excerpt from the activity log just to show how effective this is:

  Date IP Address Log Message
  8 minutes ago 217.17.22.195 HMPassphrase rejecting comment for blog 1
  14 minutes ago 202.175.26.151 HMPassphrase rejecting comment for blog 1
  14 minutes ago 61.60.21.226 HMPassphrase rejecting comment for blog 1
  30 minutes ago 202.158.165.82 HMPassphrase rejecting comment for blog 1
  37 minutes ago 84.19.184.204 HMPassphrase rejecting comment for blog 1

14.02.07

Apple AdressBook icon© 2007 Apple Inc.

Als ich mit Apple Adressbuch begonnen habe, meine Kontakte zu organisieren, habe ich nicht gerechnet, irgendwann mal im Ausland zu arbeiten. Ich habe meine schweizer Nummern ohne internationale Vorwahl eingegeben - was sich als Fehler erweisen sollte: Wenn ich mich im Ausland aufhalte, kann ich keine gespeicherte Nummer anrufen, die nicht mit 00 bzw. + beginnt.

Eine Suche bei Google nach Vorwahl und Applescript führte mich zu der Seite andare.ch, auf der David Reindl bereits ein gutes Applescript vorbereitet hatte. Allerdings führt das Ding einen vorbereitenden Test aus, um Fehlbedienung zu verhindern, der mir in die Quere kam. Also habe ich es umgeschrieben, so wie ich es brauchen kann: vorwahl_aendern.zip

Es arbeitet in 2 Schritten:

  1. Die Nummern mit internationaler Vorwahl 00xyz, die bereits Ausland-kompatibel sind, werden zu +xyz umgeschrieben.
  2. Die Nummern mit lokaler Vorwahl 0xyz werden international kompatibel umgeschrieben zu +41xyz.

Mit dieser Logik können unter der Voraussetzung, dass alle ausländischen Nummern bereits mit 00xyz oder +xyz notiert sind, fehlerfrei alle Nummern in einem Rutsch (naja, für Perfektionisten: mit zwei Loops) internationalisiert werden. Spart einen Haufen Zeit und Klickerei!

Das Skript kann natürlich auch schnell angepasst werden für Deutschland, Österreich oder sonst ein Land: Im Skripteditor die "+41" auf der 5.letzten Zeile mit der jeweiligen Landesvorwahl ersetzen. Vorausgesetzt wird jedoch, dass man ausschliesslich Nummern von einem Land ohne internationale Kennung hat.

21.12.06

I know that the planning for the next fribot challenge is already launched.

My suggestion for the task next year: build a vehicle piloted by a fish!

13.12.06

vtiger5 CRM installation protocoll on Mac OS X Server:

  • activate httpd/Apache (Server Admin.app -> Web -> Start service)
  • activate php (Server Admin.app -> Web -> Settings -> php4_module -> Save)
  • download vtiger source from sourceforge (vtiger CRM 5.0.2 Latest Stable -> Core Product -> vtigercrm-5.0.2.tar.gz) and the linux installation manual
  • unzip & copy to ~/Sites, open Terminal.app
  • cd ~/Sites/vtiger/
  • chgrp -R www .
  • chmod g+w config.inc.php cache test/wordtemplatedownload storage install install.php test/product test/user test/contact test/logo modules/Emails/templates user_privileges Smarty/templates_c tabdata.php parent_tabdata.php Smarty/cache (in the documentation it says chmod 777 ... - don't do that, it's a security threat)
  • done!

26.11.06

[no comment...]

30.10.06

Sometimes when You type an internet address, You don't supply a trailing slash to get the contents of a folder. Thus when actually wanting the file www.host.com/folder/index.html, You just type host.com/folder and hit enter. Up to now, my Apache had a configuration which enabled it to decide in a sort of intelligent way wether the request was a folder or a file.

But after moving to the new server, this property wasn't given anymore. To provide the user still with a similar functionality without need for root access, I figured a http rewrite command which does this:

RewriteRule ^(([^\.])+[^/])$ /$1/ [R]

What it does: any request (the server name is not included within the request), which doesn't contains a dot (".") and which doesn't end with a slash ("/") will be added a slash.

This looks pretty puzzling, and it took me a moment to figure it out. Let's analyse the different parts of it:

\.the character "." (without the backslash, "." a special operator)
^\.any character except "."
[^\.]class of all characters except "."
([^\.])*repetition 0 or more times of any character except "."
/ the character "/"
^/ any character except "/"
[^/] class of all characters except "/"
([^\.])*[^/] repetition 0 or more times of any character except "." concatenated with any character except "/"
(([^\.])*[^/]) above expression grouped for backreference
^ ... $delimiters to show beginning and end of the string
/$1/ redirect the request to the current host (/), to the path stored in the first backreference ($1), and add a trailing slash (/)
[R] stands for "rewrite", meaning that it will show in the address bar of the browser

This line is saved in a .htaccess file in the root directory of my server, after a line which says to enable the rewrite mechanism (RewriteEngine On).

Ain't that hard, after all, no?

5.05.06

The other day I thought about means to enhance battery life of my MacBook Pro. I'm used to the very looooong battery life of an 12" iBook, so the MBP's battery doesn't seem terrific to me. Besides the usual low brightness screen setting I disabled the second core via the Processor preference pane which is installed along with the CHUD tool from the developer tools.

Then I thought it would be great if, everytime you wake the system from sleep, a little script would check if the power adapter is plugged in and set the core's activities in function of that. It doesn't seem that there is a possibility to call a script on wakeup, but I found an alternative which can be called from your favourite app-launcher:

Use this link to create the applescript document or open the Scripteditor.app and paste the code below. Just preceed as described in the previous post: save as, enter a name, Application bundle. If you want to reactivate the core again, you have to change the applescript by uncommenting the line click menu item "2" of menu 1 of pop up button 1 and commenting the other line with two hyphens.

To change the number of active cores now, I hit [cmd][space] and type "mono" to save battery or "duo" when I need more power.

tell application "System Preferences"
    activate
    try
        set current pane to pane "Processor"
    on error
        display dialog "System Preferences pane \"Processor\" is not available.
You need Apple's CHUD-tools to be installed to change the number of active cores."
    end try
    try
        tell application "System Events"
            tell application process "System Preferences"
                activate
                tell window "Processor"
                    click pop up button 1
                    --to activate 2 cores:
                    --click menu item "2" of menu 1 of pop up button 1
                    --to activate 1 core:
                    click menu item "1" of menu 1 of pop up button 1
                end tell
            end tell
        end tell
        tell application "Finder"
            set visible of process "System Preferences" to false
        end tell
    on error
        tell application "System Preferences"
            activate
            set current pane to pane "com.apple.preference.universalaccess"
            display dialog "UI element scripting is not enabled. 
Check \"Enable access for assistive devices\""
        end tell
    end try
end tell

30.04.06

After spending a few nights I am proud to present the new Blog powered by Movable Type. I admit this has been quite a challenge to install, when it came to installing PERL extensions lets say – but everything is difficult you do it the first time, they say.

But what was most annoying was that i didn't find for quite a moment how to enable the comments – since it was for the comments I abandoned the other blogengine! The solution after all is simple, but you gotta find it: If you haven't activated the "Individual Entry Archive" in the settings, you will not have one single entry per page. And the comments and the form will not show up if you display multiple entries per page.

Moreover I didn't really understand the term "Individual", I always thougt of "customized". But one never ceases learning ... at least I hope so! So now have fun writing comments and sending trackbacks to the entries, I have to take a nap. A big, fat one!

20.02.06

Dieser Eintrag sollte eine kurze Einführung in die Befehle vom LaTeX geben. Ich konzentriere mich absichtlich aufs überlebenswichtige und lasse den Schnickschnack beiseite. Wer's genauer haben will: eine (nicht so) kurze Einführung in Latex oder die beste Befehlsreferenz die ich je gefunden habe.

Latex
ignoriert
einzelne
Zeilenumbrüche.
Wenn Text so wie oben gestaltet ist, so macht das gar keinen Unterschied zu normalen Fliesstext ohne Zeilenumbrüche. Um einen neuen Abschnitt zu beginnen, muss man eine Leerzeile lassen.

Latexbefehle beginnen immer mit \ backslash. Sonderzeichen, die man im Fliesstext meiden sollte:
  • % - Mit dem Prozentzeichen wird der restliche Text auf der Zeile als Kommentar interpretiert; für ein Prozentzeichen im Text muss ein Backslash vornedran \%
  • " - Gänsefüsschen ergeben wenn möglich ein Trema (auch genannt Umlaut) ¨ auf dem nachfolgenden Buchstaben; am besten durch einzelne Hochkomman bzw. Apostroph '' ersetzen (für Einleitende Anführungszeichen hingegen einfach zwei Kommas ,, hintereinander setzen)
  • ^ - Circumflex ergibt hochgestellten Text, \^ ergibt ein Circumflex auf dem nachfolgenden Buchstaben, und \^{} ergibt ein Circumflex solo
  • _ - Tiefer Strich oder Underscore ergibt tiefgestellten Text, also das Underscore mit einem Backslash escapen: \_
  • {} - Geschweifte Klammern müssen auch mit einem Backslash zusammen geschrieben werden: \{ und \}
  • \ - Der Backslash wird mit dem Befehl \backslash erzeugt; ein doppelter Backslash \\ im Text ergibt einen manuellen Zeilenumbruch
  • ~ - Eine Tilde (ja so heisst die Schlangenlinie richtig) gibt einen non-breaking space, zu deutsch geschützter Leerschlag; Nützlich ist die tilde, wenn man zwischen Wörtern eine Zeilenumbruch verhindern will

Titel werden nach ihrer Hierarchiestufe benannt:
\section{Kapitel erster Ebene}
\subsection{Kapitel zweiter Ebene}
\subsubsection{Kapitel dritter Ebene}
1 Kapitel erster Ebene
1.1 Kapitel zweiter Ebene
1.1.1 Kapitel dritter Ebene

Textformatierungen umschliessen den zu formatierenden Text: \textit{dieser Text soll kursiv werden.} Eine Übersicht der Textformatierungen hier:
  • \textit{} - kursiv ("italic")
  • \textbf{} - fett ("bold font")
  • \textsc{} - kapitälchen ("small capitals")
  • \textsf{} - schnörkelfreie Schrift ("sans serif")

Vertikale Abstände können mit folgenden Befehlen erzeugt werden:
  • \smallskip - gibt einen kleinen Abstand
  • \bigskip - ein etwas grösserer Abstand
  • \vspace{1cm} - gibt einen Abstand von 1cm
  • \pagebreak - erzeugt einen Seitenumbruch

Und ein nicht zu unterschätzenden Befehl für Fussnoten: \footnote{BFS 1995, S. 51.}. Das erzeugt eine übliche Fussnote mit hochgestellter, fortlaufender Nummerierung und dem Text unten an der Seite.

Diese Befehle oben waren die allgemein gültigen für Latex. Ich habe noch ein zwei Befehle programmiert, um das Leben der Juristen zu vereinfachen:
  • \materialsection - erzeugt wie \section ein Kapitel, jedoch ohne arabische Nummerierung. Speziell gedacht für die Materialien wie Literatur- oder Abkürzungsverzeichnis.
  • \definition{Abk.}{Abkürzung} - erzeugt einheitliche Einträge im Abkürzungsverzeichnis.

Update 30.03: Kurze Beschreibung für Einleitenden Anführungszeichen und Tilde hinzugefüght.

15.02.06

Meine Freundin studiert Recht im ersten Semester an der Universität Fribourg (auch genannt Freiburg im Üechtland). Und wie alle anderen Erstjahresstudenten muss sie die Propädeutische Seminararbeit als erste juristische Arbeit schreiben.

Um ihr das Schreiben zu erleichtern, damit sie sich ganz auf den Inhalt und nicht auf die Form konzentrieren kann, habe ich vorgeschlagen, dass sie die Arbeit nicht mit Word, sondern mit LaTeX (gesprochen "latech") schreibt.
(Ausserdem sehen Arbeiten mit LaTeX einfach schöner aus!)

LaTeX ist keine Textverarbeitung wie Word, denn es ist nicht WYSIWYG - man schreibt zum Beispiel die Formatierung, die man will, einfach mitten in den Text. Auf den ersten Blick mag das voll übel klingen, doch man gewöhnt sich schnell daran.

Eine Einführung in LaTeX und wie man LaTeX auf Windows installiert, das findet sich auf der Seite von Tobias Erbsland "Diplomarbeit mit LaTeX". Für Besitzer eines richtigen Computers empfehle ich Latex via i-installer und TeXShop als Editor.

Die Formatvorlage, die ich angefertigt habe, um die sehr speziellen Vorgaben für Juristen zu respektieren, sieht mittlerweile so aus: seminar.pdf. Als Beispieltext habe ich die Probearbeit in Strafrecht von Angela-Livia Nydegger genommen. Einen Blick auf den Quelltext kann man hier werfen: seminar.tex.

Die Vorlage ist momentan noch in Bearbeitung. Wer sich für eine ganz kurze Einführung in Latex interessiert, der schaue sich den nächsten Blogeintrag an.


Et encore brièvement pour les juristes francophones:

Je suis en train dem mettre en place un modèle pour les travails de seminaire en droit. Le document n'est pas basé Word mais LaTeX (prononcé "latéque"). Latex est un système qui n'est pas what you see is what you get mais on écrit une sorte de code.

Qui est interessé de utiliser Latex sur Windows, je conseille de installer Latex à l'aide de MiKTeX et utiliser l'editeur TeXnicCenter de toolscenter.org. Pour ceux qui travaillent avec un vrai ordinateur je conseille d'installer Latex avec i-installer et comme editeur TeXShop.

Le modèle que j'ai préparé: seminar.pdf. Pour ceux qui veulent voir le code de source: seminar.tex.

Dans les jours qui viennent je vais donner plus d'explications comment utiliser Latex.

14.05.05

today i noticed that php has no yet been activated on my tiger. so ... let's go to the terminal, get vim at hand, and learn some basic commands for this powerful unix text editor!

sudo vim /etc/httpd/httpd.conf
use sudo because the file is read-only for mortals. enter password, and welcome to vim. now type:
/php[enter] . . . . . . . . search for the first occurrence of the string "php"
0 . . . . . . . . jump to beginning of the line
x . . . . . . . . delete character under cursor (just in case: use u to undo...)
n . . . . . . . . find the next occurrences of the previous search string
nn . . . . . . . . continue search
0 . . . . . . . . jump ...
x . . . . . . . . delete ...
:wq . . . . . . . . write and quit.

so far for editing the config file. now restart the http-deamon with sudo apachectl graceful and your password. and there is your php, up and running.

just to mention some more useful vim commands:
64gg . . . . . . . . jump to line 64
gg . . . . . . . . jump to beginning of file
G . . . . . . . . jump to end of file
i . . . . . . . . change to insertion mode ("textmode")
[esc] . . . . . . . . end insertion mode
u . . . . . . . . undo last command
[ctrl]R . . . . . . . . redo last undo
. . . . . . . . . repeat last command
dd . . . . . . . . delete current line
yy . . . . . . . . copy current line (yank)
p . . . . . . . . paste line after cursor (put)
:q! . . . . . . . . quit and discard changes
for a more complete reference, see http://tnerual.eriogerg.free.fr/vim.html


7.04.05

i am administering a page for an association which is hosted by a university. the address is http://www.my-university.tld/association/. because this is annoying to type, we registered the domain association.tld to provide direct access. but the regulations (dt: reglement) do not allow the computer department to host any other domains on the university's servers.

so i found a webhost provider who hosts us the domain, only to redirect it to the university page. up to now we used to redirect with a html tag in the header:
http-equiv="refresh"
content="0;URL=http://www.my-university.tld/association/">

this solution works, but i is not very elegant, because:
  1. the page with the redirection has to be loaded first, it slows down the process
  2. the redirection page will be displayed for a moment (though only for a short moment it is unnecessary)
  3. any file or folder request except the association.tld/index.html will result in a 404 file not found error.

to find a more elegant solution, i looked at the apache rewrite mod. it is sort of hard to understand, but after looking around a little i found a solution:
RewriteEngine On
RewriteRule ^(.*) http://www.my-university.tld/association/$1 [R]

this is the text to place in the .htaccess file in the root folder of the association.tld server. now, every request for a file on association.tld will be forwarded, for example www.association.tld/folder/file.html will go directly to
www.my-university.tld/association/folder/file.html.

some resources to the topic of the mod_rewrite:
Module mod_rewrite URL Rewriting Engine
Apache 1.3 URL Rewriting Guide
mezzoblue § rewrite! (see also comments)
mactechnews.de forum: Apache Modul mod_rewirte konfigurieren (german)

27.01.05

the other day i wanted to speed up the annoying task of repetitive dowloads from a website. i thought, since machines are built for completing repetitive tasks fast, my computer should be able to download some files on it's own.

after launching wget with the corresponding parameters
wget -r -l 1 -H -nc http://www.thewebsite.com/index.html
i noticed that wget would fail because of the design of the website: when you arrived at the index page, there is a pull down menu in a (hidden) form, which will let you choose an entry. every entry will redirect you to the file which it had as value:

<form name="jump"><br />
<select name="menu" onChange="location=document.jump.menu.options[document.jump.menu.selectedIndex].value;" value="GO"><br />
<option value="first.html">first</option><br />
<option value="second.html">second</option>

the file you are redirected to had the interesting contents i wanted to download automatically - but wget will not recognize the value field in the select element as a local link, and thus will not follow it.

so i would have to prepare a html file which is comprehensive also for wget. i copied the options-part of the source code into my favourite text editor and replaced the tags <option value="first.html">first</option> analogous this schema <a href="http://www.thewebsite.com/first.html">first</a> .

i saved the modified code to ~/Sites/mylinkslist.html and invoked wget with the following arguments:
wget -r -l 1 -H -nc http://localhost/mylinkslist.html

this worked perfectly fine and wget downloaded all the files i wanted automatically.

wget arguments shortly explained:
-nc, --no-clobber do not download file twice
-r, --recursive follow all the links on a webpage
-l, --level=NUMBER how many link-levels to follow
-H, --span-hosts go to foreign hosts when recursive
some more useful wget arguments:
-A, --accept=LIST accepted file extensions, comma-separated
-np, --no-parent do not ascend to parent directory in recursive mode
-c, --continue resume a partially-downloaded file

w¡nd0w$ user can find a win-ified version of wget here: http://gnuwin32.sourceforge.net/packages/wget.htm.
those who own a real computer (i.e. a mac) use fink or apt-get to install wget on their system.