movie rental

when your developer gets mad

Filed under: BBC, Blogroll, tech — Wrote by Otu on Monday, December 3rd, 2007 @ 8:33 am

While I make no assertions as to the veracity behind this rant - I ‘d love to draw your attention to the viciousness of said attack. The vehemence pokes out like nipples on a cold december morning. The delivery, passionate, focused and unrelenting.

As I read, I could picture the author fuming internally, smoke screaming out his orifices like you haven’t seen since the steam locomotives were replaced by the diesel engines (not that I am old enough to remember), voice quivering and of course china flying around as he battled to contain himself.

It is oddly reminiscent of my time at a certain BigCorptm.

Don’t just take my word for it, go see for yourself [ I am Seb - On the BBC. ]

narkissos

Filed under: Blogroll, python, tech, wssecurity, zsi — Wrote by Otu on Friday, June 8th, 2007 @ 1:15 am

I am not entirely certain how it came about but a few minutes after hitting my desk this morning, I found myself on Google searching for “Otu Ekanem”. Not content with browsing through the first few results page, I hit the last page and found a blog entry with my name in it.

So what makes it special? I really don’t know, just felt it had to be mentioned - this is after all my blog not yours ;-)

The piece is a comprehensive and well written tutorial on how to talk to WebServices which implement the WsSecurity specification from Oasis, the e-business specification/standards body.

reverse looping in python

Filed under: Blogroll, code, geek, python, tech — Wrote by Otu on Thursday, June 7th, 2007 @ 12:53 pm

Neat trick I recently stumbled upon.


