Creating Graphs with PHP

graph

I don’t recall where I grabbed this snippet of code, but it’s a very straight forward way to create a vertical bar chart using PHP.

Here’s the code:
<?php

// create an array of values for the chart. These values
// could come from anywhere, POST, GET, database etc.
$values = array(23,32,35,57,12,3,36,23,32,35,57,12,3,36,54,32,15,43,24,30);

// now we get the number of values in the array. this will
// tell us how many columns to plot
$columns = count($values);

// set the height and width of the graph image

$width = 500;
$height = 200;

// Set the amount of space between each column
$padding = 5;

// Get the width of 1 column
$column_width = $width / $columns ;

// set the graph color variables
$im = imagecreate($width,$height);
$gray = imagecolorallocate ($im,0xcc,0xcc,0xcc);
$gray_lite = imagecolorallocate ($im,0xee,0xee,0xee);
$gray_dark = imagecolorallocate ($im,0x7f,0x7f,0x7f);
$white = imagecolorallocate ($im,0xff,0xff,0xff);

// set the background color of the graph
imagefilledrectangle($im,0,0,$width,$height,$white);

// Calculate the maximum value we are going to plot
$max_value = max($values);

// loop over the array of columns
for($i=0;$i<$columns;$i++)
{
// set the column hieght for each value
$column_height = ($height / 100) * (( $values[$i] / $max_value) *100);
// now the coords
$x1 = $i*$column_width;
$y1 = $height-$column_height;
$x2 = (($i+1)*$column_width)-$padding;
$y2 = $height;

// write the columns over the background
imagefilledrectangle($im,$x1,$y1,$x2,$y2,$gray);

// This gives the columns a little 3d effect
imageline($im,$x1,$y1,$x1,$y2,$gray_lite);
imageline($im,$x1,$y2,$x2,$y2,$gray_lite);
imageline($im,$x2,$y1,$x2,$y2,$gray_dark);
}

// set the correct png headers
header (“Content-type: image/png”);
// spit the image out the other end
imagepng($im);
?>

Advertisements

For Sale 1995 Chevrolet Blazer LT (SOLD)

sany0541 sany0542 sany0543 sany0544 sany0545 sany0547
sany0550
sany0549
For sale: 1995 Chevrolet Blazer LT 4WD. SOLD
4.3L Vortec V6 engine.

111,648 Original Miles as of January 17th, 2009

Starts and runs fine.

Full disclaimer:

The ABS unit went out last August and I never checked in to how much that would cost to get fixed.

The transmission shifts fine for normal driving, but the reverse gear is having some issues. I’ve been told that was a common problem for this vehicle.The transmission repair might cost around $800 or so.

The latch on the rear glass, which is normally glued to it, has come undone and I have tried using Gorilla Glue but it didn’t hold. You might know what it takes to fix it, or you could replace the whole rear glass for about $300.

It has a new set of tires, upper and lower u-joints are new, tie-rod ends are new, steering tension bar is new, radiator is new.

All of those part replacements were made because of normal wear.

With a little money put into it, you’d have a really clean and reliable vehicle for many miles to come. We’ve just acquired another vehicle and are no longer needing this one.

Asking Price: $2,100 cash

Vehicle is in Independence, Missouri 64055

UPDATE: This vehicle has been sold. Thanks!

If you knew, what would you do?

Imagine that you were given the knowledge of exactly when someone that you know is going to die.

Also, imagine that somehow if you told them about it, it would mean that you would instantly fall over dead.

(tough criteria, I know, but bear with me…)

Now, image having lots of conversations with that person – let’s say that they are telling you all of their plans for some great new online application that they are making, or perhaps they are telling you all about this new house they are going to have built.

Given what you know about them, would you listen with intent and encouragement? Would you show compassion to them knowing that whatever their dreams or plans are would never be complete?

What would you do?

Ok, assuming that most of you said that yes, you would be as compassionate as possible and show them support, etc. the real question here is this – Since none of us really know exactly when that moment is going to come, why don’t we show the same level of compassion for each and everyone that we interact with?

Why would the value of their life seem greater if we knew exactly when it was going to end?

What were you thinking about when you were reading this post?

Please chime in with the comments – if you’d like to comment on Twitter, that’s fine, but please also do so here so that the conversation will have some sort of longevity.

Maybe one day I will be a rockstar

httpv://www.youtube.com/watch?v=LRgbO7pOESU

Sorry about the volume issue in the second half – I’ll need to figure out another way to record this if I do it again.

Aiming for a better bod

On December 26th, 2008 my wife and I, along with our two kids, took a trip to our local shopping mall where we visited the GNC nutritional supplement store and I purchased the GNC Pro Performance Maximum Hardcore Muscle Stack kit.

