Kothar Labs Contact Me

Generic Adapters in Go
Sun, 13 Aug 2017 / blog / go / generics

While playing about with ideas for generic types in Go, I have come up with what I'm calling a 'Generic Adapter'.

The approach I've taken here is essentialy that described by Kevin Gillette in a 2013 Post to golang-nuts. It implements 'erasure-style' generics by wrapping the generic implementation of each method with an adapter function which handles type assertions for the caller.

type Container struct {
    T SomeType

    Set func(value SomeType) SomeType
}

type Int64Container struct {
    T int64

    Set func(value int64) int64
}

func myProgram() {
    c := &Int64Container{}
    generic.Factory(Container{}).Create(c)
}

Source code implementing a proof of concept can be found on Bitbucket. I can't really say I recommend anyone using it, but it's satisfying to show that it works!

Comments | Read more...

File sync and cloud storage client comparison
Fri, 26 Jul 2013 / blog / cloud storage

I've been trying out a number of file sync clients recently, finding that many are trying to solve the same problem and meeting with varying success. Probably the best-known service in this category is Dropbox, but nearly every big cloud services company, and a multitude of startups which base their services on top of them, are providing a 'cloud drive' of some description.

Comments | Read more...

Plex, SSL and Nginx
Sun, 24 Mar 2013 / blog

I've been experimenting with the Plex Media Server, and decided to have a go at securing remote access to the 'Web Client' interface using SSL (by default it runs over an unencrypted HTTP connection).

This post is essentially a gathering of instructions from where I found them on the internet.

Comments | Read more...

Resampling for fun and profit
Wed, 5 Dec 2012 / blog

I'm a co-author on a paper which was presented at RTNS this year. Sadly I didn't have time to attend the conference, but it's nice to have been able to contribute!

Re-Sampling for Statistical Timing Analysis of Real-Time Systems

Comments | Read more...

rtns2012_resampling

Dynamic Disqus Instantiation
Tue, 28 Aug 2012 / blog / gwt / disqus

I needed to use Disqus from a GWT app, so I needed to solve the problem of loading threads on demand as virtual pages in the app were changed.

A small amount of reverse engineering and experimentation led me to construct a utility class (below).

I also posted this answer on Stack Overflow.

Comments | Read more...

Spotify for Linux media keys with DBUS
Wed, 11 May 2011 / blog / spotify

Now that Spotify has discontinued the free account, and restricted me to an 'open' account with only 10 hours of music a month, I've ended up paying for an 'unlimited' account.

While I'm a little disappointed with this turn of events, it does mean I am now able to use the Linux client. It seems pretty decent so far, but I wanted to map some keys to do things like play/pause and next.

Comments | Read more...

Lock-Free IPC
Wed, 16 Mar 2011 / blog / programming

I was doing some reading a while back into lock-free algorithms for multi-threaded communication using buffers. The general idea is to use a circular buffer in shared memory to allow one process (or thread) to write data into a buffer so that another process can read it. The algorithm relies on atomic compare-and-swap instructions, which are part of the x86 instruction set and also present in several other architectures which have features designed to assist with concurrency.

Comments | Read more...

Shorter Bash Prompts
Fri, 5 Jun 2009 / blog / bash

I use Java a lot, and the common practice of naming java packages with long URI-derived namespaces often leads to my bash prompt becoming extremely long. Here's a script to display an abbreviated path on the bash prompt.

Comments | Read more...

Brief introduction to PolyORB
Mon, 10 Nov 2008 / blog / ada / polyorb

I've been experimenting with PolyORB at work, and the documentation, while fine for configuring and compiling your application, is sorely lacking on any help with implementing your CORBA servants.

Here I'll attempt to provide some brief hints on how to do things that don't seem to be described in the documentation. The PolyORB mailing list is a good place to find more information.

Comments | Read more...