2010-08-25

Case-insensitive XPath Search

An example of case-insensitive xpath search: to find all the contact items whose name contain 'mac', 'MAC', 'Mac' and so on.

string lookfor = "Mac"
query = "/contacts/contact" + "[contains(lower-case(name),'"+ lookfor.toLowerCase() + "')]";

Refernece:
http://geekswithblogs.net/ranganh/archive/2005/09/12/53520.aspx

2010-08-24

15 Practical Linux Find Command Examples

  1. Find Files Using Name
  2. Find Files Using Name and Ignoring Case
  3. Limit Search To Specific Directory Level Using mindepth and maxdepth
  4. Executing Commands on the Files Found by the Find Command.
  5. Inverting the match.
  6. Finding Files by its inode Number.
  7. Find file based on the File-Permissions
  8. Find all empty files (zero byte file) in your home directory and it’s subdirectory
  9. Finding the Top 5 Big Files
  10. Finding the Top 5 Small Files
  11. Find Files Based on file-type using option -type
  12. Find files by comparing with the modification time of other file
  13. Find Files by Size
  14. Create Alias for Frequent Find Operations
  15. Remove big archive files using find command

Reference:
http://www.thegeekstuff.com/2009/03/15-practical-linux-find-command-examples/

3D QML

2010-08-10

Clone a old version in Mercurial

>hg clone --rev $version $path $foldname
For example
>hg clone --rev 38 https://bitbucket.org/project/sum sum-38

Reference:
http://stackoverflow.com/questions/2540454/mercurial-revert-back-to-old-version-and-continue-from-there

2010-08-05

'extend' property of Qml State

The property 'State.extend' holds the base state. When a state extends another state, it inherits all the changes of the base state and you need only specify the difference in your extended state. The usage of this property can largely reduce the code size: See the example below:

Without using extend (bad)
states: [
State { name: "album"
 PropertyChanges { target: but_album; state: 'Selected' }
 PropertyChanges { target: but_radio; state: 'Unselected' }
 PropertyChanges { target: but_rss; state: 'Unselected' }
},
State { name: "radio"
 PropertyChanges { target: but_album; state: 'Unselected' }
 PropertyChanges { target: but_radio; state: 'Selected' }
 PropertyChanges { target: but_rss; state: 'Unselected' }
},
State { name: "rss"
 PropertyChanges { target: but_album; state: 'Unselected' }
 PropertyChanges { target: but_radio; state: 'Unselected' }
 PropertyChanges { target: but_rss; state: 'Selected' }
}
]



Using extend (good)
states: [
State { name: "default"
 PropertyChanges { target: but_album; state: 'UnSelected' }
 PropertyChanges { target: but_radio; state: 'Unselected' }
 PropertyChanges { target: but_rss; state: 'Unselected' }
},
State { name: "album"; extend: 'default'
 PropertyChanges { target: but_album; state: 'Selected' }
},
State { name: "radio"; extend: 'default'
 PropertyChanges { target: but_radio; state: 'Selected' }
},
State { name: "rss"; extend: 'default'
 PropertyChanges { target: but_rss; state: 'Selected' }
}
] 

Reference:
http://doc.qt.nokia.com/4.7-snapshot/qml-state.html#extend-prop

2010-08-02

Merge in Mercurial

>hg push (fail due to different heads, merge is required)
pushing to http://joel.example.com:8000/
searching for changes
abort: push creates new remote heads!
(did you forget to merge? use push -f to force)
>hg pull
>hg merge (manually merge is sometimes required to solve the conflict)
>hg com -m "merge"
>hg push

Reference: 
http://hginit.com/top/04.html