inspiredMind

The daily ramblings and code dump of John Barker.

XBoxLiveNation and Brightkite

XBoxLiveNation is making use of the library I created and providing updates about your xbox live status to your Brightkite stream!

Written by John

November 16th, 2008 at 11:36 pm

Brightkite PHP Object

There are a couple of more things that I would like added to this class but I have too many other things that take priority over this at the moment. Primarily the google map creation function..

If you do something with it, please post a link to it in the comments!

Usage example: $bkite = new brightkite(’username’, ‘password’); $bkite->post_note(”Post’s a note to your checked-in location.”);

<?php
 
/**
 *
 * Todo: Add the ability to checkin, post a photo, and add a comment.
 *
 **/
 
class Brightkite {
 
	private $location_address;
	private $location_name;
	private $location_long;
	private $location_lat;
	private $checkin_time;
	private $checkin_object_id;
 
	private $username;
	private $password;
 
	const GMAP_KEY = '';
 
	public function __construct($username, $password='') {
		$this->username = $username;
		$this->password = $password;
 
		$this->parse_data();
	}
 
	private function call_data() {
		$ch = curl_init();
 
		curl_setopt($ch, CURLOPT_URL, 'http://brightkite.com/people/'.$this->username.'.xml');
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 
		if (!empty($this->password)) {
			curl_setopt($ch, CURLOPT_USERPWD, $this->username.':'.$this->password);
		}
 
		curl_setopt($ch, CURLOPT_TIMEOUT, 20);
		curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 4);
		curl_setopt($ch, CURLOPT_HEADER, 0);
 
		$data = curl_exec($ch);
		$info = curl_getinfo($ch);
 
		curl_close($ch);
 
		return $data;
	}
 
	public function post_note($note) {
		if (!isset($this->checkin_object_id) || empty($this->checkin_object_id)) {
			return;
		}
 
		$ch = curl_init();
 
		curl_setopt($ch, CURLOPT_URL, 'http://brightkite.com/places/' . $this->checkin_object_id . '/notes');
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_USERPWD, $this->username.':'.$this->password);
		curl_setopt($ch, CURLOPT_POST, 1);
		curl_setopt($ch, CURLOPT_POSTFIELDS, array('note[body]' => $note));
 
		curl_exec($ch);
		curl_close($ch);
	}
 
	private function parse_data() {
		$xml_data = $this->call_data();
		$xmlObj = simplexml_load_string($xml_data);
		$place = $xmlObj->place;
 
		$this->checkin_time = $xmlObj->last_checked_in;
		$this->location_name = (!empty($place->name)) ? $place->name : '';
		$this->location_address = $place->display_location;
		$this->location_long = $place->longitude;
		$this->location_lat = $place->latitude;
		$this->checkin_object_id = $place->id;
	}
 
	public function makeGMap() {
 
	}
 
	public function getLatLong() {
		return array('lat' => $this->location_lat, 'long' => $this->location_long);
	}
 
	public function getLocationAddress() {
		return $this->location_address;
	}
 
	public function getLocationName() {
		return $this->location_name;
	}
 
	public function getLocationObect() {
		return $this->checkin_object_id;
	}
}
 
?>

Written by John

October 13th, 2008 at 10:56 pm

Posted in Technology, brightkite

Tagged with , ,

Why I love priceline…

Written by John

October 5th, 2008 at 5:01 pm

Posted in blog

Tagged with , ,

Looking good for a top draft…

So the Bengals went 0-5 today against the Dallas Cowboys. Overall they looked a lot better than the previous four games this season.

Chris Perry however has continued to hold his average of one fumble per game. His fumble definitely lost the game for us today.

I’m really beginning to question Marvin Lewis’ strategy now. I used to be a big fan of Marvin but no so much as of late. His decision to go for two AND on top of that to exclude Chris Henry in the 2-point attempt was just idiotic. Not to mention his horrible use of timeouts at the end of the game but we’ve all come to expect that from Marvin as it’s nothing new.

Houshmandzadeh becomes a free agent after this year and I guarantee he won’t resign with the Bengals. He’s too deserving of a ring and knows he’s not going to win one with the Bengals.

So the rest of the season, or at least the month of October looks very bleak for the Bengals. The Jet’s are next week, followed up with the Eagles and then the Steelers. Still possible for a winning season, but odds are against.

Written by John

October 5th, 2008 at 4:43 pm

