CanaryMod plugin tutorial

It’s been a very busy start to 2015! But to keep the chops sharp I decided to try writing a few CanaryMod plugins. It took some effort to get a basic build environment going so I made a tutorial for creating CanaryMod plugins using Eclipse out of my notes.

It’s been about 12 years since I built anything serious in Java. I mean literally: Java 1.4 was considered new. Anyway it was fun and hopefully not too many errors. Cheers and enjoy!


Erlang B Visual Basic implementation for use in Excel

Erlang B is a commonly used algorithm used to estimate required capacity for a given load. Originating in telephony for estimating required trunks/channels for an expected load, this same algorithm can be applied to any problem where you have a known arrival rate and required Grade of Service - e.g. servers required for given web traffic, lanes required for given car traffic, staff required for given customers in a retail shop, etc. I’m by no means an expert on the algorithm (it involves poisson distributions and clever things mathematicians get exited about). I do however use it so need it available in a format that doesn’t require a maths degree or regularly going to websites, hence Excel. Note also that this does not account for queuing (Erlang C for that) so may not be suitable where you expect and accept a queue, e.g. customers in your store can wait a few minutes and would not typically mind.

Read More


Install script for Teamspeak 3 server on Debian (or Ubuntu)

The ‘teamspeak-server’ package built for Debian/Ubuntu at the time of writing this article is only for Teamspeak version 2, but everyone who is anyone these days uses TS3. After trolling around the Internet looking for a prebuilt package I could trust, I decided to roll my own install script. For the impatient here are the steps to get a Teamspeak 3 server installed on Debian-based Linux quickly:

  1. Try this in a test environment first! It requires root privileges and can take your children. You have been warned.
  2. Download and transfer installts3.sh to your server.
  3. Download and transfer the correct server binary to your server.
  4. Run installts3.sh:
1
2
chmod u+x installts3.sh
sudo ./installts3.sh serverbinary.tar.gz

Replace serverbinary.tar.gz with the name of the file you downloaded from the Teamspeak website. If there are no errors the script will tell you where to get your ServerAdmin privilege key and you are good to go!

Read More


Git cheat sheet - computer setup

January 2015 update: these days I generally use the powerful SourceTree tool from Atlassian. While it’s great to be a purist, sometimes I just need to get the “job done”. The below still applies when I’m working exclusively in a shell (generally on a remote box).

These are some post-installation commands I use to get Git quickly into a working, friendly to use state - cherry-picked from http://git-scm.com/book/en/Customizing-Git-Git-Configuration:

1
2
3
4
5
6
7
# Required. Tell git who you are... appears in commit logs.
git config --global user.email "youremail@example.com"
git config --global user.name "Your Name"
# Optional! Some preferences to ease the eye and editing
git config --global core.editor nano
git config --global color.ui true

This list may grow/update over time, but this I find gets me out of the gate and over the minor annoyances quickly when using git on a fresh machine.


Fighting spam in Drupal 7 - disable the homepage field on comments

Spam is really annoying, particularly for anybody maintaining a website with anonymous contribution - in my case via comments. Mollum filters the bulk of the spammers out. Unfortunately if you want to capture anonymous commenter’s contact information in Drupal 7 this also exposes and displays the homepage field. This is also displayed to all visitors to your website that can access this content - incentive for link spammers :(

If you don’t care about following up with your commenters, or you only allow commenting by registered users - the email and homepage field on anonymous comments can be disabled here:

Administration -> Structure -> Content Types -> [choose relevant content type] -> Comment settings -> Anonymous commenting

This however doesn’t work for me - I like to be able to reach out to legitmate commenters via email and require it (but don’t display it). I don’t care for the homepage field. The easiest and quickest way to disable the field is to add the functionality yourself via a module. Adding this in a simple module should do the trick (I stuck it in my “jeff_hacks” module, you need to update the prefix to your module name):

1
2
3
function jeff_hacks_form_alter(&$form){
$form['author']['homepage']['#access'] = FALSE;
}

Drupal 7 missing 'Manage Display' in Content Types

Had an interesting issue when installing Drupal 7 the other day. I could not find the “teaser length” feature that was present in Drupal 6. This appears to be expected behaviour, however I could not see the “Manage Display” and “Manage Fields” options in the Content Types settings.

If you selected the “minimal” profile during install, the “Field UI” module will not be enabled. Turn this on and the “Manage Display” along with “Manage Fields” become visible and you can follow your nose from there.