Blog

Algorithms: 1. FizzBuzz

Introduction #

Go is a language I have only recently learnt, and so I decided, for practice, to write some of the standard algorithms and data structures in Go. None of these are particular new, all of them can be found on the web already, but the exercise for me was partly to remind myself of them, and partly to see what I learned along the way. The first one I decided to start off with was FizzBuzz.

...

Vim/Nvim Setup

When I first started working my tutor insisted we use vi. His reasoning was that vi was the only editor we were guaranteed to find on all various versions of UNIX. After 6 weeks of fighting with it, the keystrokes started to leak into my muscle memory and since then vi or one of its derivatives has been my editor of choice. I moved to vim fairly early on, but didn’t really get into the whole plugin ecosystem. Over the years though I’ve slowly added plugins (and rejected a fair few as well) and so now I have a sort of “standard set”, which, although not final, is what I am currently using. Plugin Manager For vim I was using Plug, while for Nvim I was using NeoBundle. NeoBundle is no longer being developed and Dein (by the same author) is now recommended as the replacement so I’ve changed to using that in both vim and nvim. To update your plugins run:

...

Developers and Dark Colour Schemes

Recently at our office our small development team moved from downstairs to upstairs.The upstairs has some skylights so the amount of glare is significantly higher and all of us were complaining about it. What I found fascinating though was the fact that the two of us who use Linux (Centos 7) found the glare situation worse than anyone else.

It didn’t take me long to realize the reason for that was that both of us use dark colour schemes which makes the issue of glare worse. So I did a search for Windows 10 screenshots, MacOS screenshots and Linux screenshots on Google Images. Very few of the Windows screenshots show dark backgrounds. With MacOS the number was higher but with Linux the number was significantly higher, particular if any sort of xterm type window was being displayed.

...

Using Services in Services in Ember

Ember now has the concept of services which are incredible useful and the documentation for how to use them is good. What, however, is not so well covered is how to include a service within a service. In my previous blog post Building an Ember Message Bus I showed how to create an event bus service and inject it into routes, controllers, components and models. However, I soon discovered that the particular work application I was working on I need to be able to access the event bus service from within one of my other services. While this is not difficult there were a couple of gotchas.

...

Building an Ember Message Bus

When I was looking for an event bus for the Ember application I was writing for work I came across Paul Cowan’s blog article called Emberjs - Simple Global Event Bus. This event bus uses the built in Ember.Evented and at it’s core looks as follows:

App.EventBus = Ember.Service.extend(Ember.Evented, {
  publish: function() {
    return this.trigger.apply(this, arguments);
  },
  subscribe: function() {
    return this.on.apply(this, arguments);
  },
  unsubscribe: function() {
    return this.off.apply(this, arguments);
  }
});

I’m using ember-cli 2.4.2 so my actual event bus file and it’s associated initializer looked as follows:

...

Ghost Local Mail Setup

All of my servers use a local copy of exim to forward mail to my mail server so that any messages generated out of cron etc. are forwarded to me for checking. By default the blogging platform Ghost assumes you are going to send the emails it generates directly to an external mail host like Gmail.

Looking around the web I came across this posting: https://ghost.org/forum/installation/529-use-local-smtp-server-for-sending-email/

With a bit of experimentation though I discovered I didn’t need to do all the other steps mentioned in this posting. All I did was change my config.js to have:

...

Setting Your Apt Proxy Depending on the Current Network

Before I changed over to using squid3 for my transparent proxy I was using apt-cacher-ng to proxy my debian and kubuntu repositories. The issue I had was that at work there was no apt-cacher-ng proxy, just a transparent squid proxy. Remembering to change the details between home and work became too hard so I went in search of a solution. I really battled to find one, but did eventually come upon this article.

...

Akonadi, Sqlite and Backups Part 2

There are various ways you can backup sqlite. One of the ways is to use the sqlite3 command line utility:

/usr/bin/sqlite3 ~/.local/share/akonadi/akonadi.db
SQLite version 3.8.6 2014-08-15 11:46:33
Enter ".help" for usage hints.
sqlite> .backup /tmp/akonadi.db
sqlite> .quit

This will create a backup of akonadi.db in /tmp.

Sqlite also comes with a backup API - see https://www.sqlite.org/backup.html.

As python tends to be my scripting language of choice I was looking for something that I could use in python.

...

Akonadi, Sqlite and Backups Part 1

On both my home PC and work laptop I use kontact for my email, calendaring, etc. I didn’t want to use mysql for the underlying database (I don’t particular like it) so decided to use sqlite instead. Generally I have found this to work well, with one or two exceptions.

However, searching for how to automate sqlite backups gives numerous results. The easiest way is to stop whatever is writing to it, in this case akonadi, and then copy the database. Something like:

...

No Icons or Emoticons in Firefox or Pidgin

The other day I upgraded my laptop from Kubuntu 14.04 to 14.10 and after it had completed I found that I had no icons or emoticons in all my GTK applications - including Firefox and Pidgin. Eventually tracked it down to the fact that a particular cache wasn’t available. To fix it you need to run the following command:

gdk-pixbuf-query-loaders > /usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders.cache

If gdk-pixbuf-query-loaders in not installed you need to install the following package:

...