Archive for the ‘Uncategorized’ Category

Using Google Charts API inside jQuery .load()

Monday, September 3rd, 2012

I recently tried using the Google Charts API on a page which had been .load()ed in jQuery (AJAX) and I was running into a weird problem: loading the chart would cause the page to redirect to the code for the chart, resulting in an abort of the actual page loading and a blank screen.

I used the following code which fixes the issue, note the use of the callback parameter in google.load().


<div id="chart" style="width: 100%; height: 500px;"></div>

<script type="text/javascript">

	google.load("visualization", "1", {packages:["corechart"], callback:drawChart});

	function drawChart() {
 		var jsonData = $.ajax({
			url: "generate_data.php",
			dataType:"json",
			async: false
        	}).responseText;

		var options = {
			title: 'Your Chart Title'
		};

		var data = new google.visualization.DataTable(jsonData);

        var chart = new google.visualization.LineChart(document.getElementById('chart'));
        chart.draw(data, options);
      }
</script>

How to enable Zeroconf for Apache

Monday, November 14th, 2011

Zeroconf is a great way for hosts and services to advertise themselves on the network. Unfortunately, Apache doesn’t provide support for advertising itself as an HTTP service out-of-the-box, so you’ll need to do some work to get it working.

There are two methods, the first use mod_dnssd which is good because it ties directly into Apache, so when Apache runs, it advertises, but when Apache is down (for whatever reason), then it stops advertising. It also means any changes you make to your Apache configuration (e.g. port) are automatically reflected in the advertisement.

The second method uses the built-in Zeroconf daemon in *nix called Avahi. Avahi is similar to Bonjour/mDNSResponder on Mac OS X and is used to advertise services to the network. By creating a basic XML file and attaching it to Avahi, your service will be advertised as long as the system is running. Using Avahi gives you the flexibility to advertise any service (not just Apache/HTTP) and is also a lot simpler to get up and running. I will outline both approaches here.

(more…)

Hello world!

Sunday, November 13th, 2011

Hello, hello and welcome to my blog!

I intend to keep this blog updated with information about what projects I’m working on, and will also be offering walkthoughs, tips and tricks to both beginners and seasoned developers.