A move to SliceHost and a new comment system

Tuesday, 02 November 2010

Today, I spent a few hours migrating my site back to one of my SliceHost servers. The appEngine just wasn't doing it for me. The biggest problem was storage limitations in regards to the size of files you could store. The AppEngine only allows 1mb files to be stored which is sadly stored on the database itself. Limitations like that meant that I could not host my own photo gallery and I missed not having my own gallery! Using Picasa would have been the alternative but, at the time, I didn't feel motivated enough to implement that. The nice thing about Django is that it automatically comes with a fairly straightforward administrative tool whereas the AppEngine makes you somewhat responsible for writing your own administrative tools.

Disqus comments rock! Previously, I was relying on Django comments. After that I tried a custom comments system that I made but was getting way too much spam so I decided to completely axe comments altogether. About a year or so ago I discovered Disqus but I never got around to actually implementing their comment system. 5 minutes was literally all it took to install and I was up and running. The only thing I have left is to customise the look and feel of the comment system. Though, at some point, I may try to use their new API to have a more tightly integrated comment system.

Leave a comment

Python-TwitPic v2.0

Monday, 01 November 2010

Last week I updated Python-TwiPic to API v2.0. TwitPic announced that they will continue supporting the old version, however, I recommend upgrading to the latest and greatest. Version 2.0 addresses some security concerns and comes with tons more functionality than the previous.

A while back Twitter introduced an extension to oAuth called Echo oAuth. In short, it's a way to provide a Twitter access_token to the media provider (TwitPic) instead of providing a username and password. As you may already know, TwitPic introduced more than photo uploading to their API. Now you can leave comments group and assign photos to events, and tag faces in a photo. I personally am only using TwitPic to upload photos but the extra features could be nice depending on your intentions.

The only request methods that TwitPic currently accepts are GET and POST. In this library, I chose to break up the method request calls into the four main RESTful request groups GET, PUT, POST, DELETE. Each request method belongs to a RESTful request group depending on it's function. Below is an example use case. You must first choose the appropriate method which is either: read, create, update, or remove. Then you pass a method the method call name and a dictionary of parameters (not including a service key). Seems pretty straightforward I hope. Also keep in mind that you are responsible for getting a user's access_token and should be passed as a string which I believe is fairly standard practice.

Usage:

1
2
3
4
5
6
7
8
9
import twitpic2
twitpic = twitpic2.TwitPicOAuthClient(
    consumer_key = CONSUMER_KEY,
    consumer_secret = CONSUMER_SECRET,
    access_token = ACCESS_TOKEN,
    service_key = SERVICE_KEY
)
# methods - read, create, update, remove    
response = twitpic.create(METHOD_CALL, PARAMS)

If you find any bugs please create a ticket so that I can fix them.

Leave a comment

Django-VideoThumbs

Sunday, 03 January 2010

I have been in need of a video thumbnailer for some time now and so I decided to create a proof of concept django model field that does just that. Note that since this is just a proof of concept project, I don't recommend using this in a production settings. This project is based heavily on the django-thumbs project but for videos instead. In order to create thumbnails for videos we must first extract a frame.

Extracting a frame can be done by using FFMpeg. The main problem is that the python FFMpeg libraries that currently exist are broken and have been for some time now. pyFFMpeg is getting a rewrite but it appears that it won't be ready anytime soon. As a quick hack, I simply pipe out to the command line and extract a group of frames. From there I find which frame has the most color and proceed with thumbnailing that frame. In case you were wondering, some videos contain black frames at the begin of the movie so instead of taking the very first frame, I take a sample of frames and find the frame with the most color.

For obvious reasons, this is NOT the best solution. In the future, if/when I get the time I plan on experimenting with ctypes since its a standard library that ships with python 2.5+. If you have any questions or would like to help please contact me.

Here is the Project Location.

Leave a comment

Livin' on the App Engine

Sunday, 08 November 2009

As of today, my site is officially on the Google App Engine (GAE). The switch was rather painless considering the GAE is largely python/Django-based. The main difference in the GAE versus using straight-up Django is that GAE has it's own ORM.

