Another Quick Note, This Time on Installing LibreOffice

The deb (x86_64) files available from the LibreOffice web site work smoothly to install version 4.0.3.3 on Debian Squeeze, and doubtless on all other Debian-based systems. The instructions in the readme are very clear. Of course this is also useful for Wheezy, which ships with the same LO 3.5 as in squeeze-backports. There have been great improvements in speed and MS Office compatibility, so I’d say it’s worth it.

Incidentally, here’s how to change the default template in LO 4.

Comments

A Quick Note on Laptop Power Saving

TLP seems to work quite well without any further configuration necessary. And I already got better battery life in Xubuntu than in Windows 7.

Comments

A Poor Man’s Clone Window With Mplayer

I haven’t been too happy with VLC 2.0′s changes to the clone window filter, nor with its allergies to removing window decorations from said windows. Since squeeze-backports broke my VLC a couple of days ago, here’s the closest alternative I could come up with: using MPlayer’s synchronized network playback feature on a single computer. However, since that requires running multiple instances of the program, it’s obviously a poor alternative to merely painting the same thing twice (as opposed to also reading from disk and decoding twice at the same time). On my computer it works fairly well up to 720p, and maybe on a faster computer it’ll even work with 1080p — but it can’t be good for the environment.

The surrounding fluff is my script for automatically enabling and disabling my intended output monitor.

#!/bin/bash
#mplayer-sync

# Check if the desired resolution is available and if not, add it. The check isn't really necessary for proper operation but it keeps down error output.
[[ "`nv-control-dpy --print-metamodes`" !=  *@1920x1200* ]] && nv-control-dpy --add-metamode "DFP-0: nvidia-auto-select @1280x1024 +0+0, CRT-1: nvidia-auto-select @1920x1200 +1280+0"
xrandr -r 51.0 -s 3200x1200

# -nosound is obvious, -udp-slave makes it sync with the master, -xineramascreen 1 is in my case where I want it to show up, and -fs stands for fullscreen
mplayer -nosound -udp-slave -xineramascreen 1 -fs "$@" &
mplayer -udp-master "$@"

# Give everything time to exit before checking
sleep 1

# Check if there's still an instance of VLC running.
# $$ is the process's own PID; testing the exit code of pgrep vlc for success wouldn't work 'cause this script itself would still cause that to test positive. Incidentally, see how to check for exit codes at http://linuxcommando.blogspot.com/2008/03/how-to-check-exit-status-code.html (Yes, this comment is all based on me testing something and wondering for a minute or so why my script wasn't working correctly.)
# To check that you can try
#somecommand  argument1 argument2
#RETVAL=$?
#[ $RETVAL -eq 0 ] && echo Success
#[ $RETVAL -ne 0 ] && echo Failure
[ "`pgrep mplayer`" == $$ ] && xrandr -r 50.0 -s 1280x1024

Comments (1)

Tunnel Anxiety

I was asked to publish more of the private writing I sometimes do as a past time. About a week ago, I wrote this short story in Dutch and kind of liked it, so I decided to try my hand at a quick machine-aided translation. The quality of the initial product was surprisingly high, but it’ll nevertheless be fairly rough around the edges, especially in regard to aspects like wordplay and rhythm that were lost in the process. The Dutch original is included after the tranlation, and I’ve included some hints about literary allusions at the very end.


The GPS spoke and the driver obeyed. He had seen the sign GPS, but the dark gaping tunnel mouth looked rather scary, so he turned right as the unit ordered. Therefore he now rode on a friendly, welcoming country road. It snaked through a large green pasture, enclosed with slim ditches. While a small hare hastily hopped off, leaving behind his meal consisting of now-swaying grass stalks, the driver decided that this road was truly sublimely chosen. A Mirkwood would not be found in such an environment. No, the only trees that earned more than the epithet bush-like, grew in a manner strongly reminiscent of a battleship. The mighty bow pierced the pasture without any hassle. Captain Owl was busy talking to a virgin eagle owl, who ordered him to aim the heavy calibers for the Ilian bushes — the same bushes that bordered the road. But the larks seemed not to be disturbed by these activities, so the driver felt reassured.

