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.
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.
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 successfully demonstrated this
against a number of applications.
Andrew has a good writeup of Hash Algorithm Attacks.
There are various mitigations 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;