Skip to content

Recent Articles


Awk script for changing Ubuntu network interfaces – added DNS feature

At last, I have added the DNS feature for the network interfaces awk script. This feature is only used with static network settings.

Assume we have the following settings in the interfaces file:
Read more »


Styling Qt QTreeView with CSS

Qt offers additional CSS settings such as sub-control and pseudo-states. Although there are reference and brief tutorial with examples, it doesn’t really show how this settings affect the overall look. In this article, we explore how to style the QTreeView via CSS in step by step. First of all, we use a simple treeview directory program (Python/Qt5 ) from this example and style it gradually.
Read more »


How to create HighStocks area range chart for ExtJs

Here is an example of using the Highstocks extension for ExtJs 4 to create an area range stock chart.

First, there is a minor bug in the Highstocks extension that the property name for specifying the series type is ‘series.plot‘, not ‘series.type‘. Read more »


List of Qt Icons

I was given a job to smarten up a GUI program which is implemented in PyQt. One of the tasks is to put up some icons in the user interface. I know that Qt includes it’s own set of icons. However, I can’t find any page online showing what these icons look like. So I wrote a little program to list all the available Qt icons. Here is the screenshot:

List of Qt icons
Read more »


Javascript: How to really check for an object property exists

In Javascript, undefined is a value and it can be assigned to properties. So strictly speaking, we shouldn’t use undefined to check for whether an object’s property is defined.

var foo = new Object();
foo.fieldUndefined = undefined;

Read more »


Highcharts extension for Sencha v3.2.1 is here

Highcharts extension v3.2.1 is out. This release includes important performance fix (due to my crap code) and corrupt xAxis display with connectNulls option.


Salesforce: Writing a Test class for Opportunity Product (OpportunityLineItem)

A note on writing a test class for Opportunity Product (OpportunityLineItem), when assigning a product to an OpportunityLineItem, we need to make sure the product is active. Otherwise, we will get integrity exception. To do that, we use isActive property to filter all the current active products.

    Account a = new Account(Name = 'Test Account Joe ');
    PricebookEntry pbID = [select Id, name from PricebookEntry where isActive = True limit 1];
    Opportunity o = new Opportunity();
    OpportunityLineItem ol = new OpportunityLineItem();
    insert a;

    o.AccountId = a.Id;
    o.Name = 'Test_Joe_123';
    o.StageName = 'Prospecting';
    o.CloseDate =;
    o.Type = 'New Business';
    insert o;
    ol.OpportunityId = o.Id;
    ol.Quantity = 1;
    ol.UnitPrice = 2.00;
    ol.PricebookEntryId = pbId.Id;
    insert ol;

PDNS Recursor: Forwarding DNS queries to local DNS Server

I have setup two PDNS servers running in the same host; pdns_server (the authoritative server) and pdns_recursor (a recursive server).

Here are the configurations for both PDNS servers settings:








Read more »


Salesforce: Workaround to Assign Asset Name with Auto Increment Unique Value

In Salesforce, when creating an Asset entry, the Name field is a mandatory text field. For some users, this field has no particular purpose but cannot be left empty. For others, they may want to set the field with unique incremental id. In order to assign the Name field with an auto incremental value, a workaround solution is to first create a custom numeric field, (e.g.) Auto Update Id, with auto increment property.


Next step is to create a trigger which sets the Name field to the Auto_Update_Id value. Goes to Customize -> Assets -> Triggers and creates a trigger with the following simple code:

trigger SetNameToAutoIncrId on Asset (after insert) {

    for(Asset a:{
       for (Asset ua: [ Select Name, Auto_Update_Id__c FROM Asset where Id = ]) {
           ua.Name = ua.Auto_Update_Id__c;
           update ua;

Since the auto increment value won’t be assigned until an Asset record is created, therefore we have to create a trigger with after insert event. Also Salesforce does not allow users to modify the triggered record in after insert event. So that we need to issue another SOQL query, assign the result to another Asset object and then update the record to the DB.

Although the user still needs to input something into the mandatory Name field, the insert operation will automatically overwrite the Name field with an unique numerical id.


Developing a Salesforce Trigger

Lets assume we need to develop a trigger to perform two checks on opportunities:

  • When creating or updating an opportunity, the Type selection box must be selected with a value
  • When an opportunity stage is selected to ‘Closed/Won’, the opportunity must contain Products (OpportunityLineItem) entry

Read more »


Get every new post delivered to your Inbox.

Join 43 other followers