In the new Scooby Doo movies, the Mystery Machine was equipped with a wisecracking, sarcastically mocking GPS. The driver was only too happy that his navigation system did not come from a cartoon, when it suddenly came to life. “Dude, what what are you doing? I just told you that you had to drive straight forward, but now you’re suddenly on a lousy back road. Turn around quickly, because that road has a dead end in about a kilometer.” Well, why had he turned right, against the advice of the GPS? A quick glance at the dashboard proved that it was only half past eight. The sun was shining pretty bright already, but with the A/C on gently it couldn’t be noticed. Hours a-plenty and why had he even wanted to go north? The current northeastern course was much more pleasant.

It was already half past nine when he looked at the clock again. Hadn’t the GPS claimed that this road had a dead end? Sure didn’t look like it. In the meantime, the landscape had started to change. The flat polder landscape gave way to gentle slopes, nicely fitted by the propulsive glaciers in the last glacial.

This road was really nice and quiet. The only sign of life were those three rams, who did not want to let him pass through the cattle guard — no matter how much he honked. Eventually he had gently pushed them aside with the bumper. Although only a few tens of minutes had passed, the road started to climb and was increasingly surrounded by spruce. A dilapidated wooden sign welcomed him in Nifolland, which was quite appropriate given the emerging fog.

Gradually he began to find it a little odd that he hadn’t seen anything for such a long time. The tank was almost half empty, so he would be forced to return if he didn’t run into a gas station soon. Remembering that he had a (currently very quiet) GPS, he let his car come to a standstill to look for a pumping station on the device. But as soon as he had found the right menu, the GPS said: “There is no turning back. The only accessible gas station is located one hour onward on this route.” With a shrug he let out the clutch and the sound of a lone car reached the ears of the dealer long before the driver became aware of the first signs of human civilization in hundreds of kilometers through the damp vapor.

“It is recommended to seek shelter from the upcoming snow storm,” said the GPS suddenly. “The Nifollandic Meteorological Institute recommends that no one goes on the road for the next few hours.”

The door put an old-fashioned bell in operation. The interior of the shop at the gas station was paltrily furnished. On crooked shelves stood foreign brands of unrecognizable engine oil and bags of junk food. He bent closer to read the gothic-style letters. Barbecue chips with sooty-sea-beast flavor. They probably also had those make up your own flavor competitions over here. Nevertheless curious, he picked up a bag and went to the counter, which was still vacated.

“Hello? Is anyone here?”

A noisy silence was the only answer.

“I want to refuel and buy a bag of chips!”

When still no one came, he decided to refuel, took the chips, and on the counter left what he owed. But how he was to find accommodation? Absent-minded he opened the chips and put some in his mouth, when suddenly a shouting dwarf came running. “Stop! Stop the thief!”

The driver hurriedly looked around, hoping to make the right impression on the local population with a good deed, when he was suddenly struck down by a punch on the jaw. Regaining consciousness an unknown amount of time and dazedly looking around, he saw three dwarfs menacingly standing around him. While he aimlessly blinked, the oldest dwarf — the same who had beaten him down — started to talk.

“This long john took off with the veteran’s food. Arrest him!”

“He’s obviously not from around here,” said another dwarf, recognizable as a police officer by a blue cap.

“I don’t care! In the cell with that worthless oat!”

“But wait…” the driver tried to say, but a simultaneous “QUIET!” by all three dwarfs locked the words in his mouth. How many days had gone by in the meantime while he was in jail, was not entirely clear to him. The dealer’d had the last word and now he was sitting here, while the snow blew through the open, barred window. The loneliness was becoming less pleasant, and when the lock of the cell door opened he looked forward to a brief conversation. In addition, he still did not know what was going on.

“Warden, could you tell me what crime I am accused of?”

“That is not my job. If you’re here, you’re guilty. You know what of.”

“But no, I do not know that at all. Couldn’t you ask? I want an appeal.”

“Appeal? Who’s here is guilty. That’s how it is and no other way.”

“But what if you were wrongly accused of something?”

“The law does not make mistakes. But I’m not here to keep you company: we have found your companion.”

“My companion? I’m alone.”

“Sure, sure. You can figure it out among yourselves.”

It turned out that the people in this remote hamlet were not familiar with the concept of a GPS. But it is true, the device had recently shown some rather strange antics.

“Say lazybones, what are you doing? I have come to save you.”

“…how do you mean? You’re a GPS. You can only show the way.”

