Adjusting timestamps on images with Python

by @edent | # # # # # | Read ~458 times.

As ever, mostly notes to myself. I have a bunch of old images which don't have any timestamp associated with them. This quick Python script will add a DateTime EXIF metadata tag to an image. This uses piexif which can be installed using pip install piexif This simple script reads a photo, adds a timestamp, […]

Continue reading

Don't use negative numbers for error codes

by @edent | # # # # | 7 comments | Read ~691 times.

A warning to programmers - try to understand how people will use your error codes. This morning, I was confronted with a rather bemusing error message on my WordPress blog: Ok, so this should "never happen" and yet somehow it has. I wonder what on earth the error code means? I selected the error code […]

Continue reading

Why I vertically align my code (and you should too!)

by @edent | # # # # # | 28 comments | Read ~79,718 times.

There was an interesting discussion on HackerNews last week about the Linux Kernel coding style. During the discussion, I kicked off a minor holy war about whether one should vertically align code. I'm all for it! Let me explain why. What Is Vertical Alignment? Take this trivial example: int robert_age = 32; int annalouise_age = […]

Continue reading

Extracting Your Own Location Information From Google - The Hard Way

by @edent | # # # # | 19 comments | Read ~36,093 times.

Update! There's a new way to do this - read my latest post to find out how. Two or three years ago, I was contacted by a recruiter from Google. They wanted to know if I'd be interested in working for the advertising giant. We played the usual game of dancing around salary and schedules, […]

Continue reading

Screenscraping Album Artwork From The Linux Command Line

by @edent | # # # # # # # | 9 comments | Read ~4,324 times.

Like many people, I've collected a fair number of CDs over the years. As hard-drives and MicroSD cards have got larger and cheaper, I've gradually been ripping them to FLAC. Most CD rippers automatically tag the music files with the correct metadata and, nowadays, they will also download and embed album artwork as well. (As […]

Continue reading

Aggressively Defensive Programming

by @edent | # # # # | 3 comments | Read ~506 times.

How much checking do we perform that our code is running as intended? I found a curious bug this weekend, which made me think about some of the assumptions that we use when programming. Imagine sorting an array using JavaScript. var arr = [10, 5, 66, 8, 1, 3]; arr.sort(); So far, so normal. Create […]

Continue reading

Use DRAKON to Generate Code from Flowcharts

by @edent | # # # # | Read ~14,764 times.

It's 1986. You're working on the Russian's Buran space programme - trying to create a re-usable space vehicle which will exceed the capabilities of the American's "Space Shuttle". There's a problem. You have very complicated real-time algorithms which you need to review, improve, optimise, and then turn into code. How do you do it? Obviously, […]

Continue reading

The Python Pals Program A Problem

by @edent | # # # # # | 13 comments | Read ~1,215 times.

As mentioned earlier, I've been inspired by the Byte Brothers to create a mystery story which kids have to solve using their l33t h4x0r skillz in Python. This is loosely based on The Byte Brothers Go to a Getaway, by Lois and Floyd McCoy. My well-thumbed copy was printed in 1984. I'm not sure when […]

Continue reading

API Design is UI for Developers

by @edent | # # # # # | 18 comments | Read ~22,931 times.

I've been thinking a lot about APIs and their design recently. I stumbled on this fantastic quote from Greg Parker: A programming language is a user interface for developers. Language authors should learn from HCI principles. — Greg Parker (@gparker) February 22, 2012 When I first started learning C++ (back in the bad old days) […]

Continue reading

Getting Images from a Foursquare Checkin

by @edent | # # # # # # | Read ~1,405 times.

"Oi!" shouted Whatleydude, "Get Dabr to show images from foursquare checkins!" "Righty-ho sir!" I said. I started coding furiously. Of course, things are never quite as simple as I first thought.... So, how do we go from http://4sq.com/fgIWov to ? 1 Expand the URL Get your Bit.ly API Key. http://api.bitly.com/v3/expand ?shortUrl=http://4sq.com/fgIWov &login=YOUR_BIT_LY_USERNAME &apiKey=YOUR_BIT_LY_API_KEY &format=txt You […]

Continue reading