Archives for the Month of June, 2007

Automating creation of virtual hosts with Python

This is nothing special, but I posted it for personal reference.

#!/usr/bin/python
import os
hostname = raw_input(”Enter hostname: e.g. example.com “)
os.system(”/usr/sbin/useradd -s /bin/false %s” % hostname)
print “User added ..”

vhost = “”"

ServerName name.com
ServerAlias www.name.com
DocumentRoot /home/name.com/public_html
CustomLog /home/name.com/web.log combined
CustomLog /home/name.com/main.referer.log referer

“”"

open(’/etc/httpd/conf/%s’ % hostname, ‘w’ ).write(vhost.replace(’name.com’, hostname))
print “%s was added” % hostname
os.chmod(’/home/%s’ % hostname, 755)

More on Verbs vs Nouns

Not my two-cents, actually, in response to Pat Hellands Every Noun can be Verbed
[Objects|Closures] are just a poor man’s [closures|objects] via via

Fantasy Development Methodology

Scott Berkun’s talks about dysfunctional development methodologies.
He has left out Fantasy Development Methodology.
Here are the basic steps:

Sales promises delivery of fantasy product on a fixed cost fixed time basis
Business analyst specs up fantasy software
Project managers spec up fantasy schedule
Engineers make fantasy estimates
Lead engineer adopts fantasy methodology
Fantasy driven development meets fantasy-driven schedule
Software doesn’t work, but journalists [...]

What Rich Client Applications Can Learn from the Web

Zef writes in Ajax Reality Check that

Does anybody realize where we came from and that these “web 2.0 technologies” aren’t great at all, but just the best we could do — in the browser?

However, I assert that do have something to learn from the browser1, and it’s not ajax.

Warning: os.path.join surprising behaviour

>>> os.path.join(”/a/b/c”, “/d/e/f”)
“/d/e/f”
This can be a problem if “/d/e/f” comes from an untrusted source.
As a safety measure, avoid using os.path.join in your web applications, roll your own and call it “safe_join”. You will sleep better.

A humble proposal for a few more HTML elements for HTML5

This is for the benefit of Google and Yahoo. (tongue in cheek)

<sponsored> Anything in between these tags are not to be trusted, advertisements, banner ads, text link ads, Adsense
<searchresults> Google had asked for search result pages not to be indexed
<unmoderated> Use this for sections where untrusted public can comment. Alternative to nofollow

An this is for [...]

daodejing for pythonistas I

A value is a value
Verily it is a value
A reference is a reference
Verily it is a reference
道可道,非常道。名可名,非常名。
A value’s existence is eternal1
But we can’t handle it until a reference is created2
无名天地之始。有名万物之母。
Break out of the python interpreter,
one will grok values actually are.
But running in the interpreter,
one can never know what the true value is3
故常无欲以观其妙。常有欲以观其徼。
But a value and [...]

Considerations When Designing Your Own Programming/Scripting Language

Found this - How to Design a Declarative Language - via Bill Clementson’s Blog Post (DSL Design Considerations). It’s so useful that I’m going to lift it and archive it a copy over here as well.

Contributors: Andrew Cooke, Steve Dekorte (*), Matthias Holzl (*), Jerry Jackson (*), Jonathan Rees (*), Anton van Straaten (*)
Here are [...]

In the Attention Economy, you steal Attention by Borrowing Copyright

John Andrews pushes back Lessig on a book exec’s stealing of a few Google’s computers at a book expo:
It’s no longer about stealing the book and leaving someone the lesser, Mr. Lessig. That ceased to be important when Google started advertising in search results. It’s now about monetization of the process of publishing original works. [...]

Embedding IronPython - C# Calling Python Script Part 1

Embedding IronPython is quite trivial and is documented here.
You can call functions in the embedded python module by
(1) retrieving the function using Evaluate()
(2) then apply the function using the Call() method

using (IronPython.Hosting.PythonEngine engine
= new IronPython.Hosting.PythonEngine())
{
engine.Execute(@"
def foo(a, b):
return a+b*2");

// (1) Retrieve the function
[...]

“Flow”

Getting in the flow is a concept that is common to both programmers and musicians.

In Designing Musical Instruments for Flow, Spencer Critchley writes the path to flow:

Guide for Python Newbies

Gleaned from Usenet

Varargs in Python functions
Encoding HTML Entities in Python
True And False
Ten sample simple introductory python programs to get you started

REST-compatible Ajax Patterns

Can AJAX be used to strengthen REST-style programming? Yes! Here are some common scenarios where AJAX is better than standard HTML.
User authentication
Display authentication dialog on the URL where access is attempted, instead of redirecting to a logon screen, and then redirecting back.
Dialogs
Present dialogs using DHTML instead of popping up windows. URLs should be permanent if [...]

Will Linux Ever Get Out Of It’s Driver Mess?

Linux has a scalability problem. The current vision of Linux device driver Utopia is based around “stick your source code in our tree, and as we change our kernel interface, some one in the open source world will fix up your drivers.” This approach simply wouldn’t scale, as the number of drivers in the tree [...]

Styles of programming

(Sorry for blogging in too technical terms, I’ll clean this up when I have time later)
Sean McGrath suggests that the audience for computer programs should be people, not computers.
I was most struck by the reference comparing novel writing to diary writing. I would like to add a third style, screenplay writing. OO programming [...]

What’s Wrong With this Story of Economic Growth?

China becomes the factory of the world, and the
 ensuing flurry of economic development
   creates new demand in China for oil and gas, and this
    raises fuel prices, which in turn
     causes the U.S. to turn to corn for biofuels, which in turn
      causes corn prices to rise, which then
       raises [...]