Archive for the ‘software’ Category

Adding tabs to your website

Wednesday, August 7th, 2013

Lindy hop logoSjouke and I have been actively updating and improving the Swing Dance Luxembourg website. Informally, we’ve reached a division of tasks: Sjouke is focused more on content, and I focus more on tweaking CSS, HTML and Javascript. This division is obviously not 100% clear cut, but the Javascript work on the site that WordPress doesn’t handle, I do :) (yes, the website is running WordPress – you wouldn’t say, would you?)

One of the first more substantial pieces of work was making the FAQ such that it expands questions on a click. As with any programming task, the concept is fairly trivial, and the devil is in the details (e.g. updating the “?” character to a “?” for open questions). And, of course, Sjouke is perfectly happy to pretend he doesn’t understand code, and make user requests (“we ought to have a ‘show all’ link), which sound reasonable. Of course, there’s more than one way to implement such requests, and usually the easy way is not not quite supported by my Javascript… meaning more fun for me!

We’ve had a bit of a discussion on how to organise the descriptions of the various Swing Dances. There’s quite a few we describe, and just having all descriptions under each other was rather messy. Then I hit upon a great idea: using tabs!

The internet was rather helpful, and quite a few sites provide some bare-bones instruction on how to get the tabs looking like tabs. Halfway through, I switched to using this explanation, which was simple and showed some alternative approaches.

In a nutshell, you use a regular list (UL) for the tabs. So each tab is in its own LI element. You use CSS to then tweak the presentation. The beauty of using CSS, you can actually nicely separate presentation and structure, thus ensuring a better degredation for screen readers / non-graphical browsers. In particular, you’d use list-style: none outside none; for the UL, and either display: inline or float: left for the LIs. To get the tab to look as part of the content, you extend the padding on the bottom a bit to overlap with the content (and decrease the margin by a similar amount – to ensure the content is not pushed down by the padding).

As you can see, I tweaked the looks somewhat further. Adding a border to the LIs, except at the bottom. Rounding the corners of that border (border-radius), but not the bottom-left-radius or bottom-right-radius. I added a background to the lot.

Done! Right?
Nuh-uh.
The tabs don’t work yet.
Oh, right….

So, some coding is needed. Each tab’s “content” is in a separate DIV. All DIVs except the default one are set to display: none to hide them (which is not necessarily ideal — it still involves loading all DIVs upon first opening the page). So what is to happen when we click a tab? Well, the active content DIV is hidden, and the one clicked on is shown. That part is actually trivial.

But: the tab itself must also come to the foreground. I am currently coding the required style updates in Javascript itself, which is very ugly and makes it hard to update.
I just found this little gem, so basically I should be able to just update the class names instead of tweaking styles. While it works for now, I’ll probably have a look to that soon, because it just is so much better.

