George V. Reilly

Diff a Transformed File

I wanted to diff two files. One of them needed some seds on each line and sorting. I wanted to do that on the fly, without leaving a massaged in­ter­me­di­ate file lying around.

colordiff --unified <(cat orphaned_permalinks.txt
                        | sed 's@'
                        | sed 's/.aspx$/.html/'

Subtracting Compound Objects

Quick! How many days between 2014-11-29 and 2016-05-17? What's the angle between the hour hand and the minute hand on an analog clock when the time reads 11:37?

The hard way to compute the difference between the two dates is to start counting back months and days until you reach the earlier date, or equiv­a­lent­ly to count forward from the beginning. (Don't forget that Feb 2016 has 29 days but Feb 2015 has 28.) Similarly with the angle between the hands.

The easier way is to compute the number of units between the first point and some reference (or base) point, to do the same for the second point, and to subtract continue.

Railroad Diagrams (Syntax Diagrams)

Railroad diagrams aka syntax diagrams have never really taken off. I've only come across two memorable uses of them, in a Pascal textbook that I used as a freshman and on The former was surely influenced by Niklaus Wirth's Pascal User Manual, which also used them. For com­mu­ni­cat­ing with laypeople, the simple diagrams convey much more in­for­ma­tion than a textual grammar.

There are a few tools which can generate such diagrams from EBNF grammars, including the online Railroad Diagram Generator and the Railroad-diagram Generator library. Other tools can be found in the answers to the Stack­Over­flow question.

Sample ASP Components: now at Github

From October 1996 to May 1997, I wrote a number of sample components for the then-new Active Server Pages (Classic ASP). I worked for Mi­cro­Crafts, a consulting company in Redmond, WA; the samples were written for Mi­crosoft­'s Internet In­for­ma­tion Server (IIS) team. Most of the components used Mi­crosoft­'s new Active Template Library (ATL), a C++ library for COM.

This work had two important con­se­quences for me: Microsoft recruited me to join the IIS de­vel­op­ment team to work on improving ASP per­for­mance for IIS 3, and Wrox Press invited me to write Beginning ATL COM Pro­gram­ming I was originally supposed to be the sole author of the book, but I was a slow writer and I was continue.

Review: Backbone.js Testing

Title: Backbone.js Testing
Author: Ryan Roemer
Rating: ★ ★ ★ ★ ½
Publisher: Packt
Copyright: 2013
Pages: 168
Keywords: pro­gram­ming, testing, javascript, backbone, mocha, chai, sinon
Reading period: October 2013

Backbone.js Testing is a short, dense in­tro­duc­tion to testing JavaScript ap­pli­ca­tions with three testing libraries, Mocha, Chai, and Sinon.JS. Although the author uses a sample ap­pli­ca­tion of a personal note manager written with Backbone.js throughout the book, much of the material would apply to any JavaScript client or server framework.

Mocha is a test framework that can be executed in the browser or by Node.js, which runs your tests. Chai is a framework-agnostic TDD/BDD assertion library. Sinon.JS provides standalone test spies, stubs and mocks for JavaScript. They complement continue.

30 Years of Programming

30 years ago today, I sat down at a computer for the first time, and I wrote my first program.

I was in Fifth Year of secondary school in Ire­land—the equivalent of eleventh grade. Personal computers were just coming into Ireland; few people had them. I had been taking an ex­tracur­ric­u­lar course in computer pro­gram­ming, in the school's physics lab. We wrote code on paper at our desks, as there were no computers in the room. Somehow, I hadn't realized that there was another room with computers, in a normally off-limits part of the school, until late January.

Once I sat down at a computer, I was hooked. PRINT 2+2? 4! Writing continue.

StackOverflow DevDays Seattle 2009

I spent last Wednesday at Benaroya Hall, attending the Seattle edition of Stack­Over­flow's traveling DevDays conference. It was well worth $99.

Joel Spolsky, owner of FogCreek Software and co-founder of Stack­Over­flow, opened the conference with a keynote about the dichotomy of power and simplicity. People are happier when not over­whelmed with choices. Many of the choices that software forces users to make are es­sen­tial­ly mean­ing­less to the users. However, even though people want simplicity, they also want features and different people use different features. Powerful software sells more copies.

He argues that developers and designers should put in the extra work to make good choices on behalf of the users: don't make users continue.

Review: Pragmatic Version Control Using Git

Title: Pragmatic Version Control Using Git
Author: Travis Swicegood
Rating: ★ ★ ★ ★
Publisher: Pragmatic Bookshelf
Copyright: 2008
Pages: 179
Keywords: computers
Reading period: 10–18 October, 2009

As part of my personal conversion to Git, I read Swice­good's Git book. It's a decent in­tro­duc­tion to Git and you learn how to do all the basic tasks as well as some more advanced topics. The examples are clear and well-paced.

I would have liked to see more about col­lab­o­ra­tion and workflow in a DVCS world, perhaps a few case studies: how is Git used in the Linux kernel de­vel­op­ment process; how a small, dis­trib­uted team uses Git and GitHub; how a collocated team migrates from continue.

Iframes: thinking outside the box

New post to the Cozi Tech Blog: Iframes: thinking outside the box.

Using an iframe to host some content turned out to be a big pain, so I came up with a different approach.

Hash Table Attacks

At lunch today, I told Eric about Hash Attacks: for many hash functions, it's possible to construct a large set of keys that collide. This can be used to cause a Denial of Service as hashtable operations can be induced to take O(n) time instead of O(1).

Crosby and Wallach suc­cess­ful­ly demon­strat­ed this against a number of ap­pli­ca­tions.

Andrew has a good writeup of Hash Algorithm Attacks.

There are various mit­i­ga­tions suggested. The one that I used when I first became aware of this problem is to use a salt to the hash function.

In other words, change:

unsigned hash(const char* s)
    unsigned h = 0;
Previous »