“And now I will show you the way out of this cell. What an idiot you are. Who swipes a bag of chips?”

“But I left compensation.”

“Dude, I have a currency-information function. They work with gold and silver coins.”

“You could’ve told me.”

“You’re already too lazy to look on the map. Should I have to think for you as well?”

“No, of course not. That I can handle.”

“I haven’t noticed you thinking for shit. See you later, until you think again.”

“Wait! Do not leave me alone!”

While the blizzard raged, the driver thought. For hours, days or years the driver thought. He meditated and fasted, but the GPS remained silent, until one day he dreamed of a big river. “Yes! You got it!” exulted the GPS.

“But I—” do not get it, he wanted to say, but the GPS interrupted him.

“Turn to the left and touch the door handle.”

“A cell door has no handle on the inside.”

“Turn to the left.”

He opened the door and walked outside, where the blizzard had subsided. The snow was swirling gently down and gently he swirled toward his car. On the way back the once beautiful landscape seemed formless and empty, but at the end of the road waited the unknown tunnel mouth. “Turn left,” said the GPS, but he turned right into the tunnel. It is said that the GPS slyly smiled. It is also said that the GPS smiled happily, maternally, paternally, neuterly, and so on. Yet everyone agreed that the GPS would still lead the way for many others. But where to no one knows.

Tunnelvrees

De GPS sprak en de bestuurder gehoorzaamde. Hij had het bord GPS wel gezien, maar de donkere gapende tunnelmond oogde nogal eng, dus sloeg hij maar rechtsaf zoals het apparaat beval. Daardoor reed hij nu op een vriendelijk, uitnodigend landweggetje. Het kronkelde door een groot groen weiland, omsloten met slanke slootjes. Terwijl een klein haasje nog haastig weghuppelde, zijn maaltijd bestaande uit grassprieten wuivend achterlatend, besloot de bestuurder dat dit weggetje toch werkelijk subliem gekozen was. Een Donkere Bomen Bos zou in zo’n omgeving vast niet te vinden zijn. Nee, de enige bomen die meer verdienden dan het epitheton bosjesachtig, groeiden op een wijze die sterk deed denken aan een slagschip. De machtige boeg doorkliefde zonder enige moeite het weiland. Kapitein De Uil was druk in gesprek met een maagdelijke oehoe, die hem beval de zware kalibers op de ilische bosjes te richten — dezelfde bosjes die de weg omzoomden. Maar de leeuweriken leken zich er niets van aan te trekken, waardoor de bestuurder zich gerust gesteld voelde.

In de nieuwe Scooby Doo films was de Mystery Machine uitgerust met een bijdehante, sarcastisch spottende GPS. De bestuurder was maar wat blij dat zijn navigatiesysteem niet uit een cartoon kwam, toen het opeens tot leven kwam. “Zeg gast, wat moet dat? Ik heb je daarnet nog gezegd dat je immer rechttoe, rechtaan moest rijden, maar nu zit je opeens op een of ander belabberd achterweggetje. Draai om en vlug wat, want die weg loopt over een kilometer dood.” Tja, waarom was hij eigenlijk rechtsaf geslagen, tegen het advies van de GPS in? Een vlugge blik op het dashboard bewees dat het nog maar half negen was. De zon scheen al behoorlijk fel, maar met de A/C zachtjes aan was er niets van te merken. Nog uren de tijd en waarom had hij eigenlijk naar het noorden gewild? De huidige noordoostelijke koers was veel prettiger.

Het was alweer half tien toen hij weer eens op de klok keek. Had de GPS niet beweerd dat deze weg dood zou lopen? Daar was anders niets van te merken. Intussen begon het landschap te veranderen. Het vlakke polderlandschap maakte plaats voor lichte glooiingen, in de laatste glaciaal netjes door de voortstuwende gletsjers aangebracht.

Deze weg was echt heerlijk rustig. Het enige teken van leven waren die drie rammen, die hem het veerooster niet hadden willen laten passeren — hoeveel hij ook toeterde. Uiteindelijk had hij ze dan maar zachtjes met de bumper uit de weg geduwd. Hoewel er slechts enkele tientallen minuten verstreken waren, begon de weg al flink te klimmen en door steeds meer sparren omgeven. Een vervallen houten bordje verwelkomde hem in Nevelland, wat gezien de opkomende mist erg toepasselijk was.

