Here at LShift we take our programming pretty seriously. Which is why we now warm up properly before discussing important topics like static versus dynamic typing, tabs versus spaces and other such crucial aspects of our craft.
An Emacs operator preparing for a discussion with a vim user about text editors.
Those guys at Arup are taking this seriously and unlike many others who postulate in this area they have the clout and the commercial imperative to influence decisions and make changes. Interesting times ahead…
In September we sponsored the Agile Conference
and while it was held prior to the global meltdown, the turn-out was not great. Certainly attendance at the event does not seem
to be growing at anything like the pace that Agile is being adopted. Is this because it’s now ubiquitous amongst the type of organisations that send people to conferences?
In general the most entertaining conference speakers were the most informative, with too many “case studies” turning into hard pitches. Rob Thomsett made a compelling case for the need to adopt an agile mindset at board level to make successful agile programmes.
Peter Merrick was interesting on the subject of working with new clients in an Agile context and while our approach has always been to help clients discover their requirements through the early planning phases, he advocates taking a more hands-on approach to requirements analysis. Our approach to new business seemed to resonate with him too.
While there were a fair few of the familiar faces there hawking their enterprise wares, it’s refreshing to meet the smaller practitioners who have adopted an agile approach through a will to “do the right thing and do it right”, rather than just jump on the latest bandwagon.
I spent a few days in Wellington recently with my 12-year-old brother. We somehow got to talking about ray tracing, and so we ran through a bit of linear algebra (vectors, normals, and dot products, basically) and built ourselves a raytracer in Python as a lark. We collaborated on the Vector and Point classes, and I filled in the rest of the program. There’s still a bug in the checkerboard code (see the odd horizontal lines in the reflection of the checkerboard in the yellow sphere?) but it’s not too awful for an afternoon’s idle hacking.
The code is contained within raytrace.py, and here’s the output it generates:
Wouldn’t it be nice to have classes like Vector and Point as part of the standard distribution of Python? Even better, though, and perhaps less subject to bike-shed debates, would be the inclusion of a simple, small PNG-writing module like this one as part of standalone base Python!
The instructions were pretty easy to follow (admittedly, after 10 years, you learn where the awkward spots are in linux installations) and the result is a tiny, snappy, fully-working Ubuntu machine, complete with webcam and wifi. The only bit I haven’t got working yet is microphone input to Skype; my bet is that it’s a simple mixer setting.
Update: This page has instructions on how to get the microphone working. The key piece of information is the “Capture Switch” settings.
The BBC’s new iPlayer service is great. The only thing that I’ve missed so far is RSS or Atom feeds: it’d be nice to be notified when a new episode of Favourite TV Show X turns up (and when it’s due to expire, too).
XML’s syntax for CDATA looks like this:
Tag syntax within a CDATA section is suspended, so this is well-formed XML:
<![CDATA[some <more> text]]>
even though it looks like the “<more>” tag is unclosed.
There’s only one thing you can’t say in a CDATA section: “]]>”. But there’s a trick to save us, even here. To print an arbitrary string in a CDATA enclosure, replace each instance of “]]>” with “]]]]><![CDATA[>", and then put the normal "<![CDATA["/"]]>” brackets around it:
my ]]> text
<![CDATA[my ]]]]><![CDATA[> text]]>
What’s a good way of counting the number of bits set in a word? The obvious answer, adding the low bit to an accumulator, shifting right, and repeating, is O(n) in the number of bits in the word. This is a sequential approach – and we can do better, complexity-wise, by using a parallel algorithm. Let’s assume we are using 32-bit words, and that Xn is just such a 32-bit word:
X0 = input word X1 = (X0 & 0x55555555) + ((X0 >> 1) & 0x55555555) X2 = (X1 & 0x33333333) + ((X1 >> 2) & 0x33333333) X3 = (X2 & 0x0F0F0F0F) + ((X2 >> 4) & 0x0F0F0F0F) X4 = (X3 & 0x00FF00FF) + ((X3 >> 8) & 0x00FF00FF) X5 = (X4 & 0x0000FFFF) + ((X4 >> 16) & 0x0000FFFF) total number of set bits = X5
This algorithm is O(log2 n) in the number of bits in a word.
Every ordinary N-bit-word based sequential machine is a disguised N-way, 1-bit SIMD machine with a slightly odd instruction set. Lots more on data-parallel algorithms here.
What about finding which is the highest bit set in a word?
X0 = input word X1 = X0 or (X0 >> 1) X2 = X1 or (X1 >> 2) X3 = X2 or (X2 >> 4) X4 = X3 or (X3 >> 8) X5 = X4 or (X4 >> 16)
… and feed X5 through the parallel counter-of-set-bits algorithm above. The resulting number is the index of the highest set bit in the original word, starting from zero.
Someone has put programmers’ fridge magnet poetry on our fridge. I suspect it was a well-targetted marketing freebie, like the beanbag penguin that sits looking out onto Old Street. In any case, it has already attracted the attention of several clearly very talented individuals:
gorgeous dangling cyberspaceand this ironic gem
greasy hacker @ deprecated network
tiny bucket spawn bandwidth controller
My favourite, though, is the person that has arranged some magnets into a pair of parens, with the single atom
Up close, it is a subtle play on self-description, a visual pun on syntactic abstraction; but macroscopically, the seemingly trivially-evaluated expression brings recursion into the fold – its position and spelling suggests that there is more yet to be unravelled, and poses the question “How do we define truth?”.
We started attending the Tuesday night pub quiz at the Reliance a while back, and won a few bar tabs and jackpots. Most weeks someone-or-other has something on and can’t come along, and we end up either half-strength or giving it a miss; so, we’ve struggled to continue our winning ways, even to the low point of coming last by about ten points (the night it was just TonyG and I and all the questions were about, well, not New Zealand).
Last night, however, it all came together, and with Alexis helping out, the Gerontocratic Republic of Stu’s Heroes skipped home to victory — not only first place, but the jackpot as well.
It’s fairly certain that we’ll be there next week.
You are currently browsing the archives for the Water cooler category.