Monthly Archives: July 2008

Mit find und grep in Dateien suchen

Posted on in Linux

Da ich morgen heute — in 4,5 h — Klausur über Operating Systems schreibe, ist heute Schnipseltag. Um die Zeichenkette “foo” in allen Dateien im aktuellen Verzeichnis zu finden und eine Liste dieser Dateien auszugeben bietet sich folgende Kombination aus find und grep an:

find . -type f -exec grep -qi "foo" {} \; -print

Und um bestimmte Verzeichnisse auszuschließen (z.B. .git):

find . -path '*.git' -prune -o -type f -exec grep -qi "foo" {} \; -print

Ordner unter Windows als Laufwerk einbinden mit subst

Posted on in How-Tos, Windows

Beim Lernen auf eine Prüfung ist mir soeben der Befehl subst unter Windows wieder über den Weg gelaufen. Damit lassen sich Ordner auf virtuelle Laufwerke mappen, was unter Umständen recht nützlich sein kann. Beispielsweise liegt das DocumentRoot meiner lokalen Entwicklungsumgebung für Webseiten (Apache, PHP, MySQL, … — XAMPP) unter D:srvxampphtdocs, was recht anstrengend ist, wenn man viel in dem Ordner arbeitet. Klar, ich bin selbst schuld, wenn ich mein Zeug so tief irgendwo verschachtel, aber das ist nunmal so. Jedenfalls ist es mit dem genannten subst möglich, dieses Verzeichnis auf ein eigenes Laufwerk, zum Beispiel G:, zu mappen:

C:> subst G: D:srvxampphtdocs

Um das Mapping wieder aufzuheben, reicht ein

C:> subst /d G:

Da die Laufwerke durch einen Neustart verloren gehen, am besten in eine Batch-Datei schreiben und diese beim Windows-Start starten lassen (z.B. Autostart).

AutoThumb WordPress plugin and English posts

Posted on in Development, General, Projects

I’m proud to announce two first-timers today: my first officially released WordPress plugin and the first page on this blog I wrote in English. It’s kind of a challenge to my English skills, so please correct me if you find any errors — I’m sure you will ;)

The plugin integrates the great phpThumb library into WordPress and therefore allows you to post images in different sizes flexibly.

Here we go: WordPress Plugin: AutoThumb

WordPress Plugin: AutoThumb

Posted on in Development, Projects, Wordpress

Please do not post feature requests or bug reports in the comments, but file a ticket in the designated Issue Tracker instead. Thank you!

After switching my blog to WordPress I needed a simple solution which allowed me to flexibly post images in different sizes without having to hassle with different filenames, paths etc.

The plugin is actually just a port of a plugin/snippet I wrote for MODx a while ago (see here). It scans your content’s source code for <img> tags with width and height attributes and passes them to phpThumb, a great PHP image editing library, which handles the resizing and editing of the image. Additionally, by passing parameters to phpThumb using a query string, it’s possible to edit the image in several ways (take a look at phpThumb’s demos).

The simplest way to get resized images is to specify width/height attibutes in your HTML. Autothumb will use the given values and remove the attributes from your page’s output. When you take a look at the URLs of the following example images, you will see that the <img>-tag’s src-attribute points to a file called image.php in the plugin’s directory. This file takes the image source and several other parameters and passes them to phpThumb, which will generate and output the final image (of course images will be cached).

To prevent evil people playing with the query string and letting your server generate tons of different images, the plugin generates a hash which is a combination of the query string and a secret password you set in phpThumb’s config file. So every call with different parameters (even the same image with different sizes) has another unique hash and it’s not possible to generate new images without knowing the secret password.

Continue reading →