outer haven a place to relax / 2013-10-21 1800 Vim Plugins

I’ve been recently using three (technically four) Vim plugins that have been immensely helpful with development.


Vundle is a package manager for Vim that simplifies installing Vim packages. Most of the time you just put a github repo on a ‘Bundle’ line in your vimrc and Vundle handles the rest.


Easymotion is a plugin to help you visualize Vim’s navigation easier. I have it bound to \, and if I type \w it will highlight all the places ‘w’ would take me and replaces those locations with a letter to jump to. This works for all motion commands. It’s easier to show than explain, but if you’ve always struggled memorizing how b and w work, easymotion helps a ton.


Tagbar is a plugin which opens a small window that shows all the definitions in your source file. This can help when navigating a file that references a function many times (and normal search gets annoying to step through). I have this bound to \\, and automatically start with / so I can start typing and it will jump to the definition matching the search.

You Complete Me

YCM is the closest you will get to an IDE within Vim. I normally despise IDEs, but YCM gets out of your way and surfaces helpful information while you’re typing. It’s quite intelligent.

https://stip-blog.appspot.com/article/vim-plugins https://stip-blog.appspot.com/article/vim-plugins Oct 21 2013
Getting a SIM in Argentina/Mexico

I recently took a trip to Buenos Aires and Playa del Carmen, and found getting mobile data kind of an ordeal. I wanted to document what I did since the guides online seemed slight out of date.

In Argentina

Movistar runs a prepaid cell service with unlimited data for AR$1/day. To get this:

  1. Go to a kiosko or locutorio with the Movistar logo in the window with ‘chip’ or ‘chipo’ or ‘SIM’ (not recarga).
  2. Ask for ‘chip prepago’ specifying Movistar if needed (‘chip’ is pronounced like ‘cheap’). If your phone takes micro-SIM (most newer phones), you’ll need to buy a regular SIM and cut it down to size (not too hard, just need scissors and a steady hand). None of the kioskos sell micro-SIM, and if you ask they will simply tell you ‘no’ instead of ‘buy this one and cut it down.’
  3. Your chip may have been opened, the chip taken out, and taped back in. This happened to me in Argentina and Mexico, and as far as can tell it’s OK and the chip was simply returned by the previous owner.
  4. If your phone is micro-SIM, now’s the time to break out the scissors. If you screw up, you only lose AR$10 which is about US$2 so it’s not that big of a deal. microsim-shop has details, just make sure to get the position and alignment of the metal contacts right. If you’re cutting the metal contacts themselves then you’re doing something wrong.
  5. Insert your new SIM. You may need to reboot your phone for it to register.
  6. You’ll know you did it right if the phone registers itself on the Movistar network and has signal. A fresh SIM on Movistar is supposed to have an ‘overnight’ activation period with a confirmation text, but since the SIM I got was opened I think it was operational from the start.
  7. We’re about to put money toward this number, so make sure the phone is registered on the network and has signal. If isn’t, you may need to reseat the SIM and reboot or, if you cut your own micro-SIM, buy a new card and try again.
  8. Your phone may not be able to read the number off of the SIM, so I suggest you write down the number on a piece of paper or email it to yourself so you have it handy. In Buenos Aires this should be a 10-digit-long number.
  9. Go to a kiosco or locutorio with ‘recarga Movistar.’ This may or may not be the same place you got the SIM.
  10. Ask to ‘recarga Movistar,’ give the cashier your number and pesos, and hopefully the transaction will go through. If it did, you’ll get a text with your new balance. Certain days Movistar will text you about a 2-for-1 promotion, if you’re in BA for a longer term it may be worth the wait to top off then.
  11. Some places may sell you a scratch-off card to recharge, I’d recommend just finding the places that will do it directly with your number.
  12. You should be able to text ‘SALDO’ to either 444 or *444 to get your current balance. This can be done 10 times a month before costing money.
  13. Unlimited internet is automatically charged $1/day. You may have to send DATO to 2345, or bring the phone in to Movistar HQ to have internet activated (Avenida Santa Fe 1844, usually open 9-6 on weekdays). Service is much quicker if you already have the chip, since you can just talk to the people on the first floor right at the entrance.
  14. Your number externally (if you want to attach it to Google Voice) is +54 9 (your 10 digit number). I was able to receive both voice and texts from GVoice, but was unable to call out. Inside Argentina, there is something wacky about substituting the ‘15’ for ‘11’ in your number that I don’t fully understand, Fodor’s has some data on this:
  15. I was unable to connect the sim online to ‘mimovistar,’ so I was unable to recharge the phone online.