Posted in football

Tagged with , ,

Brightkite Ubiquity Subscription

You can now subscribe to my brightkite ubiquity commands:
http://dev.d3sync.com/ubiquity/bkite

If you opt to auto-feed the subscription new commands and features will automatically become available to you as I add and change things!

Please send feedback! I’d love to hear what you have to say.

Written by John

September 30th, 2008 at 1:10 pm

Brightkite Ubiquity Message Command

Usage: bkmsg username message to send

Do take note that this is a bit buggy, and I whipped up in only a couple of minutes just to “get it out there.” If you have any suggestions please either comment or send me a message on brightkite.

const MSG_MAX_LENGTH = 140;
 
CmdUtils.CreateCommand({
	name: "bkmsg",
	icon: "http://brightkite.com/favicon.ico",
	takes: {"bkite username": noun_arb_text, "message to send": noun_arb_text},
	homepage: "http://dev.d3sync.com/ubiquity/bkite",
	author: {name: "John Barker", email: "john@brightkite.com"},
	modifiers: {},
	description: "Send a message to selected brightkite user.",
	help: "You'll need a <a href=\"http://brightkite.com\">Brightkite account</a>, obviously. If you're not already logged in you'll be asked to log in.",
 
	preview: function(pBlock, dObj) {
		var msg = dObj.text;
		var count = 0;
		var message = "";
		var pTpl = "Message to ${recipient}: ${message}</b><br/><br/>Characters remaining: <b>${chars}</b>";
		var truncateTemplate = "<br/>The last <b>${trunacte}</b> characters will be truncated!";
		var split = msg.split(" ");
		window.bkite_recipient = split[0];
 
		for (var i in split) {
			if (count > 0) {
				message += split[i]+" ";
			}
 
			count++;
		}
 
		var previewData = {
			message: message,
			recipient: window.bkite_recipient,
			chars: MSG_MAX_LENGTH - message.length
		};
 
		var previewHTML = CmdUtils.renderTemplate(pTpl, previewData);
 
		if (previewData.chars < 0) {
			var truncateData = {
				truncate: 0 - previewData.chars
			};
 
			previewHTML += CmdUtils.renderTemplate(truncateTemplate, truncateData);
		}
 
		pBlock.innerHTML = previewHTML;
	},
 
	execute: function(dObj) {
		var msg = dObj.text;
		var count = 0;
		var message = "";
		var split = msg.split(" ");
 
		for (var i in split) {
			if (count > 0) {
				message += split[i]+" ";
			}
 
			count++;
		}
 
		if (message.length < 1) {
			displayMessage("You must enter something for the message to be sent."); return;
		}
 
		var updateUrl = "http://brightkite.com/people/"+window.bkite_recipient+"/received_messages.json";
		var updateParms = {
			"message[body]": message
		};
 
		jQuery.ajax({
			type: "POST",
			url: updateUrl,
			data: updateParms,
			dataType: "json",
			// currently the api is quasi-broke. it returns false on even on success
			error: function(data) {
				displayMessage("Brightkite message sent.");
			},
			success: function() {
				displayMessage("Brightkite message sent.");
			}
		});
	}
});

Written by John

September 14th, 2008 at 5:07 am

Posted in Technology, brightkite

Tagged with ,

Fast Sync

Since disabling the “backing up” on iTunes/iPhone my syncs are now normal!

2-5 Mins tops!

Written by John

September 8th, 2008 at 1:23 am

Posted in Technology

Tagged with ,

Sluggish iPhone Backup

If you’re like me and hate the hours that it can take to backup/sync your iPhone, then disable backups altogether:

defaults write com.apple.itunes DeviceBackupsDisabled -bool YES

There you have it! Backups disabled now allowing you to only sync just like pre-2.0 era. If perhaps you decide you feel a little uneasy or unsecure about this change, simply change YES to NO.

Written by John

September 4th, 2008 at 10:58 pm

Posted in Technology

Tagged with , ,

Wordpress For iPhone

The wordpress app for the iPhone is awesome! Great for blogging on the go. It gives you control over everything even allowing you to post photos straight from the phone!

Written by John

September 2nd, 2008 at 9:37 pm

Posted in Technology

Tagged with ,

Comments!

Just installed the intensedebate comments. So comment away!

Written by John

September 1st, 2008 at 9:27 pm

Posted in Technology

Tagged with , ,