You implement a heroically recursive JS function, destined to call “Batman!!” till he
shows up … Continue reading “Trampolining your way out of overflows”
The Event Aggregator pattern
provides centralized events, thus simplifying producer/consumer registration/interaction. Continue reading “Backbone.js Event Aggregator and your garbage collector”
My impressions after some programming in Go can be summed up in two words: simple and scalable. Continue reading “Go from Simple to Scalable: downloading multiple web pages”
When working on a Flask project, you may want to override flask configurations
on different environments. Here are some suggestions.
A folder structure like the following might work well
In this structure, configs are plain python files and default is always loaded.
It is then merged with the environment-specific configuration (e.g. development).
It helps if the flask application is instantiated by a factory method/function.
Here are some ways to select the environment, each with higher precendence
than the previous one.
- read the contents of a file (in this example
- pass an environment variable (e.g.
Override with a variable (useful for testing)
from os import path
from flask import Flask, Blueprint
from flask import current_app
root = Blueprint(“root”, name)
return “Hello from %s” % current_app.config.get(“MYCONFIG”)
basepath = path.abspath(path.dirname(file))
CONFIGS = “demo.configs”
return ".".join([CONFIGS, override])
from os import environ
with open(path.join(basepath, 'configs/application.id')) as appid:
env = appid.read().strip()
except Exception, e:
environment_variable = environ.get("APP_ENV")
env = environment_variable or "development"
return ".".join([CONFIGS, env])
app = Flask(__name__)
if name == ‘main‘:
Twisted is explicit. If you kill a script that uses your protocol, it might die before data transmission finishes, unless you handle it yourself. Continue reading “It ain’t over ’till the data is sent”
Explaining how to use twisted’s
inlineCallbacks rarely goes smoothly. It usually ends in Infinite Frustration®. The learning curve is just too steep for a junior developer. Continue reading “Using twisted’s inlineCallbacks in 5 steps”
We consume lots of SOAP. Its probably a GDS thing.
Due to increased response sizes, our parsing times went up. Fun times! Here are the steps taken for optimizing XML parsing (using
Continue reading “Optimizing XML parsing in Python”
As this is powered by jekyll/octopress, it’s worthwhile to go into some detail about how to serve it on a Linode (or equivalent) and how to autoregenerate the whole site with a simple
Continue reading “Deploying an Octopress blog on linode”