Mindstorms <2017-02-18 sab 13:29>

Seymour Papert’s Mindstorms was published by Basic Books in 1980, and outlines his vision of children using computers as instruments for learning. A second edition, with new Forewords by John Sculley and Carol Sperry, was published in 1993. The book remains as relevant now as when first published almost forty years ago.

The Media Lab is grateful to Seymour Papert’s family for allowing us to post the text here. We invite you to add your comments and reflections.

xmonad + Libreoffice problems <2017-01-23 lun 14:00>

Apparently I fixed the pesky problems I had with xmonad + Libreoffice.


hledger-dupes is now in hledger <2017-01-10 mar 00:41>

Simon Michael asked me to include hledger-dupes in the main hledger repo.

Scheme interpreter going on <2016-12-05 lun 10:35>

I spent part of the weekend on my Scheme interpreter implementation, after a long hiatus. Cleaned up some code, and started enstablishing the grounds for adding closures (thus passing from the substitution model to the environment model of evaluation, a profound change).

Why Catholics Built Secret Astronomical Features Into Churches to Help Save Souls <2016-11-17 gio 19:16>   link

Quick, How Might the Alien Spacecraft Work? <2016-11-14 lun 12:00>   link

:syntax off <2016-11-06 dom 23:52>

Maybe syntax highlighting is not as good as it seems.

The Case Against TODO <2016-10-28 ven 17:23>   link

IRCv3 <2016-10-24 lun 16:37>   link

The IRCv3 Working Group is a collection of IRC client and server software authors working to enhance, maintain and standardize the IRC protocol using backwards-compatible extensions.

A history of storage media <2016-10-12 mer 16:46>   link

Kiran Bhattaram published a very interesting piece about how storage evolved in computing.

Emacs Lisp's Future <2016-10-10 lun 15:57>   link

A thread from two years ago reemerged

Writing a test library for Common Lisp <2016-10-04 mar 12:29>   dev

New page, with some notes about the ongoing process of writing a test library for CL (just a toy project, I'm not going to spoil the ecosystem).

"Finding most frequent element in a list" <2016-09-25 dom 11:45>   link

A question on Stackoverflow and a brief search led me to some thoughts I want to register to document my learning experience.

First of all, the request specifics are incomplete: what should the function return if there's more than one element that occur most frequently? What is the notion of sameness among the elements of the list?

As a beginner, I often find myself looking for idiomatic ways to do things: reusing code in a package is apparently the way to go, but I haven't found a clear path yet for such researchs: I usually look for something in Quicklisp package collection, then on github and the Clwiki. I suspect that, at least for these simple functions, CL makes it so easy to roll your own version that everybody end up writing a homemade solution.

A-LANG: ways to implement computer languages on 6502s <2016-09-20 mar 09:08>   link

Mac OS X -> Linux <2016-09-19 lun 23:41>   meta

In other news, I completely switched from Mac OS X to Linux.

The System Paradigm <2016-09-19 lun 23:40>   dev

I have used a REPL connected to a production system to change code. Yes, I have changed code in a running production system. Does that terrify you? Honestly, it kind of terrifies me a little, too! Regardless, sometimes the best way—the only way—to diagnose a particularly nasty bug is to poke a living organism and observe the result. I am more like a doctor diagnosing a patient and less like a detective trying to piece together a sequence of events from the clues left behind.

There's that and plenty of fascinating observations about the difference between a system constructed as a organism (system paradigm), and constructed as a cathedral (or a pyramid: that's the language paradigm).

I am fascinated, but I'd like to talk to someone who had this kind of experience. I understand the beauty and the utility of the REPL, yet intervening in a system in such a organic and (apparently, to me) not organized fashion seems more dangerous than it's compelling. How one can ensure the changes applied to the running deploy will be incorporated in the code base? How can you properly "undo" the changes you've made while you were tinkering with the system. Anyway, a nice and inspiring post.

The Classics of Science Fiction <2016-09-01 gio 11:14>   link

Status update <2016-08-15 lun 01:22>   meta

Some days off, not very much done. Somehow relevant in the context of this stream:

  • Writing some simple Common Lisp, for excercise. The Wireworld simulator and editor –which has some significance per se besides being interesting as a CL exercise– is on pause (while I try to figure out Lispbuilder-sdl's ways of treating surfaces), and I'm now on something simpler. It's a Sudoku solver assistant. It's not clear to me what the scope of the project will be, however I'm discovering handy techniques and tools useful for a "real" system: for example I borrowed from scmutils the idea of using TeX to obtain a representation of the Sudoku problem (it's faster than I initially thought).
  • Reading Seveneves by Neal Stephenson. I hope to write something more substantial as I reach its end.

ELisp refactoring tools <2016-07-25 lun 18:19>   dev

Started working on tools to help me refactor Elisp code. Here the first main function:

(defun create-new-function (function-name)
  "Creates a new function definition, given a selection. Removes
  the selection and replaces it with a call to the newly created function"
  (interactive "sFunction name: ")
  (let ((code (get-region)))
          (insert-new-function-definition function-name code)))
      (insert "(" function-name " )"))))

Comments welcome.

Surprising reasons to use a syntax-coloring editor <2016-07-19 mar 09:14>   link

