|
FreshDesk Python APITuesday, 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
Query a Random Row With DjangoTuesday, 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. Model.objects.random()
It can be used in your models.py 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):
return self.by
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
Box Office Champs LaunchesThursday, May 2 2013 11:05 a.m. A fantasy movie game built using Django. This is a very easy game where you pick the 15 movies you think will be the highest grossing movies of the season. You can create a group and compete with your friends. You should give the site a try today. Iron Man 3 opens tomorrow and you definitely want to have that movie on your roster. Unlike fantasy sports, you can play this game 4 times a year. The summer season starts tomorrow. Kudos to Rudy Menendez who did principal development and game design and Noah Wenz for design and HTML. The site was with spare time over the last few months. Put together, development time was about 2-3 weeks. If you need a fantasy site done, contact Ed or Rudy Menendez and we can help you out. digitalhaiku, django, fantasy, python
LittleBrownieBakers.com LaunchesThursday, 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
BestBuy Fantasy Footaball LaunchesWednesday, September 21 2011 11:59 a.m. Launched back before NFL week 1. But, that was DjangoCon 2011, so the post happens today. Best Buy's site is operating for the third year in a row. Originally it was open to the public, but now it is employee only. You play by selecting a line-up every week and play against your co-workers and against the CEO. Makes for really fun team building. digitalhaiku, django, fantasy, python
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
Voxy.com 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
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
Search Twitter Public Timeline with PythonThursday, 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:
http://apiwiki.twitter.com/Twitter-Search-API-Method:+search
If you send refresh_url then all parameters are ignored. Example usage:
search_public_timeline('menendez')
search_public_timeline('menendez', since='2010-04-15')
Ed Menendez - [email protected]
>>> len(search_public_timeline('the')['results']) > 1
True
'''
if not refresh_url:
parms = {}
parms['q'] = q
parms.update(kwargs)
query_str = '?%s' % urllib.urlencode(parms)
else:
query_str = refresh_url
u = 'http://search.twitter.com/search.json%s' % 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 HighlightingSunday, 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
Using Django as a Pass Through Image ProxySunday, 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 ProblemWe'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, NationalGeographic.com 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
Maintain Constants.py through Data MigrationSunday, March 14 2010 7:49 p.m.
This post will show you how to create a local_contants.py 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
Efficiently Test Emails in DjangoSunday, 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.
If you have a script that loads your sandbox environment automatically, you will want to load smtp_sink.py 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
Easily Code Templates for iPhone in DjangoMonday, 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
Celebrity Fantasy Game in DjangoMonday, 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
MySQL Connection Pooling with Django and SQLAlchemyFriday, 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
Launching a High Performance Django SiteSunday, July 6 2008 3:29 p.m.
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
Python Timezone Conversion Example Using pytzTuesday, 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
|
![]() More Blog Entries
|