The ICT4D Corner
Members of our tech team share insights
about technologies we use for CommCare.
Git commands I use all the time for dealing with branches.
This isn't anything new, but I use these all the time so it's nice to have something to point to for git newcomers.# create a new branch and check it outgit checkout -b BRANCH # list all branches---you should prune regularly to keep the list small...
September 25, 2012
What's a good replacement for long list comprehensions?
I’m going to preface this by saying that it might be more clever than useful, but I’ve already started using it code and gotten kind of addicted. Sometimes you have some really long list comprehension that starts spanning multiple lines, e.g. good...
September 13, 2012
How to: Use Django HTML utils
I'll often see things like this: username_in_html = u'%s' % (link, username)While it's not super great to be generating HTML in Python code all over the place, there are times where that's the simplest and cleanest thing to do. Even in those cases...
September 13, 2012
How to: Debug modems from kannel logs
(From Giovanni)Continue reading below only if you're interested in how to decode the hex strings and other info in the kannel bearerbox.log:These are the errors that keep showing up repeatedly: 2012-06-29 01:19:42   DEBUG: AT2[usb0-modem]...
July 2, 2012
More tips and tricks
if you ever get the dreaded mx.DateTime psycopg2 error when running django tests, (this is for psycopg2 == 2.4.1) this is because when you're in a virtualenv the python mx libraries don't transfer over some reason. quick fix is to pip install egen...
June 2, 2012
Some ssh and screen ninja sauce
SSH local port forwarding syntax: ssh [email protected] -L localport:targetserver:targetport any network traffic hitting localport on the local machine (the machine you’re ssh'ing from) will be forwarded over the encrypted ssh channel to remoteser...
April 20, 2012
How to: Auto-import common modules in ipython shell
if you use ipython, save yourself some typing by importing common modules automatically on load.edit your ipythonrc file (mine lives in ~/.ipython/) as such:import_mod math os os.path sys random itertools re json hashlib time urllib urllib2 urlpar...
April 9, 2012
How to: Make Python Asserts
A few very quick notes about python assertions. Most of this is probably already known / obvious to everyone but maybe this will help someone. 1. You can make your assertions more user friendly (for when they trigger and show up in logs) by passin...
March 28, 2012
How to: quickly find regressions
You've forked or frozen a repo and haven't kept up with recent dev, and now it's time to get back merged with the head. You pull, a whole bunch of code comes down, and some random thing that worked before is now broken. Which of the 200 revisions ...
March 8, 2012
All Countries in Different Languages and Formats
Interesting effort. Seems like we might benefit from the ability to be able to access this info (and transform it as part of some build process) from somewhere, even if not this dude's archive. We have a hard enough time keeping our language/count...
March 6, 2012
How to: Make sure that you're hard-refreshing (browser)
In both Firefox and Chrome one way to trigger a hard refresh is to hold down shift and click the refresh button or press ctrl-shift-r.How do I know I'm doing a hard refresh? Open up Firebug (in FF) or the developer console (Chrome).Go to the netwo...
February 29, 2012
Experience with TaskRabbit
I got quite sick of doing the buy/install/configure dance with the Wisepill devices for Project ARemind.Here's what I did to get things done /way/ more efficiently and effectively zero stress (mostly from Jon's suggestions so thanks goes to him): ...
February 10, 2012
How to: Override Equals in Python
Just got bit by this. So if you want to override the equality operator in python the simplest thing to do is override the __eq__ method. For example:class MyFoo(object): def __init__(self, equalityprop): self.equalityprop = equalityprop def __eq__...
February 6, 2012
Some tips and tricks
Neat little trick to generate HTML calendars in python for rendering in django.Once you pass it the day/month/year, you have access to each day rendering for whatever your heart's content. The way the class is structured gives you a lot of freedom...
February 1, 2012
Pulling data from CouchDB to a Relational Database made easy with _changes
(This is the first post in Dimagi’s new tech blog series, where we shift the focus from the impact of our projects to the technology side of our work.) Much has been written and debated about the various advantages and disadvantages of different document databases, and by far the most common choice in evaluating a
June 12, 2011