Archive for March, 2009

Whatpulse API

I was reading this thread: http://forums.whatpulse.org/showthread.php?p=22448#post22448 and thought I had the solution here:

<?php
//** read whatpulse userstats **//
// $userid = your whatpulse userid
// $optionsArr = the items you want (read the xml file first)
function readUserStats($userid, $optionsArr) {
// prepare an array to hold your stats
$WhatPulseStats = array();

// types of statistics
$stat_types = $optionsArr;
if(count($stat_types) == 0) {
$stat_types = array(”AccountName”,
“TotalKeyCount”,
“TotalMouseClicks”,
“Rank”,
“GeneratedTime”,
“TotalMiles”);
}

// init the xml parser and read the data into an array
$data = file(”http://whatpulse.org/api/user.php?UserID=”.$userid);
$data = implode(”", $data);
$parser = xml_parser_create();
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
xml_parse_into_struct($parser, $data, $values, $tags);
xml_parser_free($parser);

// loop through the structures
foreach ($tags as $key => $val) {
// only process stuff between the tags
if ($key == “UserStats”) {
// loop through the tags inside
$ranges = $val;
for ($i = 0; $i < count($ranges); $i += 2) {
$offset = $ranges[$i] + 1;
$len = $ranges[$i + 1] – $offset;
$statsarray = array_slice($values, $offset, $len);

// loop through the structure of the xml tag
foreach($statsarray as $key => $value) {
// match to a stats_type
for($i = 0; $i < count($stat_types); $i++) {
if($value['tag'] == $stat_types[$i]) {
// remember the value of the stats_type
$type = $stat_types[$i];
$WhatPulseStats[$type] = $value['value'];
}
}
}
}
}
else {
continue;
}
}
return $WhatPulseStats;
}

?>

send me a comment if it works

Tags: ,

St Patt’s day class-up

I pursued my regular daily routine with climbing out of my rack, and going to holds around 1830, to find that I’d finally classed up. The method to going about the curriculum is totally different than back at ATT, its pretty weird to have to relearn everything. The instructor seems pretty chill (I think he told me to fuck myself yesterday though), and so far things are simple enough to go about.

It didn’t seem like much else was being said or done that wasn’t a gripe or moan about how shitty it was to have duty on St Patrick’s day and how all the bars were going to be closed before they all got out (class ranges between 1500 – 0000). To agree with them, it was the shittiest St. Patrick’s day I’ve ever observed, I didn’t get a single beer or get to watch anything related to a parade :(

Tags: , , ,

Chi-town St. Patty’s day weekend

Boy was it a weekend to remember. Good people, good booze, good hospitality, and bad farts. Hung out downtown on the magnificent mile, stayed in the Inn of Chicago and got to see the river turn green! Of course there were plenty of drunken non-irish kids playing around the whole day Friday and Saturday downtown, especially after the parade cleared up, the bars ran out of green dye, and the women had all the green beads that they could possibly carry around their necks. I did manage to get a collage of random pictures from the weekend (here). I hope you enjoy!

Tags: , , , , , , , ,