Stumpy Version 1.5 is Now Available!

Stumpy Version 1.5 is now out and ready for testing.
Should be functional, but please submit any issues you might find to the issues page.

Changes include (from commits):

  • Removed hardcoded domains from JS. We now pipe in through the stumpy_domain var by setting a global JS var ‘DOMAIN’ in the index and then reference that JS var in our scripts. You will no longer need to set your domain as hard coded into javascript code.
  • Updated to use get submission of new URLs for shortening. This should work, but needs to be tested on the production version to make sure WSGI and such are working okay without the earlier hack that was implemented.

Stumpy Updated – v1.4.3

The Mutaku URL shortener, Stumpy, has now been updated to version 1.4.3.

You can find out more about Stumpy by clicking the first link in this post to read the initial write up on Mutaku, or you can go to the project page on Github.

Stumpy main page

This release includes a few small bug fixes as well as incorporating a new feature that, for logged in users, shows all of their submitted URLS at the bottom of the main page. Previously, this was only viewable by going through the admin interface. If you are not logged in, you will see the traditional view with the 5 most recent and 5 most visited URLs.

You get get the newest release at the Github page here: v1.4.3

Python Cookies

Code snippet time again.

Today, let’s look at a few simple classes to handle cookies. We will create functionality to deal with some user tracking cookies so please note that these are NOT being used for security or authentication purposes. We only wish to provide a simple and quick way to allow for synchronous tracking across any browser for a user. An example of usage would be to allow users to obtain a new cookie or duplicate one given a user-associated hash to enable linking of browsers across various machines, say, for url submission tagging in a URL shortener.

We will create three classes; get the token from the established cookie to tag the user, create a cookie based on a random hash if one is not present, or use an existing token to create a duplicate cookie for another browser. The code should be fairly self explanatory and will use hashlib for the hashing and simplecookie for the cookie management.

#!/usr/bin/env python

class CreateCookie():
	"Generate a Cookie using given name"
	def __init__(self,NAME,HASH=""):
		from Cookie import SimpleCookie
		self.C = SimpleCookie()
		self.NAME = NAME
		self.HASH = HASH
	def makeHash(self):
		import hashlib,random
		self.R = str(random.random())
		self.H = hashlib
		self.FULLTOKEN = self.H.sha256(self.R).hexdigest()
		self.TOKEN = self.FULLTOKEN[:10]
		return self.TOKEN
	def makeCookie(self):
		if self.HASH:
			self.C[self.NAME] = self.HASH
			self.C[self.NAME] = self.makeHash()
		print self.C

class GetCookie():
	"Retrieve cookie value or generate one if can't find it by given name"
	def __init__(self,NAME):
		from Cookie import SimpleCookie
		import os
		self.NAME = NAME
		if "HTTP_COOKIE" not in os.environ.keys():
			self.E = os.environ["HTTP_COOKIE"]
			self.C = SimpleCookie(self.E)
	def getToken(self):
			self.TOKEN = self.C[self.NAME].value
			return self.TOKEN
			print "Can't find Cookie. Generating one."

class CopyCookie():
	"Make a duplicate cookie from existing hash to tack in another browser"
	def __init__(self,NAME,HASH):
		self.HASH = HASH
		self.NAME = NAME
		if not self.HASH.isalnum() or len(self.HASH)>10:
			print "Improper hash."

Please remember, this is not an attempt to create a secure cookie or one that would, or should, be used for any sort of trusted authentication. This is simply an untrusted cookie tracker and is more of a proof-of-concept that shows simple cookie functionality. From this basic assignment and retrieval, you can start to build a cookie system. Just be sure to read up on security implications and remember to add validation checks. For something production critical, it would be better to pull in established authentication modules from projects like Django or Webpy.

As always, you can check out various code and associated projects under the programming category or visit the Mutaku Github page.

Stumpy v1.4.1 – Critical bug fix

Stumpy has been updated to version 1.4.1 to fix a critical bug that was in all previous versions [Thanks, Erik!]. There was an issue with case-sensitivity in short url lookups that is now all patched up.

For general information on the newer v1.4+ Stumpy, see post here.

Get the newest, fixed version here.

Stumpy is Now Available!

Stumpy has gone v1.0 and is now available on Github. The project is a URL shortener that I originally wrote in Python and have recently rebuilt from scratch to use the Django Python web framework. Now that I’ve reached what I felt was 1.0 functional code, I’ve moved the repository to the Github public section and is available under a BSD license.

Stumpy goes open source on Github

In brief, I have sucked in the first parts of the README.textile file you can find in the repository which should do most of the explaining as to the what and why. The full file contains instructions on setting everything up and how to get testing it out. If you should have any questions, please feel free to contact me. However, I’ve tried to keep the README as clear as possible to be able to drop into a Django environment and the code should be pretty self explanatory.


Mutaku URL Shortener


STUMPy is a URL shortener written by xiao_haozi (Mutaku) using the django python web framework.


There are many url shorteners out there, and STUMPy does not do anything groundbreaking.
However, there are several benefits that encouraged it’s development:

  • you keep all the data and can access it at your will
  • you keep all the code and can access/change it at your will
  • simple to use, simple to run, and simple code
  • because of it’s simplicity, it is easy to understand how url shorteners work and some of the possible optimizations
  • uses the django framework which allows for easy expansion, management, and tweaking
  • django also allows for a nice web UI for administration of all of the data


Everything is still in active development, so feel free to watch the repository to keep up with it’s evolution on Github. I will soon have the active Mutaku version of Stumpy up and running which I will post as soon as it’s up so that you can see the code in action.

Head over to the home at Github and clone or fork the source and have at it. Please be sure to add any comments or problems to the issues page on Github and feel free to send in pull requests if you’ve added any fun, interesting, or helpful code.

Mutaku on GitHub

After endless peer pressure, Mutaku is finally on GitHub. I have to admit, initially I didn’t really see why I would need a version control system, let alone use something like GitHub. But 10 minutes into using, I was sold on both fronts.

Mutaku GitHub page

So head on over to the Mutaku GitHub page and feel free to follow and subscribe to the activity feed.

I’ve already thrown up one project that I was starting to get together to post here at the site. I will be working on gathering together some of my other projects to post as well with the goal being to have snapshots of all the Mutaku code and projects accessible publicly on GitHub.