Linux: setting permissions for USB serial ports using udev rules

USBIt’s pretty annoying that, by default, USB serial devices come up with somewhat restricted permissions. Sometimes adding the user to the dialout  group works, sometimes it doesn’t. The most reliable way to fix this for all time is to add a udev rule but I can never remember the syntax, hence this post…

Continue reading “Linux: setting permissions for USB serial ports using udev rules”

Restarting a Qt app programmatically

I had a requirement to restart some Qt apps remotely. This kind of thing can be a little tricky in a multi-platform environment but of course Qt makes it nice and easy – just four lines of code:

    QStringList args = QApplication::arguments();
    QProcess::startDetached(QApplication::applicationFilePath(), args);

The removeFirst() is needed because the first string in the list is the app name – the result is just the arguments that were originally passed to the app.

Hollywood and the progress bar

ProgressBarWhere would Hollywood (and TV dramas for that matter) be without the tension of the non-linear progress bar that never seems to quite get to 100%? Until the very last moment that is, when the bad (good) guys are just about to discover the good (bad) guys engaged in their nefarious activities. Saw a clip of the The Net the other night – even a floppy disk wielding Sandra Bullock back in 1995 had a tense and sweaty moment with a low resolution progress bar.

Surely it’s time to move on to a completely different widget! Or at least recognize the progress bar’s contribution to movie excitement with a lifetime achievement award. And, if Bart the Bear can have his own page on IMDb, maybe the progress bar should too.

Cloning Silicon Valley

Great one page article here from IEEE Spectrum about attempts to clone Silicon Valley and why they have generally failed. To cut a short story even shorter, it comes down to an entrepreneurial attitude, quality of life and history in the author’s opinion. I mostly agree except perhaps New York, Seattle and London should have got some sort of mention. Whatever, it’s certainly apparent from CrunchBase‘s daily funding round updates that San Francisco and New York are the locations that come up most consistently.

So, what do you need to create a great environment for high tech startups?

Continue reading “Cloning Silicon Valley”

Java: converting a float to a byte array and back again

Many physical variables are best represented as floats and sometimes it is necessary to pass these variables across a network link. Floats are very standardized and can be safely passed around between different architectures and operating systems but need to be converted to a byte stream first (something like JSON can send floats as strings but this is pretty inefficient in time and space). In C or C++ this is pretty easy but Java is strongly typed and doesn’t make it easy to convert a float value to a byte stream and vice versa. However it can be done…

public void convertFloatToByteArray(float f, byte[] b, int offset) {
   ByteBuffer.wrap(b, offset, 4).order(ByteOrder.LITTLE_ENDIAN).putFloat(f);

public float convertByteArrayToFloat(byte[] b, int offset) {
   return ByteBuffer.wrap(b, offset, 4).order(ByteOrder.LITTLE_ENDIAN).getFloat();

The elimination of non-compete agreements – it can’t happen too soon

Interesting piece here about the different situations in different US states regarding the enforceability of non-compete agreements. Once again, California leads the way. And also once again, Florida is one of the worst. We can only hope that these are outlawed everywhere in the very near future. Enforcement of non-compete agreements is the last refuge of the incompetent (which apparently is an out of context quote borrowed from Isaac Asimov :-)).