Mark Jason Dominus on syntax higlighting.

Syntax highlighters should be highlighting the semantic content like expression boundaries, implied parentheses, boolean subexpressions, interpolated variables and other non-apparent semantic features. I think there is probably a lot of interesting work to be done here. Often you hear programmers say things like “Oh, I didn't see the that the trailing comma was actually a period.” That, in my opinion, is the kind of thing the syntax highlighter should call out. How often have you heard someone say “Oh, I didn't see that while there”?

Bit Twiddling Hacks <2016-07-04 lun 18:34>   link

Automatic webjump list from org <2016-06-28 mar 17:29>   emacs

Webjump is a bookmark facility for Emacs. Fed with a list of bookmarks (as an association list) it presents a menu, then open a browser page with the selected link. Simple and handy.

This function converts my list of bookmarks (expressend in a org document that is also used to build my Links page) in a data structure suitable for webjump.

(defun get-webjump-sites ()
  (with-current-buffer (get-file-buffer "~/Dropbox/")
    (delq nil
           (lambda (i)
             (let ((item-string (cdr (assoc "ITEM" i)))
                   (regex "\\[\\[\\(.*\\)\\]\\[\\(.*\\)\\]\\]"))
               (if (posix-string-match regex item-string)
                   `(,(match-string 2 item-string) . ,(match-string 1 item-string)))))
           (org-map-entries 'org-entry-properties nil 'file)))))

(setq webjump-sites (get-webjump-sites))

Update <2016-06-28 mar 23:26>

I asked for a review on #emacs, bpalmer kindly pointed out a few things that should be done in a different manner:

  • I'm building a list containing nils, which I need to delete later (delq). I shouldn't be creating them in the first place
  • Probably no need for posix-string-match instead of string-match
  • I should provide a docstring

So, here a better version, using the loop macro

(require 'cl)
(defun get-webjump-sites ()
  "converts a org document in a data structure suitable for webjump"
  (let ((regex "\\[\\[\\(.*\\)\\]\\[\\(.*\\)\\]\\]"))
    (with-current-buffer (get-file-buffer "~/Dropbox/")
      (loop for i in (org-map-entries 'org-entry-properties nil 'file)
            for item-string = (cdr (assoc "ITEM" i))
            if (string-match regex item-string)
            collect `(,(match-string 2 item-string) . ,(match-string 1 item-string))))))

It's more concise and direct, definitely better, but I'm still not satisfied: it lacks clarity and cleanliness.

New site structure <2016-06-23 gio 22:07>   meta

I just published a restructuring of my website. Content is more or less the same. Main difference is I ditched the blog: I discovered blogging (I mean, organizing the stuff I publish as distinct articles ordered in time) is not for me. I'm more comfortable dedicating a page to each project I'm following, and keep updating the page as the project proceeds.

Ditching the blog also means I'm now using one tool only for all the editing and publishing.

Things to do:

  • testing
  • implement some sort of feed for the updates
  • re-linking minor stuff that has not yet a place in the new structure

Manipulate regions <2016-06-10 ven 10:09>   emacs

A useful code snippet to manipulate regions.

(defun my/org-convert-region-quote ()
  "Converts selection in a QUOTE block"
  (progn (insert "#+END_QUOTE\n")
         (insert "#+BEGIN_QUOTE\n")))

Knowing about point and mark is useful to understand the code. One defect of this code is that it doesn't work if you select a region starting from the end.

Darius Bacon <2016-06-07 mar 14:40>   link

Oh good lord I found again a web page I was used to peruse like 20 years ago. Many journeys started from there. It's the personal homepage of Darius Bacon.

The Early History of Smalltalk <2016-06-02 gio 10:54>   link

Alan Kay's reading list <2016-05-31 mar 08:46>   link

So you want to be a compiler wizard <2016-05-26 gio 18:36>   link

On Google's last week announcements <2016-05-22 dom 09:30>

One of the things presented during the Google I/O I consider particularly important. Some annotations (which might or might not lead to a a more structured piece):

  • it was an error to compare mobile devices to computers
    • computers have protean nature; how they behave (the function they enable) depends on software
    • one chooses what functions his computer needs to perform, and buy appropriate software accordingly
    • On the other hand
    • Mobile devices use the computer and a ground model, but their nature is to be capable of many things off-the-shelves
    • Hence users can legitimately perceive as absurd the fact that software (apps) cost money
    • It feels more natural to pay for services
  • Apps are not human concept
    • I mean the fact that one has to pass from an application to another one to accomplish tasks
    • see for example "The Human Interface" by Jef Raskin
    • On the user level, computer- and human- concepts are intermixed, but there's no human reason to do so
  • Google presented "Instant Apps"
    • it seems they would eliminate to boundaries between one application and the other one
    • the OS is just a framework (with unified interfaces and metaphors) where users can accomplish tasks and access to services
    • OS seamlessly manages the acquisition of other components (modules? apps bits?) needed to do so

Nowadays, we do programming by poking <2016-05-04 mer 18:13>   link

Today, this is no longer the case. Sussman pointed out that engineers now routinely write code for complicated hardware that they don’t fully understand (and often can’t understand because of trade secrecy.) The same is true at the software level, since programming environments consist of gigantic libraries with enormous functionality. According to Sussman, his students spend most of their time reading manuals for these libraries to figure out how to stitch them together to get a job done. He said that programming today is “More like science. You grab this piece of library and you poke at it. You write programs that poke it and see what it does. And you say, ‘Can I tweak it to do the thing I want?'”. The “analysis-by-synthesis” view of SICP — where you build a larger system out of smaller, simple parts — became irrelevant. Nowadays, we do programming by poking.

Dyson's Dodecahedron <2016-05-01 dom 11:47>   link

A nice collection of hand-drawn RPG maps

Isabella the Catholic brings change to Chess <2016-04-18 lun 12:29>   link

Org as a Word Processor <2016-04-02 sab 12:12>   link

"Learning Racket" series <2016-03-29 mar 16:37>

An expert programmer learns Racket and takes notes in the process. Many interesting remarks, for example (after discovering a library that let the user bend the language):

It must be any language designer's ultimate dream.

(And this is probably Lisp's greatest weakness as well – with this level of possible diversity, everyone has to use the “common lowest denominator” simply because nobody can agree on what alternative syntax / library / etc. is better and should be used.)

Switched to Ubuntu Xenial Xerus <2016-03-29 mar 10:38>   meta

Better hardware support with less work for me (the Broadcom Wifi chip has been recognized with no problems).

eshell and why can't I convert to you <2016-03-03 gio 08:51>   link

Some interesting Emacs shell tricks in this Reddit thread.

The Lisp Curse <2016-02-26 ven 17:13>   link

Interesting read, that resounds with something we were talking about at last Haskell meetup.

Lisp is so powerful that problems which are technical issues in other programming languages are social issues in Lisp.

Consider the case of Scheme, again. Since making Scheme object-oriented is so easy, many Scheme hackers have done so. More to the point, many individual Scheme hackers have done so. In the 1990s, this led to a veritable warehouse inventory list of object-oriented packages for the language. The Paradox of Choice, alone, guaranteed that none of them would become standard. Now that some Scheme implementations have their own object orientation facilities, it's not so bad. Nevertheless, the fact that many of these packages were the work of lone individuals led to problems which Olin Shivers wrote about in documenting the Scheme Shell, scsh.

What are some of the must-read, harder Sci Fi books you all recommend? <2016-02-19 ven 15:02>   link

R setup <2016-02-06 sab 11:46>   dev

I need to setup a R environment on the Linux machine. RStudio (which I'm currently using on my Mac) eases packages installation and at the same time provides a rich and pleasant to use environment, but I'm considering going for a different setup on my Linux machine. For example, one way could be using Debian packaged R plus Emacs ESS.

Farewell, Marvin Minsky (1927–2016) <2016-01-27 mer>   link

Especially interesting is what Minsky observes about teaching programming languages:

I remember a few years ago bringing up the topic of teaching programming, and how I was hoping the Wolfram Language would be relevant to it. Marvin immediately launched into talking about how programming languages are the only ones that people are expected to learn to write before they can read. He said he’d been trying to convince Seymour Papert that the best way to teach programming was to start by showing people good code. He gave the example of teaching music by giving people Eine kleine Nachtmusik, and asking them to transpose it to a different rhythm and see what bugs occur. (Marvin was a long-time enthusiast of classical music.) In just this vein, one way the Wolfram Programming Lab that we launched just last week lets people learn programming is by starting with good code, and then having them modify it.

A surface code quantum computer in silicon   link

How modern languages will save the text editor   link

Interesting post about programming language writing tools.

[…] the languages were developed in complete ignorance of these tools, which made them somewhat hostile to those goals (anybody who tried to implement a correct C++ parser knows what I mean, life before clang was just painful). As a result, very complex tools making heavy use of specialized partial parsers, static analysis, and crazy heuristics emerged. And they emerged as part of even more complex development suites to combine them all in a coherent form: the IDE was born.


But more recently, things took a different turn (for the best I think): a new language emerged that was promoting a different paradigm: Go. Instead of making the tooling an afterthought, it’s been pretty much there at some level since inception. It even shows in the language grammar itself, which is designed to enable fast compilation, partial parsing, and a whole bunch of analysis tools.

It resonates with an old paper I'm reading: Programming in an interactive environment the “LISP” experience by Eric Sandewall.

Black Hole, by Bucky Sinister <2016-01-02 sab 19:44>   books


The best things and stuff of 2015 <2016-01-02 sab 12:33>   link

The annual post by Fogus. Great stuff.

Yay! New laptop <2015-12-20 dom 10:35>   meta

Now some work to make it work like I want (it comes with Windows 10 installed but I want a GNU/Linux system on it. So far I've only tried a live distro to check hardware support. As I expected, it's going to need some work to make the wifi chipset work properly).


Linux installed. First update from the new environment!

Creating Adventure Games On Your Computer

by Tim Hartnell, published 1983


(I found this reference in an excellent post by Michael Fogus)

Early Christmas present   books


The only way to beat this would be giving me more time to read it. (It's a wonderful boxed-set edition of the famous Feynman Lectures on Physics)

Untangling the Tale of Ada Lovelace

Nice post on Stephen Wolfram's blog ("In other words, she basically proposed to take on the role of CEO, with Babbage becoming CTO").

How to get good at chess, fast <2015-12-09 mer 13:09>

Adding dashboards to hledger <2015-12-08 mar>   dev

I spent a couple of days trying to hack some changes into hledger-web. I use it from time to time, especially to visualize the item tree generated from my journal, but I would need more to incorporate it in my workflow. What I would like is a system to describe arbitrary widgets to compose in a dashboard. Things like "monthly expenses, comparing this and last year, using a histogram". Or "breakdown of the top N expense categories, using a pie chart".

So far, I just built some familiarity with the codebase and I managed to obtain a static (I mean, non-configurable) dashboard with a single widget showing my monthly expenses. Like that (code is on github):


But the real problem is designing a sensible dashboard configuration language.

Chris Wellons: 9 Elfeed Features You Might Not Know <2015-12-05 sab 09:56>   emacs

A list of interesting elfeed tricks

Update <2015-12-06 dom 09:57>

I spent some time fiddling with my elfeed configuration. I like the interface and the way one could program and extend it. Here some more resources I found useful:

Update <2015-12-07 lun 09:00>

Some times elfeed gets stuck while downloading the feeds. Reading a relevant issue on github, I discovered the function elfeed-unjam that fixes the problem.

Programming Interactive Worlds with Linear Logic <2015-11-29 dom 11:20>   link

Logo-ish drawing environment <2015-11-27 ven 23:25>   dev

Some months ago I bought a copy of "Turtle Geometry". I am looking for a LOGO environment to follow along and do the exsercises, but I could not find anything good enough for Mac OS X (which is quite surprising, if you ask me). So I decided to write my own version. The first usable thing I produced is not quite LOGO, but enough to do fancy drawings and (I'm guessing) translate most of the exercises without efforts. Code is on github.


Update <2015-11-29 dom 09:39>

One thing I'm not sure how I could do is the interactive environment, but I discovered I have something acceptable at no cost, thanks to how Lisp and the lispbuilder-sdl package work.

Here a piece of code from my project:

;; [...]
    (with-events ()
      (:quit-event () t)
      (:key-down-event (:key key)
                       (when (sdl:key= key :sdl-key-escape))
      (:idle (reset-turtle)
             (fancy 20)
             (draw-turtle *position-x* *position-y* *direction*)

Since we're implicitly using the :poll event mechanism, the :idle event is triggered at each "game loop" iteration. Thus, if I redefine the functions used in the body associated to the :idle event while the program is running, I obtain a different drawing. What I do, at the end, is:

  • evaluate (main) (the SDL window appear)
  • focus in the Emacs window
  • edit some relevant functions (for example the body of fancy)
  • C-x C-e to re-evaluate the definition
  • voilà, new picture is drawn

A Basis for Concurrency and Distribution <2015-11-27 ven 12:00>   link

Spoiled by xmonad   meta

I'm doing some experiments with xmonad and I particularly like its mod-Space key combination to switch the window layout in a workspace. Is there something similar for Emacs?

This is similar to what I want: ThreeWindows

Update <2015-11-15 dom 11:51>

I ended up doing this (the entire code is here: larsen-functions.el)

(defvar *larsen/split-layout-type* t)

(defun toggle-split-layout ()
  (progn (change-split-type-2 *larsen/split-layout-type*)
         (if *larsen/split-layout-type*
             (setq *larsen/split-layout-type* nil)
           (setq *larsen/split-layout-type* t))))

(global-set-key (kbd "M-<f1>") 'toggle-split-layout)

John Wiegley on git <2015-11-05 gio 18:03>

From emacs-devel mailing list:

One thing to keep in mind is that Git has several distinct layers:

  • The data model
  • The plumbing
  • The porcelain

The data model is incredibly simple. This, I think, is Git's main attraction. I've written about the data model in my article "Git from the Bottom Up", and also via a Haskell library for interacting with this model, called gitlib (

The plumbing is… unintuitive to say the least. The porcelain is… fairly bad, but slowly getting better.

lispbuilder-sdl <2015-10-28 mer 22:43>   dev

Tried to install listbuilder-sdl via quicklisp, but got stuck on cocoahelper dependency. Is it supposed to work on Yosemite?

<2015-10-29 gio 21:46>

Managed to install the library on a Linux virtual machine. Tried Asteroids to test it.

Collection of CSS styles for org <2015-10-28 mer 09:04>   link

A thread on Reddit with pointers to CSS styles for org-mode HTML export.

A neat tmux trick [2015-10-19 lun 09:31]   dev

Francesco showed me his tmux conf. This is particularly useful:

bind . send-keys B Space E Enter

Clojure: If Lisp is so great, why do we keep needing new variants? [2015-10-14 mer 14:20]   link

The one thing that Lisp programmers can agree on is how much better Lisp is than C and similar languages. I was talking last week to some programmers who use the Clojure version of Lisp and it made me wonder “If Lisp is so great, why did this guy have to build a slightly different version instead of building a popular application program in an existing version of Lisp, such as Common Lisp?”

Interesting discussion in the comments

Old but interesting <2015-10-09 ven 16:19>

Published the interview with Oliver Charles <2015-10-09 ven 12:23>   meta

Trying Spacemacs <2015-10-07 mer 22:06>   emacs

In a virtual machine, to avoid compromising my existing main setup

The installation process seems to be smooth.

It asked a couple of questions: one mysterious about the environment I would prefer, and another one about the initial settings (minimal or not) I'd rather use.

Initial setup finished with no errors

Which is good. The only problem –if one wants to be picky– is that the status line looks messy, probably due to a lack of proper fonts.

I try to venture in the scratch buffer

I have, somehow, Vim keybindings and Emacs' ones. So for example I can edit some Elisp expression using "Vim" then evaluate it with C-x C-e. I think there are people that were burned like witches for much less.


I'm surprised

I had the uneducated conviction that with evilmode (on which Spacemacs is based, if I understood correctly) one could either use Vim bindings or Emacs' ones, choosing on a buffer basis. And that seemed unconvenient and unpractical to me. I should dig deeper, but this mixture seems well conceived and sound. As I wrote in another place, quoting Nic Ferrier, Vim is a superior editor, but Emacs is a superior environment to write editors. And Spacemacs is a proof.

Just arrived: Land of Lisp <2015-10-06 mar 17:52>   books


Finished Anathem <2015-10-05 lun 23:36>   books

Software I'm looking for <2015-10-02 ven 11:56>   meta

Switching theme <2015-09-25 ven 16:27>   emacs

When you use load-theme the chosen theme is applied together with any other theme precedently activated. This small function could be useful to switch theme instead of just pushing another one on the stack.

(defun switch-theme (theme)
    (intern (completing-read "Switch to custom theme: "
                             (mapcar 'symbol-name
  (dolist (curr custom-enabled-themes) (disable-theme curr))
  (load-theme theme))

Attended Yoox <2015-09-22 mar 19:00>

Giraffe: Using Deep Reinforcement Learning to Play Chess <2015-09-15 mar 15:47>   link

Freer Monads, More Extensible Effects <2015-09-15 mar 15:46>   link

Trying to configure ox-rss.el <2015-09-13 dom 18:43>   meta

I'mq trying to properly configure ox-rss.el to produce a feed for this stream.

Computer Science Courses that Don't Exist, But Should <2015-09-13 dom 10:01>   link

Genius at play <2015-09-09 mer 08:32>   books


A biography of John Horton Conway. Arrived on Monday.

The present in deep history <2015-09-08 mar 08:33>   link

Charlie Stross on his blog:

Assume you are a historian in the 30th century, compiling a pop history text about the period 1700-2300AD. What are the five most influential factors in that period of history?

The comments are interesting.

Upgrading Haskell on my system <2015-09-06 dom 17:30>

(all started trying to do some experiments with Servant)

Monkey Island turns 25yo <2015-09-04 ven 15:33>   link

I can't even start telling how much is significant to me.

Urania 1622 <2015-09-04 ven 08:55>   books


I'm told that Bruce Sterling now lives in Italy, in Turin. This is a collection of stories set around Italy. Just skimmed the very first pages so far, I noticed an overflow of the word "occult".

I have history back to ~2003. <2015-09-04 ven 08:52>   link

TMK firmware <2015-09-01 mar 18:34>

Trying the tmk firmare on the Atreus. The feature list is very interesting, but it's not clear to me if it's all appliable to the specific hardware I'm using.

Typing analytics <2015-09-01 mar 08:34>

I wish I could be able to measure my typing speed in a consistent manner, and without recurring to tools external to my flow. Ideally, it would be something sitting behind and observing my keyboard usage as I work.

First Atreus mod idea <2015-08-31 lun 18:55>

I'd like to attach a wire to the board's pins that pilot the LEDs, thus being able to see when I'm on a certain layer.

hakyll deploy command <2015-08-31 lun 12:47>   dev

Hakyll allows users to configure a deploy command:

Next question is: how could I add more commands?

Post: Double feature keyboard review <2015-08-30 dom 15:54>   meta

Width-adaptive XMonad layout <2015-08-30 dom 10:15>   link

I thing this will be handy in the future

DateTime::Duration <2015-08-28 ven 17:10>   dev

Here a surprising feature in [[][DateTime::Duration]]'s API. What this code will print?

use strict;
use warnings;

use DateTime;
use DateTime::Duration;

my $dt1 = DateTime->new( year => 2015, month => 8, day => 1 );
my $dt2 = DateTime->new( year => 2015, month => 8, day => 31 );

my $duration = $dt1->delta_days( $dt2 );
print $duration->days();

It prints 2, because the days() method is implemented as

abs( ($duration->in_units( 'days', 'weeks' ) )[0] )

meaning that the duration is first converted to weeks, then the remainder is returned.

Here an extended piece of code to show what happens:

use strict;
use warnings;

use DateTime;
use DateTime::Duration;

my $dt1 = DateTime->new( year => 2015, month => 8, day => 1 );

foreach my $d ( 2 .. 31 ) {
  my $dt2 = DateTime->new( year => 2015, month => 8, day => $d );
  my $duration = $dt1->delta_days( $dt2 );
  printf "%s days and %s weeks\n", $duration->in_units( 'days', 'weeks' );

which prints:

2 days and 0 weeks
3 days and 0 weeks
4 days and 0 weeks
5 days and 0 weeks
6 days and 0 weeks
0 days and 1 weeks
1 days and 1 weeks
2 days and 1 weeks
… and so forth

If you want to know how many days there are between two given dates, better be explicit and use $duration->in_units('days').

The doc explains it clearly if you take the time to read it:

These methods return numbers indicating how many of the given unit the object represents, after having done a conversion to any larger units.

But it's baffling to me nonetheless.

How recursion got into programming: a comedy of errors <2015-08-28 ven 13:04>   link

Anathem, by Neal Stephenson <2015-08-28 ven 08:30>   books

~15% into the book. Some action. I'm not complaining, I think this prolonged immersion in the concent's life will be crucial – not just colour, I mean – to comprehend the plot that is unfolding.

Light Up <2015-08-27 gio 22:50>   dev

Simon Tatham's Portable Puzzle Collection is a nice collection of puzzle games that should be interesting to solve automatically. I installed the Android version of the collection and played a little with Light Up.

You have a grid of squares. Some are filled in black; some of the black squares are numbered. Your aim is to ‘light up’ all the empty squares by placing light bulbs in some of them.

Each light bulb illuminates the square it is on, plus all squares in line with it horizontally or vertically unless a black square is blocking the way.

To win the game, you must satisfy the following conditions:

  • All non-black squares are lit.
  • No light is lit by another light.
  • All numbered black squares have exactly that number of lights adjacent to them (in the four squares above, below, and to the side).

Non-numbered black squares may have any number of lights adjacent to them.

First thing, board representation and some diagrams code to obtain a graphical rendition.


import Diagrams.Prelude
import Diagrams.Backend.SVG.CmdLine

data Square = Empty
            | Box
            | Light
            | Lamp
            | Num Integer

type Board = [[Square]]

board :: Board
board = [[Empty, Box,   Light, Empty, Box,   Empty, Empty],
         [Empty, Empty, Light, Empty, Box,   Empty, Num 0],
         [Box,   Num 2, Lamp,  Light, Light, Light, Light],
         [Empty, Empty, Light, Empty, Empty, Empty, Empty],
         [Empty, Empty, Light, Empty, Empty, Num 1, Num 1],
         [Num 2, Empty, Box,   Empty, Empty, Empty, Empty],
         [Empty, Empty, Num 1, Empty, Empty, Num 0, Empty]]

squareSize = 30

drawSquare Empty = square squareSize
drawSquare Box = square squareSize # fc black
drawSquare Light = square squareSize # fc yellow
drawSquare Lamp = circle (squareSize * 0.3) # fc white
               <> square squareSize # fc yellow
drawSquare (Num n) = text (show n) # fc white # fontSize (Local 16)
                  <> square squareSize # fc black
drawBoard :: Board -> Diagram B R2

drawBoard b = vcat . map (alignR . hcat) . (map . map) drawSquare $ board

sketch = drawBoard board

main = mainWith sketch

twitter followers == 0? <2015-08-27 gio 08:49>

Apparently my Twitter following/followers counter has been reset to 0.

Fixed <2015-08-27 gio 09:25>

which-key <2015-08-26 mer 18:24>

@manuel_uberti wrote about which-key, a package that displays available keybindings in popup. Manuel shows an example to activate it:


(setq which-key-idle-delay 0.5
                '(("<\\([[:alnum:]-]+\\)>" . "\\1")
                  ("up"                  . "↑")
                  ("right"               . "→")
                  ("down"                . "↓")
                  ("left"                . "←")
                  ("DEL"                 . "⌫")
                  ("deletechar"          . "⌦")
                  ("RET"                 . "⏎")))

State of the Common Lisp Ecosystem, 2015 <2015-08-26 mer 09:06>   link

an observation <2015-08-26 mer 08:49>

So, apparently the code highlighting I get publishing a org document gets affected by the current theme in Emacs (note to self: using the cyberpunk theme produces unreadable code on white background).

wiz <2015-08-25 mar 22:53>   dev

Trying to expand the vocubulary of my interpreter including graphic primitives.

  • The environment will get enriched with a list of Pictures that together compose the Sketch we want to draw (I'm using Gloss)

    data Sketch = Sketch [Picture]
      deriving (Eq)
    data Environment = Environment (Map.Map String Expression) Sketch
      deriving (Eq)
  • The Sketch is drawn at the end of the repl session (meaning that we accumulate Pictures to be drawn all together at the end of the session: I intend that only as the first step, I want an interactive environment where the user can have instant feedback on the picture he's composing). Something like that:

    draw sketch = Graphics.Gloss.display (InWindow "wiz Test" (640, 480) (10, 10))
       white (drawSketch sketch)
  • So, we pass from two to three effects evaluating an expression can have:
    1. Returning a value
    2. Changing the symbol table (part of the environment)
    3. Adding a picture in the sketch (part of the environment)

I hoped to be able to include the third effect in the eval function, but so far that's only able to return values, without affacting the environment. I guess this was a poor decision, that needs to be amended.

ghci <2015-08-25 mar 21:53>   dev

ghci + Gloss don't play well on my system. I need to do

ghci -isrc -fno-ghci-sandbox src/Main

Ron Gilbert on Thimbleweed Park <2015-08-25 mar 08:51>   link

Saving games still scare me.This is something I should have figured out months ago. The issue isn't a matter of how to store the data, it's way more complex than that. There is a lot of data to iterate through and save off in a way that can be reconstructed. Doing save games is harder today than it was back in the SCUMM years. Back then we didn't have to worry about patching. These days, the save game has to survive the game being patched and that can mean resources being added or removed.

Ryan Carmack's game <2015-08-24 lun 23:13>   link

Ryan is John Carmack's son.

I’m still taking a little heat from my wife for using an obscure language instead of something mainstream that is broadly used in industry, but I have nothing but good things to say about using Racket and DrRacket for a beginning programmer, and highly recommend it.

wiz <2015-08-24 lun 23:02>   dev

I wanted to do some progress on the Scheme interpreter, but I ended up instead fixing code that went on github by mistake, and fighting with some git nuisances.

Anathem, by Neal Stephenson <2015-08-23 dom 10:43>   books

I'm currently approximately 5% through the novel. I still have only faint ideas about what's going on. Not yet alarming, by my count.

Clojure IDE <2015-08-22 sab 19:11>   dev

Spent some time setting up a development environment for Clojure using Leiningen + Emacs + CIDER + clj-refactor. Still confused by some parts of the system but I can see how pleasant it can be.

Meeting J-Bob: Notes on "The Little Prover" Chapters 1-5 <2015-08-21 ven 10:01>   books

The Little Prover <2015-08-20 gio 11:18>   books


Just arrived. It's printed in colours!

I didn't have the courage to ask the courier about two more books I'm waiting for: he seemed very pissed off for the problems he had finding my address.

How to Help Self-Driving Cars Make Ethical Decisions <2015-08-19 mer 09:46>   link

They implemented different ethical settings in the software that controls automated vehicles and then tested the code in simulations and even in real vehicles. Such settings might, for example, tell a car to prioritize avoiding humans over avoiding parked vehicles, or not to swerve for squirrels.

As the technology advances, however, and cars become capable of interpreting more complex scenes, automated driving systems may need to make split-second decisions that raise real ethical questions.

At a recent industry event, Gerdes gave an example of one such scenario: a child suddenly dashing into the road, forcing the self-driving car to choose between hitting the child or swerving into an oncoming van.

“As we see this with human eyes, one of these obstacles has a lot more value than the other,” Gerdes said. “What is the car’s responsibility?”

Measuring things <2015-08-18 mar 22:09>   dev books

I use org-mode for registering the books I read. Here some code to produce stats.

;; Is there a better (more idiomatic) way to aggregate values?
(defun aggregate (aggregate-function lst)
  (let ((hash (make-hash-table :test 'equal)))
    (loop for key in (mapcar 'car lst)
          for value in (mapcar 'cdr lst)
          do (if (null (gethash key hash))
                 (puthash key value hash)
               (puthash key (funcall aggregate-function value (gethash key hash)) hash))
          finally return hash)))

(defun pages-per-month-raw ()
  (with-current-buffer (get-file-buffer "~/org/")
    (mapcar (lambda (b)
              (let* ((month (format-time-string "%b" (date-to-time (cdr (assoc "TIMESTAMP" b)))))
                     (pages (string-to-int (cdr (assoc "PAGES" b)))))
                (cons month pages))) 
            (books/in-year "2015"))))

(defun pages-per-month ()
  (let ((ppmr (pages-per-month-raw)))
    (aggregate '+ ppmr)))

(defun month-list ()
  '("Jan" "Feb" "Mar" "Apr" "May" "Jun"
    "Jul" "Aug" "Sep" "Oct" "Nov" "Dec"))

(defun complete-hash (hash)
  (let ((new-hash (make-hash-table)))
    (loop for month-name in (month-list)
          do (if (null (gethash month-name hash))
                 (puthash month-name 0 new-hash)
               (puthash month-name (gethash month-name hash) new-hash))
          finally return new-hash)))

;; Poor man's TSV export
;; TODO check the implicit assertion on the ordering
(maphash (lambda (k v) (insert (format "%s\t%s\n" k v)))
         (complete-hash (pages-per-month)))

Then, for example:

stats <- read.csv("/tmp/stats.tsv", sep = "\t", header = F)
names(stats) <- c("month", "pages")
stats$month <- factor(stats$month, )
p <- ggplot( stats, aes(month, pages)) + 
    geom_histogram() + 
    theme(axis.text.x = element_text(angle=45, hjust=1))


"With great power comes a really shitty UI" <2015-08-18 mar 14:53>

Installed the Chicken Scheme interpreter <2015-08-18 mar 09:50>   dev

The Turing Digital Archive <2015-08-17 lun 18:14>   link

Basic setup <2015-08-17 lun 16:46>   dev meta

Basic stream setup done.

Anachronistic computing <2014-10-13 lun>

Yay! The laptop I recently bought for a ridiculously low price is eventually working like I want.

x32.png First its characteristics:

CPU Intel Pentium M (Dothan)
HDD 40GB 2.5" PATA
Display 12.1" TFT with 1024x768 resolution

It is a IBM Thinkpad X32. A good news is it sports one of the best keyboards one can find on a laptop (and I was lucky enough to find the GB layout). I found it at an electronic fair I recently visited, and grabbed it without much thinking from the pile (literally) where it layed together with some of its twins.

I think it's remarkable that such an old piece of hardware can be a perfectly usable machine (at least for the way I'm used to work). All it takes is some attention to the software one chooses to install:

  • Linux, obvious choice to revive old hardware (in this case, I had to recur to a non-PAE kernel due to the particular CPU architecture)
  • i3, a lightweight tiling window manager
  • Emacs 24.3, where I'm going to spend much of my time (w3m is a decent surrogate of a proper graphical browser for reading documentation)
  • I'm even running Hakyll locally to prepare this post

The Internet with a human face <2014-08-18 lun>

An interesting talk by Maciej Cegłowski.


Anyone who works with computers learns to fear their capacity to forget. Like so many things with computers, memory is strictly binary. There is either perfect recall or total oblivion, with nothing in between. It doesn't matter how important or trivial the information is. The computer can forget anything in an instant. If it remembers, it remembers for keeps.


Our lives have become split between two worlds with two very different norms around memory.


The online world is very different. Online, everything is recorded by default, and you may not know where or by whom. If you've ever wondered why Facebook is such a joyless place, even though we've theoretically surrounded ourselves with friends and loved ones, it's because of this need to constantly be wearing our public face. Facebook is about as much fun as a zoning board hearing.

2011 in books <2011-12-31 sab>

Essays/Computer science/$work stuff

In 2011 I started my adventures in the perilous lands of bigdata, so I've begun harvesting literature on the subject. Extremely interesting and relatively young field. I have an almost finished review of "Data Analysis with Open Source Tools" which I hope to publish soon.


My first encounter with Douglas Coupland. I particularly liked Microserfs, that somehow seemed to be speaking directly to me. Perhaps not for everybody.

Five minutes after Games of Thrones s01e01 I realized I couldn't wait an entire week to know the rest of the story. Still entertaining, after ~3000 pages and already in the fourth book.

I'm a hardcore Neal Stephenson fan. I also have Anathem in my stack, but I decided to read Reamde first, because it seemed less dense. It was, and also more fast-paced than usual.

How fast my git repositories are growing <2011-08-06 sab>

I wrote a very small utility to gather LOC counts from a git repository. Called gitsloc, it's based on Cloc, with some extra goodness provided by Sysadm::Install (a rather inaptly named module, if you ask to me, but full of useful gems).

I guess it could actually have some uses, who knows?, but I wrote it mostly because I wanted to see how fast repos are growing, and R is the obvious tool to tinker with the results.

I'm less than a beginner with R, and I have to admit plotting data from a multi-column CSV file is less straitghforward than I expected: I had to use =xyplot= from the lattice package, like this:

  Perl + Bourne.Shell ~ 1:nrow(sloc),
  data = sloc,
  type = 'a',
  auto.key = list( space = "top", lines = TRUE, points = FALSE)

Here the result, with data provided analysing the Dancer github repository (branch devel).


Kindle first impressions <2011-04-17 dom>

I just unboxed my Kindle. I played with it for a few hours only, but I'm satisfied with the choice so far.

First of all, to the zealots that may happen to read this article and feel compelled to whine on "scent of paper" and other oddities: I'm not planning the disposal of all my "real" books, neither I'm considering buying only digital contents from now on.

I decided to buy an ebook reader because I wanted to see on my own what can be done with this technology, which I consider immature and yet to be completely exploited.  I think I am an early adopter, even if Amazon Kindle and its competitors hit the market several years ago.

Also, I think having an ebook reader is nowadays the most practical solution to the eternal problem "What books should I bring with me during the journey?". Being able to answer "All!" is a wild dream that comes true (but I understand this can be a problem as well).

Anyway, here a few impressions from a very very beginner.

  • The device itself looks beautiful. It's not heavy and it seems prolongated use will not be tiring. On the other hand, I have the impression it's not particularly sturdy. Again, this is something I can say only in a few months (or in a few hundreds kilometers).
  • I think the slogan "it's like paper" is inaccurate.  Whatever appears on the screen seems printed, but it does not recall paper to me.  Besides that, fonts are very  crisp and readable, so Kindle hits on the spot for what is supposed to be its  main use.
  • I am positively surprised by the refresh delay. Maybe because  I expected it to be even worse, I think it's bearable, at least for the kind  of books you read cover to cover in a sequential fashion. In other words, good for novels, articles and stuff like that; maybe not practical for manuals, documentation… in general, things you want to study, or browse randomly.
  • I suspect I will eventually feel hampered by the position of buttons on the device. Anyway, this can't be but a speculation.
  • I'm currently at my parents' place, and there are problems with the Internet connection, so I couldn't try its wifi capabilities yet. A pity: one of the things I was more eager to try was Kindle's use in conjunction with Instapaper.
  • Ah, the screensavers are wonderful!