Author: admin
-
Comparisons are odious — unless it’s in SQL.
One of the most frustrating things to debug is data type conversion errors when selecting a bunch of rows from one SQL table to another. In the real world, tables may have hundreds of columns, and Microsoft SQL’s error reporting is… laughable? If you’re importing 20000 rows in a query that runs for 10 minutes,…
-
Generating unique, contrasting colors in JavaScript
While working on my DOM course for LinkedIn Learning I had to solve a problem I’ve come across several times in my career. It shows up when generating graphs, or in my case when you want to show nested rectangles with contrasting colors. Like most problems, I started using the “smart friend” trick that I…
-
A beautiful gem of code from the Python docs.
So once again I found myself looking at the documentation for the Python re module, trying to remember the difference between matches and matching groups and I saw a code snippet that was so beautiful that I wanted to break it down and share it. It’s a fully-functional mini-language tokenizer in only 41 lines of code. I’ll go through…
-
A 42-line JSON template engine.
So, I’ve been building projects using NoSQL databases (like MongoDB and Apache CouchDB) for several years now, and there are a lot of things I really like about them. But one need I’m always bumping up against is the ability to summarize tons of heterogeneous documents in a straightforward way. For example, I’m producing a list of users…