Andrew Cooke | Contents | Latest | RSS | Twitter | Previous | Next


Welcome to my blog, which was once a mailing list of the same name and is still generated by mail. Please reply via the "comment" links.

Always interested in offers/projects/new ideas. Eclectic experience in fields like: numerical computing; Python web; Java enterprise; functional languages; GPGPU; SQL databases; etc. Based in Santiago, Chile; telecommute worldwide. CV; email.

Personal Projects

Lepl parser for Python.

Colorless Green.

Photography around Santiago.

SVG experiment.

Professional Portfolio

Calibration of seismometers.

Data access via web services.

Cache rewrite.

Extending OpenSSH.

C-ORM: docs, API.

Last 100 entries

Cat Soft LLC - Sell your invoices for immediate revenue that grows with Factoring Quotes's turnover!; Update; Credit Card Processing for Cat Soft LLC; Copier Quotes for Cat Soft LLC; [Book] Galileo's Middle Finger; VOIP quote for Cat Soft LLC; [Bike] Chinese Carbon Rims; Collection Agencies for Cat Soft LLC; Get Coffee Quotes for Cat Soft LLC; [Bike] Servicing Shimano XT Front Hub HB-M8010; [Bike] Aliexpress Cycling Tops; Now Is Cat Soft LLC's Chance To Save Up To 32% On Mail; Call Center Services for Cat Soft LLC; [Computing] Change to ssh handling of multiple identities?; [Bike] Endura Hummvee Lite II; [Computing] Marble Based Logic; [Link, Politics] Sanity Check For Nuclear Launch; [Link, Science] Entropy and Life; [Link, Bike] Cheap Cycling Jerseys; [Link, Music] Music To Steal 2017; [Link, Future] Simulated Brain Drives Robot; [Link, Computing] Learned Index Structures; Solo Air Equalization; Update: Higher Pressures; Psychology; [Bike] Exercise And Fuel; Continental Race King 2.2; Removing Lowers; Mnesiacs; [Maths, Link] Dividing By Zero; [Book, Review] Ray Monk - Ludwig Wittgenstein: The Duty Of Genius; [Link, Bike, Computing] Evolving Lacing Patterns; [Jam] Strawberry and Orange Jam; [Chile, Privacy] Biometric Check During Mail Delivery; [Link, Chile, Spanish] Article on the Chilean Drought; [Bike] Extended Gear Ratios, Shimano XT M8000 (24/36 Chainring); [Link, Politics, USA] The Future Of American Democracy; Mass Hysteria; [Review, Books, Links] Kazuo Ishiguro - Never Let Me Go; [Link, Books] David Mitchell's Favourite Japanese Fiction; [Link, Bike] Rear Suspension Geometry; [Link, Cycling, Art] Strava Artwork; [Link, Computing] Useful gcc flags; [Link] Voynich Manuscript Decoded; [Bike] Notes on Servicing Suspension Forks; [Links, Computing] Snap, Flatpack, Appimage; [Link, Computing] Oracle is leaving Java (to die); [Link, Politics] Cubans + Ultrasonics; [Book, Link] Laurent Binet; VirtualBox; [Book, Link] No One's Ways; [Link] The Biggest Problem For Cyclists Is Bad Driving; [Computing] Doxygen, Sphinx, Breathe; [Admin] Brokw Recent Permalinks; [Bike, Chile] Buying Bearings in Santiago; [Computing, Opensuse] Upgrading to 42.3; [Link, Physics] First Support for a Physics Theory of Life; [Link, Bike] Peruvian Frame Maker; [Link] Awesome Game Theory Tit-For-Tat Thing; [Food, Review] La Fabbrica - Good Italian Food In Santiago; [Link, Programming] MySQL UTF8 Broken; [Link, Books] Latin American Authors; [Link, Computing] Optimizatin Puzzle; [Link, Books, Politics] Orwell Prize; [Link] What the Hell Is Happening With Qatar?; [Link] Deep Learning + Virtual Tensor Machines; [Link] Scaled Composites: Largest Wingspan Ever; [Link] SCP Foundation; [Bike] Lessons From 2 Leading 2 Trailing; [Link] Veg Restaurants in Santiago; [Link] List of Contemporary Latin American Authors; [Bike] FTHR; [Link] Whoa - NSA Reduces Collection (of US Residents); [Link] Red Bull's Breitbart; [Link] Linux Threads; [Link] Punycode; [Link] Bull / Girl Statues on Wall Street; [Link] Beautiful Chair Video; Update: Lower Pressures; [Link] Neat Python Exceptions; [Link] Fix for Windows 10 to Avoid Ads; [Link] Attacks on ZRTP; [Link] UK Jazz Invasion; [Review] Cuba; [Link] Aricle on Gender Reversal of US Presidential Debate; {OpenSuse] Fix for Network Offline in Updater Applet; [Link] Parkinson's Related to Gut Flora; Farellones Bike Park; [Meta] Tags; Update: Second Ride; Schwalbe Thunder Burt 2.1 v Continental X-King 2.4; Mountain Biking in Santiago; Books on Ethics; Security Fail from Command Driven Interface; Everything Old is New Again; Interesting Take on Trump's Lies; Chutney v6; References on Entropy; Amusing "Alexa.." broadcast; The Shame of Chile's Education System; Playing mp4 gifs in Firefox on Opensuses Leap 42.2

