web developer & system programmer

coder . cl

ramblings and thoughts on programming...


how I won my latest project

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

As freelancer I am constantly looking for new projects. Sometimes is hard to find good projects, mainly because not all customers are technical customers, making hard to communicate some aspects of the project, among other stuff like programmer evaluation, without too much technical evaluation, mostly based on his accreditations. One of my latest projects was earned by handling a programming problem on the middle of the interview, I was using Skype to share my screen and allow the customer to review the source code and watch me how I was solving the problem. That was great.

simple parallel programming example

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

There are several parallel models. One of the most used parallel programming models is the threading model, where you create threads or lightweight processes which are sharing memory and resources, like open files. A thread is an independent execution space that shares memory with its creator inside the its parent process. So, imagine that you need to process 5 files containing call time duration and you need to sum and join that data. Processing that set of files sequentially probably is slower than doing a parallel program to process all files at once. Here is an example written in Python that can help you to understand a threaded solution for this problem.

typing is not a problem

published: 10-06-2012 / updated: 12-06-2012
posted in: development, haskell, java, programming, python, rants, tips
by Daniel Molina Wegener

Typing is not a problem. We have many programming languages which are using dynamic typing. Dynamic typing is not so good as you can think. It allows you to do much stuff, where you can evaluate some expressions like (int)"1" + 1 = 2, without type errors. The problem with that kind of flexibility is the fact that there is no standard on boolean evaluations, leading to logic errors, and obviously to program failures. Even in some type-safe programming languages, they allow some stuff like that, there is C++98 and further versions allowing a wide variety of type casts, where any mistake on the casted values can generate logic errors and failures.

charset detection with python

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

How many times did you require to detect the charset of a given file?. This task is quite easy to do with Python. Currently I am working in an application that requires to parse CSV files, where they come from Linux and Windows systems. The problem — as usual — are the Windows files, which are not using the UTF-8 encoding, rather than using Unicode, they are being exported as Windows-1250 and similar encodings. This is a big problem while you are trying to import data to Unicode collated tables, like those using UTF-8 encoding. On Python, the chardet module does all the magic.

writing python daemons

published: 12-05-2012 / updated: 15-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 task 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.