Langzamerhand begon hij het een beetje vreemd te vinden dat hij al zo’n lange tijd niets gezien had. De tank was al bijna half leeg, dus hij zou gedwongen zijn om te keren als hij niet snel een benzinestation tegenkwam. Zich herinnerend dat hij een (momenteel wel heel erg stille) GPS had, liet hij zijn wagen tot stilstand komen om op het apparaat een pompstation te zoeken. Maar zodra hij het juiste menu gevonden had, sprak de GPS al: “Er is geen terugkeer meer mogelijk. Het enige nog bereikbare tankstation ligt één uur voorwaarts op deze weg.” Met een schouderophalen liet hij de koppeling opkomen en het geluid van een eenzame auto bereikte de oren van de pomphouder lang voor de bestuurder door de vochtige damp het eerste sein van menselijke beschaving in honderden kilometers gewaar werd.

“Het is aanbevolen hier te schuilen voor de opkomende sneeuwstorm,” sprak de GPS opeens. “Het Nevellands Meteorologisch Instituut beveelt aan dat niemand de komende uren de weg opgaat.”

De deur zette een ouderwetse schel in werking. Het interieur van het winkeltje bij het pompstation was armetierig ingericht. Op wat scheve planken stonden vreemde merken motorolie en onherkenbare zakjes junkfood. Hij boog wat dichterbij om de gotisch gestijlde letters beter te kunnen lezen. Barbecuechips met roetige zeebeestsmaak. Ze hadden hier zeker ook van die verzin-je-eigen-smaak competities. Toch nieuwsgierig pakte hij een zakje op en begaf zich naar de toonbank, waar nog steeds niemand was.

“Hallo!? Is hier iemand?”

Een luidruchtige stilte was het enige antwoord.

“Ik wil tanken en een zakje chips kopen!”

Toen er nog steeds niemand kwam besloot hij maar te tanken, nam de chips mee, en liet op de toonbank achter wat hij verschuldigd was. Maar hoe moest hij nu accommodatie vinden? Afwezig opende hij de chips en stak er enkele in zijn mond, toen er opeens een roepende dwerg aan kwam rennen. “Stop! Houd de dief!”

De bestuurder keek haastig om zich heen, hopend met een goede daad de juiste indruk op de plaatselijke bevolking te maken, toen hij opeens door een kaakslag geveld werd. Een onbekende tijd later weer bij kennis gekomen en verdwaasd om zich heen kijkend, zag hij een drietal dwergen dreigend om hem heen staan. Terwijl hij doelloos met de ogen knipperde, begon de oudste dwerg — dezelfde die hem had neergeslagen — te praten.

“Deze langjanus ging met het veteranenvoedsel aan de haal. Arresteer hem!”
“Hij is duidelijk niet van hier” sprak een andere dwerg, door een blauwe pet als politieagent herkenbaar.
“Kan me niet bommen! In de cel met die waardeloze hannes!”

“Maar wacht eens…” probeerde de bestuurder te zeggen, maar een gelijktijdig “STIL!” van alle drie de dwergen deed de woorden in zijn mond steken.

Hoeveel dagen intussen voorbij waren gegaan terwijl hij in de cel zat was hem niet helemaal duidelijk. De pomphouder had het laatste woord gehad en nu zat hij hier, terwijl de sneeuw door het open, getraliede venster naar binnen blies. De eenzaamheid begon toch minder prettig te worden, en toen het slot van de celdeur opende keek hij uit naar een kort gesprek. Bovendien wist hij nog steeds niet wat er aan de hand was.

“Cipier, zou u mij kunnen vertellen waarvan ik beschuldigd ben?”
“Dat is mijn taak niet. Als je hier zit, ben je schuldig. Je weet zelf wel waarvan.”
“Maar nee, dat weet ik alleszins niet. Kunt u het niet navragen? Ik wil in hoger beroep.”
“Hoger wat? Wie hier zit is schuldig. Zo is het en niet anders.”
“Maar wat nu als u onterecht van iets beschuldigd werd?”
“De wet maakt geen fouten. Maar ik ben hier niet om je gezelschap te houden; we hebben je compagnon gevonden.”
“Mijn compagnon? Ik ben alleen.”
“Ja ja. Jullie kunnen het onder elkaar wel uitzoeken.”

