web developer & system programmer

coder . cl

ramblings and thoughts on programming...


writing python daemons

published: 12-05-2012 / updated: 13-05-2012
posted in: development, programming, python, tips
by Daniel Molina Wegener

A daemon in Unix™ and similar operating systems, is a background process, which runs without using the terminal or the X11 system as main I/O system. In other operating system, this is called service. A daemon has a very specific tasks to do, for example the NTP daemon keeps your computer date updated connecting to NTP servers. Many applications that require asynchronous tasks, require this kind of applications to make your life easier. For example a job queue processor for the Gearman job server can be handled with this kind of applications.

django and amazon s3

published: 19-01-2012 / updated: 19-01-2012
posted in: development, programming, python, tips
by Daniel Molina Wegener

Amazon S3 is a well known web based storage system provided as SaaS service provided by Amazon Web Services. On Django you can integrate that service using the storage interface called Django Storages, but you must have some considerations using that SaaS storage interface. Mainly regarding the Date header sent to the service on each read, write and similar operations, where you must send an updated header with the proper Time Zone and format.

decorated template tags in django

published: 06-01-2012 / updated: 06-01-2012
posted in: development, programming, python, tips
by Daniel Molina Wegener

Django provides an API to create custom template tags for those applications mounted over this nice Web Application Framework. Sometimes we need to decorate our functions, but you cannot decorate a function registered as tag in Django. The most elegant solution to solve this problem is to use a closure which will wrap the template tag function to be used decorated template tag.

integrating selenium and django

published: 12-12-2011 / updated: 12-12-2011
posted in: development, programming, python, tips
by Daniel Molina Wegener

As you know, using unit tests will only provide a testing over algorithms and low level interfaces. For a higher level approach, you have the automated testing suite that provides the Selenium, which provides you a test case API to be used in functional tests. If you want to automate functional tests under Django, you can use the selenium IDE to record your actions on the web site, and export them as test case instructions for the selenium API, which will run those tests as you in the web browser, or even other tools like Html Unit. This includes several browsers supported by the API, including a server that allows you to mount a test grid using various machines.

why to go with multi-paradigm?

published: 18-11-2011 / updated: 18-11-2011
posted in: development, programming, python, tips
by Daniel Molina Wegener

Hybrid languages are cool. Most powerful programming languages are those languages which can handle a multi-paradigm scope. You can reduce the amount of code considerably when you are using a multi-paradigm approach. Due to the imperative origin and procedural approach of object oriented languages, having only object oriented language approach is not enough to solve problems. For example as we reviewed the widely used MapReduce distributed computing model has its origin on the functional paradigm in two higher order functions called map and reduce — where the synonym of reduce is fold, applying a kind of Monoid where the data is lifted and transformed by the map function and then is processed and reduced by the fold or reduce function.

instant xml api using pyxser

published: 05-11-2011 / updated: 05-11-2011
posted in: development, programming, projects, python, pyxser, tips
by Daniel Molina Wegener

Probably you do not understand pyxser at all. It is a serializer and deserializer which converts Python objects into XML as plain text. Among JSON and other formats, XML can help in some tasks like transmitting object through the network, for example building API calls using remote queries. Here I will guide you on how to build an XML query API for your Django driven application in few minutes. You just need to understand how pyxser works and how to use the pyxser module. Remember that you can see the documentation once it is installed, even if you do not have Internet, just by running the pydoc daemon with pydoc -p 8080 and connecting to the port 8080 in your machine — you can choose another port if it is not working.

re: monoids in python

published: 12-10-2011 / updated: 10-04-2012
posted in: development, programming, python, tips
by Daniel Molina Wegener

On a recent post on his blog, Francisco Mota has described Monoids with both, the Mathematical background and the functional background. If you read careful the post, you will notice that he has created the Monoid class. He describes a Monoid as a set A with neutral element \varepsilon and an the operation ( \cdot ) : A \times A \mapsto A, where the triple \langle A, \varepsilon, \cdot rangle denotes the Monoid. In terms of Category Theory, the set should be a category and the operation should be a morphism.