archive

Archive for the ‘Programming’ Category

Data Converter

Tuesday, September 7th, 2010

Takes CSV or tab-delimited data from Excel and converts it into several web-friendly formats, include JSON and XML.

Boxplot

Thursday, August 26th, 2010

Great script (in CSS and Javascript) which makes it really easy to display boxplots on a website. Great!

Debugging AJAX

Monday, August 16th, 2010

Need to debug AJAX? Beside some tips I found on the Net, here is one I found particularly useful, at least in my current case. Just use a

tail -f /private/var/log/apache2/access_log

Or

tail -f /private/var/log/apache2/error_log

which displays the latest log entries… which can help to solve some major issues.

Export to Mapserver

Tuesday, August 3rd, 2010

Gix, this extension helps GIS developers to migrate ESRI ArcView projects to the most popular Free and Open Source alternatives for Geographic Information Systems (GIS).

Interactive Map

Tuesday, August 3rd, 2010

Like that one. Lightweight, easy, supply of additional information by mouseover. Really neat.

Mapserver

Tuesday, July 27th, 2010

Nice mapserver, enabling vector display as well. Based on GeoExt.

Public Data and theirs Mashups

Thursday, March 18th, 2010

Datamob highlights the connection between public data sources and the interfaces people are building for them.

TED: Gary Flake: is Pivot a turning point for web exploration?

Thursday, March 4th, 2010

PHP: Significant Numbers

Monday, December 28th, 2009

/**
* Formats numbers to the specified number of significant figures.
*
* @author Bevan Rudge, Drupal.geek.nz
*
* @param number $number
* The number to format.
* @param integer $sf
* The number of significant figures to round and format the number to.
* @return string
* The rounded and formatted number.
*/
function format_number_significant_figures($number, $sf) {
// How many decimal places do we round and format to?
// @note May be negative.
$dp = floor($sf - log10(abs($number)));
// Round as a regular number.
$number = round($number, $dp);
// Leave the formatting to format_number(), but always format 0 to 0dp.
return number_format($number, 0 == $number ? 0 : $dp);
}
?>

… and another one ….

round(1241757, -3); // 1242000
RoundSigDigs(1241757, 3); // 1240000
?>

Works on negative numbers too. $sigdigs should be >= 0

function RoundSigDigs($number, $sigdigs) {
$multiplier = 1;
while ($number < 0.1) {
$number *= 10;
$multiplier /= 10;
}
while ($number >= 1) {
$number /= 10;
$multiplier *= 10;
}
return round($number, $sigdigs) * $multiplier;
}
?>

PHP: Change Units

Monday, December 28th, 2009

Outputs a human readable number.

  # Output easy-to-read numbers
  # by james at bandit.co.nz
  function bd_nice_number($n)
  {
    // first strip any formatting;
    $n = (0+str_replace(",","",$n));

    // is this a number?
    if(!is_numeric($n)) return false;

    // now filter it;
    if($n>1000000000000) return round(($n/1000000000000),1).' trillion';
    else if($n>1000000000) return round(($n/1000000000),1).' billion';
    else if($n>1000000) return round(($n/1000000),1).' million';
    else if($n>1000) return round(($n/1000),1).' thousand';

    return number_format($n);
  }
?>

Outputs:

247,704,360 -> 247.7 million
866,965,260,000 -> 867 billion

Source

Treemap for Population

Monday, December 28th, 2009

Picture 252Some nice data visualization.

Number of Links to a Website

Thursday, December 24th, 2009

Picture 249Good tool to see how many web pages are linking to someone elses website.

Nice Registration Form

Tuesday, December 22nd, 2009

moof_com
Very nice login/registration form. See it here in action.

Climate Change

Monday, December 14th, 2009

Picture 240

Webpage Layout

Wednesday, November 25th, 2009

Picture 14
The 960 Grid System is an effort to streamline web development workflow by providing commonly used dimensions, based on a width of 960 pixels. There are two variants: 12 and 16 columns, which can be used separately or in tandem.

TreeMap

Tuesday, September 8th, 2009

picture-118Nicely done, and a couple of cool drill-down functionalities with this library.

Generate Keys

Monday, June 29th, 2009

picture-25Nice small app, in case you need to create some “passwords”, or lengthly keys.

PHP: Significant Values

Tuesday, March 24th, 2009

Here’s a function that uses PHP’s round() to calculate significant figures:

function sigFig($value, $sigFigs) {
$exponent = floor(log10($value) + 1);
$significand = $value / pow(10, $exponent);
$significand = round($significand * pow(10, $sigFigs)) / pow(10, $sigFigs);
$value = $significand * pow(10, $exponent);
return($value);
}

//Examples
sigFig(123.45, 6); // 123.45 (doesn't pad with zeros)
sigFig(123.45, 5); // 123.45
sigFig(123.45, 4); // 123.5
sigFig(123.45, 3); // 123
sigFig(123.45, 2); // 120 (rounds to 2 figures)
sigFig(123.45, 1); // 100
sigFig(123.45, 0); // 0 (!)
?>

Data Display: State of the Salmons (II)

Friday, March 6th, 2009

picture-207.pngpicture-208.pngAnother nice visualization of assessment data.

Data Display: State of the Salmons

Friday, March 6th, 2009

picture-203.pngpicture-204.pngNice visualization coming out of IUCN, a little bit unexpected to me. Although very visually attractive, one has always to ask if the display achieves what it is supposed to do: bring a message across, show trends, etc.