Het bleek dat de mensen in dit afgelegen gehucht niet bekend waren met het concept van een GPS. Maar het is waar, het apparaat had recentelijk nogal vreemde kuren vertoond.

“Zeg luiwammes, wat zit je daar nou? Ik ben gekomen om je te redden.”
“…hoe bedoel je? Jij bent een GPS. Je kunt alleen de weg wijzen.”
“En nu zal ik je de weg uit deze cel wijzen. Wat een idioot ben je ook. Wie jat er nou een zak chips?”
“Maar ik heb geld achtergelaten.”
“Gast, ik heb een valuta-informatiefunctie. Ze werken hier nog met gouden en zilveren munten.”
“Dat had je me eerder wel kunnen vertellen.”
“Je bent al te lui om op de kaart te kijken. Moet ik soms nog voor je nadenken ook?”
“Nee, natuurlijk niet. Dat kan ik zelf wel.”
“Ik merk er anders nog geen ene reet van. Tabee, tot nadenkens.”
“Wacht! Laat me niet alleen!”

Terwijl de sneeuwstorm voortraasde, dacht de bestuurder na. Uren, dagen of jaren dacht de bestuurder na. Hij mediteerde en vastte, maar de GPS bleef stil, tot hij op een dag droomde van een grote rivier. “Ja! Je hebt het begrepen!” jubelde de GPS.

“Maar ik—” snap er niets van, wilde hij zeggen, maar de GPS onderbrak hem.

“Draai naar links en beroer het handvat van de deur.”
“Een celdeur heeft geen handvat aan de binnenkant.”
“Draai naar links.”

Hij opende de deur en liep naar buiten, waar de sneeuwstorm was bedaard. De sneeuw dwarrelde zachtjes neder en zachtjes dwarrelende hij richting zijn auto. Op de terugweg scheen het eens zo mooie landschap woest en ledig, maar aan het einde van de weg wachtte de onbekende tunnelmond. “Sla links af”, sprak de GPS, maar hij sloeg rechtsaf de tunnel in. Er wordt gezegd dat de GPS geniepig glimlachte. Men zegt ook dat de GPS gelukkig glimlachte, moederlijk, vaderlijk, onzijdig, enzovoorts. Toch is iedereen het erover eens dat de GPS nog vele anderen de weg zou wijzen. Maar waarheen weet niemand.

Antwerpen, 2013-03-28.

Afterword

I went a bit wild with the literary allusions in this story partly because I had just read a concise criticism of Nabokov. In a one-star review of one of Nabokov’s works, the reviewer stated that Nabokov brings his entire library with him when he writes. I can’t disagree, but I love that. I don’t necessarily love that I don’t get all the Russian or even all the French allusions, but there are aids such as critical editions and the Internet.

In my own text, I think the references to Greek mythology at the beginning are fairly obvious, perhaps too much so, but I hope the Norse mythology was significantly less in-your-face. Then again, I had to resort to Old English to find a cognate to the Old Norse nifl, which probably doesn’t help any. But most important, this story pays tribute to a variety of stories originally written by Marten Toonder, although I decided to replace the explicit mention of the Dark Tree Forest by the Mirkwood as a cultural translation. The prison exchange alludes — again too obviously — to Multatuli’s Max Havelaar. The little Joycean turn of phrase at the end is probably far more obvious to speakers of English than to speakers of Dutch, and the opening line attempts to somewhat paradoxically evoke Stephen King’s The Gunslinger. Whether there is more to be found I shall leave as an exercise to the reader. I hardly brought my entire library for a two-and-a-half-page story, but I did bring a little more that’s not Dutch.

Comments

Some Notes on LaTeX

Because LaTeX offers nice typesetting, bibliography management, and most Linux distributions make it easy to play around with, I decided to experiment with the LaTeX basics. To get started on Debian and derivatives, the easiest option is to install the texlive package, which will pull in all the basics. Here’s a quick list of things that might be useful:

  • texlive: the basics.
  • pandoc, hevea, latex2html: pandoc can convert between a great many formats, the other two merely try to transform LaTeX into HTML.
  • texmaker, texworks: both seem to be good editors. Also of interest are Kile and Gummi.
  • lyx: a what you see is what you mean editor. Could be interesting as an alternative to LibreOffice Writer or Abiword.
  • jabref, biblatex, biber (not on Squeeze): JabRef is a BibLatex editor, something that makes citations easy. Biber is a superior modern Biblatex replacement which uses the same file format.
  • texlive-lang-dutch (Dutch hyphenation patterns): alter for your own languages, or just install texlive-lang-all.
  • texlive-fonts-extra: if you want some extra fonts to play with.