In Mexico

The Movistar SIM worked prefectly in Mexico, but the data rate was very expensive and I chewed through my remaining credit very quickly. I bought a Mexican SIM from Telcel (¿tiene chip prepago?) that worked fine once cutting down to microsim size. however, I had to buy a separate internet package which can be done online via credit card. The nice thing is that you are able to do this from the phone’s internet connection directly, even if you haven’t bought a plan yet. I was unable to get Google Voice to text or call the Mexican SIM.

Good luck!

https://stip-blog.appspot.com/article/getting-a-sim-in-argentina-mexico https://stip-blog.appspot.com/article/getting-a-sim-in-argentina-mexico Jan 15 2013
Programmer mind, mathematician mind: expounded

Ken Perlin recently wrote a post titled “Programmer mind, mathematician mind”. In it, he explains two different but complementary approaches to problem solving: one traditionally attributed to programmers, and one to mathematicians. I found this difference subtle but important, and my difficulties trying to explain this to a colleague prompted a post about it in more detail.

Ken’s concise description is “the former is procedural, whereas the latter is definitional.” Fleshed out, a programmer is attempting to find a series of steps to a goal, while a mathematician is trying to transform definitions to a goal. These sound pretty similar! To better demonstrate the difference, think about when either method goes awry. Let’s look at bad ways to define chess.

Bad procedural (‘programmer’) ways to define chess:

  • Chess is a game played on a grid made up of 4^3 squares.
  • Each side has two Bishops, these must always stay in the center of a square and may only move in integer multiples of sqrt(2) per turn.
  • If the King is taken, all pieces of the board must be reset to their starting positions on the next turn.

Note that these all ‘work’ in the sense that the original game of chess still functions under these rules. However, the reasoning behind the rules becomes obfuscated: why 4^3 squares instead of 64? Why not just say the Bishop always moves diagonally? Again, these are pathological cases meant to demonstrate how one ‘mind’ operates: in the case of the programmer, the ends justify the means. As long as the original game of chess somehow shows up, the exact definitions ultimately don’t matter.

Bad declarative (‘mathematician’) ways to define chess:

  • Chess is any game in which Garry Kasparov will win over almost all competitors.
  • A Bishop is any piece which moves diagonally.
  • If no other pieces are on the board, a King may not take a King.

These take the opposite extreme: instead of obfuscating the intention of each rule, the intention is made quite clear. Unfortunately, they fail from the utility standpoint: explaining that a Bishop is ‘any piece which moves diagonally’ is much less useful than ‘a chessboard starts out with two Bishops for each side, arranged like so, which only move diagonally.’ For a mathematician, the means matter just as much as the end does. However, unless you’re careful, you may not get to a satisfactory end!

Hopefully, this shines a little more light into the different forms of reasoning: programmers find rules to shift the machines in their heads (and their chips) to get the correct answer, regardless of how that happens. Mathematicians set up initial definitions and transformations which preserve ‘correctness’ through each step, and hopefully find a sequence of transformations which obtain the end result.

A final anecdotal observation: algorithms and implementations that are ‘elegant’ are usually the ones where the procedural and declarative styles meet in the middle. In this case, the implementation ‘falls out’ of the mathematics, and the result is very pleasing.

https://stip-blog.appspot.com/article/programmer-mind--mathematician-mind--expounded https://stip-blog.appspot.com/article/programmer-mind--mathematician-mind--expounded Sep 06 2012
Simple, concise programs

A professional programmer is constantly searching for sharper tools for the toolbox, and continually discards and replaces algorithms, libraries, and paradigms as better ones are found. A natural pattern emerges: these recipes for implementing ideas become cleaner and more succinct over time, asymptotically approaching an ideal. Much as a crystal forms as atoms rearrange themselves seeking the lowest energy state, the programmer’s toolbox crystallizes around the ideas that they are meant to implement.

One source of well-written, crystalized code is BSD. Most users don’t directly interact with BSD, but its permissive license and straightforward engineering have seen its code spread pervasively. Since it has a more unified development model than most Linux distributions, its code is more consistent across the whole OS – both kernel and userspace. In addition, it tends to take a no-frills approach to software (compared to GNU, for example). This may be more annoying to users, but a great boon to those reading the code.

