Posts

  • Updating an old app made with Visual Studio Tools for Apache Cordova

    Recently I had to generate new iOS and Android versions of an app that had been created in Visual Studio 2015 using the Visual Studio Tools for Apache Cordova. This wasn't... easy. In this post, I will summarize some of the challenges I encountered and the solutions I found.
  • Profiling PHP with XDebug and KCacheGrind

    Does it take too long for your PHP page to load in the browser? Have you been staring at the code for ages and tried many fixes that didn't help much? Still no idea where the performance bottleneck is? Could it be somewhere in that bloated framework that you use? Or in some new class that your co-worker made last week? Or, heaven forbid, somewhere in your own code? To find out, a profiler will be of tremendous help. In this post, I will show how to use XDebug's profiler and KCacheGrind to help make your code faster.
  • Getting a date's week number in JavaScript using (tail) recursion

    Several years ago I wrote a post about how to calculate the ISO 8601 week number of a given date without using an external library like Moment.js and without using ugly implementation details such as seconds since 1970. It worked, but it wasn't the most elegant code ever. It used a while loop. Maybe it's just me, but I don't get along well with while loops. I always get the while condition wrong at first, or I forget to increment or decrement something, and I end up with a loop that lasts forever or crashes my program.
    An alternative for a while loop is recursion. In this post, I'll examine what happens if I change the iterative function of that old post to a recursive one.

  • Syntax highlighting for source code in Blogger Dynamic Views theme with Google code prettifier

    I recently changed this blog's theme to a Dynamic Views theme. Its looks and behaviour are much more modern now. However, syntax highlightling for my source code snippets didn't work anymore. Apparently my previous solution with highlight.js doesn't work well with Dynamic Views. (For the "classic" themes it still works, though.)

    I tried modifying the theme's HTML and inserted the required tags in the header section, but I just couldn't get it to work. Maybe it has to do with the fact that posts are now loaded after the main page has loaded. I tried inserting the tags at the start of a post, but that didn't seem to work either. Searching for an alternative, I stumbled upon Google's code prettifier. It looked super easy to set up, so I gave it a try and it works well. Here's how to make it work:

  • Natural Sort in dojo's EnhancedGrid

    "Hi, I would like to report a bug in the web app you built for us."
    "Sure, what seems to be the problem?"
    "The order in the tables is all wrong."
    "Really? You can change the order of the items in the table by clicking on the column header that you wish to sort on."
    "I know, and I did. But it sorts them wrong."
    "OK, could you give me an example of what is ordered wrong?"
    "Sure. I have three rooms, called Room 3, Room 50 and Room 225. If I click the room column's header, it should order them in that order: Room 3, Room 50 and then Room 225. Instead, I get Room 225, Room 3, Room 50."
    "Oh, I see. Well, technically, that is the correct order. 2 before 3 before 5."
    "But it's 225, not 2. And 50, not 5."
    "Yes, but the sorting happens character by character. It checks the ASCII code of -"
    "Axi what? Look, I'm not interested in the technicalities, could you just get it to work properly?"

    Natural Sort

    This kind of dialogue happens in a lot of software projects at some point. Confusion arises because the two participants are talking about two different ways of sorting.

  • Revisiting my first programming language: Commodore 64 BASIC

    In the mid-eighties, when I was about 10 years old, my parents bought our first home computer. I had just read some magazine that contained a program listing for the Commodore 64, and somehow I was very curious about it, so I'd urged them to buy a Commodore 64. Somehow they listened to me and they bought the machine. Soon, after playing some Pac-Man and Burning Rubber on it, I started entering the program code from the magazine. I had no idea what sort of code it was or what it meant, but I managed to enter all lines (the last 100 of which contained nothing but DATA lines with lots of numbers in them) correctly. I figured out how to save the program to tape and how to run it. I don't remember what the program actually did, but I was fascinated by it and decided to learn how to write my own programs on that machine.

  • Managing large amounts of files in Linux

    Suppose you have a directory with millions of files in it. Performing commands on so many files in Linux is often challenging because of limits on the number of arguments that can be provided to commands.

  • Fixing Firefox issues with column headers for dojox.grid.EnhancedGrid

    In Firefox, clicking a dojox.grid.EnhancedGrid’s column header to change sorting only works for the first column. Clicking another column’s header only shows a splitter. The same goes for right-clicking a column header to bring up a popup menu: it only works in the first column. In other browsers this works fine.

  • Implementing an Android radio button dialog in QPython 3

    QPython 3 is a neat app that allows you to run Python 3 scripts on an Android device. All my scripts that I originally created on Linux worked without problems. They were all console scripts though, and I decided to Androidify them a bit. Instead of asking multiple choice questions and making the user type in the answers in the console, the scripts should show nice radio button dialogs:

  • Creating a baby journal with TiddlyWiki 5

    Keeping a journal about your baby is fun. There are plenty of online services that can help to keep such a diary, but you need to have an internet connection to access them, and you have to trust them to keep your data safe.

    This blog post descibes how to keep a journal that will also be available to you when you're offline. It will be just one file that you can store anywhere and view or edit with any modern web browser. Journal entries can contain rich text and images, and automatically show the entry's date and your baby's age at that date:

  • Syntax highlighting for source code on Blogger 2: highlight.js

    After using the excellent SyntaxHighlighter by Alex Gorbatchev for a while (see this post), I decided it was time for a change, and tried highlight.js. Here's how to set it up to work with a Blogger blog:
  • Getting a date's week number in JavaScript

    JavaScript's Date object doesn't seem to have a built-in function to get the week number of a date. There are many JS libraries that do have support for this, but I needed to get the week number in an environment where including libraries is awkward (in a TiddlyWiki 5 macro, if you really want to know). So I decided to make my own function.
  • Mounting a HiDrive in Ubuntu

    Accessing a (free) Strato HiDrive as a regular filesystem in Ubuntu is possible, though not completely trivial to set up. Here is what I had to do to get it running:
  • Running interactive programs uninteractively in Bash scripts

    Bash scripts are great for automating tasks. Some challenges arise though when you want to automate a process that involves programs that ask for user input by keyboard. You know, the kind of program that keeps asking things like: "Are you sure you want to do this (y/n)?". Most programs accept arguments that enable some kind of "non-interactive mode" for that. For example,


    rm -i somefile
    asks for confirmation before deleting somefile, while

    rm -f somefile
    does not. This of course makes the latter a lot more suitable for use in automated scripts. Unfortunately, not all programs provide these kind of arguments. What to do with them?
  • Dynamically hiding and showing columns in a Dojo DataGrid

    Still having fun with my DataGrid. (See my previous postfor more DataGrid joy.)

    Now I had a big DataGrid with lots of columns and rows. It got so big that I decided it might be a good idea to hide some rarely needed columns when the user clicks a button. As I found out, the JavaScript code to show or hide a DataGrid's column is:

  • Firing an event after updating a DataGrid's data store in Dojo

    Currently I find myself struggling with Dojo. It's rather sparsely documented and I regularly have to plow through the web to find out how to get something done. I might as well document some of my findings here, so other people (and myself because I might forget) can benefit from it.

    In this case the issue was that I had a Dojo DataGrid, and I wanted to do something after every (re)load of its datastore. For the example's sake, suppose I wanted to run the following JavaScript function:

  • Syntax highlighting for source code on Blogger

    This being a software development blog, I wanted to show some source code. This code should of course be shown in a nicely syntax highlighted way. I searched around on the web a bit, and found some articles that explain how to use the excellent SyntaxHighlighter by Alex Gorbatchev on Blogger, but they're rather old. Here are updated instructions for the new Blogger interface:

  • In Visual C# 2008 Express, Save doesn't always save your work

    The most important thing I learned in all these years using computers is to save my work often. Very often. Hardware and software, no matter on which OS, have a tendency to stop working just when you're in the middle of editing some large and important document. That's why I always save after almost every sentence. (The Blogger editor saves automatically and often too, I noticed, which I appreciate a lot.)

    In Visual C# Express however, often saving turns out to be not always enough. I created a new project, added some files to it, assuming they would be saved in the normal project location (My documents\Visual Studio 2008\Projects). I fooled around a bit with the project, ran it a few times, added more files, fooled around some more, edited my files, clicked Save File a lot, ran my application a few times, debugged it, and this went on for the whole afternoon. Then I tried to resize a panel in a form and something went wrong: Visual C# Express crashed. No problem, I thought, I've saved all my work until that last fatal change. So I relaunched Visual C# Express, clicked "Open project" and then, to my dismay, I could not see my project!

subscribe via RSS