eClassical.com

28 June 2007, 12:41 — Cool links

I have to suggest a website to you, Dear Reader.

The past days I’ve bought a few musical pieces from eClassical.com, a wonderful website that has mp3 recordings, without DRM or any other digital rights scheme, for very good prices. It’s super-easy: click on what you want to buy, enter your credit card number, and you get a download link back in the mail where you can download the files.

The selection is great. Alfvén, Haydn, Prokofiev, Telemann, Stenhammar, Mahler, Fauré, Orff, Pärt… Or try Beethoven’s nine symphonies (all of them) for $7.99…

My new favorite composer is Camille Saint-Saëns. His 3rd symphony (“Organ”) is highly recommended.

Would Be That My Dreams Took Flight

25 June 2007, 15:30 — Poetry

Ich halte meine Träume in meiner Hand
Und frage mich, warum fliegt ihr nicht?
Ihr liegt nur da, so leise und still
Keine Bewegung in meinem Gesicht.

Wenn sie endlich Flucht ergreifen
Wie schön wär’ es nicht!
Hoch über die Erde fliegen sie
Hoch und stolz in meinem Gesicht.

Bleibt noch bei mir, Träume still
Wacht noch, vergesst mich nicht.
Euere Stunde kommt. Seid bereit!
Bald fliegt ihr hoch, in aller Gesicht.

Things I Never Knew Could Be Done With Cmd.Exe

24 June 2007, 13:28 — Software Development

I spent a part of yesterday looking through all the commands in Cmd.Exe (the Windows command shell, inheritor of the old COMMAND.COM). It’s interesting how they’ve added switches and stuff to improve on it since the early days, but how almost nobody seems to use it. Admittingly, it’s a far cry from bash, the Unix command shell, but there’s a few old tricks you still can pull out of the hat. People may flame it and despise it, but I always thought you should be able to do more with the good ol’ shell.

Here’s a few of the things I found … in alphabetical order.

ATTRIB [/s] [/d]

Changes file attributes. /s makes it recursive, /d makes it operate on directories as well. I didn’t know about these switches before. Handy.

CALL :label arguments

Neither did I know you could call a label in a batch file. This should make it easier to write “gosub”-like routines. And the parameters can be expanded with new interesting features, see below. To exit from the subroutine, use the “goto :eof” statement.

CHKNTFS

Schedule a check-disk on next boot. Might come in handy sometime.

EXIT /b [errorlevel]

Exits the command shell. If you use the /b switch, exits the current batch file. You can also pass an errorlevel along.

F7

Pressing F7 brings up the history list. How come I never knew that?

FINDSTR [/r] [/c:]“search string” filespec

Find strings in files. I might still use Turbo Grep, but this is cool too. Normally it searches using an OR pattern on the search string (meaning “I love you” finds all instances of “I”, “love” or “you”), use the /c: switch to make it an AND search.

The /r parameter turns the search string into a regexp. Note, some of the fancier stuff might not work as usual, consult the FINDSTR /? or the online help for further information.

FOR %%v IN (set) DO …

The FOR command is one of the coolest features in batch programming. I had no idea you could do so much with it.

FOR %%f IN (dpr pas dfm res) DO COPY *.%%f \deploy

Copy all Delphi source files for a project to a specific directory.

FOR /d %%d IN (set) DO …

Match directories in wildcards instead of files.

FOR /r [path] %%v IN (set) DO …

Recursive operation on files found, optionally operating relative to “path” instead of the current directory. It might be used like “FOR /r c:\deploy %%f IN (*.*) DO ATTRIB -r %%f”, which will recursively remove the read-only attribute from all files in c:\deploy.

FOR /l %%v IN (start, step, end) DO …

For-loop. “FOR /l %%v IN (1, 1, 5)” gives the sequence 1 2 3 4 5.

FOR /f ["options"] %%v IN (file-set | “string” | ‘command’) DO …

The /f parameter is probably the most interesting feature I’ve found. It reads lines from an input file, string, or result from a shell command, tokenizes them and processes a command for each line. Normally, the token delimiters are space and tab, and it usually operates on the first token found, so without extra options you will always get the first word in each line. But it can be modified with the following options:

