FreshDesk Python API

Tuesday, December 2 2014 11:54 a.m.

FreshDesk is a great helpdesk system with a fully functional API. Recently a client asked to integrate FreshDesk into their Django based CRM. I created the Python interface to the API.

Here's the gist...

django, programming, python
Continue reading

Query a Random Row With Django

Tuesday, May 14 2013 5:38 p.m.

Here's a gist for a drop-in Django manager class that allows you to return a random row.


It can be used in your like this:

class QuoteManager(RandomManager):
    def random_filter(self):
        return self.filter(is_active=True)

class Quote(models.Model):
    quote = models.TextField()
    by = models.CharField(max_length=75)
    is_active = models.BooleanField(default=True)

    objects = QuoteManager()

    def __unicode__(self):

Advantages over using the order_by('?') is performance. Random sort at the database seems to be extremely slow on most databases even if the table only has a few thousand rows. Note that the count of records is cached for 5 minutes, so if the table changes often you may want to change that. A limitation is that it only returns one row.

django, programming, python

Getting AngularJS Authentication Working with Django

Thursday, March 28 2013 2:24 p.m.

django-angular-auth is a very simple example app or seed to get AngularJS authenticating using Django and Tastypie.

Although AngularJS' documentation has gotten much better, it still took me quite a while to figure out what exactly was the best path to take. Also, there are a few gotchas with allowed headers and cross-site security which are already solved in the example. Take a look and let me know what you think.

angularJS, django, programming
Comment Launches

Thursday, November 17 2011 8:39 p.m.

Little Brownie Bakers are the bakers that make Girl Scout Cookies. They required a custom CMS where they could enter info about cookies, post selling tips for parents, kids and volunteers; and generally update the world on the latest cookie news. And now they have it...

digitalhaiku, django, programming, python
Continue reading

US Open CourtConnect Launch!

Tuesday, September 6 2011 4:45 p.m.

The US Open CourtConnect site allows you to watch in real-time what people are talking about on Twitter and Facebook regarding the US Open. You can see personal photos taken right at the event by the general public, as well as those tweeted by players, experts and celebrities. CourtConnect takes the tweets and status updates and automatically color commentates by attaching facts relevant to the keywords in the message. It also highlights experts, players and celebrity tweets so you know who is who.

CourtConnect was built in Python using Django 1.3 and jQuery using Masonry in a very compressed timeline by Rudy Menendez, the team at Blenderbox and myself. We were able to use APIs from Mass Relevence and Pusher to push this site through that timeline. Other cloud services used are Embedly and EC2.

digitalhaiku, django, programming, python, realtime
Continue reading Launch!

Friday, May 6 2011 7:30 a.m.

Voxy helps you learn a language from life. That means, doing things you would do anyway but learn a language while you do it. Like reading about the NFL lock-out in Spanish. If you're learning English, an English version is also available here.

The iPhone app has reached #1 in the AppStore for education apps in 14 countries. Android app is coming any day now too. Both apps support location based learning. Are you near a bank and need to figure how to linguically maneuver through a transaction? Voxy can help!

digitalhaiku, django, programming, python
Continue reading

National Geographic Education Site Launch!

Monday, April 18 2011 9 a.m.

National Geographic creates educational programs, reference material and news used by teachers, students and parents in the United States and across the world to promote geo-literacy. And now this content is available online using a custom CMS built with Django.

digitalhaiku, django, programming, python
Continue reading

Search Twitter Public Timeline with Python

Thursday, April 15 2010 10:13 p.m.

This Python function takes a search string as a parameter and returns a dictionary representing the JSON returned by Twitter with your search results from the public timeline. Code requires simplejson. It supports all the parameters as defined by Twitter here.

def search_public_timeline(q, refresh_url=None, **kwargs):
    Searches the public timeline for the q string. There is no sanity checking
    of the parameters. It's all passed straight to the API. Spec defined here:
    If you send refresh_url then all parameters are ignored. Example usage:
    search_public_timeline('menendez', since='2010-04-15')
    Ed Menendez - [email protected]
    >>> len(search_public_timeline('the')['results']) > 1
    if not refresh_url:
        parms = {}
        parms['q'] = q
        query_str = '?%s' % urllib.urlencode(parms)
        query_str = refresh_url
    u = '' % query_str
    #user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'
    #headers = {'User-Agent' : user_agent}
    req = urllib2.Request(u) #, None, headers
    return simplejson.load(urllib2.urlopen(req))

programming, python, twitter

Python Syntax Highlighting

Sunday, April 4 2010 11:30 p.m.

Simple web utility that colors your python code. Useful for putting in blogs, HTML emails, etc.

See: Python Color Utility

programming, python

Human Resources in the Cloud

Tuesday, March 23 2010 3:34 p.m.

Photo by BamaWester

Back in the days when everyone thought a computer virus was science fiction, you would have to travel to a computer to use it. Computers were large, required special environments and special knowledge just to keep them running. You couldn't take this computer with you, or connect to it from very far.

With time, technology improved. Many innovators made fortunes with computers that became more portable. As the capabilities of the internet have grown, entrepreneurs have figured out how to make products where the real processing isn't happening anywhere near you, but somewhere else where you don't even see it. This is called, Cloud Computing.

You probably already use cloud computing and may not even be aware of it. Gmail is a cloud computing product. As is Facebook and WordPress. The real hard work of running those tools is not done on your tiny phone or in your web browser. The work mostly happens in the cloud.

management, politics, programming
Continue reading

Using Django as a Pass Through Image Proxy

Sunday, March 21 2010 8:39 p.m.

