La mucama y él

El azar lo explica todo, hasta se atreve con el Universo. Una calle cerrada, un desvío y la pizarra escrita con tiza con la promoción del día, tres cajas de vino tinto Lampedusa Malbec al precio de dos. Irresistible. Sin embargo, no podía distraer esa cantidad de dinero, tampoco podía disimular dieciocho botellas de la mirada regente de mi esposa por hallarme ante una supuesta recuperación de lo que los virtuosos llaman adicción y que no es otra cosa que ser un buen bebedor.

Fate explains everything, until it dares to explain the Universe. A dead-end street, a detour and the board scrawled with chalk with the sale of the day, three boxes of red Lampedusa Malbec for the price of two. Irresistible. However, I couldn’t spare that much money, even if I could hide eighteen bottles from the keen sight of my wife for finding me before a supposed recovery of the virtues called addiction, and that is not something other than being a good drinker.

Continue reading “La mucama y él”

Annotated “Mr Stone’s Window”

Durante el último año, mi mundo había consistido en estar conectada a máquinas que envuelven los rayos o los tubos que infunden líquidos dentro de mi cuerpo. Como el resto de los pacientes en la sala, monitoreados y drogados, habíamos abandonado nuestro estatus e identidades personales, de manera que ya no éramos las mismas personas que cuando fuimos admitidas al llegar al Hospital.

During last year, my world had consisted of being connected to machines that involved wires and tubes which infused liquids into my body. Like the rest of the patients inthe room, monitored and drugged, we had abandones our status and personal identities, as if we were no longer the same people who were admitted on arriving at the Hospital.

Continue reading “Annotated “Mr Stone’s Window””

Javscript Regex Cheatsheet

I always forget how to do this:

r = /^[^0-9]+/

string = '1a'

me = 'b2'

/* this returns false */


/* this returns true */


then how about capture groups – you can’t iterate over them in one go, that’s the problem, you have to do it via exec() which you run multiple times on the same str variable, weirdly enough. The return value is an array with always just two elements: the entire match and the capture group match.