eol=c Set the end-of-line character. One character only.
skip=n Skip n lines in the beginning.
delims=xxx Delimiter set, default is space and tab.
tokens=x,y,n-m Which tokens to feed into the command. Variables start at the variable given, and allocates further as needed in alphabetical order. * means “the rest of the line”.
usebackq Use backticks instead of apostrophe for the command evaluation. The format changes to (“file-set” | ’string’ | `command`). Required if you use filenames with spaces.

FOR /f “eol=; tokens=2,3* delims=, ” %%i IN (myfile.txt) DO @ECHO %%i %%j %%k

Parse each line in myfile.txt, ignoring lines that begin with semicolon, pass 2nd and 3rd tokens into the command, separating each token my either comma or space. Notice how the sequence goes: %i, %j, %k.

FOR /f “usebackq delims==” %%i IN (`set`) DO @ECHO %%i

Enumerate all variables found.

Expansion of variable parameters is also available, see below.

GOTO :eof

Jump to end of file. Handy way of exiting from a script.

IF [NOT] ERRORLEVEL n ..
IF [NOT] EXIST filename …
IF [NOT] string1==string2 …
IF [/i] string1 EQU|NEQ|LSS|LEQ|GTR|GEQ string2 …

The normal IF command is enhanced, too. It can check errorlevels as before, file existance, and compare strings. But is also has new operators. For instance, the “IF ERRORLEVEL 3″ statement can now be written “IF %ERRORLEVEL% LEQ 3″.

/i means case-sensitive (or case-insensitive, I forgot which). Numeric strings evaluate as numbers, not strings.

IF now also supports multi-line statements and ELSE statements, see below.

MD \a\b\c\d

Will create new directories in sequence.

MORE /e

Extended more. These keys are available:

P n – next n lines
S n – skip n lines
F – next file
Q – quit
= – show line number
? – show help line
space – next page
return – next line

MORE +n

Start from line n.

PUSHD \\server\path

Create a temporary drive allocation, starting from Z:, for the particular UNC path. This will be cleared with POPD.

RD /s /q

Very dangerous command.

SET [var[=[value]]]
SET /a [var=]expression
SET /p var=[prompt]

SET only will display all variables. SET P will display all values starting with P. SET P= will clear variable P.

SET /a will perform a calculation, for instance SET /a X=2*2 + 5.

SET /p will prompt for user input and store the result in a variable.

SETLOCAL / ENDLOCAL

Make local changes to the environment. Work all you want with it, then call endlocal to revert back to where you were. Also handy, especially with some of the advanced SET features.

SHIFT [/n]

Shift parameters. Optionally start at the nth position, preserving all elements %0 .. %(n-1).

SORT [/+n] [/o outfile]

Sort may start sorting at the nth position now. Could be good for unwanted stuff in the beginning (timestamp in logs, perhaps). /o is faster than piping.

Interesting ways of treating variable expansion

Some new ways of treating variables are available. Like, string substitution and substring matching.

%PATH:str1=str2% Substitute all occurrences of str1 with str2.
%PATH:~10,5% Substring, start at position 10 and extract 5 characters.
%PATH:~-10% Only get the last 10 characters.
%PATH:0,-2% Extract all but the last 2 characters.
 
%CD% The current path
%DATE% Current date
%TIME% Current time
%RANDOM% A random number between 0..32767.
%ERRORLEVEL% The current errorlevel.
 
%* All arguments
%0 .. %9 Arguments
%~1 Remove quotes from parameter 1
%~f1 Expand to fully qualified filename
%~d1 Expand to drive letter only
%~p1 Expand to path only
%~n1 Expand to file name only
%~x1 Expand to extension only
%~s1 Expand to short file name only
%~a1 Expand to file attributes
%~t1 Expand to file date/time
%~z1 Expand to file size
%~$PATH:1 Search through all directories specified in %PATH%. If the file is found, return the
fully qualified filename in that directory. If the file isn’t found, return blank.
%~dp1 Expand to drive and path. (Further elements may be combined: %~ftza1 gives a DIR-like output)

Interesting ways of doing IF and FOR statements

There’s a syntax I’ve never seen either with IF and FOR statements. You can use IF-ELSE-syntax in this way:

IF EXIST hello.txt (
    DEL hello.txt
) ELSE (
    ECHO hello.txt is missing!
)

