George V. Reilly

Diffing a fragment of a file

A while back, I had extracted some code out of a large file into a separate file and made some mod­i­fi­ca­tions. I wanted to check that the dif­fer­ences were minimal. Let's say that the extracted code had been between lines 123 and 456 of large_old_­file.

diff -u <(sed -n '123,456p;457q' large_old_file) new_file

What's happening here?

A similar example: Diff continue.

40 Years of Programming

40 years ago this month, I sat down at a computer and wrote a program. (Or "pro­gram­me", as I spelled it then.) It was the first time I had ever used a computer. Very few people had used computers in 1982, in Ireland or elsewhere.

What was the program? No idea. Just a few lines of AppleSoft Basic. But it was enough to get me hooked and change my life.

I still get a hit when a little bit of code unlocks in my brain. It's quite addictive. There's always more to learn and to see.

I wrote more about this in 2012: 30 Years of Pro­gram­ming.

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@http://www.georgevreilly.com/@@'
                        | sed 's/.aspx$/.html/'
                
continue.

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 JSON.org. 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.

Previous »