Tag: Google

Charting Weight Change With Google Visualizations

July 5, 2010 » Consume, Geek, Life

I started trying to lose weight a while back, since we both know I’m a bit heavy and sitting in front of a computer isn’t going to lose the weight for me.

Naturally, it’s important that I incorporate technology into my weight loss somehow, right? So I decided to give the Google Visualizations API a spin.

I worked up a quick data format and a method to pop the data out. Nothing fancy, just a fixed width flat file. This doesn’t deserve a database.

1
2
2010-06-30 235.4
2010-06-29 236.8

Easy to read, easy to edit, and easy to consume. Every morning I just hop on the server, add the day’s weight and log off.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
  // Get the max days back we want to look.
  $max_days = 7;
  if( isset( $_REQUEST['days'] ) and ! empty( $_REQUEST['days'] ) )
    $max_days = intval( $_REQUEST['days'] );
 
  $i = 0;
  $lines = array();
 
  $fh = fopen( 'data.txt', 'r' );
  while( ! feof( $fh ) and ++$i <= $max_days ) {
    $line = fgets( $fh );
    if( empty( $line ) ) { continue; }
    array_unshift( $lines, $line );
  }
  fclose( $fh );

Now I just needed to represent it. The API is very object oriented and easy to work with. I wish there was a less verbose way of presenting the data, but you can’t have everything.

Actually, there may be a better way, I just didn’t come across it while speed reading the docs.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
function drawChart() {
  var data = new google.visualization.DataTable();
  data.addColumn( 'string', 'Date' );
  data.addColumn( 'number', 'Weight' );
 
  data.addRows( <?php echo count( $lines ); ?> );
 
  <?php
    $i = 0;
    foreach( $lines as $line ):
  ?>
  data.setValue(
    <?php echo $i; ?>,
    0,
    '<?php echo substr( $line, 0, 10 ); ?>'
  );
 
  data.setValue(
    <?php echo $i; ?>,
    1,
    <?php echo floatval( substr( $line, 11 ) ); ?>
  );
  <?php
    ++$i;
    endforeach;
  ?>
 
  var chart_div = document.getElementById( 'chart_div' );
  var chart = new google.visualization.LineChart( chart_div );
  chart.draw(
    data,
    {
      width: 800,
      height: 600,
      title: 'Weight Over Time'
    }
  );
}

And there you have it, fancy charting in no time.

Example Chart

See it in action at http://static.velvetcache.org/weight.php

Get the full source at http://gist.github.com/459148.

Google: We’re Sorry

April 28, 2010 » Geek

So this is a new one. I left my laptop alone with two Gmail’s and Google Reader open in Firefox. When I came back they had locked up, as Firefox sometimes does.

I restarted Firefox (kill -9 ftw!) and when I did Google had a quick humanity test for me.

Sorry!

I assume that my Firefox was spamming them with requests while it was locked up, so this isn’t “weird” per-say, just new to me. Thought I’d share!

Gmail Attachment Gets Stuck Scanning For Virus

December 26, 2008 » Geek

I’ve been having trouble with Gmail for my domain getting stuck scanning for viruses on my attachments, which means I can’t download them, which is annoying.

I got fed up with waiting for Gmail, so I just got them through the old fashioned means.

Here’s how…


Attachment is stuck…


View the original message…


What that looks like (click image for bigger view)


Find the base64 encoded contents of your attachment (click image for bigger view)

Then you just copy and paste that into a file and run it through base64, a la $ base64 -d getImage.raw > getImage.php

A Great Moment In My Life

January 25, 2007 » Geek, Life

It’s a momentous occasion! Today, as of 1/25/07, I am the top-ranked page on Google for the search terms “expired mayonnaise“.
All because of this little post: Expired Mayonnaise Really Doesn’t Taste All That Different. My mother would be so proud. I think I’m going to make a little tracker to see how long I can stay in spot #1. It will be a grand experiment in SEO.

Tags:

Gregarius And Google Reader Update

September 28, 2006 » Geek

I just finished installing Gregarius because I wanted to access my feeds no matter where I was and have a consistent read/unread status across all machines. Before I used to use RSSOwl, which is a great app, but when I got home I would have to go through and “read” items I had already read elsewhere. I had tried Google Reader, but there weren’t enough features.

Sure enough, as soon as I installed Gregarius on Dreamhost one of the first feed’s was Robert Scoble’s. It was a brief on the new Google Reader features. I’m going to try out the new Google Reader, but for now I’ll leave Gregarius installed, as it’s a very nice application.