Category Archives: Programming

Web Clients Are Getting Thick

Remembering days when client-server rules the world, then days when everybody praised light web clients where all user interface (UI) was prepared on web server and any user action was communicated back to server (this could lead to heavy network traffic – I’ve seen one mainstream ERP  program, where a change in one input, say line item quantity,  lead to several megabytes being sent over network).  I’m quite amused to see how we’re returning back to thick clients and passing  more and more UI tasks back to user devices.   This probably make sense, taking into account the computing power available in user devices now (my mobile has approximately same computing power (dual core 1.2 GHz ARM CPU)  as  a reasonable  server  ten years back(Sun V240 for instance)) and  improvement of web browsers and especially their Javascript engines.   Normally utilization on an average client machine would be very low, unless client is dealing with digital media, so using  available computing  power there  is an obvious step. Network bandwidth could be now  more precious resource then client  computing cycles. Continue reading Web Clients Are Getting Thick

Dynamically Mix in Methods into An Instance in Python

As Python is a dynamic language it offers many possibilities how to manipulate object instances during runtime.   We may for instance inject methods from another class,  achieving similar results as  if  this instance has this calls as a mix-in super class. This approach could be useful to hack some existing libraries with extra functionality, in case we have to work with created  instances.

This function will inject methods from mixin_class into instance assuring that method is properly bound to the instance.

Continue reading Dynamically Mix in Methods into An Instance in Python

Django tests auto-discover

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

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

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

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.

Writing to file in Firefox Extension

Mozilla has provided nice high level API in its Add-On SDK, where one can relatively easily write an extension, without need for any special knowledge about internals of Firefox – the general knowledge of Javascript, HTML and CSS plus very nice and detailed documentation of the SDK are basically enough.

However there are some functionalities, that are not available in SDK and then more effort is needed and  XPCOM components have to be used via their JS interfaces.  This requires bit more  research, so I’d like to share one useful snippet of code  – how to save string to file, which user has chosen via standard file picker dialogue: Continue reading Writing to file in Firefox Extension

GSettings – Flexible Configuration System

GSetttings is the standard way how Gnome 3 applications store their configuration. GSettings is the front-end interface for application, actual values are stored by back-end – standard one is called dconf. We can then use the tool dconf-editor to easily browse all stored configurations for all applications. Thanks to GObject introspection we can also work easily with GSettings from python. Continue reading GSettings – Flexible Configuration System

LOB As A Link in Apex

APEX 4.1 enables to include a download link to LOB object in standard or interactive repors.   Documentation is available  here, however the approach is not so obvious from it.  So here is quick recap, how it works:

  1. In report query you must have column that contains LOB length  (not LOB itself!) –  so something like select dbms_lob.getlength(MY_LOB) my_lob_lenght from MY_TABLE
  2. The report column corresponding to LOB length should be set as:
    Display As: Display As Text (escape special characters, does not save state)
    Number/Date Format: DOWNLOAD:TABLE_NAME:LOB_COLUMN_NAME:ROW_PRIMARY_KEY_COLUMN
    (beware names are case sensitive here)
  3. When more sophisticated download behaviour is needed you should also include  columns for MIME type of data, file name and modification timestamp.   Once you store basic DOWNLOAD format you can edit it with masked edit link “BLOB Download Format Mask”
  4. Download link is only shown when LOB length > 0 and is not null.

Continue reading LOB As A Link in Apex