Archive for the 'Soft Hacks' Category

Unix timer utility

Timer microbenchmark

Timer utilities performance on C and Perl of "echo -n"

The Unix time(1) command can only give a precision of 10 milliseconds by default. But being the engineer who goes insane after precision, I made my own script to be able to get differences in terms of microseconds. My first timer utility was made in C but I got stuck with the insane exec(3) family of functions since you need to fork the process to a child for the parent process to create successful timing. Hence I used Perl with the Time::HiRes library which is a wrapper to <time.h> and <sys/time.h>. Later on, I found out that C itself has the system(3) functioin in <stdlib.h>

Performance-wise you can see that C has a much faster runtime when the program was being invoked. But you can see in the graph above that Perl has much more consistent values so its standard deviation is lower than C. When I tested both programs for my data-intensive computing experiments, I get better results with the Perl utility! Perhaps I forgot to do all the magic the system function in Perl does in my C implementation?

Here is my Perl code:

#!/usr/bin/perl

use Time::HiRes qw ( tv_interval gettimeofday );

$start = [gettimeofday];
system @ARGV;

$elapsed = tv_interval ( $start );
print $elapsed, "\n";

Here is my C implementation:

#include <stdlib.h>
#include <stdio.h>

#include <time.h>
#include <sys/time.h>

int main(int argc, char* argv[])
{
	struct timeval start, end, diff;
	gettimeofday(&start, NULL);
	char* command = malloc( sizeof(argv) );
	int i;
	sprintf(command, "%s", argv[1]);
	for( i = 2; i < argc; i++ )
	{
		sprintf(command, "%s %s", command, argv[i]);
	}
	system(command);
	gettimeofday(&end, NULL);
	timersub(&end, &start, &diff);
	printf("%d.%06d\n", diff.tv_sec, diff.tv_usec);
	return 0;
}

The future of public health: grid gains traction

From iSGTW Feature - The future of public health: grid gains traction.

Feature - The future of public health: The grid gains traction

Dr. Ida A. Bengston (1881-1952) was one of the first women employed on the scientific staff of the Hygienic Laboratory of the Public Health Service, the predecessor to the National Institutes of Health. Bengston was particularly noted for her studies of bacterial toxins.

What are the infrastructure challenges of public health informatics that requires leveraging the grid?  Of course Doc Eloy Marcelo has his CHITS and also there is the OpenMRS project.  Perhaps this is an *integration* of existing systems? It would be interesting to see a web service interfacing CHITS and OpenMRS.

GRID Computing Now! - Competition 2008

From GRID Computing Now! - Competition 2008. Too bad it’s only open for UK residents :(

Enter the Grid Computing Now! Competition 2008

Grid Computing Now! is pleased to announce its second competition for applying innovative grid computing solutions to an environmental problem. The competition is supported by the British Computer Society, The 451 Group, Intellect, Memset, Microsoft, National e-Science Centre, Oxford e-Research Centre, the Technology Strategy Board and WWF.

Of course supercomputing systems have are already widely used to analyze weather patterns like MM5 and other NWP suites. So what solutions kinds of solutions can show one’s creativity? The middleware component is very interesting for us system integrators but we build the system so that the end-user (the average scientist) can make their data exploration much faster and draw deeper insight into a situation. Computational scientists, meterologists and disaster rescue operatives coordinate their workflows together to support relief efforts in a natural disaster. It is indeed true that today’s grand challenges in science is also the concern of everyone in the society and not just a single discipline.

Other links that might be of interest is the press release of the previous winners. But I can’t find the links to the project deployments of the winning projects. Anyone know their URLs?

The Philippine National Public Key Infrastructure

About time. Original article from Inquirer.net: CICT explores use of digital signatures.

MANILA, Philippines–The Commission on Information and Communications Technology (CICT) has secured a $2.3-million grant from South Korea to help establish a national public key infrastructure (PKI) standards body in the Philippines.

This PKI body will be responsible for issuing digital signatures (or digital certificates) for individual and business users transacting with government-run websites.

It’s nice to know that got some grant so that the government can do some action. Doc Mana has been ranting about creating an infrastructure a few months ago during press releases about the modernization of the national elections.

Even if we did not receive a grant, the Philippines can creatively setup an infrastructure. Given that PKI technology is not new and a lot of local companies are providing these service anyway, we can simply setup a national federation of Certification Authorities (CAs) in the Philippines issues these public keys.

Probably most of the funds of the grant will go into the pilot deployment on government organizations like the BIR (which volunteered). But hey, how about Comelec? You guys have a deadline right?

Tweak your del.icio.us most visited sites

The del.icio.us Firefox add-on provides very neat integration into the latest version of Firefox three. I like the synchronization between local bookmarks, shortcuts, etc. The “most visited” tab actually counts how many times you clicked a bookmark and updates the toolbar respectively. The only problem is that for private bookmarks like the ones that initiate javascript link calls do not update the bookmark counters.

One of my favorite links is the citeulike.org’s add to library shortcuts which initiates a javascript call containing the current url on your browser such as an overview page of a journal article. This frustrated me for a while but after “grep”-ing my Firefox profile directory for the name of my citeulike bookmark, I edited the citeulike entry in my ~/.mozilla/firefox/$PROFILENAME/delcious.rdf:

<NC:Bookmark RDF:about="rdf:#$iw2hg3" NC:URL="javascript:var%20pw=window.open('http://www.citeulike.org/posturl?username=aespinosa&bml=popup&amp;url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title),%20'citeulike_popup_post',%20'width=800,height=600,scrollbars=1,resizable=1');%20void(window.setTimeout('pw.focus()',250));"
        NC:Name="CiteULike: A free online service to organise your academic papers"
        NC:ShortcutURL=""
        NC:Description=""
        NS1:LastCharset=""
        NC:PostData=""
        NS2:shared="false"
        NS2:localonly="false"
        NS2:hash="cfbf4f27149a10bca7a44c05be12ca99"
        NS2:metahash="af1dd1906f18340e4a74c20e9497ceb3">
    <NS2:tag>bibliography</NS2:tag>
    <NS2:tag>citation</NS2:tag>
    <NS2:tag>bookmarking</NS2:tag>
    <NS2:tag>research</NS2:tag>
    <NS2:tag>reference</NS2:tag>
    <NS2:tag>academic</NS2:tag>
    <NS2:tag>tagging</NS2:tag>
    <NC:VisitCount NC:parseType="Integer">300</NC:VisitCount>
    <NS1:LastModifiedDate NC:parseType="Date">Tue Jul 03 07:49:43 2007 +000000</NS1:LastModifiedDate>
    <NC:BookmarkAddDate NC:parseType="Date">Tue Jul 03 07:49:43 2007 +000000</NC:BookmarkAddDate>
</NC:Bookmark>

The code entry above shows the XML entry for a bookmark. Simply change the “NC:VisitCount” tag to a very high value and it will appear at the top of your del.icio.us toolbar most-visited tab.

Enjoy your new favorite bookmark!