Nevertheless, the current result is already le awesome! To support old links to anchors (...#blues and such), I even added some Javascript to check if such a link was requested and then load the requested DIV. One funny thing that tripped me up there: you can only switch DIVs after the DIV is loaded. Rather obvious once phrased like that, but it means that that particular piece of Javascript has to be at the bottom of the page :)

Skype on Ubuntu 12.04-64 bit

Wednesday, March 20th, 2013

here’s what did work for me.
(sorry for the short post, in a hurry!)

Unity crashes on Alt-Tab (Ubuntu 11.10)

Thursday, February 21st, 2013

So, there’s a bug, where Unity (Ubuntu’s window manager) crashes on Alt-Tab. It’s been fixed for a year now in the newer Ubuntu’s, but those of us running the old stuff… we’re stuck.

Unless, of course, we follow the advice in one of the comments:

  • Install “compizconfig-settings-manager”
  • run “ccsm”
  • go to “Ubuntu Unity Plugin” -> Switcher
  • disable all key bindings.
  • Go back to the main screen and enable “Static Application Switcher”.
    (If you do it the other way around, you will get segfaults.)

It gives you a more limited switcher (only to windows on current desktop). On the other hand, this one switches to windows instead of applications — so no more annoyance trying to switch to the right window of an application that you’re running 10 times (such as a terminal window).

SokoDroid

Thursday, January 10th, 2013

sokodroid logoThanks to Filipe Ferreira, we have tested Soko2012 on an Android system. You can see the result below.

It works!!!
photo of sokoban on android tablet

SokoBan 2012 released!

Friday, January 4th, 2013

Arnout de Mooij and I are proud to announce the first official release of SokoBan 2012! This is a classic version of the game Sokoban, completely programmed by Arnout and myself. We started programming this around the time we both just had access to pentiums. Or perhaps even slightly before. Well, it took so long this game can go straight into nostalgia haven!
Sokoban menu

Quick install

  1. download and unzip soko2012.zip
    Android users: you’ll need an unzip utility.
  2. install DosBox 0.74 or higher
  3. For Windows only, here’s how to create a shortcut (see also the below picture):
    • Go to the Desktop.
    • Select the DosBox icon.
    • Press Ctrl+C and then Ctrl+V to copy the shortcut.
    • Right-click, select “Properties”
    • At the end of the field “Target“, add the full path of soko2012.exe.
      E.g., if “Target” was "C:\Program Files\DOSBox-0.74\DOSBox.exe" -userconf, and the files were extracted to C:\Users\hugo.jonker\Downloads\sokoban\, then “Target” should become "C:\Program Files\DOSBox-0.74\DOSBox.exe" -userconf C:\Users\hugo.jonker\Downloads\sokoban\soko2012.exe.
    • Change the field “Start in:” to point to the folder where you extracted the zipfile.
      E.g., continuing the previous example, “Start in:” would now become C:\Users\hugo.jonker\Downloads\sokoban\.
    • Change to the Tab “General” and rename the icon to SokoBox.

Shortcut icon properties

To play:

  • Unix: run startsoko.sh from the command line.
  • Windows: Double-click the SokoBox icon.
    Potentially the game runs slow, press Ctrl+F12 a few times to speed up DosBox.
  • Android: Run DosBox and enter the following commands:
    • cd Downloads\sokoban
    • soko2012.

Screenshots

Sokoban's level selector Sokoban's image sets
Sokoban lvl 6 in play playing lvl 5

Features

  • 48 completely original fields
  • 22 completely original, totally not-ripped graphical sets, including:
    • a fastfood-themed set
    • a halloween-themed one
    • a crisis-themed one (bring your money to the bank)
    • a Sinterklaas-themed one
    • a christmas-themed one (notice that Sinterklaas != Santa)
    • a few inspired by videogames of the 8-bit era
    • and more!
  • a stand-alone level editor
  • a stand-alone graphics editor (heavily updated in 2012!)
  • Keeping tracks of 2 types of highscores:
    1. the best efforts (least moves, then quickest) for the first 10 levels
    2. the 10 players who got the farthest completing all levels
  • A player-state saving system, so that you could continue to improve your score for the 2nd type of highscore
  • Level selector with thumbnails of the levels
  • a demo mode (don’t touch any key for a while in the beginning, and the game will play one of the first 20 levels).
    Pointless? FUN! :)
  • Opening and ending scrolling titles
  • Insanely trivial-to-break encryption scheme for said titles :)
  • And, lest we forget: CHEATS! Including a complete internal level editor. I kid you not.

System requirements

Yeah, that’s sort of it. This game was in development for a while, and unlike Duke Nukem Forever, we never deviated from the original specs. Sure, we need some memory (640K is enough :),  CPU (press Ctrl+F12 to speed up, Ctrl+F11 to slow down — these are dosbox controls, not ours), and some graphical requirements (stock VGA modes). Really, your smartphone can handle these. With two fingers in its nose.  :)

Development history

