This page lists only the software pages. SoftwareUsed might be another page of interest. (But it’s rarely updated!)
This is based on How to Convert Unprotected WMA Files Into MP3 Files. I’m leaving the instructions here for my future self. 
for file in *.wma; do
mplayer -vo null -vc dummy -af resample=44100 \
-ao pcm:file="${file%%.[Ww][Mm][Aa]}.wav" "$file"
lame --preset standard "${file%%.[Ww][Mm][Aa]}.wav" \
"${file%%.[Ww][Mm][Aa]}.mp3"
done Use locate lame|grep 'lame$' and locate mplayer|grep 'mplayer$' to find the location of your executables. On a Mac, they’re probably not on your PATH… I installed MPlayer OSX and iTunes-LAME to get the executables. You’ll need to do something similar.
This is the result I just used for some files with upper case file extension:
for file in *.WMA; do
"/Applications/MPlayer OSX.app/Contents/Resources/External_Binaries/mplayer_intel.app/Contents/MacOS/mplayer" \
-vo null -vc dummy -af resample=44100 \
-ao pcm:file="${file%%.[Ww][Mm][Aa]}.wav" "$file"
"/Applications/iTunes-LAME.app/Contents/Resources/lame" \
--preset standard "${file%%.[Ww][Mm][Aa]}.wav" \
"${file%%.[Ww][Mm][Aa]}.mp3"
done I’m a big fan of the Forgotten Depths. I wanted to use its map as the goal for my Text Mapper. As the mapper now allows the inclusion of other files, I’ve saved my library of colors and icons as default.txt and I’ve saved the map as forgotten-depths.txt. That’s why all you need to do now is include the map:
If you see white hexes, then I haven’t added any definitions for them, yet.
Tags: SVG
Software
Maps
Text Mapper 
I need help with SVG filters. This question is also on StackOverflow.
This is what I want to achieve:
Previously, I’d duplicate the text element, make the background white, and blur it:
<defs>
<filter id="label-glow">
<feGaussianBlur stdDeviation="1" />
</filter>
</defs>
<text stroke="white" stroke-width="5" filter="url(#label-glow)">Harald's Repose</text>
<text>Harald's Repose</text>I’m trying not to duplicate the text element. Here’s how to do it using filters:
<defs>
<filter id="label-glow">
<feFlood flood-color="white"/>
<feComposite in2="SourceGraphic" operator="in"/>
<feGaussianBlur stdDeviation="2"/>
<feComposite operator="over"/>
<feComposite operator="over"/>
<feComposite operator="over"/>
<feComposite operator="over"/>
<feComposite in="SourceGraphic"/>
</filter>
</defs>
<text filter="url(#label-glow)">Harald's Repose</text>Unfortunately the output of the Gaussian blur is very weak which is why I need to overlay it multiple times. What am I missing?
Update: As I’ve been experimenting with it, I’ve decided to drop filters altogether. When using Firefox and printing the map to PDF, the filters all result in bitmap elements that don’t scale well.
Recently I wanted to create a little hex map and I wanted to do it on an iPad, I wanted to eventually integrate it into my campaign wiki, I wanted it to be SVG based, and so on. All that meant, Hexographer wasn’t the appropriate tool. I needed to cook something up myself. Based on code I wrote nearly five years ago—the Old School Hex Mapper—I wrote up a little something.
I’m calling it the Text Mapper because it takes text input. No interactive fiddling with the map.
There are various sections of the input.
This is simple. Coordinates, terrain.
# map definition 0101 mountain 0102 mountain 0103 hill 0104 forest 0201 mountain 0202 hill 0203 coast 0204 empty 0301 mountain 0302 mountain 0303 plain 0304 sea 0401 hill 0402 sand 0403 forest
The rest of the input determines how things look: what colors to use, what icons to display. When you start the Text Mapper, the input area already contains an example. Start with that before doing anything else.
Now it gets tricky. For every terrain we used, the script will generate a hex. We need to provide some SVG attributes! Need documentation? Check out the polygon in the SVG specification and click on show next to presentation attributes. That’s what you should be looking at.
# attributes empty attributes fill="#ffffff" stroke="black" stroke-width="3" plain attributes fill="#7cfc00" stroke="black" stroke-width="3" forest attributes fill="#228b22" stroke="black" stroke-width="3" hill attributes fill="#daa520" stroke="black" stroke-width="3" mountain attributes fill="#708090" stroke="black" stroke-width="3" sand attributes fill="#eedd82" stroke="black" stroke-width="3" coast attributes fill="#7fffd4" stroke="black" stroke-width="3" sea attributes fill="#4169e1" stroke="black" stroke-width="3"
In order to add little icons, you can specify a path per terrain.
plain path M -18,-13 C -13,-6 -13,4 -8,12 C -11,14 -15,21 -18,26 C -20,17 -22,4 -28,0 C -26,-4 -21,-9 -18,-13 z M 5,-31 C 4,-19 3,-6 6,5 C 1,10 -0,14 -3,19 C -2,6 -3,-4 -4,-16 C -4,-21 2,-26 5,-31 z M 26,-1 C 16,6 19,5 9,18 C 12,3 21,-8 34,-17 C 32,-12 29,-6 27,-1 z
If you don’t want this path to be black, you need to specify attributes for the path element.
plain path attributes fill="#76ee00" hill path attributes fill="#b8860b"
And finally, the coordinates are simple text elements.
text font-size="20pt" dy="15px"
If you wanted a black and white map, for example, you could use different strokes…
empty attributes fill="white" stroke="#b3b3ff" stroke-width="3" mountain attributes fill="white" stroke="#b3b3ff" stroke-width="3" hill attributes fill="white" stroke="#b3b3ff" stroke-width="3" forest attributes fill="white" stroke="#b3b3ff" stroke-width="3"
If you want to create new path elements yourself in Inkscape, you should draw them in a rectangle from (-100,-100) to (100,100) and extract the the path info from the SVG. Yeah, adding new icons isn’t easy.
I need to add more icons. I’d also like to add multiple icons for the same terrain such that the code will pick one at random.
I wonder how easy it’s be to add text labels, roads, rivers and borders. 
The result of the above:
(Also on GitHub.)
Tags: RPG
Hex
Maps
Software
Text Mapper 
In 2012, I basically took pictures using Instagram, shared them with Facebook (part of the family), Twitter (another part of the family), Flickr (my favorite), and I used IFTTT to send a copy to Picasa Web because I felt that I’d like to have some pictures for people to see on Google+.
But then, when Instagram changed its terms of service (they rephrased them somewhat) and I decided that I might want to look into using something else for a bit.
I liked the new Flickr app somewhat.
I tried organizing my pictures on Picasa Web but was unable to create a new empty album in order to move some of my pictures in the Scrapbook album. When I selected more than 300 of the pictures and tried to move them, it also told me I could not move more than 100 at a time. I was confused. It looked like the user interface could use some improvements. I even started up my local Picasa copy and wasn’t clear on how to use it to manage my albums online. Perhaps you can’t. I was not impressed. It looks as if I’m not going to abandon iPhoto any time soon. Then again, I really want to abandon iPhoto one of these days because I hate it’s opaque storage regime.
Also, the lens or the protective plastic cover of my iPhone camera is scratched. The photos from the main camera now all look hazy. The terrible quality had resulted in me taking a lot of self-portraits from the second camera.
Since I didn’t want to use Instagram too often, I have uploaded the pictures to Flickr directly. This means that I haven’t posted any pictures to Facebook; I haven’t posted any pictures to Twitter, and none where uploaded to Picasa Web.
Strangely enough it doesn’t bother me.
Maybe it bothers me a bit because I’ve been using simple photos of my daily life as a replacement for status updates for my family and friends. We’ll see. Perhaps I’ll post status updates again. Or I’ll abandon Facebook. Or resume the use of Instagram.
Sometimes it’s hard to remember how cool awk used to be – I haven’t used awk ever since I switched to Perl about 15 years ago. 
Today I wondered who had so many sleeping php-cgi processes on the server hosting Campaign Wiki:
ps aux | awk '/php-cgi$/ { user[$1]++} END { for (u in user) { print u, user[u] }}'
1231 233
greywulf 1Thanks, awk. You might be awkward to use, but you get the job done. Now we just need to figure out who this user 1231 is. Who needs 233 php-cgi processes running?
Tags: Software 
greywulf Wish I could figure out what’s causing these. Most annoying 
– greywulf 2012-10-17 21:25 UTC
AlexSchroeder Not your fault! When I looked you had one php-cgi process running. That makes total sense. It was this other user id that had more than 200 sleeping processes running that I cared about. (Added this clarification to the blog post, too.)
– AlexSchroeder 2012-10-18 07:00 UTC
I was writing a Perl CGI script that takes a SVG file I created with Inkscape, replaces a few placeholders and serves it via the web. How to supply this SVG file with an external TrueType font?
Upload the font – http://campaignwiki.org/Purisa.ttf
Add an appropriate MIME type – in the directory where the font file is, register an appropriate MIME type in your .htaccess file:
AddType application/x-font-ttf .ttf
If you are creating a new .htaccess file, remember it needs a permission like -rw-r--r--.
Add an external style sheet to the SVG file – it is not obvious how to do this in Inkscape. I guess you can open the XML Editor and add an svg:style element. I just pasted the following into the beginning of my SVG file:
<style
type="text/css">
@font-face {
font-family: 'Purisa';
src: local('Purisa'),
url('/Purisa.ttf') format('truetype');
}
</style>Care about Internet Explorer? I don’t have access to IE at the moment. I read that you might need to add an .eot file to support IE, and that would also require another MIME type to be added. You can convert a .ttf font to an .eot font using ttf2eot on the web.
Once again I’ve decided I needed to work on the memoirs of my grandfather Roland Li-Marchetti. I had digitized 16 pages many years ago but his memoirs contain a total of 45 pages of typed text. The last time I worked on this, I was using the OCR software that came with my scanner (a cheap Canon LiDE 25) – but today the scanner was no longer recognized by the operating system. I faintly remember having experienced this before when I upgraded my system. Bit rot!
Anyway, I was in the mood to try something new. Free Software?
(While the stuff is compiling, I am in fact using a free online OCR service.)
Here is the original, taken with my Pentax K100D, loaded into Gimp, rotated, cropped, and auto-adjusted levels.
The tesseract output is pretty cool:
que mes vingt prochaines années soient aussi riches d'aventures et de bonheur auprès des miens, main dans la main avec Agnès mon inséparable complice qui a beaucoup sacrifié et que j'espère pouvoir encore rendre heureuse.
(When I tried it on a direct photo of the page the result was far less pleasing.)
Yay!
for ((i=20; i<=46; i++)); do
tesseract IMGP$((5210+$i)).JPG "page-$i" -l fra
doneComments on 2012-08-03 Free French OCR for Mac
Andreas Gohr Nice, there are multiple ring binders of my grandfather’s memoirs as well. One day I should digitize them too.
BTW. you might want to have a look for other OCR solutions (I guess most of what I’ve written there would apply to Mac as well).
– Andreas Gohr 2012-08-03 13:09 UTC
AlexSchroeder Excellent! Thank you very much. I feel relieved that I seem to have picked the best free option. 
– AlexSchroeder 2012-08-03 14:09 UTC
I have a job that creates backups of my sites using rsync. My sites are in Germany and the USA, the backups are in Canada and Chile. The point was to protect myself against hosting services disappearing and my sites getting lost. Recently I was thinking about data corruption, however. As soon as the cronjob writes the corrupted data to the backups, there is no way to retrieve my data. (There is in fact a third backup: every few weeks I use rsync to copy the remote sites to one of a rotating set of mobile disks, one of which is always outside our apartment.)
There is in fact an option for rsync which will allow you to create copies of your file tree at certain intervals using hard links for the files that haven’t changed. I found a tutorial on how to do it: Time Machine for every Unix out there subtitled “Using rsync to mimic the behavior of Apple’s Time Machine feature.”
And that’s exactly what I did.
I maintain a wiki engine called Oddmuse. It’s the software used to run my blog, for example. It is written in an older scripting language called Perl. Perl predates Unicode. That’s why the use of UTF-8 or UTF-16 is not mandated. That, in turn, means that usually bytes are interpreted as an UTF-8 encoded character is only visible as two bytes.
Consider this regular expression to match WikiWords: [A-Z][a-z]+[A-Z][a-z]+
How would you extend it to parse ÖlPlattform?
Assume the following Perl code was written in a source file that was UTF-8 encoded:
$str = "OelPlattform"; print "OelPlattform YES\n" if $str =~ /[[:upper:]][[:lower:]]+[[:upper:]]\w+/; $str = "ÖlPlattform"; print "ÖlPlattform YES\n" if $str =~ /[[:upper:]][[:lower:]]+[[:upper:]]\w+/;
This will just print OelPlattform YES because what looks like “ÖlPlattform” actually starts with the bytes C3 96 and C3 is not an upper case letter. It’s actually unclear what it is. In a Latin-1 environment the C3 would print as ×the dreaded sign of encoding errors!
I wanted to keep Oddmuse encoding agnostic. Users could specify a different encoding which would be served together with the page HTML such that they could have wikis using GB 2312. This is why Oddmuse contained the following line and similar code:
# we treat input and output as bytes
eval { local $SIG{__DIE__}; binmode(STDOUT, ":raw"); };This resulted in problems when some packages I was using did in fact produce UTF-8 and so I had to use code as follows:
eval { local $SIG{__DIE__}; binmode(STDOUT, ":utf8"); } if $HttpCharset eq 'UTF-8';
print RSS($3 ? $3 : 15, split(/\s+/, UnquoteHtml($4)));
eval { local $SIG{__DIE__}; binmode(STDOUT, ":raw"); };I’m not sure why I surrounded it all with an eval—I assume it was to support an older version of Perl but I’m not sure.
Ok, so I wanted to get rid of all that.
The solution seems deceptively simple: add use utf8; to the source files and open all files using the UTF-8 encoding layer.
When printing UTF-8 to STDOUT, you need to tell Perl that STDOUT can in fact handle multi-byte characters. Since the HTML produced is UTF-8 encoded, I know that this is true. If you don’t, you’ll get “wide character in print” warnings.
binmode(STDOUT, ':utf8');
You need to be careful with all input and output, however.
open(F, '<:encoding(UTF-8)', $RcFile);
The same is true for output:
open(OUT, '>:encoding(UTF-8)', $file)
or ReportError(Ts('Cannot write %s', $file) . ": $!", '500 INTERNAL SERVER ERROR');Oddmuse also offers the ability to include other pages (Transclusion) and to produce feeds. This can be a problem. The default page processing is to parse the raw text and start printing HTML as soon as possible because I have always felt that it was more expedient to start printing the top of the page while the rest was still being parsed. What happens when I don’t want to do this, eg. I’m in the middle of building the RSS feed?
The solution I had been using was to redirect STDOUT to a variable. Perl calls this a “memory file.” The problem is the encoding of this memory file:
Here’s what I had to write:
open(STDOUT, '>', \$page) or die "Can't open memory file: $!"; binmode(STDOUT, ":utf8"); PrintPageHtml(); utf8::decode($page);
I think this works because binmode tells all the print instructions that it’s ok to print multi-byte characters and utf8::decode makes sure that all those bytes are in fact decoded back to Perl’s internal representation.
Then I discovered that I needed to look at the bytes if I wanted to URL-encode strings:
utf8::encode($str); # turn to byte string
my @letters = split(//, $str);
my %safe = map {$_ => 1} ('a' .. 'z', 'A' .. 'Z', '0' .. '9', '-', '_', '.', '!', '~', '*', "'", '(', ')', '#');
foreach my $letter (@letters) {
$letter = sprintf("%%%02x", ord($letter)) unless $safe{$letter};
}Now that I’m looking at the above I wonder what sort of bugs I’m introducing with the inverse operation that I haven’t changed:
$str =~ s/%([0-9a-f][0-9a-f])/chr(hex($1))/ge;
I feel that this requires a call to utf8::decode when done! Strangely enough none of my tests have picked this up. 
(Actually I think I know why I haven’t stumbled across this problem: I only use the function to decode the Cookie, and all the functions accessing the cookie go through an extra encoding/decoding step that would not be necessary if I had fixed the URL-decoding function.
)
Another problem I stumbled upon: directories. Directories often ended up Latin-1 encoded.
utf8::encode($newdir);
return if -d $newdir;
mkdir($newdir, 0775)
or ReportError(Ts('Cannot create %s', $newdir) . ": $!", '500 INTERNAL SERVER ERROR');The reason I didn’t discover I had the same problem with filenames was that I’m using a compatibility layer on my Mac when I do my developments. The Mac uses UTF-8 NFD instead of UTF-8 NFC as is the standard on the web. Thus if you take bytes encoding a filename from the web and create the file, or if you go the other way, you have a problem. I store the index of all pages in a files. When a new page is created, I get the page name (NCF encoded) from the web, and store it in a file. When I read the file, the content contains the NFC bytes and with these, I cannot find the NFD encoded file (because the filesystem changed the encoding as it wrote the file). I hated it so much. Thus, the Mac compatibility layer does an extra encoding and decoding to get everything from NFD to NFC—and thereby protected me from this error.
As soon as I installed it on my sites, however—they all use Debian and ext3 filesystems, I think—I had a problem.
The necessary fix:
utf8::encode($file);
if (open(IN, '<:encoding(UTF-8)', $file)) {
local $/ = undef; # Read complete files
my $data=<IN>;
close IN;
return (1, $data);
}And:
utf8::encode($file);
open(OUT, '>:encoding(UTF-8)', $file)
or ReportError(Ts('Cannot write %s', $file) . ": $!", '500 INTERNAL SERVER ERROR');
print OUT $string;
close(OUT);Another stumbling block was that the non-breaking space was no longer just a byte sequence like any other, namely C2 A0. Perl suddenly recognized it as whitespace! This is a problem if a path contains non-breaking spaces! The old code translated spaces to underscore characters, so that wasn’t really a possibility. But whenever I had been “smart” and used a non-breaking space, I now had a problem. The glob function splits its arguments on whitespace. Where there was one pattern, I now had two broken patterns!
Here’s an example:
glob(GetKeepDir(shift) . '/*.kp'); # files such as 1.kp, 2.kp, etc.
Here’s another example:
foreach (glob("$PageDir/*/*.pg $PageDir/*/.*.pg"))The solution is to use File::Glob ':glob' and replace every occurence of glob with bsd_glob. Wow, my application was very much unsuited to filenames containing whitespace and I hadn’t even realized it!
foreach (bsd_glob("$PageDir/*/*.pg"), bsd_glob("$PageDir/*/.*.pg"))Remember the regular expression to detect wiki words I used at the top? This was the actual regular expression I had been using:
$WikiWord = '[A-Z]+[a-z\x80-\xff]+[A-Z][A-Za-z\x80-\xff]*';
Essentially wiki words only worked for a first letter containing an ASCII upper case letter.
At first, I switched this to the following regular expression (trying to minimize changes):
$WikiWord = '[A-Z]+[a-z\x{0080}-\x{ffff}]+[A-Z][A-Za-z\x{0080}-\x{ffff}]*';It turns out that Perl 5.8 chokes on this regular expression, howeveer. FFFE and FFFF are noncharacters. I had to change the regular expression.
$WikiWord = '[A-Z]+[a-z\x{0080}-\x{fffd}]+[A-Z][A-Za-z\x{0080}-\x{fffd}]*'; # exclude noncharacters FFFE and FFFFI’m sure this list isn’t complete but I’m sure it’s long enough to illustrate my main point: this is painful. It’s HTML quoting all over again.
Comments on 2012-07-20 Perl and UTF-8
Things to do for Oddmuse:
– Alex
Can it recognize new WikiWords as “ÖlPlattform”, thanks to change regular expression to match them?. As far I can understanding it a little, does it need change those regex and changes way of read (write?), string (from url, for instance) and files?
– JuanmaMP 2012-07-22 01:16 UTC
Actually, I think that a simple change of the regular expressions is all that is needed. 
– AlexSchroeder 2012-07-22 05:11 UTC
Wow, this looks great! I think I’ll need to re-map parts of the Mystara campaign … I may have some time on Sunday.
– Harald 2013-03-01 10:56 UTC
AlexSchroeder Too bad creating new icons takes so damn long. Also, two line labels would be nice. And big, diagonal labels to label areas. “Mirkwood” or something like it. Nice coastlines, roads, rivers…
Regarding roads and rivers: I’m discovering that Bézier curves need a bit more effort since simply doing a quadratic curveto (’T’ in the SVG spec) the hex midpoints isn’t working very well. I will need to rediscover my trigonometry basics!
– AlexSchroeder 2013-03-01 12:00 UTC
Add Comment