Tuesday, June 28, 2011

[Non-Linux] Purchasing Power Parity

A description on why I can buy a hot dog in London for $8 (also what is a New York Style Hot Dog?). Purchasing Power Parity theory.

Also a handy chart featuring the venerable Big-Mac Index.

Tuesday, June 21, 2011

Use strict AND warnings!

StackOverflow has had several questions in the last few days about strict and warnings. Let me say it here definitively:


Until you KNOW when to turn of some fraction of these (e.g. `no warnings 'once'`) and why you are doing it (e.g. `no strict 'refs'), should you do anything except `use strict; use warnings;`!

You really should stop reading here, but if you must, here is some small explaination.

The short reason is, Perl lets you do ANYTHING, and this truly is too much power. These commands save you from the power and from yourself. Don't try to be a hero, you will do something wrong and your code won't work.


Saturday, June 18, 2011

Canon's hidden Linux support

I know that many companies don't feel that it would be "worth it" to support Linux, however I have now seen a new one: a company that hides its Linux support. I just bought a Canon wireless printer (PIXMA MG5220) and of course saddled up to fight the driver battle. I googled and found that others had already found that Canon provides a driver, but only on their Asian site (all drivers (including scanner) and linux debian package!).

I wrote the Canon support to tell them that they should post these (working!) Linux drivers on their North American site, to which they replied that they do not support any operating systems other than Windows and Mac. Why not tout Linux support WHEN IT IS ALREADY PROVIDED??

Monday, June 13, 2011

Regexp::Grammars for more DWIM regexes

Perl is famous for its emphasis on DWIM (do what I mean, otherwise known as the principal of least surprise). Unfortunately one of Perl's other great features is its Regex powers, which are dramatically "Do exactly what I say". Now its not a silver bullet and it still only does what you say, but Regexp::Grammars goes a long way to making regexes look like what you mean.

For example, on SO this post was looking for a way to implement a rather pathological parse on each line of text. The OP didn't seem to understand that the specification was rather odd (though several other posters didn't hesitate to inform him). It appeared to me that the OP trying to recover code that had been serialized to single lines. This is complicated by the fact that it appeared to contain line comments started with a `//` and ended by multiple spaces. To me this seemed to be an excellent time to pull out regexes that are more DWIM.

By defining the types of structure I hoped to match and then having them automatically parsed into a hash structure (%/) the job becomes far less painful and far more readable. Certainly this would have to be expanded and debugged to fully to what the OP probably needs, but it is a nice example of a more modern Perl for more modern Perl programmers.

Wednesday, June 8, 2011

[Non-Linux] WunderMap Weather

Partially because some computer geeks are weather geeks too, partially because it is a cool interface and partially just so I can save this link: wunderground.com has a really cool interactive weather map. I found it from the Tom Skilling / WGN (Chicago) weather blog.

Tuesday, June 7, 2011

2D CAD for Linux

I have long been using QCAD for my 2D drafting, and I am still waiting for FreeCAD to be a little more usable for 3D, but in the meantime I saw an interesting new (commercially developed?) entry into the Linux 2D CAD world: DraftSight.