Question: what does this version of Sokoban have in common with such pretentious names as Guns n’ Roses’ Chinese Democracy, or the game Duke Nukem Forever?
Answer:

  • Chinese democracy: in development 1998-2008
  • Duke Nukem Forever: in development 1997-2010
  • Sokoban by us: in development 1994-2012

Message to take home: all good things deliver. Alternatively: not everyone can maintain their development quality as long as Arnout and I can :)

Thanks

Big thanks due to everyone who helped and inspired us. You’re probably named in the titles already!

Questions/comments

If you have any questions or comments, don’t hesitate to contact me!
If you’re reading this blog, you ought to know how :)

Thunderbird’s context menu disappears

Wednesday, November 28th, 2012

Thunderbird logoI like cleaning up my inbox. Right-click a message, “move to” and select a folder.

Except that sometimes, I right-click a message, but before I can select “move to”, the context menu is gone again. Annoying. Apparently, I’m not the only one.

Work-around: minimize the window and then restore the TB window again. The bug is still being hunted, as far as I can tell.

SVN “generic failure”

Saturday, November 17th, 2012

Talk about weird errors:
$ svn up
svn: generic failure

Le what?!

Apparently, this can have multiple causes:

  • Hostname of your local machine not being resolved (try adding to hosts file of the SVN server)
  • Firewall issue(s)
  • Negotiation issues (try changing from “file://” to “svn+ssh://”)

The first issue (your computer does not know who it is) is actually a problem. Diagnose this by checking with “sudo echo hello world” — does sudo report “cannot resolve host ….”? If so, then the below will probably solve it:
echo "127.0.0.1\t`hostname`" >> /etc/hosts

Sloppy focus (focus follows mouse) in Ubuntu 11.10

Wednesday, November 14th, 2012

Had to upgrade my ubuntu when they ended support for Ubuntu 11.04. Of course, now I no longer have the nice window manager…

But this one can be tweaked too. Install “MyUnity” to set # desktops, and (e.g.) set whether devices should be shown (a good option since it’s harder to find them now than before).

Another tweak, adapted from this tip, is how to re-enable sloppy focus:

gconftool-2 --type string --set /apps/metacity/general/focus_mode sloppy

Apparently, according to an answer to that question, there are 3 different values: sloppy, click, and mouse:

  • click: click in window to get focus
  • sloppy: point into a window to give it focus
  • mouse: focus on window if (and only if) mouse is in window

I prefer my focus sloppy, thankyouverymuch :)

Dosbox won’t get Ctrl-Break…

Thursday, November 1st, 2012

As you do not know, during my recent bike holidays, I ran into Arnout and had another go at Sokoban. Of course, I couldn’t just let it be and I’ve been having some fun ever since tinkering with the source code.

Point of particular annoyance: in Dosbox, QB / QBasic does not react to CTRL+Break. Which happens to be the key code to halt the program and edit it — in other words, my debugging key. I now got curious, and turned to The Google.

  • Here’s why CTRL+Break doesn’t work in a normal DosBox setup.
    (tl;dr version: no event generated whatsoever by the keypress. Also: this is a “magical” key-combo, in that it triggers an erase of the keyboard buffer and a call to a special handler — in short: special magic is needed, and none of it is there).
  • Apparently, there is a patch to enable CTRL+Break (note that this patch requires another patch). Didn’t try it myself.
  • Best of all: QB / QBasic respond similarly to CTRL+ScrollLock. Which works out of the (dos)box. :)

Sound in TuxGuitar

Thursday, November 1st, 2012

I just accidentally uninstalled TuxGuitar (it uses Java, which I have a habit of deleting from my system :). Unfortunately, that meant I not only had to reinstall it, but also had to re-find-out how to get sound working. The problem: default midi for TuxGuitar is /dev/sequence, which, by the way, does not exist.

Oookay…

After a search, I found one way to do it:
sudo apt-get install timidity tuxguitar-jsa
This installs a real-time sequencer.
Tweak the settings in TuxGuitar (F7 -> sound) to use this, on the appropriate MIDI port — in my case, Gervill.