blog/ notes/ projects/ colophon

After almost a year of not flying easyjet (yay flybaboo!), I had to go to Bordeaux, and the only convenient times were offered by Air France (via Paris : min : 3 h 30) or easyjet. And Easyjet was half the price and a third the time of Air France.

After dodging the speedy boarding, travel insurance, 'extra' luggage, hotel booking, car rental, remembering my password, narrowly avoiding the credit card extra charges (backtrack to step 2, change currency to euro, do the above again then change payment method to 'carte bleu'), I am greeted by this:

wtf Easyjet

Which, according to google translate is the Croation blurb about not leaving your luggage unatended etc...

The page was all in french, the ads were all in french except this paragraph. WTF ?!?

On the 42nd day of a streak in calendar about nothing I simply forgot to do and commit something. After a new streak was well underway, I decided to add a snapshot of the page to my Mac desktop, so as to try and ward off another lapse. A quick google search found CutyCapt, a Qt & Webkit based program available as a Windows binary or as source code. As I already had installed Qt, Xcode and GeekTool, I decided to use the source code rather than look for something simpler to install.

GeekTool is a very practical app for Mac OS that allows you to display images, text files or shell scripts result in a layer between your desktop image and your desktop icons.

Here is what the combination of the above can look like :

Geektool + calendar about nothing - All the crap usually lying around on the desktop have been moved to the 'all my stuff' folder for this posed screenshot.

If you are not interested in installing Qt, Xcode and compiling random source files, you can download CutyCapt in binary form for mac and skip to the GeekTool setup. Or you can build it from source. For that option, you need to use the Terminal, and already have Xcode and Qt installed.

How to build CutyCapt (once you have all the prerequisites installed):

  • Download and untar the CutyCapt sources from the website (scroll down).
  • In the Terminal, cd to the directory extracted from the archive and run qmake (no option), which will generate the Xcode artefacts.
  • Compile the Mac binary by running xcodebuild (no option either). The binary will be in the newly created CutyCapt.app/Contents/MacOS/* directory. You can copy it to some shorter path if you want.

Setting the image on the desktop :

The following setup will download your calendar page and wait 5 seconds for the scripts and css to execute, render the result, and repeat this every hour (the echo 'last updated the image on :';date; part it to see when the command was executed last).

  • Install GeekTool
  • In the GeekTool preference pane, drag a Shell widget to your desktop, for calling the CutyCapt.
  • In the Command field, put, all in one line, echo 'Last updated the calendar snapshot on :' ;date ;{path/to/CutyCapt/binary}/CutyCapt --url=http://calendaraboutnothing.com/~{your github account} --delay=5000 --out={somewhere/on/your/machine}/calendaraboutnothing.png.
  • Set the Refresh to 3600 seconds.
  • In the GeekTool preference pane, drag an Image widget to the desktop.
  • In its option, click "Set local path" and select the image generated by the script setup above (GeekTool will refresh the image when it notices that the image has been updated).
  • Done.

The image will be rendered every hour on you desktop. Once you're done for the day, you can de-activate this group in the GeekTool menubar menu.

A while ago, there was a HN post about Jerry Seinfeld's Productivity Secret. In the comments, a few interesting links showed up, amongst which calendar about nothing which generates your streak (an unbroken sequence of days in which you attained some personnal objective) from your public (open source) github commits.

When It was mentioned again a few month later in another HN post (Ask HN: Share a gem. Teach me and you.) and I was already using github, I decided to give it a try. Long story short, my public output dramatically increased :

calendaraboutnothing_effects

Obviously not all days are equally productive, but at least every day I move something forward, either some code or some content for this blog (as announced earlier, this blog's content is on publicly available on github). One of the drawbacks is that on some days I do a commit, keep working and only commit these changes the next day. But on average, it is a net gain.

a.k.a 'clipping'.

If you expect to retain the original image, you can use BufferedImage.getSubimage(x, y, h, w), which should be fast and memory efficient, as, per the Javadoc, it "Returns a subimage defined by a specified rectangular region. The returned BufferedImage shares the same data array as the original image".

If you expect to eventually get rid of the original image while keeping the clip, using this method will create a memory leak as, when you set the reference to the original to null, each clip will retain a link to the original raster and prevent it from being garbage collected.

Here are two ways of creating an independent copy of a sub part of the original image :

  • in a succint but slow manner:
  • in a much more verbose but 10 times faster manner:

Here are the time measured, on the same machine, for clipping a 200x200 pixel area from the center of a bigger image 1000 times, 10 times in a row :

slowClip :1000 times = 3717 ms
slowClip :1000 times = 3440 ms
slowClip :1000 times = 3409 ms
slowClip :1000 times = 3406 ms
slowClip :1000 times = 3403 ms
slowClip :1000 times = 3399 ms
slowClip :1000 times = 3390 ms
slowClip :1000 times = 3397 ms
slowClip :1000 times = 3390 ms
slowClip :1000 times = 3597 ms

fastClip :1000 times = 366 ms
fastClip :1000 times = 269 ms
fastClip :1000 times = 336 ms
fastClip :1000 times = 252 ms
fastClip :1000 times = 226 ms
fastClip :1000 times = 232 ms
fastClip :1000 times = 220 ms
fastClip :1000 times = 222 ms
fastClip :1000 times = 221 ms
fastClip :1000 times = 266 ms

Your pick :-)

I implemented these two methods after reading this related thread from stackoverflow about fast copy of BufferedImage pixels.

As an added benefit, the fast clip method takes around the same time should you ever want to reverse the content of the clip vertically in the same operation. You just have to change the start index and the line offset.

I haven't been updating this site or the software running it very much for the last year and a half. Time sure flies. In the mean time, ideas evolve and mature. So after reading about Toto, a tiny Ruby + git blog software, I resolved to update nnmc and finally implement a few idea I had at the beginning. Here is what I did today:

  • I now use git (via github) for the version control of the software. You can now peek at the ugly php code behind this site.

  • I also use git for the content. Unlike Toto, I use a separate repository for the content of the website. I don't have templates but I have a few different categories of content, not just a blog. As the content is easily scrapable from the web, I just made the raw source available on GitHub (also, it will not count toward my private repo quotas).

  • I finally created a setup script to handle the different configuration between the local (dev) version and the production (remote) sites. You can peek at it.

One nice idea of Toto that I like very much is to not have a component to edit the content from the web. I didn't create that much content via the web interface anyway. That sure simplifies the security aspect, especially when you can't have ssl on your host. I'll see when I have time to remove it.

To migrate this website from being a set of files to being a checkout off github, I had to do a bit of research to find a way around using git clone. The problem was that I wanted to checkout the content of the repository in the public directory from where files are served, not create a 'nnmc' dir and symlinking that. So here is what I did, after ssh-ing into my account. I ran the following commands from /home/public directory that serves the files.

To get the software :

git init
git remote add origin git://github.com/nicolasH/nnmc.git
git fetch origin

The following command will actually make the files appear in the directory. I use the -f to overwrite the files that are both in the repository and on the website.

git checkout -f -t origin/master -b master

Then just symlinks the .htaccess and config.php to the prod_ files:

bash setup.sh prod

To get the content is much simpler, as it was already in a separate directory:

git clone git://github.com/nicolasH/content_nnmc.git

And "that's it". I can update either the content or the software with a git pull. Which I will have done to update this post.


blog/ notes/ projects/ colophon