Posts tagged programming

Adventures in code: PHP unit testing

If you want to make a PHP package available that works on versions of PHP from 5.3 to 8.0, testing is a giant pain. There are versions of phpunit that work for each, but none that works for all. Additionally, the basic class names changed at some point in the past. Getting all of this to run on Travis, including running code coverage (but only once for each build!) was a complex series of trials, but I finally figured out the correct .travis.yml incantation, along with a magic test wrapper for aliasing classes

It turns out you can make a browser based chat client without using any JS or forcing page reloads. Truly amazing/evil. Probably not practical, but does show a clever mechanism for allowing some dynamic data flow with JS disabled.

Way back in July, I was inspired by Tripelbyte's language identification quiz, so I made my own version for esoteric languages. Never got around to sharing it outside of Slack, but here it is.

TraceGL is really stepping up the game of JS debugging in the browser.

This review of Doom 3's source release is full of tons of interesting stuff, even for non-graphics programmers. [via waferbaby]

Regexp Kung-fu

There are two answers guaranteed to show up on nearly every PHP question on Stack Overflow - use the mysqli/PDO extension instead of the deprecated mysql one (to avoid SQL injection), and that you can't parse HTML with regular expressions.

With that in mind, my favorite two answers:

  • [How PDO is still vulnerable to SQL injection attacks](http://stackoverflow.com/questions/134099/are-pdo-prepared-statements-sufficient-to-prevent-sql-injection/12202218#12202218) by Anthony Ferrara
  • [Parsing HTML with regular expressions](http://stackoverflow.com/questions/4231382/regular-expression-pattern-not-matching-anywhere-in-string/4234491#4234491) by Tom Christiansen

Github March Wrapup

I've posted a bunch of projects to Github in the last few months and haven't linked to them anywhere, so here's a quick roundup of recently notable projects:

  • [lib_timezones](https://github.com/iamcal/lib_timezones) - A PHP and JS library to handle user-specified timezones properly, with reasonable client-side auto detection.
  • [lib_classsify](https://github.com/iamcal/lib_classify) - A partial PHP port of Github's own [linguist](https://github.com/github/linguist) which can automatically detect the programming language, given a code fragment.
  • [js-emoji](https://github.com/iamcal/js-emoji) - A JavaScript library to allow display of Emoji in then browser for OSs without native support (anything that's not OSX 10.8 or iOS 6)
  • [lib_autolink](https://github.com/iamcal/lib_autolink) - My old PHP URL-detection and linking library, updated to handle multiple protocols.
  • [lib_solr_query](https://github.com/iamcal/lib_solr_query) - A PHP library to turn user-entered complex search queries into valid SOLR query syntax. Supports phrases, booleans, nesting, assertions and more.

Chrome continue to get better and better. Ilya Grigorik explains some of the optimizations going on under the hood in this chapter from an upcoming performance book. If you work on the web, it's a fascinating read.

If you're working with JSON on the command line, then I can highly recommend jq for simple data manipulation. It let's you mine into JSON data using an XPath-like query syntax and makes quick work of extracting the stuff you actually care about. The source is on the githubs.

The silver searcher is basically ack, rewritten in C to be crazy fast. If you're regularly using grep to search a codebase, this is probably a much better idea.

Patricio Palladino has done a really nice job with hieroglyphy, a library for turning any JavaScript code into strings of only ()[]{}!+. The explanation of his blog is a great read.

Björn Höhrmann's excellent compact UTF-8 decoder is one of those C masterpieces that makes you realize quite how powerful the language can be.

In the wake of password-hacking-month (Linkedin, Last.fm, Yahoo, etc) Jeremy Spilman talks about an interesting idea for increasing the cost to stealing password databases, rather than just the hashing: part 1, part 2

Javelin JS is full of interesting little things - always fun to find out what compormises other teams make to allow their particular development model to scale. The css classes vs sigils part makes a lot of sense.

Shut up and use bcrypt

With all the current excitement about leaked password databases, I thought I'd take the time to make doing it the right way a bit easier. If you're working on a PHP app, start using lib_bcrypt right now.

Twelve-factor app

12 factor app says a lot of good things that i agree with, but the server-process model rule is odd. there doesn't seem to be an obvious reason why the php/apache/processes model is wrong, but it's not allowed. uh?

Facebook Engineering Process

A nice read about facebook's release engineering approach. This should all sound very familiar to Flickr alumni.

31st March, 7:46 pm

rev dan catt has written up a nice piece on image processing for backgrounds. a really nice effect

29th March, 2:41 pm

the macpaint and quickdraw source is available on the computer history museum site

6th February, 10:46 am

mp3 decoding is interesting

9th November, 4:49 pm

it's now over 8 years old, but the 12 views of mjd is still good reading

8th July, 2:05 pm

bookmarking for the future: echoprint is a free open-source music fingerprinting system

7th June, 5:08 pm

php sadness points out a lot of real issues, but it's still the best tool for many problems

27th May, 1:26 pm

damn, someone has figured out my secret

9th May, 5:02 pm

math for programmers makes a lot of good points. i just need a way to track my wikipedia usage and claim it as 'studying'

15th April, 3:02 pm

this guide to the interesting bits of javascript is really good

19th August, 2:15 pm

thanks to kastner for pointing me to this thread from 6 years ago. guess what retarded commenters? i was right all along. see also: everything written on large distributed databases since then.

22nd March, 3:19 pm

HgInit is actually a pretty good introduction to distributed version control. it doesn't sell it very well (sooo complex, comparatively), but it does a good job of explaining the mechanics

26th January, 6:12 pm

this visual automation language looks pretty cool, but the video narration is awful. so slow. i get the concept already - demo it faster!

16th November, 2:03 pm

my C is weak, but this presentation on compiler optimizations is a great read

19th September, 12:19 pm

old, but still good: Java2K uses a 11-based number system, which is a very good approximation of the 10-based decimal system for many purposes, including counting up to and including 9.

9th April, 2:39 pm

audiotool is an amazing piece of work - reason redone in flash. very very slick. seems to be the work of andre michelle, whose demo work is also excellent

28th February, 7:13 pm

warehouse looks pretty good, but it requires both ruby on rails (easy-ish to install) and the ruby-svn bindings (which are basically a bitch). why do the harder languages to get up and running on the web (ruby and python) require the bindings while the easier languages (php and perl) just shell out and so work easily? gah. currently using websvn in php which does a reasonable job and is trivial to set up.

8th February, 12:37 am

learning javascript oddities from wikipedia: using !! for normalization and the return from || and &&. nice

10th October, 11:56 am

tron versus unprotected memory. kinda awesome

7th October, 4:14 pm

uncov is coming back

24th September, 1:06 pm

the video of my djangocon keynote has just tipped over 40k views. wow

17th September, 9:14 am

and wtf - _why has revealed the magic behind the scenes. _why drawing something based on something i caused is the most awesomest thing evar. he's my hero in a total fanboy way

8th September, 11:40 am

the PHP_Debug bar is kinda neat. very ugly, but packed with useful info

3rd July, 11:04 am

mr kastner has passed me a silly chain thing, only not too silly since it's about programming. amy hoy did one too. but i don't have a long-form blog!

13th August, 4:37 pm

fileformat.info has the best unicode codepoint reference docs i've seen [via ph]

16th November, 11:25 pm

a paper about intercal. very nice

30th October, 6:05 pm

salt pointed me to this excellent windows programming article which talks about the problems with visual studio and code generation. a long read, but worth it if you're interested in the history of vs, vb and resource scripts.

21st October, 11:56 pm

man, joyce sure hates templates. i suspect anyone how really wants to use xslt in a real application is fundamentally sadistic

23rd September, 5:37 pm

a c boardgame. sooooo awesome

29th May, 8:48 pm

the ICFP programming contest seems fun - i wonder if anyone's planning on implementing in brainfuck. or smith. or maybe homespring :)

11th October, 11:23 am

i'm working on timezone stuff again, and came across this great timezone faq. some timezone stuff is really terrifying/retarded from a programming pov - "China observes one time zone UTC/GMT + 08:00 - which makes this time zone uncommonly wide. In the extreme western part of China the sun is at its highest point at 15:00, in the extreme eastern part - at 11:00."

About

This is the personal website of Cal Henderson, Slack co-founder & CTO.

I give occasional talks, write code and sometimes articles.

» About Cal

Recent Tags

aws books bools cheese code doge emoji food games havana ibm japan language maps memes minecraft php programming reading regex slack technology via-matts wiring

Popular Tags

apple awesome bacon code coding comics design flickr food games javascript lego maps movie music perl php programming software tech tv video visualization web

Archives

2024: Jan Feb Mar
2023: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
2022: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
2021: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
2020: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
2019: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
2018: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
2017: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
2016: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
2015: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
2014: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
2013: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
2012: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
2011: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
2010: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
2009: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
2008: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
2007: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
2006: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
2005: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
2004: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
2003: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
2002: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
2001: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
2000: Jun Jul Aug Sep Oct Nov Dec