…or even…

IF EXIST hello.txt (DEL hello.txt) ELSE (ECHO hello.txt is missing!)

And how about this?

FOR /l %%v IN (1 1 5) DO (
    ECHO This is line number %%v.
)

The crucial thing seems to be, in ELSE statements, that ELSE has to be written “on the same line” as the IF statement. This is why ELSE is written on the same line as the parantheses.

So there you are. A whole new way of writing batch files. No extra software needed, just plain old Windows XP.

Wallpaper, Constitution Series

21 June 2007, 8:12 — Design

I designed some wallpapers themed on the U.S. Constitution and history. Feel free to download them if you like. They’re 1200×1024. (What the…? I thought they were 1280 in width…?)



The Star-Spangled Banner


The Declaration of Independence


The Bill of Rights

Pictures from Skärhamn

19 June 2007, 20:55 — Reflections

Inspired by my friend Marie Breskic’s pictures from Brcko, I had to set out and create my own little presentation of the surroundings where I live – which I have repeatedly promised to a number of people on a number of occasions and not quite yet gotten around to. So, without further ado:

This is the house where I presently live. It doesn’t look much to the world, but it’s much nicer inside than outside. I live on the second floor, and I occupy pretty much all of it with my three-room apartment. The main entrance is on the other side, and every morning I go out, and around the back and jump into my red car. Yes, it’s a bit rusty. Get over it.
If I just step outside through the door basically, I have the ocean right in front of me. The little harbor/bay where I live is the home of hundreds and hundreds of boats, some large, some small. Whenever summer comes around, the boats magically appear from wherever they’ve been standing over the winter, and they put to sea. On calm days like this, there’s bound to be boats all over the place, heading out toward open sea.

And yes, if you go through the narrowish strait away there in the distance, you’ll sooner or later end up in England. Sometimes, from the top of Tjörne huvud, you can see large oceanliners far off the in the distance.

If you climb up to the church, you’ll see most of town spread out like this. It’s a very rocky, hilly terrain around here, with not many trees or natural vegetation (most of the trees are in people’s back yards). Lots and lots of boats in the harbor, and further away you can see several larger structures. One of those, towards the right, is the watercolor painting musem, where they have an exhibition right now of 17th to 19th Century British watercolor painters and their works. I’ve been meaning to go there and look but haven’t found time yet.

The larger, greyish structure to the left is the fishery plant. There’s always a foul smell just around that building.

There’s a better view of the bay from the church as well. It only takes a minute to get up there, and offers a beautiful view of the bay.

Just imagine what it’s like in winter when the gale from the nortwest comes howling in over the North Sea and hits us head on. There’s not much snow that sticks; last year they had two weeks of snow, apparently… otherwise it’s just raining. Summer is much better.

Since there are all these rocky cliffs, it sometimes leads to buildings buing built in quite fanciful locations. Like this one.

Most of the town is built this way. At least the older part; all houses are wooden and painted nicely white. For a while it seems like everyone was going for those plates that cover the entire building (like on my building), but I’ve seen people putting back the white boards instead. And it does look much nicer.

Beyond the old part of town, buildings look more conventional: brick houses, concrete buildings. But downtown all looks like this. It’s amazing.

When you go just up the side streets off main street, everything becomes really narrow and winding. Streets go at impossible angles relative to each other, they twist and turn ever which way and sometimes become so narrow that it seems impossible to squeeze a car through. And yet people do. They carve out little places in the rock to put their cars, and find places to build and improve on their little back yards.
Every morning from Monday to Friday, I travel 20 km to Stenungsund. I took this picture while out walking one day around downtown. Stenungsund is the major petrochemical center in Scandinavia. There are a couple of very sensitive industries that lie here; Akzo Nobel, Borealis, Hydro and a number of others, which leads to this fanciful view of the surroundings. When something goes wrong, for instance in the big petrochemical cracker, all the excess gases are burned off with a flame that lights up the entire city. And when chemical incidents happen elsewhere in the country, the response team comes from… Stenungsund.
So it’s nicer to cool off a bit in the evenings. Provided that you make it back over Tjörn bridge without a scratch and still mentally sane, a much nicer view opens up. This picture is from Toftenäs nature reserve just a mile from my house. You walk out over the cliffs, and sit down right on the edge of the ocean, and watch the sun set over the ocean. It’s a true miracle of nature every evening. And the only sounds you hear out there in the evening are from seagulls crying in the distance.
Apart from birds, this is about the only life that thrives out here. On this side of the island, there are hardly any trees, just little pretty flowers that cower in the cracks between the cliffs. It feels a little strange for me who grew up walking around in fields and forests. But the nice part is that you only have to drive some ten minutes to the north side of the island, and walk around in the nicest forest I’ve seen in a long while.