An earlier post shows you how to setup Nginx as a pass through image proxy. This post shows you how to do it with just Django and nothing else.

The Problem

We've solving the same problem as the earlier post. However, I will repeat it here for clarity as there's been some confusion.

You have a production DB with lots of images uploaded by users. For example, has over 11gb of user uploaded images. When you download a data dump of the production database, it has links to all these images which you don't have. You either have to download and sync all the images locally every time you copy the database, live with broken images or point your static images to the prod server.

django, programming, python
Continue reading

Maintain through Data Migration

Sunday, March 14 2010 7:49 p.m.

This post will show you how to create a file using Django South. If you're not familiar with South, it's a data migration tool. Stated differently, it's a tool that helps keep your database changes current across different sandboxes and server environments.

django, programming, python, south
Continue reading

Configuring Nginx as a Pass Through Image Proxy

Saturday, March 13 2010 8:26 p.m.

This post shows how to setup Nginx has a pass-through image proxy server. This is useful for local sandboxes, UAT and QA servers where you copy production database down to but don't want to copy all the user generated images to the non production environment.

django, programming
Continue reading

Efficiently Test Emails in Django

Sunday, July 19 2009 6:08 p.m.

Testing emails can be an inefficient process. The email needs to leave your machine, arrive at the SMTP server, get forwarded to your test mail server and then downloaded by your email client. Do you want those 30 seconds of your life back?

Using an SMTP sink, you can receive the email to your screen instantly. Setup is easy.

  •  ♦  Download
  •  ♦  Put it in whatever your project directory is. You will want to create a "inbox" directory. Besides outputting to the screen, this will automatically copy the email to the inbox directory in case you need to reference it later
  •  ♦  Change your to have: EMAIL_HOST = '', EMAIL_HOST_USER = '', EMAIL_PORT = 25

If you have a script that loads your sandbox environment automatically, you will want to load automatically. It will send a test signal to see if it's already running and not start twice.

If you run automated test scripts, the output of the "inbox" can be tested.

django, programming, python

AvaTint Launched!

Tuesday, June 30 2009 11 p.m.

The site very simply takes your avatar and turns it into any color you select. The online community is starting to do this to support and protest many things. This is the 2.0 way of making your page background black for a cause.

We created this site in 90 minutes using Django on June 19th.

django, programming, python
Continue reading

Easily Code Templates for iPhone in Django

Monday, May 4 2009 9:49 p.m.

Sometimes, you want to create a custom page for an iPhone or other small phone browser but don't want a custom URL or view for it. This can easily be handled by using the mini_render_to_response function.

django, programming, python
Continue reading

Celebrity Fantasy Game in Django

Monday, August 18 2008 9:53 p.m.

If you've played fantasy football or any fantasy sport you know what I'm takling about. If you're new to the concept, you pick a roster of celebrities and if they show up in the news, you get points.

The site was written using Django (trunk as of the 13th!) and Postgres 8.2. We've built a fantasy games package on top of the Django core which we would probably open-source if the community showed some interest in it.

This is our 2nd major site in Django and we really love it. To begin with, Python is a great language. When we built our fantasy engine, it was originally coded on MySQL. We encountered quite a few problems porting it over to Postgres. There are lots of little things where MySQL does type conversions for you automatically and Postgres (correctly in my opinion) does not. I definitely feel the conversion was worth it so that now we're on an enterprise level database.

django, programming, python
Continue reading

MySQL Connection Pooling with Django and SQLAlchemy

Friday, July 25 2008 12:41 p.m.

Here's a quick and dirty recipe to get connection caching from SQLAlchemy. This is really not connection pooling as that would require a separate process to only handle connections. All this does is prevent the connection from closing after you finish a query. We're also not replacing the Django ORM.

To give a little more background, normally when you use Django to get to your database, Django will automatically disconnect from the database when the thread is done with that query.

django, programming, python
Continue reading

Launching a High Performance Django Site

Sunday, July 6 2008 3:29 p.m.

Are the brakes on your Django app?

When building an application using an application framework like Django... the priority is often to get the application working first and optimize it later. The trade off is between getting it done and getting it done for 1 million users. Here's a check list of things you can do to make sure your application can be optimized quickly when you put on your optimization hat. Note, most applications don't need all of this since most applications do not get anywhere near enough traffic to justify even bothering. But if you're lucky enough to need to optimize your Django app, I hope this post can help you.

django, programming, python
Continue reading

Python Timezone Conversion Example Using pytz

Tuesday, May 13 2008 12:11 a.m.

Here's an example showing how to convert from one timezone to another in Python. Note that you won't be able to save the full date/time in MySQL without stripping out the timezone info.

programming, python
Continue reading

MySQL, Dates and Time zones, Postgres and Mindshare

Saturday, May 10 2008 12:27 a.m.

A database can’t be all things to everyone. Each one has its sweet spot. MySQL happens to be the Wal-Mart of the database world. A large market sweet spot with lots of really cheap stuff, questionably good for you and serving a basic need.

Occasionally, MySQL will let you down with some basic things… like time zones.

django, mysql, programming
Continue reading

New Site. Now With 80% More Blog

Thursday, May 1 2008 11:56 p.m.

Hope everyone likes the new updated blog format. Been trying to get this online for several months, but never had enough time to get it just right. It's still not, but it's good enough.

Complete change in technology for the new version. Using Django app framework on top of Python. Python is the most fun coding since SQLWindows (another OOP language with forced language formatting).

Features coming soon... RSS feeds and tagging.

django, programming

Subscribe RSS Feed

More Blog Entries
Ed Menendez' Facebook profile