/kb

personal knowledgebase

Google Data API: Unsupported browser. Continue at your own risk.

without comments

Opera is not officially supported in the Google Data API and the following error message is thrown as an alert(!) when loading the API: Unsupported browser. Continue at your own risk.

Remove the error message by sending an empty anonymous function to the init method:

google.gdata.client.init(function() {});
var service = new google.gdata.calendar.CalendarService('my-calendar');

Ref. Google Data API Documentation.

Written by hgrimelid

June 13th, 2011 at 12:42 pm

Posted in Programming

Tagged with , ,

Translation of Django Core

without comments

cd django_trunk
svn update
# Generate .po files:
bin/django-admin.py makemessages -l nn 
bin/django-admin.py makemessages -d djangojs -l nn
cd conf/locale/nn/LC_MESSAGES

Edit .po files. Search for text string fuzzy and empty double quotes (“”) to find untranslated strings.

Finally, create diffs:

svn diff django.po > nn-django-translation-update.diff
svn diff djangojs.po > nn-djangojs-translation-update.diff

Written by hgrimelid

August 7th, 2010 at 9:31 pm

Posted in Programming

Tagged with ,

SSH aliases

without comments

In ~/.ssh/config add the following:

Host ALIAS
HostName DOMAIN
User USERNAME
Port PORT_NUMBER

Written by hgrimelid

June 18th, 2010 at 10:02 am

Posted in Server,Shell

Tagged with ,

Compile Vim in Snow Leopard

without comments

./configure –enable-pythoninterp –with-macsdk=10.6

via Chris Moyer: OSX, Vim, and Python.

Written by hgrimelid

April 28th, 2010 at 11:01 am

Posted in Editors,Programming,Shell

Tagged with ,

Git: Start a new branch after making changes

without comments

Sometimes I realize that my latest changes actually should belong to another branch than the one I’m currently working on. The easy way to add the changes to a new branch is to use the stash command.

[… changes …]
git stash
git stash branch name_of_new_branch
git commit []
git push origin name_of_new_branch

Ref. git stash.

Written by hgrimelid

April 23rd, 2010 at 12:39 pm

Posted in Programming,Shell

Tagged with

Translation of Django Apps

with 2 comments

I recently created a Django app that needed translation of the Django administration. It took some googling and messing around to make it work, so this quick and dirty walkthrough will hopefully be helpful for others.

Here’s how I did it:

Add translations for all model fields:

class Stuff(models.Model):
    title = models.CharField(_('title'), max_length=255)
    the_other_model = model.ForeignKey('othermodel', verbose_name=_('the other model'), verbose_name_plural=_('the other models'))
 
    class Meta:
      verbose_name = _('stuff')
      verbose_name_plural = _('stuffs')

Then the language (.po) files must be created:

mkdir locale
python manage.py makemessages -l LANG_CODE

Then edit your language files in locale/_LANGUAGE_/LC_MESSAGES/django.po. When you’ve finished editing the language file must be compiled:

python manage.py compilemessages

If you want to translate app names as well, you can add something like this to your project __init__.py:

from django.utils.translation import ugettext_lazy as _
 
_(u'auth')
_(u'configuration')
_(u'sites')
_(u'appname')
_(u'Auth')
_(u'Configuration')
_(u'Sites')
_(u'Appname')

This feels like a dirty hack but I couldn’t find any other way to do it.

Source: Django documentation – Internationalization and localization, and some Google Groups thread that I can’t find right now, for the app name translation.

Written by hgrimelid

March 4th, 2010 at 3:50 pm

Posted in Programming

Tagged with ,

Install PIL (Python Imaging Library) in Leopard

without comments

Installing modules when using pip, virtualenv and virtualenvwrapper is a breeze, but it took some time before I realized what was the easiest way to install PIL.

I do it this way:

pip -E PATH_TO_VIRTUALENV install http://dist.repoze.org/PIL-1.1.6.tar.gz

This installs a slightly repackaged version of PIL. The latest PIL version is 1.1.7, but as far as I know it’s not available in this form.

Written by hgrimelid

February 7th, 2010 at 1:09 pm

Posted in Programming

Tagged with , , , , ,

Exclude several files or directories from tar

without comments

It’s very useful to be able to exclude certain files or directories when using tar. Here’s how I did in Leopard:

tar czvf FILENAME.tgz --exclude={.svn,wiki*,static} FILES_OR_DIRS_TO_TAR

Written by hgrimelid

August 9th, 2009 at 4:08 pm

Posted in Shell

Tagged with , , ,

Passwordless login with MacFusion

without comments

Put a reference to the private key file in ~/.ssh/config, for example:

IdentityFile ~/.ssh/id_rsa

Source: FAQS.org

Written by hgrimelid

August 6th, 2009 at 9:28 am

Posted in Server

Tagged with , , , ,

Make SSHKeychain work in Leopard

without comments

Here’s how I set up SSHKeychain on my Mac:

  1. Modify the package content as described
  2. Add stuff to .bashrc/.profile
  3. Add keys to SSHKeychain: Preferences > SSH Keys
  4. Check Manage (and modify) global environment variables (this probably has no effect, ref 2.)

Written by hgrimelid

June 22nd, 2009 at 10:43 am

Posted in Shell

Tagged with , , , ,