© 2006-2017 Andrew Cooke (site) / post authors (content).

Starting a Scala Project

From: andrew cooke <andrew@...>

Date: Sun, 27 Sep 2009 15:35:39 -0400

I just decided to do a quick + dirty project - I want to run through
my mp3s, read the tags, store everything in a database, and then pull
tags from the API so that I can automatically construct
playlists of related music.

I also decided the time has come to learn Scala.  I could do this
easily in Python, but I've been postponing Scala for too long.

I looked at Scala yesterday and downloaded the port of processing,
which used sbt (Simple Build Tool).  I was thinking about looking at
ant+ivy (something else I need to learn), but I *think* sbt uses ivy
under the hood (or uses Maven, or all share the same basic
infrastructure).  So for now I am going with sbt. (which I had installed

So, first step was to create a new directory and run sbt.  It asked if
I wanted to create a new project and I said yes, and gave it a name.
Now it seems to be downloading stuff.

OK, so that left me with some basic directories:

spu63 uykfd: ls
lib  project  src  target

OK, now how do I make that work with Eclipse?  No idea.
suggests using IvyDE (note - I have already installed the Scala plugin
in Eclipse).  So I install this via

reload + deliver-local in sbt (following instructions at
IntegrationSupport link above).

I still don't get this.  I think I need to create the Scala project
first in Eclipse, so move the directories generated with sbt above out
of the way, create the Scala project from within Eclipse, and then
move the sub-directories back.

But Eclipse is using Scala 2.7.6 and sbt is using 2.7.5

So delete those and in the project directory created by Eclipse run
sbt again, giving the correct Scala version.

That gives an error "unknown resolver sbt-chain" which I am going to
ignore, and otherwise seems to have worked.

F5 to refresh Eclipse and we seem to be cool.

Run reload and deliver-local again in sbt.  F5 again in Eclipse and
add library as described in link above.  Looks good.

Next I create a HelloWorld class in the main.scala package, based on but when I try to run it in Eclipse
it is treated as "HelloWorl" (no final "d") and so fails!

If I fix that in the run configurations I then get
Exception in thread "main" java.lang.NoSuchMethodError: main
which sucks somewhat.

This is not looking good.

Running via sbt gives something similar.  Does the "main" have to have
a special name?

I checked with the example and had "class" rather than "object";
fixing that doesn't seem to change anything in Eclipse, but now sbt

> run main.scala.HelloWorld
[info] == copy-resources ==
[info] == copy-resources ==
[info] == compile ==
[info]   Source analysis: 1 new/modified, 0 indirectly invalidated, 0 removed.
[info] Compiling main sources...
[info] Compilation successful.
[info]   Post-analysis: 2 classes.
[info] == compile ==
[info] == run ==
[info] Running main.scala.HelloWorld ...
hello world
[info] == run ==
[success] Successful.
[info] Total time: 2 s

Trying with the syntax at also works
with sbt, but not with Eclipse.

Looking at the comments for Application (via Eclipse F3) it seems it's
not recommended.  So revert to earlier syntax:

package main.scala

object HelloWorld {
  def main(args: Array[String]) {
    println("hello world")

Which seems identical to the example.


Scala Bug Report

From: andrew cooke <andrew@...>

Date: Sun, 27 Sep 2009 16:01:55 -0400


Trying Again (New Instructions)

From: andrew cooke <andrew@...>

Date: Sun, 27 Sep 2009 18:35:59 -0400

OK, as you can see via the bug report, it's not clear what went wrong,
but the following appears to work:

- First, install all software (sbt, Eclipse plugins for Scala and Ivy)
- Next, start Eclipse with a new workspace
- Create the project from inside Eclipse using the "new Scala project" wizard
- In the project directory, run sbt and create a new project with a
matching name (so that you end up with the "src" directory Eclipse
created matching the "src" directory sbt would also create)
- F5 in Eclipse to pick up new files
- At this point I created a HelloWorld object in main.scala, which
worked just fine
- run main.scala.HelloWorld in sbt also runs the hello world
- inside sbt, "reload" and "deliver-local" to generate the ivy file
- F5 again in Eclipse, then projects settings, Java build path,
libraries, and add the Ivy file (in the target directory)

The above creates a project that works both in Eclipse and sbt.

To add a dependency you need to open the ivy xml file using the
dedicated editor.  For example, right click on the ivy xml file in the
build part of the project explorer (NOT the file in target) and select

The edit the dependency (the values seem to be as for Maven).  So, for
example, to include Empire DB - - I added:
  <dependency org="org.apache.empire-db" name="empire-db"
and when I saved the file, it went off and downloaded that and a pile
of supporting libraries (not very quickly - I am in S America and the
net is not that fast, so perhaps that's the reason - but it did work).


Scala in More Detail

From: andrew cooke <andrew@...>

Date: Sun, 27 Sep 2009 19:35:30 -0400

So now I'm at the point where I need to understand Scala more.  This
is a good overview of the main language features:
(as I read it, I realised that some examples assume familiarity with
ideas from functional programming, so it may not be for everyone).

There's also more specific details (scroll down to the "table of
contents") on individual features here -

One thing that has already puzzled me is the use of "object", which is
illuminated by the first link: "In fact, every Java class is seen in
Scala as two entities, a class containing all dynamic members and a
singleton object, containing all static members."

There's a nice clear separation between Value and Reference types
(which in Python would help clarify things for newbies and in Java
helps unify equality).  And explicit Nothing and Null (reference)

Oh and operators are methods (and vice versa!) with fixed precedence
(right associative if they end in a colon, which just happens to give
a sweet syntax for list consing!).  Parameterless methods are
possible.  And "override" is a modifier, not an annotation (ie it's

Whoa.  Pass by name exists (lazy evaluation).  The syntax is a little
odd (a "=>" precedes the type).  Ah, because it's a think that "goes
to" a value, I guess.  Evaluated each time they are used (implemented
as parameterless function).

Mixins!  called traits.

I need to go cook dinner, but this is awesome :o)


More on Scala

From: andrew cooke <andrew@...>

Date: Sun, 27 Sep 2009 21:06:34 -0400

Continuing with notes from

Anonymous (using => again), curried and generally first class
functions.  And closures.  And partial evaluation:
  forall(row, 0 ==)
page 6

Functions implemented via generic FunctionN classes.

Wow - arrays are treated as functions over integers (special handling
of assignment to functions via "update").

Sequences and list comprehensions.

Good discussion of co + contra variance.  Helps clarify some problems
I have had with generic types in Java.

Surprisingly, "new" still seems to exist.  I thought it was
unnecessary, so why keep it?

Enough type discussion to make my head explode.

Aha.  Traits must have empty constructor arguments.  That's a very
nice way to keep mixins clean.

The "case" modifier gives you constructor-like matching.

Native XML support including queries.

Hmmm.  Seem to have stalled at views.  Try again tomorrow.


Revised Instructions for Adding Dependencies

From: andrew cooke <andrew@...>

Date: Mon, 28 Sep 2009 09:09:43 -0400

The notes above on adding dependencies are incorrect.  The problem is
that the ivy file is generated by sbt.  So extending it is not
permanent.  It exists only as a mechanism to communicate from sbt to
Eclipse.  The actual configuration of dependencies is done in sbt.

It turns out that sbt is configured by writing a scala class:

- Under the project directory add a "build" directory
- In the build directory create a class named after your project (in
my case uykfd):

import sbt._

class uykfdProject(info: ProjectInfo) extends DefaultProject(info)
  lazy val hi = task { println("Hello World"); None }
  val empire_db = "org.apache.empire-db" % "empire-db" % "2.0.5-incubating"

- The "hi" above defines an action, so inside sbt you can type "hi"
and it will print "Hello World" (pointless, but a good test that
things are working)
- The "empire_db" defines a dependency.  The name of the value doesn't
matter and the various strings are as above (ie as Maven).
- If sbt is still running you need to "reload" to pick this up
- You then MUST do "update" to download
- After that "compile" should work.  For example, I altered my test class to be:

package main.scala

import org.apache.empire.db.DBDatabase

object HelloWorld extends Application {
    object db extends DBDatabase {

- To get this working in Eclipse you then use the ivy xml file, so
"deliver-local" and then click around in Eclipse to get the ivy.xml
file to be added to the build path
- It's not at all clear, but you can also delete the ivy build path
thing via the Eclipse build path dialog (under libraries).
- Once that is done, the libraries downloaded by sbt/ivy appear in the
Eclipse project too.


Switched to Emacs

From: andrew cooke <andrew@...>

Date: Tue, 6 Oct 2009 09:02:43 -0400

This page is getting a few hits, so I should add that I have given up
on Eclipse and switched to emacs (for Scala - I still use Eclipse for
Python and Java). So much was broken that emacs does the same and uses
much less memory on my laptop.

To set up emacs follow the instructions at

Despite that having an sbt window, I use sbt in a separate console
(the emacs window shows some strange control characaters and I need to
exit sbt regularly to kill the in-memory database I am using).

In short, Scala tooling is not that great, still.  The language itself
appears to be fine, however.


Comment on this post