Adam.Blog()
Adam Presley's blog
Decorator for Serializing MongoDB Dictionaries to JSON in Python
Before you read this I’m going on the record stating that this problem has likely been solved hundreds of times before. So here is yet another take on how I am managing to serialize Python objects that are returned as a result of a query to a MongoDB database. The...
Comparing Classes in Python
Most object oriented languages have a means to compare two objects or classes. Java has the **Comparator** interface. In C# you can override the **Equals()** method. Python naturally has a way to make your class comparable by using a magic method named **__eq__**. It takes an argument of the object...
Quick Blurb on Python Beaker and Memcached
Real quickly I wanted to post to show how one can configure Beaker for session management using Memcached as the session storage. It took me a minute and a few searches to put it all together, so hopefully this will help someone searching the web. SESSION_OPTS = { "session.type": "ext:memcached",...
How I Deployed a PHP App via FTP Using Fabric and Git
A project I’ve been working with for a bit now uses a popular hosting provider to host a PHP application I’m writing. My normal workflow with this project is to make changes, commit my code to my Git repository, push it to Github (a private account), then FTP the files...
Python itertools - Display repeating permutations of a number set
Back in July of 2010 I blogged about displaying a set of repeating permutations of a number set. In this blog post I explained how my daughter had a kid’s “spy safe” that had four buttons on it that could be used to enter a passcode. At the time I...
Python itertools - Filtering items
Continuing my exploration of the itertools module in Python I wanted to look at the ifilter() method. ifilter() is a method that returns an iterator of items that return true from a test function (or lambda expression). In this sample I have an array of products. I want to get...
Python itertools - Grouping an array by key
Have you ever had a flat dataset and you needed a portion of the data grouped into a sub-array? I came across such a need this weekend and thought I’d share my experience. In this code sample we’ll see how to take an array of dictionaries (similar to what might...
Internet Explorer Testing VMs
I’m not sure how long this site has been up but I’m just now finding it. http://www.modern.ie/ is a developer site with tools and resources to help test and detect issues in older IE versions, as well as provide a cloud-based testing suite offering. The particular feature I find most...
A Good Resource on Web App Performance
Last night I came across an online, public domain license book by Stoyan Stefanov called Book of Speed. Although it is incomplete the information found in this book is very good. In this book the author talks about many of the intricate details of web page optimization, such as minification,...
Sort a List of Strings Starting With a Number in Python
I recently ran into a situation where had a list of strings I wanted sorted in a particular way in Python. The sorted() method offers a quick way to sort a collection, but in my case I needed to do more than just sort alphabetically. The following is a partial...