Archive for January, 2010

Linux: FileSystem command tips

Saturday, January 23rd, 2010

List the file systems

df -h

Size given folder

du -sh /path/to/folder

Sort/List largest directories/subdirectories

du /var/log/ | sort -nr | less

Other Links

jQuery: bubbleBind jQuery Plugin to bind bubbling events

Monday, January 18th, 2010

UPDATE 2010-02-26: JQuery 1.4.2 added the delegate method, which does exactly that. Use the jQuery.delegate rather than bubbleBind (I just kepp the code below for reference)

bubbleBind is a jQuery plugin to conveniently bind bubbling events for given child targets. It is very similar to jQuery.bind and uses it under the cover (as well as Nothing magic, just simple, convenient, and familiar.


<div id="parentDiv">
            alert("you clicked on an span tag: " + $(this).html());

Plugin code

License free: use as you want, modify as you can, attribute as you feel.

(function($) {

   * Allow to bind a bubbled-event at the parent level for a given child (matching the childSelector).
   * The selected element(s) will be considered the parent(s), and the childSelector will filter the target element.
   * If, an only if, the target match the childSelector, then, the handler will be called. The key work "this" will
   * point to the target document element (as in jQuery bind)
   * Example:
   * 	$("#parentDiv").bubbleBind("span","click",function(){
   *            alert("you clicked on an span tag: " + $(this).html());
   *    });
   * @param {String} childSelector the jQuery selector for the targeted child. This will be use in $
   * @param {String} a jQuery evenType (same a jQuery bind)
   * @param {Function} the handler function
   * TODO: need to support eventData
  $.fn.bubbleBind = function(childSelector,eventType,handler) {

      // iterate and reformat each matched element
      return this.each(function() {
  		  var $parentElement = $(this);

  		  //bind the even to the parent

  		  	//get the target and test the target against the childSelector
  		  	var $target = $(;
    			if (${
    				// If matched, call the handler method using the target html element as reference
    				// Note: Might be a smarter and more conventional way to do this. Feel free to suggest.
    				$target.get(0).bubbleBindHandler = handler;




jQuery: Plugin Skeleton & Authoring

Monday, January 18th, 2010

Should be in file jquery.samplePlugin.js

(function($) {

   * Skeleton for jQuery plugin
   * @param {Object} options
  $.fn.samplePlugin = function(options) {

      // extends options with the default one
      var opts = $.extend({}, $.fn.samplePlugin.defaults, options);

      // iterate and process each matched element
      return this.each(function() {
          var $this = $(this); // jQuery object for this element
          //do what is needed


  // samplePlugin default options
  $.fn.samplePlugin.defaults = {};


jQuery Authoring Doc

JavaScript: JSONP Quick Ref & Service List

Sunday, January 17th, 2010

JSONP quick sample with Twitter

var tweeturl = "";
  $.getJSON(tweeturl, function(data){
	      $.each(data.results, function(i, item) {
		        .addClass(i%2 ? 'even' : 'odd')
			.prepend("<img src='" + item.profile_image_url + "' />")



         "created_at":"Mon, 08 Mar 2010 02:16:46 +0000",
         "text":"Geaux Haiti! "Far Away" by Lecrae... Powerful song for a honorable cause. Keep praying for Haiti brothers and...",
         "source":"<a href="" rel="nofollow">Facebook</a>"

Twitter JSON Search result

Services supporting JSONP

Feel free too add new one as comment I will update this page

Git: remove the Git UI Loose Objects dialog popup

Monday, January 11th, 2010

Edit the from git/share/git-gui/lib/database.tcl and change

	if {$objects_current >= $object_limit} {
		set objects_current [expr {$objects_current * 250}]
		set object_limit    [expr {$object_limit    * 250}]
		if {[ask_popup ....


	if {$objects_current >= $object_limit && false} {
		set objects_current [expr {$objects_current * 250}]
		set object_limit    [expr {$object_limit    * 250}]
		if {[ask_popup ....

Source: Stackoverflow: How to skip “Loose Object” popup when running ‘git gui’

Git: Merging patches git am -3 vs git apply

Friday, January 8th, 2010

Merging patches

When git-am fails to cleanly apply It will ask you to apply it yourself, to  git add the file and to run git-am --resolved.
In fact, git-am can help you a lot. When the call to git-am for a patch fails, simply run :

git-am --3way

Il will merge the file that can be automatically merge. Some files may be marked with CONFLICT and in this case, edit them to do a manual merge, and once they are fixed and run

git-am --resolved

Merging workflow

  • I’d recommend using File -> Save As, selecting “Raw Message Source”
    as the format, then apply using:

    % git am < /path/to/saved/message
  • Consider creating a topic branch for applying the patch and then
    merging that to master. e.g.

    % git checkout -b bugfix_from_john master
    % git am < /path/to/saved/message
  • Check things out. Make minor edits if needed. You can then use “git
    add” to add in your edits and “git commit –amend” to make those
    changes part of the patch the author sent.
  • Once you’re happy:
    % git checkout master
    % git merge bugfix_from_john
    % git branch -d bugfix_from_john