texlive-fonts-extra requires running (sudo) getnonfreefonts-sys -a to actually get most of them to work. Unfortunately it’s missing in Ubuntu 12.10. As a workaround we can get it straight from the horse’s mouth. However, it has some issues logging in as anonymous to the FTP, so we need to use HTTP instead: sudo getnonfreefonts-sys -H -aThe problem seems to have been fixed. sudo getnonfreefonts-sys -a will do.

pandoc and hevea seem to produce the best HTML. Unfortunately HeVeA doesn’t work with BibLaTeX, while pandoc sort of does. However, it needs a little coaxing.

pandoc GNL3-2012-2013.tex -o output.html --bibliography boeken.bib -s --toc

-o outputs to a file
–bibliography specifies the bibliography file to use, which isn’t automatically taken from the LaTeX file
–toc neither is the insertion of the TOC
-s creates a standalone file; is required for the title page and the TOC to be inserted.

It’s not quite ideal though.

Texmaker and modern times

In Texmaker you can simply replace the pdflatex line with luatex and you’ll be good to go.

To replace bibtex with biber, also make sure to remove the file extension. So instead of bibtex %.aux, we use biber %. Something similar applies to TeXworks.

Now that all the software is set up, you can start using LaTeX. There’s a very useful Wikibook about LaTeX. Or you can ignore all of the above and look into ConTeXt, which I understand should be easier to stylistically manipulate.

Comments (2)

Strip The Junk Out of Word or Writer Files with Writer2LaTeX and Pandoc

While playing around with LaTeX stuff I noticed that the clean article and ultra-clean article Writer2LaTeX options were quite useful. It occurred to me that aside from converting anything Writer can open to LaTeX, this might also be used to strip the cruft from those very same files. Just convert them back to ODT afterward.

pandoc -o output.odt input.tex

Since Writer2LaTeX was a command-line utility before it became a LibreOffice extension, we can automate it a bit more like this after installing the writer2latex package:

w2l -latex -ultraclean input.odt

Unfortunately that won’t handle everything LibreOffice does. If you want to stick to the command line you can take care of that like this:

loffice --headless --convert-to odt input.docx

I stuck it all in a shell script:

