Practical design!

Practical design does not anticipate what will happen to your application, it merely accepts that something will and that, in the present, you cannot know what. It doesn’t guess the future; it preserves your options for accommodating the future. It doesn’t choose; it leaves you room to move. Practical Object-Oriented Design in Ruby, Sandi Metz

Sencha touch 2 apps and scrolling issue in Chrome/Android

I was revisiting a conference app I developed in Sencha Touch 2.3 (ST from this point onwards), and realised that the scroll for a couple of lists have suddenly stopped working. This was really weird as the scroll used to work fine and nothing has changed on the code side. This made me think whether the issue persists in how Chrome is rendering the list. I checked the same thing in Safari and it was working fine, which made me realise that the issue has to do with Chrome and the way the WebView renders the app on Android. A bit more digging made me realise that Chrome 43+ has caused this issue. There are two solutions to the problem. 1. Upgrade to ST 2.4.2 which resolves the problem. 2. Use a couple of overrides which are available here: I have personally taken option 2, as I want to retain my app on ST 2.3.1. The solution has worked simply out of the box and a big thanks go to Josh Morony.

Hydra as a Digital Asset Management System

We are currently looking for a solution to store the different forms of digital objects/assets that are generated by various researchers/academics/departments/faculties at Lancaster University. The traditional repository model does not feel like it is best suited to accommodate the ever expanding range of digital assets. We are talking about Research Data, Digitised objects, Open Educational Resources, Video and Audio files, Software packages, etc. So we started looking into other appropriate solutions. From my previous experience, I remember Fedora was designed for this very purpose. The hint is in the name, Flexible Extensible Digital Object Repository Architecture. We are really keen on the flexible and extensible aspects. However, experience has also taught me that Fedora can become very complex to manage very quickly. Something, we at Lancaster, can’t afford at this time with our limited resources. At the same time, we are also looking into two wrappers/solutions on top of Fedora, aptly named as Hydra and Islandora. Hydra is based on Rails (Ruby) whereas Islandora is based on Drupal (Php). Considering we have expertise in neither (we are primarily a Django/Python shop), we are open to both solutions, or something else completely. Between Hydra and Islandora, however, it seems like Hydra

Continue Reading

Sencha Touch 2.3, hasMany association, and duplication of store entries

If you are working with Sencha Touch 2.3 (ST from this point onwards), then you may have developed a love/hate relationship with the platform like myself. Some aspects of the framework are great, whereas some others are sadly atrocious. The lack of coherent document, and the wide variety of conflicting information also does not help. In a recent incident, I am using a hasMany association in the model and found a peculiar issue happening. To give you background of the issue, I have a model called Session which has a hasMany relationship with another model called Participant. Both models below: The Session model: Ext.define('MyApp.model.Session', { extend: '', requires: ['MyApp.model.Participant'], config: { idProperty: 'id', fields: [ { name: 'id', type: 'int' }, { name: 'number', type: 'string' }, { name: 'time', type: 'string' }, { name: 'date', type: 'string' }, { name: 'day', type: 'string' }, { name: 'title', type: 'string' }, { name: 'abstract', type: 'string' }, { name: 'track', type: 'string' }, { name: 'room', type: 'string' }, { name: 'building', type: 'string' } ], hasMany: { model: 'MyApp.model.Participant', name: 'participants', primaryKey: 'id', foreignKey: 'session_id', associationKey: 'participants' } } }); The Participant model: Ext.define('MyApp.model.Participant', { extend: '', config: {

Continue Reading

Parsing XML with lxml in Django – Multiple Namespaces and XPath

A few days ago, I was trying to figure out how to parse XML with multiple namespaces and get information using XPath in Django. I came across lxml which I think is really good. You don’t have to csrf_exempt this procedure as it is GET based and thus safe. I am doing it for consistency with the rest of my code. I am using Primo Webservices basic search here as an example, but you may not be able to open this URL as it is a protected URL. Also, this may not be the best way to do this, so if you can think of improvements, please let me know. from django.http import HttpResponse from django.views.decorators.csrf import csrf_exempt import simplejson as json import urllib from lxml import etree   @csrf_exempt def brief_search(request):     errors = []     if request.method == 'GET':         searchTerms = request.GET.get('query')         bulkSize = request.GET.get('pageSize')         indx = request.GET.get('start')         if indx:             indx = int(indx) + 1             DEFAULT_NS = ''             query = 'any,contains,' + searchTerms             url = '' + query + '&indx=' + str(indx) + '&bulkSize=' + bulkSize             content = urllib.urlopen(url)             xml = etree.parse(content)             docset = xml.getroot().xpath('//sear:SEGMENTS/sear:JAGROOT/sear:RESULT/sear:DOCSET', namespaces={'sear': '', 'def': DEFAULT_NS})             totalhits = docset[0].get("TOTALHITS");             docs = xml.getroot().xpath('//sear:SEGMENTS/sear:JAGROOT/sear:RESULT/sear:DOCSET/sear:DOC/def:PrimoNMBib/def:record', namespaces={'sear': '', 'def': DEFAULT_NS})  

Continue Reading

Configuring AWStats for Response Time Parameters

Recently I was looking at various web log analysers that I can use with Apache to generate standard and custom statistics. The package that seemed most promising was AWStats. AWStats does a great job, especially with standard statistics. It is also very easy to install. However, if you want to see performance related attributes in AWStats, you need to use the “Extra Sections” in AWStats. I was interested in the response time parameter for a query in Apache. As a result, my Apache LogFormat looks something like: >LogFormat “%h %u %l %t ”%r” %>s %b ”%{Referer}i” ”%{User-Agent}i” %T %D” 443_combined Where %T represents the response time in seconds (useless as most requests are performed in under a second) and %D represents the response time in microseconds. The 443_combined is the nickname you can give to your LogFormat string, and then use this nick name to format when defining log files. You can call it anything. Equivalent AWStats log format is: >LogFormat=”%host %other %logname %time1 %methodurl %code %bytesd %refererquot %uaquot %other %extra1″ And to show the %extra1 parameter in the graphical page, you use the EXTRA SECTIONS. ExtraSectionName1="Response Time (in microseconds)" ExtraSectionCodeFilter1="200 304" ExtraSectionCondition1="URL,/" ExtraSectionFirstColumnTitle1="Response Time" ExtraSectionFirstColumnValues1="extra1,([0-9]*)$" ExtraSectionFirstColumnFormat1="%s" ExtraSectionStatTypes1=P ExtraSectionAddAverageRow1=0 ExtraSectionAddSumRow1=0

Continue Reading

Primo Enrichment Plugin for Nielsen Data

Primo, the Ex Libris resource discovery platform, provides an architecture to write plug-ins on top of it. One of these plug-ins is the Enrichment plug-in. I have recently written one of these plug-ins, which enhances Oxford’s resource discovery platform called SOLO (based on Primo). The plug-in searches Nielsen data against every record in Primo and enriches the record (more precisely record’s PNX) with table of contents, short descriptions and long descriptions (whichever available). The enriched data is displayable and searchable. Nielsen data is indexed in Apache’s Solr search server and request for the data are made through a web service call from within the plug-in. More details about the plug-in along with source code and installation instructions can be found here.

Site Footer

Sliding Sidebar

About Me

About Me

Strategy, Leadership, Innovation and Code Monkeyism

Social Profiles

Latest Tweets