Limitations:

  1. Performing complex queries is somewhat difficult to do. When using Google Query Language (GQL) or the filter query method, sorting becomes an issue. For example, lets pretend that we would like to filter blog posts based on their category. We would filter using the category foreign key. Simple enough, what's wrong with that? Well nothing, but according to the documentation, there is an ordering limitation. A query can only be ordered by the item that it was being filtered on. In our case we are filtering on a category FK. If we wanted to order by date instead, according to the docs, that is not possible.
  2. Read-only access to the file system is another limitation. If you need to upload an image, you're out of luck. However, storing file data in the database as a blob is an option (although not a good one) but you are limited to 1MB. In most cases, this will not be an issue but when dealing with large images or videos consider you might consider YouTube or Picasa which can easily be integrated.
  3. Domain configuration documentation is lacking on how to point to a project. I actually had to find the solution on a non-google forum. Since the google app engine works by using sub-domains, I also have to use the ugly www prefix which is not a big deal but I prefer not to take a step back to 1995. I prefer non www domains, they look nicer!

Advantages

  1. Apps are super easy to setup and deploy.
  2. No need to spend to time being a sys-admin. Google takes care of that.
  3. All the great tools and applications that Google has Docs, Picasa, YouTube, gmail, etc.. can either be integrated into your app or setup on a sub-domain.
  4. Perhaps the best feature that I am befitting from is the fact that I am saving $10/month in hosting fees. The likely hood of my site ever exceeding the quota for free accounts is very slim.

Overall, I feel that the advantages outweigh the disadvantages at this time and I plan on making more apps on the GAE. One feature I wished that the GAE offered is access to the gmail spam filter through an API. How awesome would it be if you could filter comments or any type of text for spam? I would totally implement that. Speaking of which, I finally turned my comment system back on.

Previously, I had no solution for combating comment spam. I spent some time playing around with akismet but could never get it to function correctly so I ditched that solution. Next, I stumbled upon recaptchas.net, But I didn't like having an ugly badge that didn't flow with my site just to validate that a user is human. Finally, I found captchas.net, a very light weight captchas system. So I hope this will help combating my spam issues. In the event that spam gets through, I have an easy way of disabling spam as soon as it comes in. Maybe Google will implement my feature request then I can avoid captchas altogether.

I am still in the process of adding my gallery back. It's completed, I need to spend some time migrating the data over. Since GAE is using Django components I felt that I could keep the Django badge on my site. That's about it. I hope you like my subtle design changes!

Leave a comment

Textmate Bundles

Saturday, 24 October 2009

Updated on: March 15 2011 at 10:00 p.m.

TextMate is my primary editor of choice. The main reason I use TextMate is for the bundles which is a major productivity increaser for developers. TextMate comes with a few bundles by default but the official bundle repository provides a wider variety of bundles to choose from.

In order to get the official bundles, run the following terminal commands:

Official bundles:

1
2
3
4
5
6
7
8
mkdir -p /Library/Application\ Support/TextMate/Bundles cd /Library/Application\ Support/TextMate/Bundles
svn co http://svn.textmate.org/trunk/Bundles/ .
osascript -e 'tell app "TextMate" to reload bundles'

mkdir -p /Library/Application\ Support/TextMate/Bundles
cd !$
git clone git://gitorious.org/git-tmbundle/mainline.git Git.tmbundle
osascript -e 'tell app "TextMate" to reload bundles'

Updating the official bundles:

Use this command to update the official TextMate Bundles.

1
2
cd /Library/Application\ Support/TextMate/Bundles svn up *.tmbundle
osascript -e 'tell app "TextMate" to reload bundles'

JavaScript Tools Bundle:

A personal favorite of mine. When working with JavaScript JSLint is ran on your code every time you save your code and will indicate whether or not there is an error in your code.

1
2
3
cd /Library/Application\ Support/TextMate/Bundles
git clone git://github.com/subtleGradient/javascript-tools.tmbundle.git
osascript -e 'tell app "TextMate" to reload bundles'

Django (python) Bundle:

This bundle is another favorite of mine. It contains some convenience commands for auto generating model field code so that you waste less time typing.

1
2
3
cd /Library/Application\ Support/TextMate/Bundles
git clone git://github.com/textmate/python-django.tmbundle.git
osascript -e 'tell app "TextMate" to reload bundles'

Django Template Bundle:

Another Django bundle that contains commands for auto generating standard Django template methods and logic.

1
2
3
cd /Library/Application\ Support/TextMate/Bundles
git clone git://github.com/textmate/python-django-templates.tmbundle.git
osascript -e 'tell app "TextMate" to reload bundles'

Leave a comment