<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>FunkyNERD</title>
	<atom:link href="http://www.funkynerd.com/feed" rel="self" type="application/rss+xml" />
	<link>http://www.funkynerd.com</link>
	<description>geek-&#62;code.execute()</description>
	<lastBuildDate>Mon, 26 Jul 2010 01:17:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>XML-RPC client class in PHP</title>
		<link>http://www.funkynerd.com/xml-rpc-client-class-in-php</link>
		<comments>http://www.funkynerd.com/xml-rpc-client-class-in-php#comments</comments>
		<pubDate>Mon, 26 Jul 2010 01:09:38 +0000</pubDate>
		<dc:creator>Jazz</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://www.funkynerd.com/?p=160</guid>
		<description><![CDATA[I currently have a project that requires communicating with a 3rd party application server via XML-RPC.  Having never worked with XML-RPC before  I went looking for a PHP wrapper class that could help.  Unfortunately I couldn&#8217;t find one so I had to write one from scratch.  I have decided to publish it here for anyone [...]]]></description>
			<content:encoded><![CDATA[<p>I currently have a project that requires communicating with a 3rd party application server via XML-RPC.  Having never worked with XML-RPC before  I went looking for a PHP wrapper class that could help.  Unfortunately I couldn&#8217;t find one so I had to write one from scratch.  I have decided to publish it here for anyone else that needs to use XML-RPC in PHP and wants a tidy wrapper class to make life easier.</p>
<p><span id="more-160"></span></p>
<p>This class makes use of a fantastically powerful and dangerous &#8216;magic&#8217; method named <strong><em><a href="http://php.net/manual/en/language.oop5.overloading.php">__call</a></em></strong>.   What __call does is allows any inaccessible method to be overloaded.  This means that when you instantiate the class, ANY method that is not accessible in the class will run through the __call method.  Therefore it is possible to use this class to execute methods on the remote application server.</p>
<p>Enjoy</p>
<pre>class xmlrpc_client {
 private $url;
 private $proto = 'http';
 private $host;
 private $fhost;
 private $uri = '/';
 private $port = 80;

 private $method_pfx = '';

 private $debug = false;

 function __construct($url, $method_pfx = '', $debug = false){

  $this-&gt;method_pfx = $method_pfx;
  $this-&gt;debug = $debug;

  if(preg_match('/(\w*):\/\/(.*?)(\/.*)/', $url, $matches)){
   list($this-&gt;url, $this-&gt;proto, $this-&gt;host, $this-&gt;uri) = $matches;
   switch($this-&gt;proto){
    case 'http':
     $this-&gt;port = 80;
     $this-&gt;fhost = $this-&gt;host;
     break;
    case 'https':
     $this-&gt;port = 443;
     $this-&gt;fhost = 'ssl://' . $this-&gt;host;
     break;
    default:
     $this-&gt;dbg("Unknown protocol '$this-&gt;proto'.  Defaulting to port $this-&gt;port.");
     return;
     break;
   }
   $this-&gt;dbg("Correctly parse URL '$this-&gt;url'");
  }else{
   $this-&gt;dbg("Invalid URL supplied");
   return;
  }
 } 

 private function dbg($string, $op_xml = null, $force = false){
  if(!$force &amp;&amp; !$this-&gt;debug) return;
  echo "&lt;h3&gt;$string&lt;/h3&gt;";
  if($op_xml) echo "$op_xml";
 }

 private function notice($string, $op_xml = false){
  return $this-&gt;dbg($string, $op_xml, true);
 }

 public function __call($name, $args){

  if(!$this-&gt;fhost &amp;&amp; !$this-&gt;port &amp;&amp; !$this-&gt;uri){
   $this-&gt;dbg('No host, port or URI has been specified');
   return;
  }

  $method = ($this-&gt;method_pfx?$this-&gt;method_pfx . '.':'') . $name;
  $response = '';

  $this-&gt;dbg("Generating request for method '$method'");

  $output = array('version' =&gt; 'xmlrpc');
  $request = xmlrpc_encode_request($method, $args, $output);

  $this-&gt;dbg("opening socket to host: $this-&gt;fhost, port: $this-&gt;port, uri: $this-&gt;uri");
  $sck_fd = fsockopen($this-&gt;fhost, $this-&gt;port, $errno, $errstr, 3);

  if($sck_fd){

   $content_len = strlen($request);

   $http_request =
           "POST $this-&gt;url HTTP/1.0\r\n" .
           "User-Agent: xmlrpc-epi-php/0.2 (PHP)\r\n" .
          "Host: $this-&gt;host\r\n" .
          //$auth .
           "Content-Type: text/xml\r\n" .
           "Content-Length: $content_len\r\n" .
           "\r\n" .
           $request;

   $this-&gt;dbg("Sending HTTP request:", $http_request);

   fputs($sck_fd, $http_request, strlen($http_request));

   $this-&gt;dbg('Receiving response');

   $header_parsed = false;

   $line = fgets($sck_fd, 4096);
   while ($line) {
    if(!$header_parsed){
     if($line === "\r\n" || $line === "\n"){
      $this-&gt;dbg('Got header:', $header);
      $header_parsed = 1;
     }else{
      $header .= $line;
     }
    }else{
     $response_buf .= $line;
    }
    $line = fgets($sck_fd, 4096);
   }

   fclose($sck_fd);

   $this-&gt;dbg('Reponse:', $response_buf);

   $response = xmlrpc_decode($response_buf);

   if((is_array($response)?xmlrpc_is_fault($response):false)){
    $this-&gt;notice("Error #$response[faultCode] - $response[faultString]");
    $response = null;
   }

  }else{

   $this-&gt;dbg("Unable to open socket.  ERR: $errno# - $errstr");
  }

  return $response;
 }

}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.funkynerd.com/xml-rpc-client-class-in-php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FunkyNERD (p)re-launch!</title>
		<link>http://www.funkynerd.com/funkynerd-pre-launch</link>
		<comments>http://www.funkynerd.com/funkynerd-pre-launch#comments</comments>
		<pubDate>Wed, 21 Jul 2010 04:11:30 +0000</pubDate>
		<dc:creator>Jazz</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://www.funkynerd.com/?p=122</guid>
		<description><![CDATA[A while back I decided to ditch FunkyNERD.com and just use at as an email domain.  But, I have started developing for Android lately and so I have decided to revive FunkyNERD and use that as my developer account with Google.  So while I was at it I decided to add some of my other [...]]]></description>
			<content:encoded><![CDATA[<p>A while back I decided to ditch FunkyNERD.com and just use at as an email domain.  But, I have started developing for Android lately and so I have decided to revive FunkyNERD and use that as my developer account with Google.  So while I was at it I decided to add some of my other projects.</p>
<p>So, this is sort of a &#8220;soft launch&#8221; so that people that are looking for articles on the old website know what it going on.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.funkynerd.com/funkynerd-pre-launch/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Merging multiple AVI files into one on Linux</title>
		<link>http://www.funkynerd.com/merging-multiple-avi-files-into-one-on-linux</link>
		<comments>http://www.funkynerd.com/merging-multiple-avi-files-into-one-on-linux#comments</comments>
		<pubDate>Sat, 21 Nov 2009 04:28:37 +0000</pubDate>
		<dc:creator>Jazz</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://www.funkynerd.com/?p=138</guid>
		<description><![CDATA[Occasionally I come across AVI files that have been split up, for whatever reason, and I want to put them back into one file. Every time I do, I end up having to dig through tonnes of Google search results to find what I want and then make sense of it. Therefore I decided to [...]]]></description>
			<content:encoded><![CDATA[<p>Occasionally I come across AVI files that have been split up, for whatever reason, and I want to put them back into one file.  Every time I do, I end up having to dig through tonnes of Google search results to find what I want and then make sense of it.  Therefore I decided to figure out the best way to get this work for me and then do this little write up.</p>
<p><span id="more-138"></span>What I discovered, is that it&#8217;s actually VERY easy and you can do it in one command.</p>
<p><strong>Step 1 &#8211; Install mencoder</strong></p>
<p>This is easy.  Simply execute the following:</p>
<p><code>sudo apt-get install mencoder</code></p>
<p>This will install mencoder which is the program we&#8217;ll use to merge and fix up the AVI files.  This will also install any dependencies along with it.</p>
<p><strong>Step 2 &#8211; Merge and re-index</strong></p>
<p>This is the meat of it.  It&#8217;s just one command that until now I never knew could actually take multiple files for input.</p>
<p><code>mencoder -forceidx -oac copy -ovc copy file1.avi file2.avi -o output.avi</code></p>
<p>This command does a couple of things in one go.  Not only will it merge the file1.avi and file2.avi files, it will re-index the streams so that the audio and video are synced correctly.  This is usually a problem when you merge files the &#8216;old fashioned&#8217; way by simply running cat file1.avi file2.avi &gt; output.avi.   Now because this isn&#8217;t actually changing any of the audio or video data (it&#8217;s just copying it) this should be quite quick.  I merged two ~700MB files and it took about 5 minutes.</p>
<p>You could also, if you want, change the -ovc copy to make it re-compress the video to make the file smaller.  So maybe I&#8217;ll do that in another post.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.funkynerd.com/merging-multiple-avi-files-into-one-on-linux/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>uShoot – Job management for creatives</title>
		<link>http://www.funkynerd.com/ushoot-%e2%80%93-job-management-for-creatives</link>
		<comments>http://www.funkynerd.com/ushoot-%e2%80%93-job-management-for-creatives#comments</comments>
		<pubDate>Wed, 21 Oct 2009 04:27:12 +0000</pubDate>
		<dc:creator>Jazz</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://www.funkynerd.com/?p=136</guid>
		<description><![CDATA[Even though I am a software developer by day, in my spare time, I am a freelance photographer (hoping to become full time). Right now, I&#8217;m in the process of starting my own business. There are standard things that need to be done such as, business cards; marketing materials; websites; etc. Most are going well, [...]]]></description>
			<content:encoded><![CDATA[<p>Even though I am a software developer by day, in my spare time, I am a freelance photographer (hoping to become full time).  Right now, I&#8217;m in the process of  starting my own business. There are standard things that need to be done such as,  business cards; marketing materials; websites; etc.  Most are going well, and are either completed or almost done.</p>
<p><span id="more-136"></span>However, the biggest pain in the @$$ is finding an accounting software that suits all of my needs. So far, I have not been able to find anything that does everything I need, and in a nice easy-to-use package.  Sure, there&#8217;s Blinkbid, which comes close but is missing job scheduling;  then there&#8217;s Light Blue : Photo, which comes even closer but is expensive and has a very cludgy interface.  There are also a few others that exist, but these are designed for large studios with even larger budgets. So, unable to locate the perfect sofware package for my business, I decided to write my own.</p>
<p>Introducing:</p>
<p><a href="http://www.funkynerd.com/wp-content/uploads/2010/07/ushoot_logo.png"><img class="alignnone size-full wp-image-72" title="ushoot_logo" src="http://www.funkynerd.com/wp-content/uploads/2010/07/ushoot_logo.png" alt="" width="200" height="102" /></a></p>
<p>The purpose of uShoot is to handle my day-to-day scheduling; estimates; invoicing; and contacts.  I&#8217;m sure it&#8217;s duties will grow in the future, but these are my immediate goals for the software.   To get the word out there, here are a few features that I already have in mind:</p>
<ul>
<li>Web Based &#8211; so it will work from anywhere.</li>
<li>Google Calendar Synchronisation.</li>
<li>&#8216;T&amp;C in a Can&#8217; &#8211; allowing Terms and Conditions to be generated in legalese just by selecting a few drop down options.</li>
<li>Contact Management &#8211; hopefully with Google contacts sync.</li>
<li>Workflow Management.</li>
<li>PDF Estimate and Invoice Generation.</li>
<li>Much more&#8230;</li>
</ul>
<p>What&#8217;s with all the &#8216;google sync stuff&#8217; you ask?  Well, this is actually the major feature that I wanted from this software, and this is what others don&#8217;t really do too well, if in fact, at all.  With mobile phones talking to &#8216;the cloud&#8217; (god I hate that term) more and more these days, it makes sense to have my mobile phone show up my contacts and calendar.</p>
<p>I&#8217;m also thinking of offering this as a service, as well as a package for sale.  This means, if you don&#8217;t want to pay a few hundred dollars for it, then you can just pay 10-15 bucks a month and use it over the internet.  With this, there can be some multi-user/community stuff incorporated into it as well.</p>
<p>Well, that&#8217;s it.  I really just wanted to get the word out there so that other people in my boat, who are looking for software for a small photography business, can see that there&#8217;s an alternative solution coming.  Feel free to contact me if you have ideas or to express interest.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.funkynerd.com/ushoot-%e2%80%93-job-management-for-creatives/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Update on using kBluetooth</title>
		<link>http://www.funkynerd.com/update-on-using-kbluetooth</link>
		<comments>http://www.funkynerd.com/update-on-using-kbluetooth#comments</comments>
		<pubDate>Tue, 21 Jul 2009 04:14:40 +0000</pubDate>
		<dc:creator>Jazz</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://www.funkynerd.com/?p=127</guid>
		<description><![CDATA[In my last post (Using A2DP Bluetooth in Kubuntu Karmic (KDE)) I mentioned that I used gnome-bluetooth to setup my A2DP headset and then I remove it. Well, I did some more thinking/playing and I have completely switched over to gnome-bluetooth. So far I haven&#8217;t noticed and downside, apart from the initial manual configuration. So, [...]]]></description>
			<content:encoded><![CDATA[<p>In my last post (<a href="http://www.funkynerd.com/using-a2dp-bluetooth-in-kubuntu-karmic">Using A2DP Bluetooth in Kubuntu Karmic (KDE)</a>)  I mentioned that I used gnome-bluetooth to setup my A2DP headset and then I remove it.  Well, I did some more thinking/playing and I have completely switched over to gnome-bluetooth.<span id="more-127"></span></p>
<p>So far I haven&#8217;t noticed and downside, apart from the initial manual configuration.</p>
<p>So, all I ended up doing was</p>
<p><code>apt-get remove kbluetooth<br />
apt-get install gnome-bluetooth</code></p>
<p>After that, to get gnome-bluetooth to start when I log in I went into System Settings and clicked the Advanced tab.  Then start the Autostart manager and add a program to execute bluetooth-applet and that&#8217;s it.</p>
<p>Works a treat!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.funkynerd.com/update-on-using-kbluetooth/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using A2DP Bluetooth in Kubuntu Karmic</title>
		<link>http://www.funkynerd.com/using-a2dp-bluetooth-in-kubuntu-karmic</link>
		<comments>http://www.funkynerd.com/using-a2dp-bluetooth-in-kubuntu-karmic#comments</comments>
		<pubDate>Sun, 12 Jul 2009 04:14:01 +0000</pubDate>
		<dc:creator>Jazz</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://www.funkynerd.com/?p=125</guid>
		<description><![CDATA[I&#8217;ve been using Kubuntu Karmic on my ASUS G1s notebook for a couple of weeks now and I&#8217;m quite happy with it. On the most part, everything &#8220;just works&#8221;. One thing that didn&#8217;t work out of the box though, was my A2DP bluetooth headset. I have a Nokia BH-503 that I use quite often while [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using Kubuntu Karmic on my ASUS G1s notebook for a couple of weeks now and I&#8217;m quite happy with it. On the most part, everything &#8220;just works&#8221;.</p>
<p>One thing that didn&#8217;t work out of the box though, was my A2DP bluetooth headset. I have a Nokia BH-503 that I use quite often while I&#8217;m working so it&#8217;s something I really wanted to get work. Unfortunately, the KDE desktop widget for managing bluetooth still leaves a lot to be desired. At the moment it really only manages input devices, such as bluetooth mice. I found a pretty easy work around though.</p>
<p><span id="more-125"></span></p>
<p><strong>Step 1: Install gnome-bluetooth because kbluetooth is lame (for now)</strong></p>
<p>Now, because kbluetooth is pretty lame when it comes to this stuff, the easiest thing for us to do is ditch it and install gnome-bluetooth which is a lot more mature and can set up devices other than input devices.  So:</p>
<p><code>sudo apt-get install gnome-bluetooth</code></p>
<p>It will probably try and install some other stuff that it needs, so let it.  Once that&#8217;s done, you&#8217;ll need to run it manually to start it up as it won&#8217;t put anything in KMenu.</p>
<p><strong>Step 2: Run gnome-bluetooth and pair your device</strong></p>
<p>Running it is easy, despite the executable not being called gnome-bluetooth.  Just run:</p>
<p><code>bluetooth-applet</code></p>
<p>and it will popup in the widget tray.  Left click on it and select Setup new device.  Just follow the wizard and pair your device.  This will be different for every device so I won&#8217;t go into any detail here, other than to say, put your device is discover mode and it should find it.</p>
<p>Once it&#8217;s found it, you should see your headset in the devices list of gnome-bluetooth&#8217;s popup menu.  Strangely enough, that&#8217;s all we need gnome-bluetooth for.  You can now pretend it doesn&#8217;t exist for all intents and purposes (you can even uninstall it if you really want. I did).</p>
<p><em>NOTE: Funnily enough, if you still have kbluetooth running you can see your A2DP audio device in the devices list in there too!!!</em></p>
<p><strong>Step 3: Get PulseAudio up and running</strong></p>
<p>To get the audio component working, we need something can intercept the audio and send it to the headset.  This used to be done with bluetooth-alsa which was part of the BlueZ project.  But this required a whole lot of messing around with config files and once it was setup, you had to manually switch between audio output devices should you want to use something besides your headset.</p>
<p>The elegant solution is to use PulseAudio to handle audio in KDE.  This is really easy to get up and running and pretty much just requires you to install the pulseaudio and pulseaudio-module-bluetooth packages and reboot so everything starts up correctly.  There&#8217;s also a bunch of config utils that make working with PulseAudio a lot easier so we&#8217;ll install them too.  So from a command line, simply:</p>
<p><code>sudo apt-get install pulseaudio pulseaudio-module-bluetooth padevchooser paman paprefs</code></p>
<p>Of course, this will probably try and install a whole bunch of other dependencies, so just let it.  As far as I can tell it&#8217;s all just libraries and stuff.  Once this is done, it easiest just to reboot and let pulseaudio start up and load all it&#8217;s modules.</p>
<p><strong>Step 4: Listen to music</strong></p>
<p>That&#8217;s pretty much it.  Once you have rebooted you can log back in and just set your audio device to use PulseAudio (in system settings).  Initially your audio will still come out of your default device, but if you run pavucontrol or from kMenu Pulse Audio Volume Control you have complete control over everywhere your audio comes from and goes to.  Pulse is actually pretty cool.</p>
<p>Anywayz, if everything worked, in pvaucontrol the Configuration tab should show your A2DP device.  If it has selected the HSP profile in the dropdown box, simply select the A2DP (it will remember this).  Now, while audio is playing you should be able to select your headset as the audio output device.</p>
<p>Alternatively, you can setup and use padevchooser to select your audio server and output device, but I&#8217;ll leave that for a later post.</p>
<p>The coolest part of all this is that PulseAudio will seamlessly switch between output devices.  For example, I have my A2DP headset set up as my default device for Amarok.  So I can start playing music and it will come out my crappy laptop speakers.  But if I turn on my headset and it connects the audio will automatically switch to there.  I don&#8217;t even have to stop the currently playing audio track!  The opposite also works where if I turn off my headset, audio switches back to my speakers.  Pretty cool!</p>
<p>Hope this helps someone out there.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.funkynerd.com/using-a2dp-bluetooth-in-kubuntu-karmic/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