Python 2.4.3 (#2, Oct 6 2006, 07:52:30)
[GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> l = range(10)
>>> l
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> print [x for x in l[::-1]]
[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]

Useful if you have a list which looks like this

l = [1,2,3,4,3,2,3,4,5,6,7,8,54,3,54,6,]

and need to walk backwards while preserving order.

>>> print [x for x in l[::-1]]
[6, 54, 3, 54, 8, 7, 6, 5, 4, 3, 2, 3, 4, 3, 2, 1]

xslug may meetup

Filed under: Blogroll, london, tech, uk, xsl, xslug — Wrote by Otu on Saturday, May 12th, 2007 @ 11:47 pm

UPDATE
We have had to change the date from Thursday May 31st to the Tuesday May 29th.
All other details remain same.

Details of the XSLT usergroup meeting in May are up on upcoming.org

http://upcoming.yahoo.com/event/190628

Details:

Date: May 29th (Thursday)
Time: 6:30 pm.


Venue:
The Anchor pub
34 Park Street
London, London SE1 9EF

See Map if you don’t already know how to get there.
Nearest stations are London Bridge, Cannon Street and Blackfriars.

Please help spread the word.

For notice of future events, please subscribe here.

serving static pages from django

Filed under: Blogroll, python, tech — Wrote by Otu on Saturday, May 12th, 2007 @ 3:53 am

When building webapps, I serve static resources directly from apache for obvious reasons. I do this using apache’s mod_rewrite. Code shown below.


RewriteEngine On
RewriteBase /
RewriteRule ^(media/.*)$ - [L]
RewriteRule ^(admin_media/.*)$ - [L]
RewriteCond %{REQUEST_URI} !(dispatch.fcgi)
RewriteRule ^(.*)$ dispatch.fcgi/$1 [L]

All static files javascript, css, images live in subdirectories under media/.

The issue occurs when I want to access the web application directly without proxying through apache. My standalone app has no idea where the media files referenced in my html lie. If you ‘v ever visited a site where the styles and images didn’t load up, you know what I am talking about.

To ensure my media files get served up, I install the media/ folder in my django project directory with my django apps and add this entry to my urls config file urls.py


from os import path
media_root = path.abspath('media')


urlpatterns += patterns('',
# static resources
(r'^media/(?P .*)$’, ‘django.views.static.serve’, {’document_root’: media_root, ’show_indexes’: True}),
)

From the apache root, I simply create a symbolic link to my media files, thus ensuring that no matter how it is accessed, you never see ugly blank textonly pages.

skip first N lines in a file

Filed under: Blogroll, awk, expr, geek, python, tail, tech, unix — Wrote by Otu on Thursday, May 10th, 2007 @ 11:58 pm

To skip the first N lines in a file:

declare a variable to hold the total number of lines in the file. I use awk to calculate this. wc -l /path/to/file would also work(sic)

io2@berlin:~/Desktop$ l=$(awk ' END { print NR }' global.css)

Use expr to calculate the difference between the total number of lines and N, the number you want exclude.

io2@berlin:~/Desktop$ expr $l - N

Tie it all together using the unix tail command


io2@berlin:~/Desktop$ tail -n $(expr $l - N) global.css | less

Of course if this weren’t a test to see how well I *nix, I ‘d personally with a short python script I can call skip_n.py and add to my toolbox


fp = open('/path/to/file', 'r')
lines = fp.readlines(); fp.close()
print "".join(lines[10:]) # skip the first 10 lines and print the rest

Please submit easier/shorter alternatives in the comments. I am no expert ;-)

in my toolbox

Filed under: Blogroll, python, tech, xpath — Wrote by Otu on Monday, May 7th, 2007 @ 4:16 pm

I hear a lot of people say “I hope I never have to look at another raw XML file again”. For some reason, this comment always make me smile. Mostly because while I see what they mean by it, I love working with XML and given the myriad tools available for manipulating, transforming and processing them, I don’t see myself stopping any time soon.

Recently I needed to evaluate an xpath expression against a bunch of files I had. There are lots of different ways to do this, but they all mostly involved me using some IDE or writing some XSLT file to do this. None of this suited my purpose so I decided to add another tool to my ad-hoc scripts which live in

~/bin

Below is the python script which will evaluate any xpath I pass to it and print out the result on the terminal.

#!/usr/bin/env python
import sys
from xml import xpath
from xml.dom import minidom
from os import path

if len(sys.argv) < 3:
    print "Usage:\n\n%s source-xml-document path-to-evaluate" % path.basename(sys.argv[0])
    sys.exit(0)

source, request = str(path.abspath(sys.argv[1])), str(sys.argv[2])
doc = minidom.parse(source)
results = xpath.Evaluate(request, doc)
print "Result of Evaluation"
print "--------------------\n"
print "Source document '%s'" % source
print "Evaluated'%s'" % request
print "--------------------\n"
print "\n".join([x.toxml() for x in results])
print "--------------------\n"
print "Count: [%s]" % len(results)

An example usage is shown below:

xpath.py topartists.xml "//artist"

Note:
This is in no way exhaustive. For instance, I have made the assumption that the returned result is a list. Clearly not always true, but for my intents at the time, very suitable. Modify for your purpose if you find this useful.

PyXML for Python 2.5

Filed under: python, sdk, tech — Wrote by Otu on Tuesday, May 1st, 2007 @ 3:40 am

A lot of libraries still depend on the no longer supported PyXML module. ZSI is one of these, so is twisted. Although there are moves within these projects to remove the dependency, this isn’t happening as quickly as we ‘d want.

So here is a link to download pyXML 0.8.4 for python 2.5 pre-built by Luis Miguel Morillas

so would he?

Filed under: Blogroll, claims, geek, tech — Wrote by Otu on Wednesday, April 25th, 2007 @ 10:31 pm

The question is this: “With Scheme would he have done better?”

detained fox

Courtesy of JeffPalm over at JeffPalm.com

london xsl meetup

Filed under: Blogroll, ferrier, london, tech, xsl, xslug — Wrote by Otu on Thursday, April 12th, 2007 @ 10:45 pm

Nic Ferrier and I have been doing a lot of work with XSLT recently. This prompted a discussion on the merits of forming an XSL community and to find out whether other known XSL users in London saw the merits of one, we decided to have a preliminary event (another excuse for a pub visit) in order discuss pros and cons.

We met last night at the Prince Regents Pub on Marylebone High street and in attendance were Ian Forrester, Tom Morris, Andre Lambrechts (Larry) and Will Prescott (both from Thompson) and of course Nic and myself. Sheila Thompson was planning to join us but could make it unfortunately. There’s something to be said for communities and even though a small gathering, it became immediately obvious why such a group would be beneficial for all involved. Larry put it best when he said “We need a way of seperating the wheat from the chaff.”

It isn’t my intention to discuss the benefits of XSL in this post, any number of mailing lists and more talented developers and designers are doing that everyday. A few of the problems we are hoping to solve include providing companies with a place to look when in need of XSL developers. Agencies, we have determined are no good at this, all you need is a mention of XSL in your CV and you are viewed as being a qualified candidate - this isn’t the case when your only use involved the transform of a SOAP response to some other format 3 years ago. In fact more often than not, you either get someone with no idea besides a simple use a while ago or an expert who wants to break your bank account and rewrite xalan first. Yes, functional programming breeds zealots. We ‘d also like to provide developers with a forum to show off their skills, teach and mentor other developers.

We plan to meet once a month for small hacking/tutorial/masterclass sessions. We need interested developers to attend and we need capable hackers to come teach at these events and this is where you come in. We are forming a community and we want YOU to become a member of our community. Leave comments if you are interested in helping out, no effort is too little and we ‘ll keep you updated.

Stay tuned for more news of our website launch and first event shortly.

Formation SAGE © il maestro ignoto