Django framework provides integrated tests runner, which can be started by ./manage/py test
(see docs for more details, key advantage of this runner is that it’ll create new empty database for tests, so they do not interfere with each other or your development instance). This tests runner runs unit tests from tests.py
or models.py
modules in active projects. However in larger projects we would like to have other organization of tests code – have for instance special test package within project that contains many testing modules, each focused on particular aspect of the application. Continue reading Django tests auto-discover
All posts by admin
UbuntuOne client behind proxy
It can sound bit weird, but most problematic platform for UbuntuOne client is Ubuntu itself – especially when your PC is behind proxy – or even worst when you’re moving between several networks with your laptop, where some nets are using proxy. Continue reading UbuntuOne client behind proxy
Converting files in directory structure
Often I needed to convert a set of files (audio files to different format, text files to different encoding, …) in some directory structure and save results to a new destination while retaining directory structure. In order to walk through directory structure we can use find
command, but if we are to create output in new place, subdirectories have to be created, which is where find
command line gets bit complicated (especially if we have to consider spaces in files/directories names). So here is an example for converting text files encoding:
find . -name "*.txt" -exec bash -c 'mkdir -p "/dest-dir/`dirname "{}"`"; iconv -f utf-8 -t windows-1250 -o "/dest-dir/{}" "{}"' \;
Long Running Taks in Web App/Django
Some types of web applications require to start long running tasks – like import of file, compilation etc., but user still needs to have real time updates about progress of the task, eventually some error messages, warnings from the task (cannot import particular line, compilation error). There are existing robust solutions like Celery, but it is aways fun to reinvent the wheel 🙂 In this case we focus on simple solution, without need for request broker in middle, which enables immediate/ real time updates on running tasks to client browser.
For our solution we will use two cool technologies/libraries web sockets and zeromq library. Continue reading Long Running Taks in Web App/Django
Playing with maps (QGIS, PostGIS, OSM)
I do like maps. Recently I was looking at some digital maps and got into more details and found several nice open source tools about which I’d like to write in this article. As in any area open source provides interesting alternatives to work with digital maps and geographical data and what is also very interesting there are now free sources of good quality geographical data, which can be used freely by everybody to create their own maps. In this article I’m explaining how use data from Open Street Maps (OSM) project for creating maps in QGIS and how to use PostGIS to store geographic informations and have fun playing around with their different features of map data and tools. This tutorial is focused on linux (debian based – ubuntu 12.04 resp. mint in my case) desktop and assumes some basic knowledge of your linux desktop administration. Continue reading Playing with maps (QGIS, PostGIS, OSM)
AppIndicator3 – how to use custom icons
Recently I’ve updated TheTool to support also AppIndicator3 interface so it can show icon in Unity panel. Although the documentation is not saying it, you can use absolute path to PNG image as icon-name ( apart of stock icon name). I was trying to add application specific stock icons, but is somehow did not work well (only possibility is to use xdg-icon-resource install --novendor --size 32 picture.png icon-name
, but python code for creating application specific icons with Gtk.IconFactory was not working for me – see this post on stackoverflow). Continue reading AppIndicator3 – how to use custom icons
Software RAID 1 And LVM
While adding more capacity to my Ubuntu 12.04 based server I decided to use two disks in RAID 1 – although the whole topic is well discussed and described, it still took me some time to put all pieces together, so here I’d like to share my experiences. Plus there are couple of decision point on the way, so I’d like to explained my decisions, based on informations I read. Continue reading Software RAID 1 And LVM
Diskless PC (booting from USB stick) with Ubuntu
Recently I decided to revamp my linux HTPC and this time to do it properly – there is no disk and all media are on separate server (or NAS – I prefer server, because I’d like to run some other things there, which might be problematic to run on pure NAS box). New PC should boot from from common USB stick – 8GB – value around 5 EUR (I thought it would be more convenient to build system and I did not have any server yet to boot from network only – actually old HTPC would become server, but first new HTPC has to be created). To overcome two major issues of common USB stick – limit on number of write operations (too much writes decrease lifetime of the stick) and slow write operations speed I decided to use overlays file system (or sometimes called union file system), where (once all system is set up) all writes go to memory – this is similar to linux live CDs or USB sticks. In order to be able to do some user customizations after installation and that user can save various data his home directory, the home directory is hosted on server/NAS and shared via NFS. The recipe described below is for xubuntu 12.10. Continue reading Diskless PC (booting from USB stick) with Ubuntu
Timezones and DST in Oracle APEX
Almost all APEX applications I’ve been working with recently are used across multiple timezones, where many timezones uses DST (Daylight Saving Time) – that is basically almost all Europe and North America. The natural requirement is that users can see date+time information in their timezone time, reflecting if DST is active or not. Timezones and time conversions are always bit of mess and APEX is not supporting this completely out of box, but with small effort we can make our applications really global. Continue reading Timezones and DST in Oracle APEX
Good Book About Javascript
I’ve have been working with Javascript here and there – always small pieces – as I know Java, C, Python I though that I do not need to learn anything special about Javascript, that I should be able to manage right away – In fact I somehow did, but I’ve been always bit struggling with some strange behaviours. Having to write couple of Firefox add-ons recently I decided to read some book about Javascript to shed a light on those anomalies – I found this book very good – Javascript: The Good Parts by Douglas Crockford.
It relatively small book – I’ve read it in a few hours, but it gives you very good overview of all features of the language and show you how to write good and maintainable code in JS. Now I know that Javascript is very expressive language, where I can use some powerful features like functional programming, prototypes etc.