#!/bin/bash
#clean-writer.sh
#http://stackoverflow.com/questions/965053/extract-filename-and-extension-in-bash/965072#965072
FILENAME=$1
EXTENSION=${FILENAME##*.}
FILENAME=${FILENAME%.*}

SCRIPT_NAME=`basename "$0" .sh`
TMP_DIR=${SCRIPT_NAME}-tmp
OUTPUT_FILENAME=${FILENAME}-clean.odt

mkdir ${TMP_DIR}
cp $1 ${TMP_DIR}
cd ${TMP_DIR}

#convert to ODT if the file is DOC or something
if [ "$EXTENSION" != "odt" ]
then
	loffice --headless --convert-to odt $1
fi

w2l -latex -ultraclean ${FILENAME}.odt
pandoc -o ${OUTPUT_FILENAME} ${FILENAME}.tex

mv ${OUTPUT_FILENAME} ..
rm *
cd ..
rmdir ${TMP_DIR}

And thus you end up with a much more manageable Writer file. Just be careful: e.g. tables aren’t supported by Pandoc quite properly.

Comments

Compose Key on Xfce

Since the compose key is one of my favorite things in Linux, I was rather disappointed not to immediately find an obvious means of configuring it in Xfce. Not to worry, the slightly unintuitive but still easy method of configuring the compose key consists of adding the Keyboard Layouts widget to one of your panels.

screenshot-keyboard-layouts

As much as I love the portability, readability, and power of plain-text configuration, for just setting a compose key I don’t think it can get much better than the Gnome keyboard configuration dialog. The easiest alternative method would seem to be xmodmap, which should work in any desktop environment, not just Xfce. But of course it didn’t, because Xfce somehow overwrites those settings. For the sake of completeness, here’s what I tried in ~/.Xmodmap:

clear Lock
keysym Caps_Lock = Multi_key

It might be better to use to setxkbmap.

So there you have it. I haven’t yet figured out the ideal way of setting up my keyboard, but as long as it works I’m not too bothered yet.

Comments

Synergy wants Qt4

Apparently the Synergy package doesn’t presently (1.4.10) add Qt4 to its dependencies. Grab libqtgui4 manually to fix the problem: sudo apt-get install libqtgui4.

Comments

parseIntHelper()

The results of parseInt() are somewhat inconsistent, so I wrote this to clean it up (also see there). What to do with it? Who knows; it might come in handy someday.

function parseIntHelper(numberString, radix) {
	numberString = (typeof numberString === 'number') ? numberString.toString() : numberString; // I guess we should support number input just like parseInt.
	radix = (typeof radix === 'undefined') ? 10 : radix; // Set radix to 10 if undefined.
	
	numberString = numberString.replace(/^\s\s*/, '').replace(/\s\s*$/, ''); // Trim. Taken from http://blog.stevenlevithan.com/archives/faster-trim-javascript
	
	// Check if octal; non-standard but in line with other languages
	if ( numberString.indexOf('0o') === 0 || numberString.indexOf('0O') === 0 ) {
		numberString = numberString.slice(2); // Remove '0o'.
		radix = 8;
	}
	
	// Check if hex
	if ( numberString.indexOf('0x') === 0 || numberString.indexOf('0X') === 0 ) {
		numberString = numberString.slice(2); // Remove '0x'.
		radix = 16;
	}
	
	for (var i=0; i<numberString.length; i++) {
		var nStr = numberString[i];
		if (nStr === '.') {
			continue; // Ignore decimal mark, or rather the radix point. Maybe a check against more than 1 of these?
		}
		var parsed = parseInt(nStr, radix);
		if (isNaN(parsed)) {
			return parsed; // Return NaN if found
		}
	}
	return parseInt(numberString, radix); // Return regular parseInt if there was no shenanigans. Note that we do not support octal numbers prefixed with 0 because it's not in the ECMAScript 5 spec, although we do support the equally non-standard prefixed with 0o. That's because the behavior prefixed with 0 is just too unreliable, while we control what happens with 0o.
}

Comments

On My Header Image

In what is probably the biggest visual change since I first created this theme back in ’05 — yes, it’s that old! — on June 2, 2011 I replaced the header image with a picture I took a month prior in the Keukenhof.

The opportunity presented itself to experiment slightly with decent JPEG compression, rather than simply depending on GIMP’s output, which unfortunately is virtually guaranteed to be suboptimal. Since all I did was crop and resize, I used PNG as my working format. I might’ve been able to use jpegcrop and jpegtran, but since I was going to re-encode in a lossy manner afterward that would have been nothing but needless extra effort.

First I tried cjpeg, which doesn’t support a lot of input filetypes, so I had to save a copy as BMP.

cjpeg -quality 80 -optimize -progressive -dct float -outfile test80.jpg head.bmp

Then I discovered that imagemagick can do the exact same thing, optimized by default and everything. It also uses libjpeg under the hood, so the resulting image is exactly the same.

convert -quality 80 -interlace plane head.png test80.jpg

That results in JPEGs that are about as small as they can get without enabling options that might not be readily supported by all viewers. I wrote a (very) simple shell script to aid with a quick overview of size versus quality.

#!/bin/bash
#jpegs.sh
filename=$1
extension=${filename##*.}
filename=${filename%.*}
convert -quality 30 -interlace plane $1 ${filename}30.jpg
convert -quality 40 -interlace plane $1 ${filename}40.jpg
convert -quality 50 -interlace plane $1 ${filename}50.jpg
convert -quality 60 -interlace plane $1 ${filename}60.jpg
convert -quality 70 -interlace plane $1 ${filename}70.jpg
convert -quality 80 -interlace plane $1 ${filename}80.jpg

My rationale is that any quality under 30 is most likely too ugly and anything over 80 will result in a file size that’s too large for my intended purpose of using lower quality — but not low quality — images on the Internet.

I also decided it was time to get rid of my half-hearted concessions to Internet Exporer. This in no way inhibits readability of the content.

Comments

Older Entries »