gnc1-5314754dtI started taking it that afternoon and on December 27th, 2008 (the next day) I had my first workout in almost one year.

I workout every other day, so as of today I have had seven workouts.

I already feel more tone and I seem to be standing up straighter (simply because it now feels better than slouching).

My workout routine isn’t anything fancy. I have a set of free weights with two barbells, a dumbbell, a preacher bar and a weight bench. There’s about 320lbs of weights.

I am not doing any lower-body workouts, but I plan on adding that in about two months.

For abs, I do three sets of 13 crunches, while holding a 45lb weight against my chest. I also do three sets of leg lifts.

For the bench press, I do three sets of 8 reps and add more weight before each workout (I’ve added weight 6 times). I am currently bench pressing 130 lbs.

I also do curls with the dumbbells, again three sets of 8 reps each.  I have a few more exercises, but right now I’m not sure of what the common name is for them. One is for the triceps where you squat on the bench with one knee and hand and raise the dumbbell up and extend your arm backwards.

I’ve been focusing on Form over quantity of reps, so I’d rather have 6 good reps rather than 8 sloppy ones.

I imagine after I keep this up for awhile I will develop a more rigid routine and begin to target individual muscles, but for now, just making the workout routine a regular part of my life is my main goal.

Baby steps.

2009 the year ahead

sonyvaioHappy New Year everyone – I hope that the next 12 months lead you even closer to whatever it is that you want.

For me, it will be a continuation of a simplification process.

As we no longer use credit cards at all, we’ve pretty much gone to a cash-and-carry lifestyle (that’s helped out a bunch – impulse purchases aren’t really all that satisfying anyhow).

Gadgets, gadgets, gadgets – somehow (as if I don’t know how ;^) over the last few years I’ve ended up with several digital cameras, about 5 mp3 players, 2 laptop computers and 4 desktop machines – I’m still on the quest to find a single machine and OS which I can use on a daily basis.

As many of you already know, my desk contains 3 machines – a Windows XP machine, a MacBook Pro and another machine running some flavor of Linux (currently, Kubuntu 8.10). I have yet to find a single platform which allows me to do everything that I need – they all get “close” but there are still things missing from one platform to the next. I’ll continue the search…

MP3 players -of all of them (iRiver, Creative Zen Xtra 30GB, 8GB iPod Touch, iPod 30GB video) I prefer the Zen Xtra – I’m not really sure why, it has the largest physical size – perhaps it it reminiscent of my first Game Boy device (which I played for-evah!). For the rest of them, well – I added all of my CD’s to the Zune yesterday – but today I find myself copying that music library over to the Zen – I’ll need to get rid of the others (wife and kids first, sorry! ;^)

Electricity – we’ve been using less and have also been replacing each light bulb in the house with the twistie compact fluorescents. Our electric bill was $44 less in December than it was in November and we used almost 500kW less power. Our goal would be to use less than 8kW on a daily basis. Part of our reduction was to elimate our use of a second freezer which we kept in the garage.

MobaTalk – Dozens of iterations past, I have the system framed in and now it’s a matter of completing the coding and getting it released. Ever forward!

How’s your 2009 starting out so far? There are only 350 days left until 2010 – get crackin’! ;^)

Schulz Philosophy

I received the following in an email, and of course, I never “forward to 10 people” so here it is for all 48,000 of you who read this blog.

The following is the philosophy of Charles Schulz, the creator of the ‘Peanuts’ comic strip.

You  don’t have to actually answer the  questions.

Just read it straight through, and you’ll get the point.

  1. Name the five wealthiest people in the  world.
  2. Name the last five Heisman trophy  winners.
  3. Name the last five winners of the Miss America  pageant.
  4. Name ten people who have won the Nobel or  Pulitzer  Prize.
  5. Name the last half dozen Academy Award winners  for best actor and actress.
  6. Name the last decade’s worth of World Series  winners.

How  did you  do?

The point is, none of us remember the headliners of yesterday.

These are no second-rate achievers.

They are the best in their fields, but the applause dies…Awards tarnish…Achievements are forgotten.

Accolades and certificates are buried with their owners.

Here’s another quiz.

See how you do on this one:

  1. List a few teachers who aided your journey through school.
  2. Name three friends who have helped you through a difficult time.
  3. Name five people who have taught you something worthwhile.
  4. Think of a few people who have made you feel appreciated and special!
  5. Think of five people you enjoy spending time with.

Easier?

The lesson:

The people who make a difference in your life are not the ones with the most credentials, the most money, or the most awards.

They simply are the ones who care the most.