It really turns out that Tjörn has everything. *)

*) Except for tundra, deserts, big rivers, tropical rainforests, prairies and a few other things, but who keeps track?

FutureMe

19 June 2007, 11:03 — Reflections

I received a letter from the past today. It was sent by myself, on Sunday, February 12th, 2006, and it read as follows:

This is a little message I sent to my future me. I hope you are doing well. It’s cold out here now, but the sun is shining and it’s a wonderful day. Tomorrow is work again. Back to fixing 2.0 bugs. But all in all, things are fine. Have a nice day.

There’s a website called FutureMe.org, that allows you to send emails to yourself in the future. It’s an interesting read to go through the public entries. People send letters to themselves up to 20 or 30 years into the future, with questions and reflections on all kinds of things. Of course, you’d better hope that the email box will still be around in 30 years (and that SMTP is still used).

Personally, it’s nice to receive a little email from myself. Of course, back in my mind I knew I had, but I had forgotten when and what I wrote. It’s a nice little reminder. A thought from my past reaching out in time. Since then, I’ve only switched jobs (twice!) and moved to an entirely different city. And I’m now happily watching the innovation team sitting and fixing 2.2 bugs, while I’m supporting the 2.0 branch. Life is strange.

Or, like Winnie the Pooh said: “Yesterday is history, tomorrow a mystery. Today is a gift. That’s why we call it the present!” (Thanks, Sophie!)

Beautiful, Beautiful Fonts

9 June 2007, 12:23 — Design

I’m starting to develop a love for fonts. What, you say? Yes, fonts. Typefaces. The art of typography is absolutely wonderful; it comes the elements of text, lettering, and words, into an art of design and readability.

I think one of the best things you can do if you’re serious about typography is to go out and buy the Adobe Type Basics package. It includes wonderful typefaces, including all-time classics like Garamond. And then, add on with as many as you like…

What really sets apart the professional fonts from many of the downloadable public fonts, is an immense clarity when you use them in text. The readability is enormous. And yet, when you pull them up in several times magnification, they are absolutely beautiful.

These are some of my absolute favorites:


This is Adobe Garamond. Originally designed by Claude Garamond and first gained popularity in the 1540’s, it is one of the most well-known typefaces. It is a wonderful serif font, with a sense of “old-school” writing and a fluidity that is amazing, especially in the italics.


Futura is an interesting sans-serif designed in 1927, building on the Bauhaus ideals and the Universal typeface. It was used heavily in the 50’s and 60’s, and its fans include both Stanley Kubrick and the Pittsburgh Steelers.


A new font, made in the early 90’s, it is much warmer and friendlier than Futura. I like it best in its heavy setting, giving an impressive weight and clarity to the text.

Life in a New City

8 June 2007, 16:38 — Reflections

By the 31st of May, my contract on my old apartment finally expired. Having paid double rent for two and a half months, it was something I looked forward to. Now someone else lives there, and I’m gone from Skövde for good.

Having left the place where I grew up – permanently – is a rather strange experience to me. Skövde has been my home for the past 30 years (with brief exceptions) and it feels rather odd not to be able to go there any longer. Of course my Mom still lives there, but Skövde – my city! – is no longer mine. I don’t live there any longer. I am excluded.

Not that I’m complaining. Skärhamn is turning out to be a little piece of heaven on earth. Tjörn is amazingly beautiful and this quaint little town is very pretty as well. White little houses along the sea, seagulls floating by in the soft breeze from the ocean, blue skies and green trees interspersed among the cliffs. Right where I’m sitting now, on my balcony, I can if I just turn around see the harbor and the ocean a few hundred feet away, and a hundred little sailboats anchored up or heading out towards the calm sea glittering in the sunlight.

