tech notes

django.db.utils.DatabaseError: relation "django_content_type" does not exist

19 January 2011

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco} I was getting an error while running unit tests and the test database was failing to be created.django.db.utils.DatabaseError: relation "django_content_type" does not existeventually found the problem.  I had the following in a file that was imported to a models.py:hrd_type = ContentType.objects.get_for_model(HttpReferrerDomain)The idea being that it can just set the var when it loads up and after that its always there.  But this means for creating a fresh database, the db is ... more...

django has two classes called ValidationError

4 February 2010

There is one in django.core.exceptions and one in django.forms.util Using that space age IDE Eclipse I have to say I'm enjoying how much time I've saved just going shift-command-O to organize and resolve all of my imports.  But today I've just lost a few hours due to my ok-ing the wrong class. Quite mysterious it was, I raised a ValidationError (core exceptions one) in my form's clean() and watched as the try: except ValidationError: in django's full_clean() completely ignored my ... more...

GDAL fails to build: `.rodata' can not be used when making a shared object; recompile with -fPIC

23 January 2010

  libtool: link: g++ -shared -nostdlib /usr/lib/gcc/x86_64-linux-gnu/4.4.1/../../../../lib/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.4.1/crtbeginS.o .libs/libgdal.la.lnkscript  -L/usr/local/lib /usr/local/lib/libgeos_c.so /usr/local/lib/libgeos.so /usr/local/lib/libexpat.so -L/usr/lib -lpq -lrt -ldl /usr/lib/libcurl.so -lssl -lcrypto -lz -L/usr/lib/gcc/x86_64-linux-gnu/4.4.1 -L/usr/lib/gcc/x86_64-linux-gnu/4.4.1/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.4.1/../../.. -lstdc++ -lm -lc -lgcc_s /usr/lib/gcc/x86_64-linux-gnu/4.4.1/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/4.4.1/../../../../lib/crtn.o         -Wl,-soname -Wl,libgdal.so.1 -o .libs/libgdal.so.1.13.2 /usr/bin/ld: /usr/local/lib/libz.a(crc32.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC /usr/local/lib/libz.a: could not read symbols: Bad value collect2: ld returned 1 exit status make[1]: *** [libgdal.la] Error 1 make[1]: Leaving directory `/home/crucial/tmp/gdal-1.6.2' ... more...

installing MySQLdb on Ubuntu (mysql-python)

23 January 2010

MySQLdb is the python support bindings for MySQL.  Not that the name would lead you to beleive that. Its sourceforge page calls it http://sourceforge.net/projects/mysql-python/ which makes more sense. you need setuptools, which you usually already have:     sudo aptitude install python-setuptools You need MySQL-devel to compile, but its not called that, its called: libmysql++-dev on Ubuntu     sudo apt-get install libmysql++-dev download MySQLdb itself from:     http://sourceforge.net/projects/mysql-python/     # the version you download will be more recent     tar xfz ... more...

postgres login as admin user postgres

18 January 2010

When installing postgres a user will be created named 'postgres' with a password of '!!' which means "cannot login".  But yet you need to login as that in order to run psql (the postgres db shell) to create other users and to create database templates. The solution is to first log yourself in as root (in your normal shell): su root (enter password...) then you will no longer be subject to password checks and you can login in as user ... more...

How to uninstall PyDev Extensions from Eclipse

12 January 2010

I'm enjoying Eclipse for Python Django development. The integrated lint check is great and has saved me much time already. Nearly automatic handling of imports is simply a life saver.  Imports are the most time consuming and frustrating aspect of python development and I always wished they would just resolve themselves. With Eclipse and PyDev they do ! I dream of one day getting the debugger and integrated unit tests to work properly.  It takes a while to get used ... more...

django: post_syncdb signal

4 January 2010

My word the docs are verbose.     from django.db.models import signals   from mysite.fixtures import load_fixtures import sitetools.models as site_models   def loader(**args):       load_fixtures()   signals.post_syncdb.connect(loader,sender=site_models) Every time an app in your INSTALLED_APPS is installed a post_syncdb signal will be sent. Specifying sender means that you are connecting to only the signal that gets fired when your app is installed. If you depend on the Site object to be created then you need to have your ... more...

