2009-11-14

Go Sample: Link Checker

You should have heard about Go, Google's new language. To be honest, it is one of the ugliest languages I've ever used (I mean among the ones not designed to be ugly); but it's interesting enough, and I decided to teach myself some.

Here's the result of a few hrs of reading, searching, coding, reading again and coding: an (almost) port of Josh's Python URL Link Checker; it doesn't support checking local files, but it has a nice -v switch which lets you see all processed URLs. So far, programming Go felt a bit like programming C++; also Go statically links code at the moment, which results in an executable of size 1.2MB for 64bit Linux. (DISCLAIMER: the following program is a toy, don't use it for anything serious)

2009-10-20

Jsonrpclib Chat Server and Client

Josh is pretty involved with JSON RPC these days, and he has written a Python client and a Python/Tornado server plugin. The cool thing about his jsonrpclib is, it mostly supports the same interface with Python's XMLRPC model, so you'll have no trouble replacing XMLRPC with JSONRPC. I've written a simple chat server and client to get myself familiarized with his modules.

2009-10-15

Getting the Current Module in Python

Say, you want to insert a function, class or any other object into the current module dynamically; how can you do that? Of course, you start with getting the module name:

myName = globals()['__name__']

Then, getting the module itself:

import sys
me = sys.modules[myName]

OK, you got the module, now insert something in it:

setattr(me, 'hello', lambda x: 'Hello %s'%x)

We can call hello in our module from now on:

print hello('World')

2009-10-14

Merging PDF Files Using Ghostscript

If you have to merge PDF files, you need no other than Ghostscript (which is installed by default with many Linux distributions); here's the command line:

gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=firstANDsecond.pdf -dBATCH first.pdf second.pdf

2009-10-09

Josh's CouchDB Articles...

My friend Josh is writing a series of articles on CouchDB; he is covering CouchDB from the ground up, be sure to check it out!

Web Application Testing with Selenium: Basics and Setup

Introduction

It's always hard to ensure an application works up to a specification and continue keeping up to the specs in the course of development. Testing web applications is even harder, since they are composed of more components, and usually at least some of the components of the application are not directly controlled by the developers, such as links to other internet resources or mashups.

Luckily, there's a great tool for easing the pain of web application testing: Selenium. Selenium simulates a human user, by controlling a web browser using Javascript through a system called Selenium Core. The simulated behaviour includes clicking on links, form and dialog buttons; filling in forms; drag&drop and others.

2009-10-08

PySWIP: Facts and Rules

PySWIP is a Python module which enables accessing SWI-Prolog's foreign language interface using our beloved computer language. Here's a small tutorial on adding facts and rules to prolog knowledgebase.

2009-10-07

Testing Syntax Highlighter

Alex Gorbatchev wrote a cool Javascript syntax highlighter. Here's a test:
        import os
        import fnmatch

        function filterPythonSource(path):
            return fnmatch.filter(os.listdir(path),
                '*.py')

        if __name__ == '__main__':
            print filterPythonSource(os.getcwd())