Category Archives: Development

Filter Google Code Commits

Google code project hosting doesn’t give you an easy way to filter commits easily. In any way really. Hadeer Younis has posted a nifty script that dynamically filters them from the changes page.

Being the person I am, I refactored that script for easier usage.

  • Browse normally to the commit list page, example: http://code.google.com/p/smartsoft-12/source/list
  • Load this once:
    if(!window.jQuery||confirm('Overwrite\x20current\x20version?\x20v'+jQuery.fn.jquery))(function(d,h,s){s=d.createElement('script');s.type='text/javascript';s.src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js';((h=document.head)||(h=document.getElementsByTagName('head'),h?h[0]:document.body)||document.documentElement).appendChild(s)})(document);
    var total_commits = -1;
    var results = false;
    function filter_commits(regex) {
        if (total_commits == -1) {
            total_commits = $('.pagination:first').text().split('of')[1].split('Older')[0].trim()
        }
        $('div.list b:last').html('Please wait while we filter the log...');
    	if (results == false)
    	    $('#colcontrol').load('list?num='+total_commits+' #colcontrol', function(){
    	        results = $('#resultstable>tbody').clone();
    			do_filter(regex);
    	    });
    	else
    		do_filter(regex);
    }
    function do_filter(regex) {
    	$('#resultstable>tbody').html(results.html())
    	$('#resultstable>tbody>tr + tr:visible').each(function(){
    		if(!$(this).text().match(regex))
    			$(this).hide()
    	});
    	$('div.list b:last').html('Committed changes (done filtering)');
    }
  • Run this to filter
    // enter a regular expression to match against (username, r#, [uU]pdate issue #, etc)
    filter_commits("kamasheto");
    

Preview Print CSS on-the-fly

There are countless tools to help you with debugging CSS intended for the front-end “screen.” Inspector tools are now bundled with most modern browsers and are very powerful in terms of letting the developer manipulate the DOM in realtime.

However as soon as you try to develop UI for the printer it starts to get lame. Previewing the printer friendly version requires sometimes lots of steps and that could be quite exhausting on the long run. You could use addons that attempt to make this easier, but it still gets exhausting.

A good workaround I came across is using Javascript to dynamically remove the screen CSS and enable the print CSS instead. The underlying idea is quite simple: (jQuery)

	$('link[media="screen"]').remove()
	$('link[media="print"]').attr('media', 'screen')

You could run this code on load ($(function(){ /* here */ });), or trigger it on a certain event (clicking a certain test button for example.)

AutoCompleteTextView Not Showing On-Screen Keyboard

Problem

When attempting to write in an AutoCompleteTextView element, the on-screen keyboard doesn’t show. After changing views and going back to the Activity that had the element, the keyboard worked as intended.

Environemt

The on-screen keyboard worked as intended on the android 1.6 emulator. However on the Samsung emulator (2.2) and a Samsung device the keyboard failed to show.

Solution

You should not requestFocus by the autocomplete element. After removing the requestFocus the autocomplete worked with the on-screen keyboard every time it got focus.

Credits: @dina_helal for reporting. Thanks!

Change Mac OS X Menu Bar Icons

As much as I love how Mac OS X looks, I sometimes hate how some applications decide to just do things their own ways and make things look out of place. Whether it be in terms of app UI, dock icon, or sometimes even menu bar.

If you’re anything like me, it’s hard to settle for this menu bar:

Continue reading

XML File Reader

I’ve been looking for a very simple XML reader to use for my bachelor project. I didn’t want a complex reader that manipulates the entire DOM (parse the attributes, etc), or one that is complicated to use. So I’ve come to implement my own.

Continue reading