TDD in C

I do frontend AngularJS work for a client in Portland. One of the things I really like about their setup is its test-friendliness. They use Grunt to watch the client-side files and run tests and re-compile everything automatically when a change is detected. Everything gets wiped from the “build” directory when the process starts, and a failing test or JSLint warning blocks the whole process. This renders the developer’s copy of the web app inaccessible until the issue is addressed. I’ve found I enjoy this particular workflow as I’m immediately made aware of when I write something that breaks the tests. It keeps me from building on top of broken foundations.

This weekend I decided I wanted to sharpen my C skills by writing a simple CLI utility to convert strings of hexadecimal to memorable phrases and back again. Since my intended use case was encoding and recovering 256-bit private keys, I wanted to take extra care to ensure correctness of output. So I set out with the intention of writing both unit and user acceptance tests using a TDD flow similar to the one I use in my AngularJS work.

OpenERP/Odoo Review

Background

This post is meant to be a helpful reference for developers who are either just beginning OpenERP development or who are considering beginning OpenERP development. It’s also a fairly thorough catalog of my gripes with it. Hopefully this will help save someone somewhere some pain. I start with a summarized list of its pros and cons, followed by a more thorough explanation of each of the cons, and finish up with a list of tips that I personally would have found useful back when I was getting started.

AngularJS at Devsigner 2014

For those of you near Portland interested in seeing me speak in person, I’ll be giving my “HTML Reloaded” presentation at Devsigner this weekend.  Devsigner conference is for “the coders who paint and the designers who send pull requests.” It’s a rather timely endeavor, in my opinion, as I’ve recently noticed increasing crossover between the graphic design and developer worlds. The advent of CSS compilers like Sass and Less, and of frontend frameworks like AngularJS, seem to be both a result and a cause of this. I’m looking forward to seeing what other people have to say about this emerging cross-disciplinary field.

Display an image from stdout [ubuntu]

To send bitcoin from my mobile phone to a plaintext address on my laptop, I like to use QR codes. At first I used websites like qrstuff.com to generate the QR codes, but leaving the command line just to generate and display an image felt like too much of a hassle to me. Then I started using the feh and qrencode utilities in Ubuntu’s package repositories, but that involved creating an image file on my hard drive and then deleting it afterward, which felt messy. So I found a quick and easy way to generate and display a QR code from the command line without creating an intermediate file.

Things coming

Since my last post, I’ve decided that I really ought to do as much as possible with other people’s code. It seems to me that “Don’t Repeat Other People” ought to be considered almost as important as “Don’t Repeat Yourself.”

The fact is that WordPress has been a quite serviceable platform for me so far, and I don’t really want to expend a bunch of effort writing a whole new blogging platform. I don’t have much reason for doing so, to be honest, and I will probably be of more use to more people if I build my new platform using other people’s components as much as possible

De-obfuscating a botnet infection

Last night I was working on a PHP website for a client when I stumbled upon this line of code whitespaced way off the screen on the first line of a few of our files: https://gist.github.com/ryepdx/5016290

That looked pretty suspicious to me, so I googled “$GLOBALS['QQOO']” and the only result that came up was this Pastebin: http://pastebin.com/71nwAsj6

Definitely didn’t like the look of that, so I grepped the rest of our files and found the same code embedded in the same way on four more files. I removed it from all of them, re-uploaded the cleaned files, and got to work figuring out what this code was doing.

Building a web crawler for extracting GPS data from JPGs (part 3)

At this point things are going to pick up a bit. I wrote a Python class to handle reading GPS data from a JPEG using what I learned from walking through the file with the EXIF spec and the Fetid Cascade example at hand. I’ve posted the Python class on GitHub as part of the gps-exif-webcrawler repository I started for this project. I haven’t had as much time to spend honing my Python skills as I used to have, so there are probably a few things about it that could stand some tightening up. (If you see anything, please drop me a line. I’m always interested in improving the quality of my code.)

Building a web crawler for extracting GPS data from JPGs (part 2)

Recap:

>>> f = open("gps_exif.jpg", "rb")
>>> f.seek(20)
>>> f.read(10)
'\xff\xe1#\x86Exif\x00\x00'

 Big-endian, little-endian:

The endianness of the JPEG is determined by the four bytes following the APP1 opening headers. ‘II\x2a\x00′ stands for Intel, whose CPUs are little-endian, and ‘MM\x00\x2a’ stands for Motorola, whose 680×0 CPUs are big-endian. (Source)

>>> f.read(4)
'MM\x00*'

Awesome, we have a big-endian file on our hands. So the higher-order byte will come first in this encoding. Concretely, this means that the number 256 will be encoded as ‘\x01\x00′ instead of ‘\x00\x10′ (as it would be in little-endian encoding).