• Speeding Up Your Python Code

    Posted on March 16th, 2013 | Tags: Optimizations

    In my opinion the Python community is split into 3 groups. There's the Python 2.x group, the 3.x group, and the PyPy group. The schism basically boils down to library compatibility issues and speed. This post is going to focus on some general code optimization tricks as well as breaking out into C to for significant performance improvements. I'll also show the run times of the 3 major python groups. My goal isn't to prove one better than the other, just to give …

    read more

  • Django Settings File Tricks

    Posted on March 9th, 2013 | Tags: Django

    Here are two really awesome tricks that have helped me with keeping my code sane on development and production.

    Environment Variables

    Environment variables are just like they sound. They are variables local to an environment such as development and production. You can basically store variables on the system so that when Django starts up it can use a certain variable value from development and a different one from the production server. We can set a DEBUG variable like so using a terminal window: …

    read more

  • Creating an API With Django

    Posted on March 2nd, 2013 | Tags: Python, Django

    It's been a crazy week for me put I wanted to make sure I got some useful content out. This week I'll be jumping back to python/django and talking about decorators and how they can be used for creating an API.

    A lot of people recommend Tastypie but I like to keep things simple when possible. Most APIs don't need anything as complex as Tastypie and just need something that can restrict access to some functions. Decorators make this really simple to do …

    read more

  • Introduction to Graph Theory: Finding The Shortest Path (Part 2)

    Posted on February 23rd, 2013 | Tags: Ruby

    A couple of weeks ago I did an introduction to graph theory using Dijkstra's algorithm. I received some awesome feedback so this week I want to take it a step further and build on that using the A* algorithm. The big difference between A* and Dijkstra's algorithm is the addition of a heuristic function. This heuristic function allows us to give a best guess of which path to take rather than always taking the path that is the shortest distance from the …

    read more

  • RSS Feed Is Live

    Posted on February 16th, 2013 | Tags: Django

    Over the past few weeks I've been getting requests for an RSS feed. Luckily Django provides a super simple way to convert my blog posts to RSS and Atom feeds.

    #urls.py
    from core.feeds import rss_feed, atom_feed
    
    urlpatterns += patterns('',
        url(r'^rss/$', rss_feed()),
        url(r'^atom/$', atom_feed()),
    )
    
    #feeds.py
    from core.models import Entry
    
    from django.contrib.syndication.views import Feed
    from django.utils.feedgenerator import Atom1Feed
    from django.utils import text
    
    class rss_feed(Feed):
        title = "Max Burstein's Blog"
        link = "/blog/"
        description = "Latest posts from Max Burstein's technical blog"
        
        def items(self):
            return …

    read more

<< Older Posts Newer Posts >>