let str = '<h1>Hello, world!</h1> <h1>Hello1, world!</h1> <h1>Hello3, world!</h1>';
 let reg = /<h1>(.*?)<\/h1>/g;
 let match;
 while (match = reg.exec(str)) {

voila – you get first the 2 elements, “<h1>Hello, world!</h1>” and “Hello, world!” and then the two elements, “<h1>Hello1, world!</h1>” and “Hello1, world!” and so on

Docker Compose Steps

Quick note to remind myself how to re-run my Docker containers:

  1. Is my Docker Compose part of a network? Make sure all required services are running elsewhere.
  2. Did I change anything in the build steps? (E.g., with Rails, did I change the Gemfile?) – run docker-compose build --no-cache
  3. Clean things up: Run an rm step that can remove exited containers.

Continue reading “Docker Compose Steps”

Books for Beginner Coders

Someone emailed me and asked what good books to read for beginning-level coders.

I usually recommend that if you are starting to learn how to code, you should first extend your research by asking the same question (“What’s a good beginners’ book for…?”) for a list of popular programming languages – here’s a highly selective list I got Continue reading “Books for Beginner Coders”

Android Fundamentals for Programmers

This post documents some fundamentals of Android programming, for someone who’s already been programming in other languages. Here are things you should know:

Rage and Rant

The Android layout XML markup basically re-invents CSS. Fuck you, Google. Why can’t you have just extended open standards, and made it easier on all of us? “Do the Right Thing,” my sainted ass.

XML attribute to make your view be as big as its parent? match_parent. Heard of divs, Google? What’s wrong with fucking HTML divs?

Bah. Anyway, smoke on that a bit first, and now let’s go on.


  • Activity is a class in the Android SDK. An activity is responsible for managing user interaction with a screen of information.
  • Every widget is an instance of the View class or one of its subclasses (such as TextView or Button.)
  • ViewGroup is a View subclass that contains and arranges other widgets.
    • Other ViewGroup subclasses are FrameLayout, TableLayout, and RelativeLayout.
    • FrameLayout is the simplest ViewGroup and does not arrange its children in any particular manner. The arrangement will use the android:layout_gravity attribute, instead of the ViewGroup’s pre-determined layout.
  • Sometimes, you want your widgets to have “resource IDs.” To generate a resource ID for a widget, you include an android:id attribute in the widget’s definition.
  • There is a + sign in the values for attributes that you are creating and not merely referencing.
  • Some class names are food-themed. Why?


  • Everything on screen is a “view”; that is, a View. So to create an interaction, you have to get the view via its ID (that you set in a corresponding resource XML file), and then call a method on the appropriately-casted View object that sets an event listener. This means you have to learn a whole new vocabulary of event listener methods, instead of finding pleasantly that the methods are named the same as, oh I don’t know, some library that already implements event-based actions for a visual interface, now I wonder where one could find such a language…

The View

  • Pulling things into the view involves specifying them in your content_*.xml file. These things are pulled in either as strings (android:text=”@string/…) or images (android:drawableLeft=”@drawable/…) I guess there are other possible “drawable” values you can set to put your images in different parts of a given widget. At least one of them is drawableEnd, which I am guessing intelligently moves the right-most image object to the left-most spot, for right-to-left screens.
  • The type of view used depends on the device configuration and other factors. The resources corresponding to each of these is in its own, appropriately-named, folder. There is a list of configuration qualifiers that Android recognizes and the pieces of the device configuration that they refer to.


  • The Log.d(String, String, Throwable) signature logs the entire stack trace at the point the Log.d function was called, if the third argument is simply a “blank” instance of Exception (i.e., new Exception())
  • One can debug using “exception breakpoints” which is nice – and is in fact a feature of Byebug too, one I wasn’t aware of.


I’ll say this about statically-typed languages, though – it’s nice to have an IDE that can do fairly complex code analysis. Knowing that static fields can be converted to local variables? Gold.

Some of the IDE actions could equally be done in dynamically interpreted languages – finding the library that defines a symbol name, say, or knowing that a defined variable has never been used (which is in fact something Perl will tell you in warnings mode, so it’s a pity other languages aren’t as good about it. (I’m looking at you, Ruby.))


  • Oh yay. Java won’t apply the modulus operator to negative numbers to return a positive value. Which is exactly how none of the dynamically interpreted languages do it. Fun.

The Emulator

  • To rotate, hit Fn-Ctrl-F12


Some of these resources will probably come in handy later:



In our previous post on this topic, we started exploring some basic text analysis techniques. We looked at term counts or term frequencies as a measure to help automatically generate tags. The list of words by term frequency is also referred to as a “word cloud” sometimes, especially when the ‘cloud’ is visualized by arranging the words in a circular shape, and having more frequent words displayed in larger text.

In the first cut at a tagging algorithm, we probably started to see a few good candidates, but the first problem we would have run into is that one of these words, or something similar, is the most common: ‘a’, ‘an’, ‘the’, ‘of’, ‘that’, etc.

Continue reading “TF/IDF. WTF? Part II”


In this post, we will go over some basic theory behind statistical analysis of text. This theory encompasses some of the ideas used in a lot of modern big data analytics and is surprisingly relevant and useful even today, over forty years after it was invented.

Let’s start with a simple question – what is any document about? Alternatively, we can pose this question as, if we had a document that needed to be tagged, how can we do that automatically, that is, write a program to do it? Continue reading “TF/IDF. WTF? Part I”

Some Common Tricks with Ruby on Rails

Today we will use Ruby on Rails along with some Javascript libraries to code a few common patterns –

  • Autocomplete in a text box
  • Uploading files by dragging and dropping them into an area inside a browser.


The Javascript library, jQuery.token-input, is great for quickly building a Javascript-based autocomplete solution. You have to do only three things to get started: Continue reading “Some Common Tricks with Ruby on Rails”