-
posts
-
Unreadable
What is it about some C programmers that makes them write code that looks like this:
if(len<16) {
for(k=start;k<start+len;k+=j) {
j=1;x=V[I[k]+h];
for(i=1;k+i<start+len;i++) {
if(V[I[k+i]+h]<x) {
x=V[I[k+i]+h];...
-
Transactions on App Engine
The way to store data on App Engine is with
Google’s Datastore
which has support for transactions. However, the transactions are quite limited
in that,
You can only execute callables inside transactions. Which means you
basically call run...
-
Werkzeug and reverse urls
I wanted to impove a Google App Engine
application that a friend of mine created
(ほぼ汎用イベント管理ツール(jp)) and noticed
that he was redirecting directly to
urls. He is
using Werkzeug to handle url routing so I wondered
if there was a method for generatin...
-
QueryDict and update()
Yesterday I ran into an interesting quirk with Django’s QueryDict object and
the normal dictionary update() method. Normally the update method will allow
you to merge two dictionary or dictionary like objects but because the
QueryDict internally h...
-
IE, JSON, and the script tag
My coworker recently introduced me to one of the most blatantly bad behaviors
in web browser history. He introduced it thus:
Out[1]: simplejson.dumps({'foo': '<script>alert(document.cookie);</script>'})
Out[2]: '{"foo": "<script>...
-
Field/column Queries in Django
One of the neat things making it’s way into Django 1.1 is F object
queries.
The F object is kind of like the Q object as it can be used it queries but it
represents a database field on the right hand side of an equality/inequality.
For the exampl...
-
jQuery Multi-Pageslide
Earlier this week I came across the jQuery Pageslide plugin via
Ajaxian and was impressed with the design. I set
about using it to display help messages to the user for a site I am working on.
It worked well and all but I found that you can only ...
-
Python date range iterator
I couldn’t find something that gave me quite what I wanted so I created
a simple Python generator to give me the dates
between two datetimes.
def datetimeIterator(from_date, to_date):
from datetime import timedelta
if from_date > to_da...
-
Introduction to Algorithms
Today my copy of Introduction to Algorithms came in the mail (a gift from the
family). I’ve decided, mostly inspired by Peteris
Krumins to revisit classic algorithms as it’s been a
while since I’ve taken a look at them.
I have decided to als...
-
UTF-8 with guile
Getting UTF-8 to work with guile is a bit of a stretch as guile doesn’t have
any real encoding or UTF-8 support to speak of, but I was able to get at least
some basic stuff working by using the Unicode
Manipulation
routines which are part of the
G...