Living here and working in Stenungsund has its unique advantage. I work in the city, with a mall within walking distance (although its rather small), and every day I get to go home to the nice little village on the coast, where west of me is nothing but open sea, and then England. The only exception is the traffic over Tjörn bridge, which sometimes (like this Friday afternoon) can add another 20 minutes to the daily commute.

A nagging feeling stays with me though: The “what am I doing here” question is in the back of my head. The divine purpose eludes me for the moment, although, like the people on the boats in the distance, I’m sailing along with the wind, taking me wherever it may lead. So far, everything is going well.

It’s a walk of faith for sure. Gradually the feeling sinks into me that this is permanent. This is now where I live, and where I am likely to stay for the foreseeable future. I suppose, in a way, that this is the next shock wave; the first being the initial shock of moving from a city of 50,000 to a town of 3,000; and now I start realize that there is no way back.

It’s a big, scary world. “Thy sea is so great, and my boat is so small.” But I am so happy and so blessed to have Daddy’s (=God’s) hand to hold. I know He takes care of me and leads me to green pastures. And in time I suppose I’ll find things out, where this wind is carrying me and what my destination is. Sometimes I think I may even find that the journey was the destination, and that some day, I’ll come full cycle and head home again… wherever that may be.

Robots and our Children

6 June 2007, 15:19 — Reflections

I have the picture to my right as wallpaper on my cell phone right now.

It’s interesting to pause and reflect on it for a minute. The picture clearly depicts a little robot, dancing together with a little child in very playful fashion. The robot, for all its mechanical exterior, seems happy; and the child is happily playing with it. There seems to be a genuine bond of friendship between them.

To a parent, the picture seems more frightening. What is the robot doing? Why does it look so scary? Can I trust the robot with my child? How do I know the robot is benevolent, and that it will not, the moment I turn around, attack my child and hurt it? The looks of the robot even seem frightening. Although it seems to get happily along with the child… who knows what it can do?

The picture, in a way, seems to highlight the difference between childhood and adulthood. Why is it that children are so naive and trusting, whereas grownups are so much more eager to distrust and shy away from what they do not understand? The child in this picture no doubt has observed how different it looks, but quickly sees beyond that, deeper down to the “personality” of the robot. She has quickly learned to trust the robot, sensing the deeper qualities within.

Is there a lesson to be learned here? Why are we adults so obsessed with exterior looks? Why do we glance quickly at something, and in that flash of an instant, determine that it’s either good or bad (or neutral = uninteresting), and act accordingly? How often do we not treat people in the same way? An rugged person on the street – quickly judged as an alcoholic and troublemaker; when perhaps it might turn out to be the most delightfully kind and loving person, if only we took the trouble of seeing beneath the unpolished surface.

In a lesser sense, what does the robot think? Does it think at all? Does it have emotions, or is its programming of such character that it simply enjoys fulfilling its basic function? Perhaps it follows the Three Laws. Perhaps it – like R. Giskard Reventlov – is enormously complex and sensitive, a remarkable intelligence hidden behind a foul exterior, that simply delights in being a playful friend of a little child. How angelic in character! Or if it possesses a will of its own, does it ever think about gaining selfish advantage? Playing a part until it can subdue the humans and establish a rule and justice of its own? What does a robot want? And how can we judge the character of a machine without a deep, innate understanding of its inner workings?

In the end, I suppose the cynical nature of adults – if it is right to call it that – is a warranted safety feature. To navigate in a world of six billion, with our time constantly being filled with advertising of every form, takes a certain natural skepticism. It is not then very strange that we’ve turned into jaded, cynical people who have learned to judge and discriminate in a second or two.

But for now, it is nice to ponder this image of a child, so naturally trusting and open, play with a little electromechanical machine. Maybe, for a moment, we might do well to forget about our busy day and do the same.

Summertime at the Office

5 June 2007, 15:45 — Uncategorized

And once again, it’s the time of the year when temperatures climb – not outside, inside – to 28 degrees.

Swedish houses are built to contain heat and not let it out. Which means that whenever the sun comes out and summer temperatures roll in, all the houses become little saunas. Our office does the same, too.

I’m surprised that no one has learned yet.

Older Posts »