Author Archive for Allan Espinosa

Technology for the masses’ sari-saris

The sari-sari store is a key economic and social installation in Filipino communities.  It allows the community easy access to basic good. The term sari-sari is Filipino for “various kinds”.  See more from its wikipedia entry.

Mark Ruiz of Hapinoy shares some updates on their company deploying a POS system for these sari-sari store. Technology is not only a key component in streamlining systems of today’s enterprises but it is also needed by people like Nanay Delia. Below is the image from his blog post:

Nanay Delia learning a Point-of-Sale System for her Sari-Sari Store. Whatever doubts of the applicability of technology for the smallest unit of retail were laid to rest after the training session. The potential of becoming more efficient in pricing controls, inventory management, and accounting were key benefits that were very much appreciated. [description from Mark Ruiz blog.

Nanay Delia learning a Point-of-Sale System for her Sari-Sari Store. Whatever doubts of the applicability of technology for the smallest unit of retail were laid to rest after the training session. The potential of becoming more efficient in pricing controls, inventory management, and accounting were key benefits that were very much appreciated. [description from Mark Ruiz' blog

Web2.0-generated wallpapers

blog pag background

Blog page background header

I decided to create a backround header image for my blog and Multiply page. Tons of randomly writter equations would be nice to have. The Yahoo Image search allows you to specify if you the types of pictures you want like black and white photos, image size, etc. I used the yahoo_collage.pl from Uppal’s blog and modified it to exceed the maximum images per query of 50 limit from Yahoo’s image search api. Below is the patch:

*** yahoo_collage.pl	2005-09-16 20:07:50.000000000 -0500
--- ycollage.pl	2008-08-13 13:56:45.000000000 -0500
***************
*** 1,4 ****
! #! /usr/local/bin/perl -w
  ################################################################################
  # Yahoo Image Search Collage Generator
  #
--- 1,4 ----
! #! /usr/bin/perl -w
  ################################################################################
  # Yahoo Image Search Collage Generator
  #
*************** my $count   = 50;
*** 33,38 ****
--- 33,39 ----
  my $file    = undef;
  my $width   = 50;
  my $height  = 50;
+ my $init = 0;

  GetOptions(
      'query=s'   => \$query,
*************** GetOptions(
*** 41,46 ****
--- 42,48 ----
      'width=i'   => \$width,
      'height=i'  => \$height,
      'help'      => \$help,
+     'init=i'      => \$init,
  );

  if ($help) {
*************** if ($help) {
*** 56,71 ****

  die("Must specify a query!\n") unless ($query);

! if ($count > Yahoo::Search::MaxCount('Image')) {
!     die("Yahoo! does not allow querying for more than " .
!         Yahoo::Search::MaxCount('Image') . " results at once!\n");
! }

  print STDERR "Querying Yahoo for "$query"...\n";
! my @results = Yahoo::Search->Results(
      Image => $query,
!     Count => $count,
! );

  print STDERR "Generating HTML...\n";
--- 58,86 ----

  die("Must specify a query!\n") unless ($query);

! #if ($count > Yahoo::Search::MaxCount('Image')) {
! #    die("Yahoo! does not allow querying for more than " .
! #        Yahoo::Search::MaxCount('Image') . " results at once!\n");
! #}

  print STDERR "Querying Yahoo for "$query"...\n";
! my $summary = Yahoo::Search->Query(
      Image => $query,
!     Count => "50",
! 	Start => $init,
! 	Color => "bw")->CountAvail;
! my $i;
! my @results;
! for($i = $init; $i < $count + $init; $i += 50)
! {
!     my @partial = Yahoo::Search->Results(
!         Image => $query,
! 		Start => $i,
!         Count => 50,
!         Color => "bw");
! 	push (@results, @partial);
! }
! print "Generated image $init to $i from $summary\n";

  print STDERR "Generating HTML...\n";
*************** sub generate_html {
*** 92,99 ****
      my $html_images = "";

      foreach my $image_result (@$ra_results) {
!         $html_images .= "<a href="" . $image_result->HostUrl() . ""> <img src="" .
!                         $image_result->ThumbUrl() . "" width=$width height=$height></a>";
      }

      my $html_credits = qq{Created with <a href="http://upster.blogspot.com">Siddharth Uppal</a>'s
--- 107,114 ----
      my $html_images = "";

      foreach my $image_result (@$ra_results) {
!         $html_images .= "<img src="" .
!                         $image_result->ThumbUrl() . "" border=0> ";
      }

      my $html_credits = qq{Created with <a href="http://upster.blogspot.com">Siddharth Uppal</a>'s
*************** sub generate_html {
*** 104,120 ****
      my $html_page = qq{
          <html>
          <head>
!         <title>Yahoo Image Search Collage Generator: $query</title>
          </head>
!         <body><center>
!         <font face="Trebuchet MS" color="Black" size="4"><b>$query</b></font><br>
!         <p align="center">$html_images</p>
!         <font face="Trebuchet MS" color="Black" size="2"><br><b>
!         To show off your collage, just copy and paste the text below into your blog or website!<br><br>
!         <textarea rows="25" cols="50">$html_images<br>$html_credits</textarea><br><font size="1"
!         face="Verdana" color="Gray">
!         </b><br>$html_credits
!         </center></body>
          </html>
      };

--- 119,129 ----
      my $html_page = qq{
          <html>
          <head>
!         <title>$query</title>
          </head>
!         <body style="width: 1024px;">
! 		<p align="center">$html_images</p>
!         </body>
          </html>
      };

Here are some selected of my generated collages:

latex equation

latex equation

modulator

modulator

Midwest Grid School 2008 @UChicago

Yey! Malapit na malapit lang :) More information about the program and registration information is found in its OSG Page. Workshop dates from Sept 17-19.

The Open Science Grid (OSG), the TeraGrid and the Computation Institute of The University of Chicago present a three day intensive course in grid computing and its application to scientific discovery.

The course introduces the techniques of grid and distributed computing for science and engineering fields, with hands-on training in the use of national grid computing resources. The workshop introduces essential skills that will be needed by researchers in the natural and applied sciences, engineering, and computer science to conduct and support large-scale computation and data analysis in emerging grid and distributed computing environments.

School participants will work with grid computing experts during the 3-day training. The workshop will focus on enabling the use of the national cyberinfrastructure -The Open Science Grid and TeraGrid- to perform large-scale computations and data-intensive processing in the your field of research. Participants will learn to use grids of thousands of processors and will be able to continue to use these resources for their research after the class. We encourage you to bring your research project to us for suggestions and help in porting your application to the grid. We would like to offer you support in transitioning your application to this platform.

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.