A while back, I had extracted some code out of a large file
into a separate file and made some modifications.
I wanted to check that the differences 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?
- sed -n '123,456p' is printing lines 123–456 of large_old_file.
- The 457q tells sed to abandon the file at line 457.
Otherwise, it will keep reading all the way to the end.
- The <(sed ...) is an example of process substitution.
The output of the sed invocation
becomes the first input of the diff command.
A similar example: Diff …continue.
40 years ago this month,
I sat down at a computer and wrote a program.
(Or "programme", 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?
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 Programming.
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 intermediate file lying around.
colordiff --unified <(cat orphaned_permalinks.txt
| sed 's@http://www.georgevreilly.com/@@'
| sed 's/.aspx$/.html/'
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 equivalently 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 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 communicating with laypeople,
the simple diagrams convey much more information 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 StackOverflow question.
From October 1996 to May 1997, I wrote a number of sample components
for the then-new Active Server Pages
I worked for MicroCrafts, a consulting company in Redmond, WA;
the samples were written for Microsoft's
Internet Information Server
Most of the components used Microsoft's new
Active Template Library (ATL),
a C++ library for COM.
This work had two important consequences for me:
Microsoft recruited me to join the IIS development team
to work on improving ASP performance for IIS 3,
and Wrox Press invited me to write
Beginning ATL COM Programming
I was originally supposed to be the sole author of the book,
but I was a slow writer and I was …continue.
Title: Backbone.js Testing
Author: Ryan Roemer
Rating: ★ ★ ★ ★ ½
Reading period: October 2013
Backbone.js Testing is a short, dense introduction
Mocha, Chai, and Sinon.JS.
Although the author uses a sample application
of a personal note manager written with Backbone.js
throughout the book, much of the material
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.
They complement …continue.
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 Ireland—the equivalent of eleventh grade.
Personal computers were just coming into Ireland;
few people had them.
I had been taking an extracurricular course in computer programming,
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!
I spent last Wednesday at Benaroya Hall,
attending the Seattle edition of StackOverflow's traveling DevDays conference.
It was well worth $99.
Joel Spolsky, owner of FogCreek Software and co-founder of StackOverflow,
opened the conference with a keynote about the
dichotomy of power and simplicity.
People are happier when not overwhelmed with choices.
Many of the choices that software forces users to make
are essentially meaningless 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.
Title: Pragmatic Version Control Using Git
Author: Travis Swicegood
Rating: ★ ★ ★ ★
Publisher: Pragmatic Bookshelf
Reading period: 10–18 October, 2009
As part of my personal conversion to Git, I read Swicegood's Git book.
It's a decent introduction 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 collaboration and workflow in a DVCS world,
perhaps a few case studies:
how is Git used in the Linux kernel development process;
how a small, distributed team uses Git and GitHub;
how a collocated team migrates from …continue.