Spend some time poking around the tree: one item I have used often is NetBSD’s hash library, which holds up well despite being 18 years old (!). Another program I enjoy is rain (of which I have an updated version on github). Really cool stuff, and you’ll come away a better programmer and a better engineer.

https://stip-blog.appspot.com/article/simple--concise-programs https://stip-blog.appspot.com/article/simple--concise-programs Aug 19 2012
blarg is now public

The source for this software is now happily hosted on github. I’m a fan of the ‘get things working, then clean them up afterward’ style of development, which can work well in totally greenfield development work. Since I knew neither Go or AppEngine very well, I’ve changed my mind on a lot of the design decisions as I went :). Luckily, having the platform up and running means further work can be incremental and much less cognitively scary.

Major things I’d like to see: more cloud service integration, page caching, better post admin interface, editing the sidebar as just a special page, better editing screen, style tweaks, general code cleanup, and a ‘getting started’ guide which brings you up from scratch to appengine.

https://stip-blog.appspot.com/article/blarg-is-now-public https://stip-blog.appspot.com/article/blarg-is-now-public Aug 17 2012
Setting up Tomato on a WRT160Nv3

I just went through a pretty harrowing experience setting up my router with the Tomato firmware. In the effort of saving some people some time, I thought I should document what I did here since there were many non-obvious things going on. Note that there are 3 versions of the WRT160N, each with slight incompatibilities. From what I understand v1 and v3 are both capable of new firmware, but this guide is specific to v3. There also might be a quicker way to get up and running, but the way I’m describing is the most foolproof (starting from a bricked-as-possible state and working up from there).

  1. Download the official WRT160Nv3 firmware from Linksys. We’ll need this in case things go south. The firmware can be found under the ‘downloads’ tab. (Make sure you select version 3.0). If you hit a snag, skip to step 5 and start from the beginning again, perhaps with a different tomato firmware.
  2. Download a DD-WRT image compatible with the WRT160Nv3. This one works well.
  3. Download a TomatoUSB version compatible with the 160N. Decoding the table at the bottom means you want something that fits the pattern tomato-K26-MIPSR2 that fits in under 4Mb. Note that the TomatoUSB project has diverged into the realm of mods. I found the older Shibby mods to work OK. Note that Shibby’s builds fall into 52, 54, and 5x. The 5x had ‘RT’ in their title and did not seem to work. The 54 did, and one known to work is tomato-K26-1.28.9054RAF-EN-MIPSR2-beta-036H-Std.trx (make sure to get the MIPSR2 one and not MIPSR1).
  4. Not necessary, but you may want to set your computer to have a static IP of just to make things easier once you’re hopping firmwares.
  5. We’re going to proceed in three steps: from a bricked machine we’ll upload the official Linksys firmware. The Linksys firmware doesn’t like tomato but likes DD-WRT, so we’ll upload DD-WRT. Taking care to get the DD-WRT password first, we’ll finally upload tomato which will hopefully work. If you’re already at a stage (say, you’re starting from the normal Linksys firmware) then skip ahead to that step.
  6. [Starting from a ‘bricked’ router]: do the 30 / 30 / 30 reset, which puts the router in maintenance mode. Upload the Linksys firmware. My router really wanted to reset the connection here a lot, just keep trying until it goes through. Restart when finished.
  7. [Starting from the official firmware]: go into administration and then firmware upload. Upload the DD-WRT firmware. You will be prompted to enter a password, use ‘root’ for your login and make up a quick pw here.
  8. [Starting from DD-WRT]: Telnet into your router, using ‘root’ and the password you gave before (DD-WRT always uses ‘root’ for the telnet login regardless what you set the login to be). Run nvram get http_passwd and save that gibberish string. This is what we will use to login to tomato. Login to the DD-WRT web interface, go to administration and firmware upload. Upload the tomato firmware and reboot.
  9. Access your router. You should be prompted with a login, use ‘root’ or ‘admin’ and the nvram’d password you obtained in the previous step. The first thing you should do when you first log in is change your password to something sensible. Congratulations, you’re in!
https://stip-blog.appspot.com/article/setting-up-tomato-on-a-wrt160nv3 https://stip-blog.appspot.com/article/setting-up-tomato-on-a-wrt160nv3 Aug 17 2012