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.

Friday, May 20, 2011

PDL::IO::Export2D now uses Dist::Zilla

My module (PDL::IO::Export2D) has made the switch to Dist::Zilla and I am impressed with how easy it makes authoring modules for CPAN!

My source tree now only consists of the actual module, the test scripts, the Changes file, (yes, there is the README.pod, but that is generated by D::Z for github's benefit) and the dist.ini file for Dist::Zilla. This file contains the distribution metadata and the plugins / plugin configuation to be used in the build process.


name = PDL-IO-Export2D
version = 0.030
author = Joel Berger <joel.a.berger@gxxxx.com>
license = Perl_5
copyright_holder = Joel Berger
abstract = Provides a convenient method for exporting a 2D piddle.

[GatherDir]
[MetaYAML]
[MakeMaker]
[Manifest]
[PruneCruft]
[License]
[Readme]
[PkgVersion]
[AutoPrereqs]

[ReadmeAnyFromPod / pod.root ]
filename = README.pod
type = pod
location = root


... yep thats all. It makes my other files (meta, readme, etc), it even puts the version number in the module file for me!

Now if I want to make a small change and publish it, all I need to do is make the change, increment the version number in dist.ini then do


dzil build
dzil test


and finally upload to PAUSE. Simple, convenient.

Thursday, May 19, 2011

Installing PDL

The PDL wiki has an instruction set to install PDL from CPAN, however I find it is missing a few things so here are my instructions (also my instructions use CPAN when possible):

Step 0) If installing over SSH (if not go to Step 1)

If you are installing over an SSH shell be sure you used the -X (and/or the -Y) flag when connecting (ssh -X host.name.etc). Then execute

export LIBGL_ALWAYS_INDIRECT=y

to allow OpenGL to work correctly.

Step 1) Install system packages


sudo apt-get install libxi-dev \
libxmu-dev freeglut3-dev libgsl0-dev \
libnetpbm10-dev libplplot-dev \
pgplot5 build-essential gfortran


Step 2) Install Perl modules

I use cpanm, one may also use cpan, but it makes you hit 'y' many more times


cpanm Term::ReadLine::Perl Inline Astro::FITS::Header ExtUtils::F77
cpanm -v PGPLOT OpenGL
cpanm -v PDL


I like to use the -v on the graphical modules and PDL because they have tests where it helps to read the output that cpanm suppresses. If you don't need that, you may omit the -v.

Also if it seems that any of those hang, try hitting the enter key to continue. Some of the plotting tests require you click around, do so, sometimes hitting the right mouse button as well. You may need to close the PGPLOT server window at some point as well (black window that doesn't seem like its doing anything).

Step 3) Test the tricky modules


perl -e '
use PDL;
use PDL::Graphics::PGPLOT;
use PDL::Graphics::TriD;
print "success\n"'

Wednesday, May 18, 2011

Perl in Go!

I have been meaning to learn a compiled language and Google's Go language has intrigued me. It's a new compiled language with high-level features. Finally though I think I have found a reason to try: Campher, it's Perl in Go! Now I have all the security blanket of a language I know and love in a new one!