February 21st, 2010
I found this via the etsy “code as craft” blog: http://velocityconference.blip.tv/file/2284377/
My big takeaway is validation of something I have always done – code configuration by user/bucket/site is a “good thing”. It’s so much easier to roll out changes to a select population and deal with changes that way. Something I like to do using django groups. It is a sort of a/b testing, but just a little different. Very useful.
Tags: django testing
Posted in Uncategorized | No Comments »
February 20th, 2010
I’m very grateful there is a boxee.log file written, otherwise I would not have thought that boxee was going to try to load the main.xml~ instead of main.xml by default!
Tags: boxee
Posted in Uncategorized | No Comments »
February 13th, 2010
I suppose I knew in the back of my mind, you’re not going to need it now, but eventually you will need to shard this*. So if you’re going to do anything in appengine, my advice is: just shard everything from the start. You’ll save yourself a world of hurt later on.
http://code.google.com/appengine/articles/sharding_counters.html
* This could be anything, it needn’t be just counters. Now the article is all about write contention, but it also demonstrates a very good approach to sharding data in the abstract. Depending on what you’re doing this is a very useful thing to do.
Tags: AppEngine
Posted in Uncategorized | No Comments »
February 10th, 2010
Found this today via jlapenna’s buzz on how to add more feeds to your buzz:
http://www.google.com/buzz/bradfitz/PPjHXDhANAC/Want-to-connect-your-blog-or-some-other-feed-to
Very useful.
Tags: buzz
Posted in Uncategorized | No Comments »
January 26th, 2010
Put all the callable defaults you want into a Model, the ModelForms aren’t evaluating them properly in Django 1.0.4. Luckily there is a patch: http://code.djangoproject.com/ticket/11940
Tags: django
Posted in Uncategorized | No Comments »
January 14th, 2010
I’m working on a few django sites all at the same time, and keeping the PYTHONPATH environment variable set correctly was getting to be a pain, and virtualenv seemed like it took a lot to set up – or that’s the way it looked from all the other blog posts out there.
So I took the plunge, and I’m happy to say it didn’t take all that much effort to go from a homebrew environment hack to using virtualenv.
Install Virtualenv
This works for me, but note, I have to use python2.5 (because of Google AppEngine) and I’m on OSX or ubuntu all day long.
sudo easy_install-2.5 virtualenv
That’s it. A lot simpler than I originally thought with all those other articles mentioning pip and zc.buildout.
Use virtualenv
It turns out using virtualenv is a lot easier than I thought also. A lot of the articles talk about using pip to install dependencies, etc. I’m sure pip is great and once I start rolling it out I’ll probably never look back. But for now I have a relatively small set of teams to manage, and everyone uses their own setup that works for them.
There’s only two setup steps and then you can use virtualenv. You don’t have to change your source control unless you really want to.
First, set up the new environment:
virtualenv --no-site-packages --python=python2.5 my_env_name
Then you activate the new environment:
source my_env_name/bin/activate
Now you are running with an empty environment. You need to perform your dev environment setup in this python virtual environment. But you only have to do that once.
Switching environments just means sourcing the right activate script. After a couple of alias changes in bash I’m all set.
Posted in Uncategorized | No Comments »
December 31st, 2009
When you are a startup, every minute counts. It makes complete sense to want analytic analysis of your website, however, it does not make sense to spend a lot of time building analytic databases/engines/reporting into your website. These things already exist, and are often free or very low cost.
I often recommend chartbeat.com for real time analysis. It tells you a lot of great stuff about how many people are on your site now, how they got there, and what they’re saying on twitter.
Google Analytics is great. Sometimes you want to know a little more than just url – like what are people searching on if you a custom search implemented in your site. This is easily added using the Event Tracking feature. With just a couple of javascript calls, you have a lot more data at very little cost. Best part, you don’t have to build any of it into your database or chew up database cycles reporting it.
If you want to see what people are searching on in your site use the Event Tracker from google analtyics like this:
pageTracker._trackEvent(”Search”, “HeaderSearch”, “{{search}}” );
Then simply slice and dice to your heart’s extent in analytics. No extra data stored in your database.
Posted in Uncategorized | No Comments »
October 14th, 2009
Sometimes, not all the times, but sometimes it is better to just allow traffic from certain countries you know are legitimate. MaxMind’s mod_geoip2 makes it easy: http://www.maxmind.com/app/mod_geoip
Posted in Uncategorized | No Comments »
September 15th, 2009
Was going through a code review, and saw something like this:
def some_function(user_id, bobj_id):
user = User.objects.get(id=user_id)
bobj=Bobj.objects.get(id=bobj_id
item, created = MyObject.objects.get_or_create(user=user, bobj=bobj)
return item
But that is two hits to the database we don’t need since the id’s are passed in. Remember, if you have id’s then you can shortcut pulling the object from the ORM like this:
item, created = MyObject.objects.get_or_create(user__id=user_id, bobj__id=bobj_id)
That will do the
.get()
just fine, but fails when it tries to
.create()
with this error:
psycopg2.IntegrityError: null value in column “user_id” violates not-null constraint
You got the error because
get_or_create
does not automatically use the query spec for the default. There’s probably an enhancement filed for that. Remember to send in the defaults explicitly:
item, created = MyObject.objects.get_or_create(user__id=user_id, bobj__id=bobj_id,
defaults={'user_id':user_id, 'bobj_id':bobj_id})
Be sure you look for that in your api calls where you have mainly ids coming in and not object references.
Posted in django | No Comments »
September 10th, 2009
Currently, if you want to insert ads into a video stream, you are going to write a flash video player which periodically stops the video stream and displays an ad stream. Adobe could make this a whole lot easier if they would let you insert the stream at the flash media server instead of the client.
Why don’t they do that?
Posted in Uncategorized | No Comments »