./paulOr

Eat bandwidth for breakfast!

Parsing CSV files with PHP

Posted on Thu 1st Jul 2010 · Development · 0 Comments

Today at work I had the amazing job of importing around 50 different artists profiles in to a database - each with about 12 different columns of values in a CSV file.

I could copy & paste it from the document - or create a quick little import script... Yea, I made an import script :]

<?php
	$file_handle = fopen("file.csv", "r");
	while (!feof($file_handle)) {
		$data = fgetcsv($file_handle, 1024);

		## PARSE THE VALUES OF EACH CELL
		## STARTING AT 0 AND WORK YOUR WAY ALONG
		$data[0].'<br />';
		$data[1].'<br />';
		$data[2].'<br />';
		$data[3].'<br />';

		## AND SO ON...
	}

	fclose($file_handle);
?>

Show/Hide Elements w/ jQuery

Posted on Tue 29th Jun 2010 · Development · 0 Comments

I'm currently making a site which requires a rollover on an image that will show the images name and a description in a div which appears on hover.

Heres how I've done it.

<!-- JQUERY FROM GOOGLE AND JS UNDER IT -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script>
$(document).ready(function() {
	$(".image_slide").hover(
		function() { $(this).children('.slide_info').show(); },
		function() { $(this).children('.slide_info').hide(); }
	);
});
</script>

<!-- HIDE BY DEFAULT WITH CSS :] -->
<style>
.slide_info {
	display: none;
}
</style>

<!-- HTML ELEMENTS -->
<div class="image_slide">
	Image
	<span class="slide_info">Image info & Description</span>  
</div>
<div class="image_slide">
	Image
	<span class="slide_info">Image info & Description</span>  
</div>
<div class="image_slide">
	Image
	<span class="slide_info">Image info & Description</span>  
</div>

DailyBooth API: Most Recent Snap

Posted on Wed 23rd Jun 2010 · Development · 2 Comments

The DailyBooth API is a land yet to be chartered when it comes to developing on it. Its very much still in beta, and Jon or Ryan might even shout at me for starting to document into at this stage. But i'm willing to risk it!

Overall, DailyBooth API is pretty straight forward and really quite simple, which is great. Ill quickly show you how to grab your most recent snap via the API.

<?php

	## GET THE USERS USER ID VIA THERE USERNAME
	$userID = json_decode(file_get_contents('http://api.dailybooth.com/v1/user/id/paul.json'));

	## NOW COLLECT THE IMAGES FROM THERE FEED, VIA THERE USERID
	$feed = json_decode(file_get_contents('http://api.dailybooth.com/v1/user/pictures/'.$userID[0].'.json'));

	## PRINT OUT THE IMAGE
	echo '<img src="'.$feed[0]->urls->medium.'" />';
	

?>


More soon, If Jon & Ryan don't go wild at me!

Just playing to try learn more about WordPress as I have taken a drastic disliking to it as of recent, which is probably due to the fact I haven't really given it the time of day so far.

This adds javascript to your header that will activate Twitters @Anywhere API stuff and also add hovercards.

<?php
	/*
	Plugin Name: Twitter @Anywhere
	Description: Add Twitters @Anywhere to Wordpress 3.0
	Version:     0.1
	Author:      Paul Fraser
	Plugin URI:  http://www.paulOr.net
	Author URI:  http://www.paulOr.net
	*/

	function add_twitter_anywhere() {
		echo '<script type="text/javascript" src="http://platform.twitter.com/anywhere.js?id=<-- API KEY -->&v=1"></script>'."\n";
		echo '<script type="text/javascript">'."\n\t";
		echo 'twttr.anywhere(function(twitter) {'."\n\t";
		echo 'twitter.hovercards();'."\n";
		echo '});'."\n";
		echo '</script>'."\n";
	}

	add_action( 'wp_head', 'add_twitter_anywhere' );
?>


Remember and add your API key...

To the top!