com_digidesign_FWMbox2ProDevice kernel panic

8 August 2009

One of the skills of a good music producer is the ability to remain unperturbed and not swear at the fucking equipment when it misbehaves. panic(cpu 1 caller 0×003EB81C): “A driver releasing a(n) com_digidesign_FWMbox2ProDevice has corrupted the registry\n”@/SourceCache/xnu/xnu-1228.5.18/libkern/c++/OSObject.cpp:241 I got Kernel Panics twice from Live and/or Logic quitting or unexpectedly quitting and causing problems with the MBox 2 Pro. Download the new leopard compatible Digidesign Core Audio driver: http://www.versiontracker.com/dyn/moreinfo/macosx/20926 more...

Capistrano sudo shows password, doesn't work

5 August 2009

On one of my Linux Ubuntu servers the newish capistrano seemed to have broken. Wouldn't accept sudo authentication and showed what I typed in plain view. the fix: add this to the top of your capfile set :sudo, 'sudo -p Password:' the problem was that it was looking for the wrong text in the server's output to recognize that a prompt sequence was happening. a'ight, carry on more...

Quicksilver action: quickly write a file from text

2 August 2009

I wanted to do this: invoke Quicksilver, hit "." to enter text mode, enter a quick twitter-to-self and have it save that in a file named "{timestamp}.txt" without any further dialog. twitter-to-self within a few seconds with very low CPU disruption (for while I'm making music). Quicksilver has "append to file" but I wanted to do be safe with regard to newlines and I wanted the file to have a creation date that could be read later (when importing it ... more...

Clearsilver not installed - Trac doesn't work on Hardy

3 July 2009

The error that Trac displays is "Clearsilver not installed" and yet clearsilver is clearly installed, but has a problem with python 2.5 The error sadly has been in Hardy's distribution for nearly 2 years, but newer Ubuntus should be fine. To quickly fix it on your machine, simply get this .deb directly: curl -O http://mathiasson.nu/debian/pool/main/c/clearsilver/python-clearsilver_0.10.4-1.0pm0_amd64.deb and install it thusly: sudo dpkg -i python-clearsilver_0.10.4-1.0pm0_amd64.deb On another note, Trac claims to have migrated to Genshi and requests it to be installed, but ... more...

Qt PyQt4 license incompatible

1 July 2009

PyQt-mac-gpl-4.5.1 has a bug in configure.py It will complain that the license is incompatible between itself and the "Desktop" version of Qt. The solution is to download a more recent snapshot (not the stable build at the top of the page, go further down the page). That compiles fine. update: no, sadly it does not install completely. see below. My eyes tend to glaze over when the license stuff comes up. I'm just playing around here, I'm not a lawyer. ... more...

django ajax select for ManyToMany

2 March 2009

I've posted the first of many django apps: http://code.google.com/p/django-ajax-selects/ Initial version This is working for foreign key fields and many to many fields. Improvements still to come. Requirements Django 1.0 + jquery 1.26 + Autocomplete - jQuery plugin 1.0.2 http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/ jquery.autocomplete.css Usage install as a normal django app INSTALLED_APPS = ( ..., 'ajax_select' ) There is a single view for ajax lookups that uses named channels and lookup objects that do the searching and formatting work. peoplez/managers.py from peoplez.models import ... more...

django cron jobs with envir variables

16 February 2009

Although there are many posts out there about django and cron jobs, none fully solved my problem. You can set envir vars directly in your crontab file, but I had forgotten to copy all the ENV vars from my website.wsgi file : DJANGO_SETTINGS_MODULE=website.settings ENV=beta PYTHON_EGG_CACHE=/home/crucial/tmp PYTHONPATH=/home/crucial/gitpo/djapps:/home/crucial/gitpo/pluggables:/home/crucial/gitpo:/home/crucial/gitpo/website * * * * * /home/crucial/gitpo/website/manage.py send_mail more...

MySQL case insensitive LIKE

23 December 2008

I always thought LIKE in SQL was case insensitive. Oh.... today I learn that it actually uses the collation settings of the field / table. Two ways to solve this: select * from table where field COLLATE latin1_general_ci LIKE '%search%' or get off your ass and convert your tables to UTF-8 ALTER TABLE table CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci; more...

global .gitignore

24 September 2008

to get git to always ignore things like .pyc files (without having to put  .gitignore files in every project):  create a ~/.gitignore in your user directory  .DS_Store  *.pyc  .svn then run: git config --global core.excludesfile ~/.gitignore  more...

django circular imports due to new admin

1 September 2008

Django 1.0 : now in URLS.py you get an automatic : admin.autodiscover() which replaces explicitly adding any admin.py in your modules. I had import admin in several of my ``__init__.py`` files, but this is no longer needed. The error message was confusing: localhost:~/Sites/sustainall/sustain crucial$ python manage.py shell Error: cannot import name Artist so it was some kind of a circular import. more...

that &*^%ing UTF-8 MySQL *&^@ing truncate bug again

5 August 2008

MySQL will silently truncate UTF-8 strings at the first "damn foreigner" character or even m-dash or Microsoft Word Apostrophe. If you set it to strict mode via your my.ini file you can cause it to correctly throw the error "data truncated" which is still an incomprehensible error, but at least its not a silent error. I detest silent errors. Otherwise you will just wonder why your data got whacked. the solution: ============= Dump your database to a sql file, including ... more...

firefox firebug vs gmail = application not responding

27 July 2008

Firebug by default is disabled for all sites and you enable it site by site, which is very good. If you accidentally enable scripting debugging for gmail, you cannot get into gmail at all or Firebug/Firefox will lock up, the CPU will spike high and you have to force quit. Since you can't get in, you can't re-disable scripting-debugging for mail.google.com I installed firebug 1.2.0b7 which has a new sites menu that let's you add and remove sites without going ... more...

copy and paste from password protected PDF files OS X

16 July 2008

A password protected PDF file will let you select text but not copy it. You may well have legal and justified needs to copy this text. In OS X open the file with ColorSync Utility (comes with OS X). The Export.... save as PDF. password is gone. more...

django and TextMate : open Exception location file

7 July 2008

if you are working on your localhost, TextMate has a URL scheme to open a local file. http://manual.macromates.com/en/using_textmate_from_terminal.html so when an Exception happens in django you can click to open the file directly. this saves months of looking. these large code projects are all about going from one file to another. the quickest thing to do is just to hack the django. later I'll try to make it into a middleware or replacement template. Index: /Users/crucial/Sites/sustainall/django/views/debug.py =================================================================== --- /Users/crucial/Sites/sustainall/django/views/debug.py (revision ... more...

django: those pesky silent template variable failures

29 June 2008

Developers do not like silent failures. I guess that "Designers" get all freaked out if they see a big messy error, they get frustrated and stop working for the day. So django has decided to silently ignore variable failures in templates: {{ user.email }} will produce nothing if there is no user but in your settings.py you can set a format string to be used in place of it: TEMPLATE_STRING_IF_INVALID = "!!!INVALID:%s!!!" !!!INVALID:user.email!!! more...

django / MySQL 4.1 : bogus "Data truncated for column" error

23 June 2008

I was importing a bunch of posts, setting the text body directly to my posts post.body = maintext Trying to save them got an error "Data truncated for column..." which makes no sense because the body is a TextField which is a MySQL longtext type. Hours later .... (remember kids, always google FIRST, then try to solve it yourself. this way humanity can quickly evolve past these boring problems and go onto greater endeavors.) Its this django ticket: http://code.djangoproject.com/ticket/4336 which ... more...

tip: don't name django apps common names like "collections"

14 June 2008

Because an app of mine was named "collections" and it was in the PYTHONPATH, this caused havoc elsewhere. Other internal django things would import collections and then find the deque didn't work. File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/handlers/wsgi.py", line 1, in from threading import Lock File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/threading.py", line 13, in from collections import deque ImportError: cannot import name deque or even more mysteriously: File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/contrib/databrowse/__init__.py", line 1, in from django.contrib.databrowse.sites import DatabrowsePlugin, ModelDatabrowse, DatabrowseSite, site File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/contrib/databrowse/sites.py", line 2, in from django.db import models ... more...

django reverse() url lookups

25 May 2008

There is a useful django template tag : {% url app.views.viewfunc %} which is the same as: reverse('app.views.viewfunc') that should lookup through your ``urls.py`` to find the url pattern that matches that view. it should then return the formatted URL. this allows you to configure all of your urls in your ``urls.py`` file(s) and keep your templates this often does not work if your reg-ex is complicated eg. r'^track/?(?P.+)$' where there may or may not be a ``/`` and there ... more...

django development server vs example.com

18 May 2008

If you are using the django development server (started via the commandline, running at http://127.0.0.0:8080 ) and you have 'django.contrib.sites' installed as an app (which is installed by default) you will find that editing in the admin interface offers you links to "example.com". This site is installed as a default site in Sites. change it to: 127.0.0.1:8000 (with no http:// and no trailing slash) more...

django debugging : forcing files to recompile

12 May 2008

I tried django a few years ago when they just started and quite liked it. But I couldn't find the time or the reason to port my code (PHP) into it. I'm doing it now. Some things about debugging take a bit of guessing. I'm running django's development server. If a python file fails to compile, if you fix the compile error and then reload the page you still get an error telling you that the view was not found. ... more...

apple goofs up airport update

8 April 2008

The new mac airport update breaks most audio programs. We now get nasty crackling and CPU spikes. Solution: turn airport off when making muzak. or revert the airport update: http://www.ableton.com/forum/viewtopic.php?t=88815&postdays=0&postorder=asc&start=0&sid=63b29a6140f11d35ef1b64db664f3cb5 and the thing is this is the first time in 5 months that my airport has worked with our apartment's WLAN. I've had a cable running down the hall and I can't shut my door. george clinton has two houses : one for music, one for business. more...

php or || : more reasons to dislike php

10 March 2008

$test = false or true; $test is false why ? because the = has higher precedence than the logical operator. what a retarded language. always use $test = false || true; $test is true how it happens in the field: echo (NULL or true);// 1 $true = NULL or true; // set this to a variable echo $true; // nothing ie. false if(NULL or true) { echo "true"; } // true $test = NULL or true; if($test) { echo "true"; ... more...

how to set up a local svn repository (for SC)

21 February 2008

How to create and maintain a local SVN repository for your private work. If you are just working locally, you don't have to run an svn server at all. Its much easier than I thought. ( this is mainly a post about working with supercollider packages. if you just want to know how to set up a local svn repository then I'll cut to the chase: svn import ~/Documents/SC3docs/felix-imported file:///Users/crucial/svn/sc/trunk/felix -m "initial felix import" then check out a working copy: ... more...

how not to get your myspaced hacked

2 January 2008

This is a public service announcement. Jan 2, 2008 one of your friends appears to send you a stupid thing to post as a comment. you know its spam, because your friends would never post anything that stupid. when you get the request to post the comment and myspace asks you to deny/approve, deny it. then then when you are on the SECOND screen when myspace asks you to confirm , hover the mouse over the deny/submit area and if ... more...

myspace breaks when using safari : aug 22 2007

22 August 2007

Something inside of myspace breaks when it notices that the browser is Safari. The entire website does not function if you are using Safari. Their solution ? "download firefox" more...

logic pro audio cut out

8 August 2007

Since the recent Logic upgrade (7.2) the audio now cuts out occasionally with a loud DC thump. This happens often when enabling record ! Even while play is already happening, simply hitting record causes all audio to cut out with a rude thump. It can also happen just when playing. Usually a few stops and starts serves to get the sound back, but now I'm finding NOTHING short of rebooting the audio or rebooting the application (same thing) will get ... more...

MacBook pro wireless problem Airport

24 July 2007

The new (July 2007) MacBook Pros have a problem with their wireless cards. The new cards are 802.11g and these have problems with slow data when connecting with some wireless hubs eg. Airport Express (which is the older 802.11n) Really slow data rates, hanging pages. Memories of dial up. This worked for me: using the Airport Utility application, in the Wireless tab, switch the Airport Express to "802.11b only" mode, rather than the more logical "b/g compatible". I'm back up ... more...

set CSS class by javascript

23 July 2007

document.getElementByID('yourID').className = "highlight"; more...

svnX and switching an SVN working copy to a different user

20 July 2007

When commiting changes using svnX, it appears that the username is whatever the last authenticated username for that working copy was. Although my working copy was checked out for username2, svnX was still trying to use username1 until I did one manual commit on the command line using username2. After that svnX knew to use username2. or so it would appear... more...

Cocoa MySQL can't connect

16 July 2007

yes, my username, password and permissions are correct dammit ! oh, my MySQL was recently updated "CocoaMySQL v0.5 cannot connect to MySQL > 4.1 because of the new password enryption. If you want to connect to a server running MySQL > 4.1, you have to use one of the following solutions:" downloaded the new beta version, works great http://cocoamysql.sourceforge.net/faq.php MySQL themselves are now offering their slick MySQL admin and query browser applications for OS X for free. Nice, though I ... more...

the real reason apple can't let third party applications on the iPhone

2 July 2007

Steve says its because they want to make sure that the applications are safe and don't cause the phone to crash. The real reasons: 1. It has wifi. People could write file sharing applications that go phone to phone. File sharing would explode. 2. It has wifi. Skype could write a VoIP app for the iPhone and you could then make free calls everytime you are near a wifi signal. This would hurt AT&T. They know that widespread free wifi ... more...

Mac automatic transfer from old machine to new machine

19 June 2007

This is quite slick ... you buy a new mac, connect the old one via firewire cable and you get zapped over. but... especially if you are transitioning from PPC to Intel, I would advise against this. Lots of little .kext (kernel extensions), outdated midi plugins, outdated applications etc. get transferred over. My old computer has been obviously sick for a while. Lots of rolling beach balls, and its due to some conflict of extensions that causes frequent hangs. I ... more...

Logic Audio hangs while validating Native Instruments AU

19 June 2007

This has happened to me twice and the second time I had already forgotten that I had solved this before : Logic Audio hangs while trying to validate Native Instruments Audio Units. When the Native Instruments application (Kore, Massive, Reaktor etc.) starts up for the first time it may find that some directory is missing or not writeable. It would like to pop open a dialog and ask you about this. Since it is being started up as a windowless ... more...

reaktor, logic and freezing tracks

7 May 2007

Reaktor doesn't freeze very well. Often after freezing the track there is no audio in the file, and sometimes the controllers appear not to have been chased correctly. I would think there would also be problems doing non-real time bounces (its the same NRT processing, right ?) but I haven't had any yet. more...

logic channel strips and reaktor patches

5 May 2007

You can't make Logic channel strips with reaktor patches and expect them to recall exactly. I would expect the channel strip to save all memory of all plugins in the strip. For Logic plugins they do : you can edit all your plugins freely and then just save the whole strip. (but be careful with EXS24) With Reaktor patches it doesn't work. That would be nice ... its much faster to recall a channel strip then to open reaktor and ... more...

SDII format specification

3 December 2004

Sound Designer I file format is the original Digidesign sound file format first released in 1985. It is widely used and supported as evidenced by the many CD ROM discs with sound effects stored in this format. It is primarily used to store mono 16 bit short duration (on the order of seconds) audio samples. We recommend that you support this format for short sounds, but that you use Sound Designer II format as a primary format due to its ... more...

coltan and cassiterite Timeblind : Solar Life Raft Ingredients
Backwardation : Version 12"