Sunday, October 19, 2008

Fear Factor presentation from Tim Bray

Tim Bray gave a great talk/presentation at FOWA in London titled Fear Factor. In speach he outlined some general tips and strategies for web developers to survive this economic crisis.

He also created series of blog posts starting with "On tough times" that go more in depth to each of his major survival points:

Make sure you read comments on individual posts.

In presentation and later in blog post he mentioned his belif that current cloud computing offers lead to vendor lock-in. There are some very insightful comment on his original post (Get In the Cloud) and the follow up Lockin-Free Cloud? (my comment on the topic)

But my biggest take form his talk was when he talked about old javaEE an php code bases. There will be good opportunities for people to work with them, since people will be less likely to risk something new (read anything from ruby or python) and will rather patch the old code.

I am just developing application in Django, but after I finish with it I think I'll put some of my time in learning new PHP [1] just in case. [2]

Also like he said this is good time to add to your skills. On my immediate howto is jQuery (and js in general), and finally learn ruby on rails. (If you get to create new project from scratch you are not limited to old languages and tools )

[1]: last time I worked with php it was still at 4.*
[2]: I have never worked with javaEE, only plain java in University and some desktop apps. I don't know if its worth learning it form schrach at this time though.

Saturday, October 11, 2008

Code highlighting on blogger

Ok lets see if new highlighter works.

#! /bin/env python

def python_funct():
a = a + b
print "Hello Highlighted code"

class Foo(Bar):

So how to do it?
Simply use googles own client side code highlighting library .

Its easy. Just include this two lines at top of your blogger template:

<link href="" type="text/css" rel="stylesheet" />
<script type="text/javascript" src=""> </script>

And change body tag in your template to include onload="prettyPrint()":
<body onload='prettyPrint()'>

And thats it. Now all you have to do when you want highlighted piece of code in your blog is to use.

<pre class="prettyprint">
... # Your code goes here
EDIT: Urls to prettyfy.js and prettyfy.css were wrong. They are fixed now.

Creating new python project

How to set up development environment for new python project.

Some of the tools I use:

  • virtualenv - creates self contained python enviroment (you can even ignore systems site-packages). Its usefull for installing new python libraries or eggs that you may not want to install systemwide.
  • paster - (from pastescript)it helps you with crating project skeleton (including and eggs config). If this is wsgi project you can also use it for deploying.
  • nose - my preferred python testing framework. One of its biggest benefits is that it works with existing unittest tests and doctests.
So tipicly for crating new project cli session would look like:

$ cd py.virt/
py.virt$ virtualenv --no-site-packages Foo
py.virt$ cd Foo && source bin/activate
(Foo)$ easy_install nose
Searching for nose
(Foo)$ easy_install pastescript
Searching for pastescript
(Foo)$ paster create Foo
Selected and implied templates:
PasteScript#basic_package A basic setuptools-enabled package

egg: Foo
package: foo
project: Foo
(Foo)$ cd Foo
(Foo)$ python develop # creates registers with python so that ' import Foo works'
running develop
running egg_info
writing Foo.egg-info/PKG-INFO

Now our package should be created and registered with python. Lets see:

(Foo)$ python
Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import foo
>>> dir(foo)
['__builtins__', '__doc__', '__file__', '__name__', '__path__']

Now we can start coding.