Posted by Holger Schauer in
Lisp
Wednesday, November 21. 2007
Every now and then, I'm still blown away by the elegant power that the repl (read-eval-print-loop) of Common Lisp provides for everyday tasks. A recent example: I needed to fix a broken column definition in one of my Postgres databases. I'm not a DB pro, so I will just drop the column. But of course, we want to retain the old data, so here we go (using CL-SQL):
SOMEDB> (connect +db-spec+)
#
SOMEDB> (defvar *olddata* (select [id] [data] :from [sometable]))
*OLDDATA*
SOMEDB> (execute-command "ALTER TABLE sometable DROP COLUMN data;")
NIL
SOMEDB> (execute-command "ALTER TABLE sometable ADD COLUMN data varchar;")
NIL
SOMEDB> (loop for (id value) in *olddata*
do (update-records [sometable]
:attributes '(data)
:values (list value)
:where [= [id] id]))
NIL
SOMEDB> (disconnect)
That's it. First we open a connection, store away the olddata (which will be returned as a list of tuples) in a global variable, modify the table and finally restore the data. Now, what I find really nice about this is that I can operate on the data as if I had an intersection of psql, shell and a real programming language, which is pretty much the point of this blog post. I think that Ruby probably provides a similar environment with irb. And, hey, today I learned that XEmacs comes with an interface to postgres, so I might have been able to do it from within my favourite editor, too ...
Posted by Holger Schauer in
Freiburg, German
Thursday, November 15. 2007
Liebe Leser, zuerst die offensichtliche Nachricht: Es ist Mitte November. In other news, 2+2=4. Aber nicht so offensichtlich ist, dass der Schneebericht des Liftverbunds Feldberg 50cm Schneelage verkündet sowie fünf geöffnete Lifte am kommenden Wochenende. Schön, dass die Brettlemärkte in unserer Umgebung schon waren. Weniger schön, dass ich meine neuen Ski erst noch einstellen lassen muss. Aber Schlittenfahren dürfte auch genug Spaß machen.
Posted by Holger Schauer in
German, Music
Wednesday, November 14. 2007
Die taz versucht sich an der Erklärung Wie Indie-Rock den Soul verlor. Die taz und/oder auch der zitierte Frere-Jones scheinen jedoch eher jeglichen Plan verloren zu haben.
Zum einen ist es absurd, so zu tun, als wäre in den 70ern die Rockbewegung voll von schwarzer Musik gewesen. Fakt ist, dass natürlich Bands wie The Clash im Reggae-Umfeld umtriebig waren. Aber das war bei weitem nicht bei allen so. Wo ist etwa das Reggae-Stück der Sex Pistols oder von Joy Division? Dass es zeitgleich zur Explosion der Punk- und Independent-Szene auch noch ein Revival (und somit nicht eine Initialzündung) der Beschäftigung von Weißen mit schwarzer Musik gab, ist sicher eher Zufall als Absicht. Erstens gab es in der Disco-Musik der 70er viel schwarze Musik, Soul, der den Namen auch verdiente. Zweitens war gerade Reggae populär. Drittens wurde nochmal (Revival!) die Musik, die die jamaikanischen Einwanderer in die armen Viertel Englands mitbrachten, populär: Ska, mit dem typischem Offbeat, wie ihn zu der Zeit etwa die Specials, Selector oder Madness spielten. Da die Skinheads und die Punks in den gleichen Ecken hausten, ist es nicht so verwunderlich, dass es da Vermischungen gab. Aber was gab es denn jenseits vom Offbeat-Griff bei Police und Clash? Man sollte sich vielleicht mal daran erinnern, dass nach dem Ur-Punk gleich der coole Synthie-Pop bzw. New Wave gefeiert wurde.
Zum anderen ist es ebenso absurd, zu behaupten, dass im heutigen Indierock keine schwarzen Wurzeln mehr erkennbar wären. Nehmen wir ein sehr plakatives Beispiel: Bloc Party. Sehr erfolgreich mit einem farbigem Sänger. Jetzt kann man sich natürlich streiten, ob der Sound von Bloc Party "Soul" enthält, aber "Rhythmusgefühl" und "genreübergreifendes Zitieren" findet sich da ganz sicher. Aber nehmen wir noch ein anderes Beispiel daher: Die Blues Explosion, besser bekannt auch als John Spencer Blues Explosion. Sie zelebrieren ausschließlich den modernen Rückgriff des Indierocks auf alte "schwarze" Musik. Dann hätten wir noch so Bands wie "At the Drive-In", die eine sehr moderne "schwarze" Variante des modernen Post-Hardcore feierten. Was genau ist denn eigentlich der angeblich verlorene Soul? Gilt etwa ein Jimmy Hendrix auch als "schwarze Musik"? Dann sind "Motorpsycho" oder "The Mars Volta" Beleg dafür, wie sinnlos die Behauptung ist.
Moderne Musik wäre ohne den Einfluss schwarzer Musik nicht denkbar. Das gilt für Indiemusik genauso wie für das alltägliche Radiogedudel.
Posted by Holger Schauer in
Lisp
Friday, November 9. 2007
Some time ago, I was looking at splitting some text with Elisp, Perl, Ruby and Common Lisp. Yesterday, when I again had to do quite the same thing, it occurred to me that the Common Lisp solution was unnecessary complex/long. I'm not a Perl guru, but I believe the following is probably hard to beat even with Perl:
CL-USER> (format t "~{<li>~A</li>~%~}" (cl-ppcre:split "\\|" "Kim Wilde|Transvision Vamp|Ideal|Siouxsie and the Banshees|Nena|Iggy Pop"))
<li>Kim Wilde</li>
<li>Transvision Vamp</li>
<li>Ideal</li>
<li>Siouxsie and the Banshees</li>
<li>Nena</li>
<li>Iggy Pop</li>
NIL
For the uninitiated, it's not the cl-ppcre library which is interesting here but the built-in iteration facilities of format. See the Hyperspec on the control-flow features of format for details. Now, I usually tend to avoid the mini languages that come with Common Lisp like the one of format or loop when writing real programs, but when using Lisp as a glorified shell they come in very handy.
Posted by Holger Schauer in
Lisp
Tuesday, November 6. 2007
Dear Lazyweb, I'm looking for a way to automate unit testing with the help of ASDF. I'm using XLUNIT at the moment, but this isn't really relevant. What I want to achieve is that on every compilation of some source file, it's corresponding test file will be loaded (and hence the tests it contains run). However, what I seek to avoid is simply adding the test files to the component definition; the test files should be kept separately. From what I gather from the ASDF documentation, this should be possible using :perform forms, but the very same docs leave me wondering how. What I found (looking at Jörg Höhles asdf file for iterate) is how to load and run a complete test-system, but this is not what I want to do. Ideally, I would like to have a single perform instruction looking something like this:
(defmethod asdf:perform ((op test-op) c)
(when (asdf:glorified-find-component "my-component" c)
(let ((component-test (find-component-test c)))
(when component-test
(asdf:operate 'asdf:load-op 'component-test)))))
Here #'glorified-find-component needs to recursively follow the components parent and #'find-component-test should return a component c-test (with c expanded, obviously). Now, I guess I'm just clumsily reinventing the wheel and hence I'm wondering if somebody has already solved "the problem".
While I'm at it (it referring to testing), Stefil looks like a very interesting test environment in case you're developing your programs with Emacs and Slime. From there, I found a link to Phil Gregory's test framework comparison which I found much more enlightening than the ALUs list of test frameworks.
Posted by Holger Schauer in
Freiburg, German, Politics
Monday, November 5. 2007
Morgen abend wird in Freiburg eine der dezentralen Kundgebungen gegen Vorratsdatenspeicherung stattfinden. Die Demo unter dem Namen "Freiheit statt Angst" findet am 6.11. ab 17.00 Uhr am Münsterplatz statt. Ich werde leider nicht da sein können, weil ich mal wieder in Mannheim weile, aber hoffentlich finden sich auch so genügend Leute.
|