Slaptijack Title

Archive for the ‘Programming’ Category

UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019'

Once again I was working on some Python code for EVE Online. This particular bit of code gathers a list of kills for a particular region and then summarizes that data in a daily report. Everything had been working properly, until one day... Traceback (most recent call last): File "/Users/scott/Dev/Scripts/Slaptijack/EVE/loss_report/", line 163, in <module> main() […]

Categories: Programming

Python urllib2 with gzip or deflate encoding

The other night I was working on some Python code that interacts with the zKillboard API. The API call returns kill information via JSON for EVE Online. While making the request, I was getting an error that I was using "non-acceptable encoding." It turns out that the zKillboard guys require you to accept gzip or […]

Categories: Programming

MySQL Multiple-Column Indexes: Order Matters

This will just be a short reminder. If you're planning to create multiple-column indexes in MySQL, remember that the order of the columns matters. As the MySQL documentation points out, any "leftmost prefix of the index can be used." This means that the index can be used for any number of columns in a where clause as long as those columns are at the beginning of the index column list and in the same order.

Categories: Programming

If Your Post Doesn't Start With An Image, Display an Ad Instead

I usually start my posts off with an image that is relevant to the post. I think it adds a bit of drama to what I'm writing about, and it also gives me a nice place to anchor a link to a WordPress tag about the subject. I had this idea the other day that if I didn't include an image at the beginning of a post, I should put a Google AdSense ad there instead.

Categories: Programming

Python: Convert String Date to Date Object

Occasionally, you may run across a date in a format that can't be easily loaded into a Python date object. For example, I recently had a situation where a file I was parsing was full of dates in this format: 7/7/2008.

Categories: Programming