Saturday, January 21. 2012
Fake French is Fun!
Thursday, January 19. 2012
Watch your Django field defaults do not load objects if you use South
Just ran into a South migration issue. Basically we had a field that looked like this (simplified):
class MyModel( models.Model ):
hostname = models.CharField(
default = random_unique_hostname,
)
where random_unique_hostname() was written like so (again, simplified):
def random_unique_hostname():
test = generate_random()
try:
MyModel.objects.get( hostname = test )
except MyModel.DoesNotExist, err:
return test
else:
return random_unique_hostname()
the actual code is significantly more complex, but that illustrates the problem. When you try to generate a South migration to add some other field to this model (i.e. a few months after you've added this default), you'll see the migration creation fail because South is calling your default (ouch) with a database that doesn't have the new field (the pre-migration DB).
The solution is to use a minimal query, rather than calling .get, use .filter().count() or use .filter().values_list('id') or any other query that doesn't map to the whole object being loaded, just to check for unique-ness.
Bad Coder, No Cookie
We use globalsub and MockProc extensively in our test-suite at work. Today I wanted to look up the name of the argument in MockProc (we use globalsub in almost every test case, so I don't need to look that up). So, look up the docs... wow, whoever wrote this library really sucks, there's just some stupid blog post rather than real documentation. What a loser! Oh, yeah...
So, suitably shamed, I sat down and wrote a bit of documentation this evening for both packages. Cookies!
Monday, January 16. 2012
Minor changes to OpenGL.raw
I've just done a bit of hacking to make the (Py)OpenGL.raw hierarchy a little more "normal" looking when you read the auto-generated code. There are now functions declared, the functions are then annotated with decorators to make them into wrappers (which actually replaces the original functions). Doesn't really affect how the code works, it just uses Python structures to define "functions" rather than raw data-structures. It also reduces the distribution's size by about 5%, but I doubt the 44KB matters to anyone.
[Update] and then I did even more, so the unimportant package size is now down around 12%, but more importantly, the core library is being auto-generated from headers (again), which is what I really wanted to get to, as I want that change for future work.
Monday, January 9. 2012
Forget "pledges" to release updates and fuzzy timelines
Hey, google/android peoples. Here's a proposal: shame every licensee into releasing official unlockers for every Android phone ever released. The unlocker should just install an open bootloader that can install whatever ROM the user wishes (it can scream loudly at the user that they are voiding their warranty, of course).
To be clear; not for upcoming, or recently released devices only. For every phone ever. Then we might begin to feel that a licensee cares an iota about keeping Android up to date. I know they don't, but heck, at least that way users don't have to jump through a dozen hoops just to get a Cyanogen or similar ROM on their phone when the manufacturer abandons them.
Sure, making an iTunes-like financial incentive to keep users up to date would be nice too. But that takes a lot of engineering effort versus signing some image that can be uploaded to the phones.

Comments
2012-01-27 04:49
hmmm thanks for answering...be cause i'm kind of a starter wi th django und JQM 1.) can yo u post an example of ho [...]
2012-01-26 08:34
You add it on the form view; j query mobile uses it to say "d o this post as a regular reque st rather than a json re [...]
2012-01-26 03:53
I Have a question concerning " adding data-json="false" is us eful when you are doing POSTs" my request for login [...]
2012-01-20 09:05
.exists() does sound like the correct approach. These new-f angled things... sheesh, am I really now an old-and-cr [...]
2012-01-20 04:33
This is one of the big problem s with south migrations - as a rule of thumb, one shouldn't use your models in them, [...]
2012-01-19 22:27
i thought exists can only be u sed on querysets. a "get" woul d return the actual object no?
2012-01-19 21:49
For this kind of query you sho uld use '.exists()' (need Djan go >= 1.2).
2012-01-19 12:19
I'll have to look into globals ub. I'm doing something simila r in my reimport package, and I'm hoping to glean more [...]
2011-12-29 01:28
Android 2.2 was all about the JIT compiler, much faster than 2.1. 2.3 was a pretty minor update to 2.2 in my opin [...]
2011-12-29 00:43
A work mate linked me to your resource. Thank you for the re sources.
2011-12-28 21:49
Thanks for the comments all. I may wind up re-doing the ins tallation in the future, so ma y attempt one of the oth [...]
2011-12-28 14:05
I do Android development on Ub untu. Unfortunately the Ecl ipse shipped with Ubuntu tends to lag and is not updat [...]
2011-12-28 13:03
I develop an Android app using the Ubuntu-packaged Eclipse ( as yet unreleased). General ly, I follow the instruc [...]
2011-12-28 10:36
You may want to give IntelliJ IDEA Community Edition a try, I found it to be a lot more us er friendly for getting [...]
2011-10-29 15:47
re: motivation to solve TG's i ssues - me neither ! that's w hy I put out these general wav es of "use SQLAlchemy di [...]