Yak Shaving

just me

Plone in debug mode

without comments

This is more a reminder for me :) The code below allows you to talk to ZODB in an interactive way.

$ bin/instance debug

from Acquisition import aq_parent
from zkaffold.consolehelpers import login
from Products.CMFCore.utils import getToolByName
app = login(app, 'zopeadmin')
pc = getToolByName(app.portal, 'catalog')
content_fragments = pc({'getId': 'id', 'portal_type': 'ContentFragments'})
content_fragments
[, ]

Login allows you to query the catalog otherwise no results are returned.

Written by channam

January 13th, 2011 at 2:17 pm

Posted in Uncategorized

Tail a file over http with Node JS

without comments

The code below will refresh a web page when the file is updated. I was using it to make syslog available over http.

http = require('http');
var spawn = require('child_process').spawn;
var sys = require('sys')

// log to monitor
var filename = process.ARGV[2];

if (!filename)
  return sys.puts("Usage: node monitor.js filename");

// fire up tail on the log file
var tail = spawn("tail", ["-f", filename]);

http.createServer(function (req, update) {
  update.writeHead(200, {'Content-Type': "text/plain;"});
  tail.stdout.on("data", function (data) {
    update.write(data);
  });
}).listen(8000);

Written by channam

January 8th, 2011 at 3:28 pm

Posted in Uncategorized

Building node.js on Ubuntu

without comments

sudo apt-get install build-essential libssl-dev

Should be enough to make ./configure happy.

Written by channam

December 29th, 2010 at 4:00 pm

Posted in Uncategorized

My CV

without comments

For my latest CV click here.

Written by channam

November 30th, 2010 at 12:28 pm

Posted in Uncategorized

Django Testing and Fixtures

with one comment

I am currently refactoring a project I’m actively developing. The initial development was not test driven but more “Oooh this is cool, hack, hack hack”. I’m quite a fan of the idea of premature optimisation being a bad thing, although sometimes this can be an excuse for laziness.

So I find myself refactoring and creating tests to prove the new code works. This led me to need fixtures or exmaple data to test against. As I already had data in the database creating said fixtures was a easy task:

manage.py dumpdata app_name.model_name

Where app_name in the name of the application you create in Django and the model name is the defined database object usually in models.py. This command dumps the structure of the object out to the command line in json format. To use it create a fixtures directory in your application directory and add the json file. Or the easy way:

manage.py dumpdata app_name.model_name > fixtures/fixtures.json

The file name doesn’t matter.

Written by channam

November 25th, 2010 at 9:49 pm

Posted in python

My Current Podcasts

without comments

I have steady commute to work and after getting fed up with the news and purchasing a Nexus One I listen to a lot of podcasts. These are mostly tech and science ones. so in the spirit of sharing below is an OPML export of my current selection: google-reader-subscriptions.xml.

Written by channam

November 24th, 2010 at 12:54 am

Posted in Uncategorized

Novell and Linux

without comments

As the dust settles on the surprise purchase of Novell by Attachmate (I have no idea either) it seems about the right time to start the crazy conspiracy theories.

I had wondered for a while after Novell “won” the SCO case and were found to have various UNIX copyrights see http://en.wikipedia.org/wiki/SCO-Linux_controversies for a much better explanation. Add in Novell’s interesting patent catalogue (they also signed that patent deal with Microsoft) and the company starts to more like a patent trolls dream.

Rumours are also starting to surface about how the deal was financed http://blogs.computerworld.com/17416/who_really_bought_novell_microsoft. I am certainly no expert but the whole deal seemed fishy from the start.

I think the the future has a lot of law suits from Attachmate and a slow lingering death for Suse Enterprise and OpenSUSE. This deal has all the hallmarks of an asset stripping fire sale.

Written by channam

November 24th, 2010 at 12:14 am

Posted in Uncategorized

Speeding up the Linux Desktop?

without comments

Reading about the internet I came across http://www.networkworld.com/community/blog/speed-linux-no-kernel-patch-required. This looks pretty cool.

I thought I’d give a go as my EEE PC 1005 has been suffering a little since upgrading to Ubuntu Maverick. Following http://www.webupd8.org/2010/11/alternative-to-200-lines-kernel-patch.html the Ubuntu guide I have given it a whirl.

Can’t say I have noticed a difference as yet but these things can be subjective. I will add an update when I notice something.

Update 1:
So I got this tweet: http://twitter.com/#!/1stvamp/status/6385998627864576

I haven’t tested this package but it looks like an easier way to implement the changes.

As for performance improvements I’m not entirely convinced. It has dropped the load when running Chrome. Usually Chrome ran the laptop at a load of 1 ish that has now dropped to around .5. Which is nice for battery life.

Written by channam

November 19th, 2010 at 9:07 pm

Posted in Ubuntu

OAuth and Python

without comments

#!/bin/python

Written by channam

November 18th, 2010 at 9:09 pm

Posted in Uncategorized

Compiling Couchdb on Karmic

without comments

This had my annoyed for a while. When I came to run ./configure I got:

checking for JS_NewContext in -lmozjs... no
checking for JS_NewContext in -ljs... no
checking for JS_NewContext in -ljs3250... no
checking for JS_NewContext in -ljs32... no
configure: error: Could not find the js library.

Is the Mozilla SpiderMonkey library installed?

I was unable to find much help until I looked at the instructions for installing from source http://wiki.apache.org/couchdb/Installing_on_Ubuntu?action=show&redirect=InstallingOnUbuntu. Which in retrospect would have been a good place to start. Use the following to stop the above error:

./configure --with-js-include=/usr/include/xulrunner-1.9.1.9/unstable --with-js-lib=/usr/lib/xulrunner-devel-1.9.1.9/lib

Oh and make sure you have xulrunner and its dev package installed.

Written by channam

May 5th, 2010 at 12:40 pm

Posted in Uncategorized