katratxo on Software Development

tail -f /var/log/brain | grep -i software

Archive for January 2010

Development tips – Part I

with 5 comments

This is the first one of a series of posts about development tips that I use in a daily basis. I think that you can benefit from them, and speed up your daily work. There are some one-line commands that you can use to execute several things in one shot. Those is targeting GNU/Linux users.

Speeding up Firefox

I have found a few tips that can improve its performance.

Use different profiles

Add-ons could decrease the performance of your browser. One example of decreasing performance add-on is Firebug. It’s just a great tool to debug JavaScript, CSS, HTML, monitor requests, etc, but it has a known issue:

“… If you have Firebug installed you are probably not getting fast Javascript. Firebug doesn’t have to be active on your current page …”

That’s why is a best practice to use Firebug in a different profile.

I have a profile named “debug” where the only add-on installed is Firebug and made a simple bash script ffbug to open Firefox with that profile:

#!/bin/bash
firefox -no-remote -P "debug" &

The -no-remote parameter allows you open a new instance of Firefox and not just a new window linked to the current running one. The -P is to define which profile you want to use.

VACUUM the SQLite databases

You can improve the performance of Firefox by vacuum your bookmarks, history, etc. databases.
Close all your running Firefox instances and execute:

~ $ for i in $(find -name '*.sqlite'); do sqlite3 $i VACUUM; done;

Useful one-line commands

Updating the source code of the modules your working on

In some cases you work with several modules at the same time, and you want to get all the changes made by your colleagues. You can update your local repositories by executing this line inside your modules folder:

for i in $(ls -1); do cd $i; hg pull -u; cd ..; done;

Example of the output of this is:

~/src/openbravo/working/pi-reference/modules $ for i in $(ls -1); do cd $i; hg pull -u; cd ..; done;
pulling from https://code.openbravo.com/erp/mods/org.openbravo.base.seam
searching for changes
no changes found
pulling from https://code.openbravo.com/erp/mods/org.openbravo.client.freemarker/
searching for changes
no changes found
pulling from https://code.openbravo.com/erp/mods/org.openbravo.client.kernel/
searching for changes
no changes found
pulling from https://code.openbravo.com/erp/mods/org.openbravo.service.datasource
searching for changes
no changes found
pulling from https://code.openbravo.com/erp/mods/org.openbravo.service.json/
searching for changes
no changes found
pulling from https://code.openbravo.com/erp/mods/org.openbravo.userinterface.selector
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 13 changes to 13 files
13 files updated, 0 files merged, 0 files removed, 0 files unresolved
pulling from https://code.openbravo.com/erp/mods/org.openbravo.userinterface.smartclient
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 3 changes to 3 files
3 files updated, 0 files merged, 0 files removed, 0 files unresolved

You can easily hack this line by executing another Mercurial command, e.g. See what’s the status on each repository:

for i in $(ls -1); do cd $i; hg st; cd ..; done;

Update and build the latest pi

Assuming that you want to use the latest stable revision from pi, you can check our continuous integration framework and see what’s the latest revision that passed all the tests, then you can update your local repository to that revision and rebuild your system. Or you can copy this bash script (pi-update), and execute it inside your pi working copy:

#!/bin/bash
REVISION=`wget -q -O - http://builds.openbravo.com/job/erp_devel_pi-full-pgsql/lastSuccessfulBuild/changes | awk -F: '/https:\/\/code\.openbravo\.com\/erp\/devel\/pi\/rev\// {print substr($3,0,12)}' | head -n1`
hg pull
echo "Updating to rev $REVISION"
hg up -r $REVISION
ant smartbuild -Dlocal=no

This script uses wget and awk to get the latest revision from the last successful build page, pulls all the changesets of PI and updates your working copy to the detected revision, then updates your database and compiles the application.

Cleanup your working copy

The hg status command will tell you which files Mercurial doesn’t know about; it uses a “?” to display such files …

I often want to clean my working copy and remove all unversioned files. You can rid of those file by executing:

 hg st -nu | xargs rm -rf

That’s all folks! I’ll come back with more tips in the future. Disclaimer: I’m not a bash expert so I know that some of this commands could be simplified. I would also like to thank iarwain for simplifying some of this commands.

Written by katratxo

January 15, 2010 at 11:21 am

Posted in Openbravo

Tagged with ,

Follow

Get every new post delivered to your Inbox.