<?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>Billy&#039;s Blog of Geekery &raquo; Billy&#039;s Blog of Geekery</title>
	<atom:link href="http://geekery.the-kid.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://geekery.the-kid.org</link>
	<description>I want to change the world but they won&#039;t give me the source code.</description>
	<lastBuildDate>Tue, 07 Feb 2012 18:03:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>AMV files in Linux &#8211; revisited</title>
		<link>http://geekery.the-kid.org/2011/09/20/amv-files-in-linux-revisited/</link>
		<comments>http://geekery.the-kid.org/2011/09/20/amv-files-in-linux-revisited/#comments</comments>
		<pubDate>Tue, 20 Sep 2011 01:26:35 +0000</pubDate>
		<dc:creator>billy</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[My Scripts]]></category>

		<guid isPermaLink="false">http://geekery.the-kid.org/?p=967</guid>
		<description><![CDATA[I just did a re-write of one of my most popular hits on this blog. It was all documented in the comments of the script&#8217;s page but it&#8217;s a bit of a mess so here&#8217;s the definitive step-by-step walkthrough to converting your videos to AMV format in Linux (I use Ubuntu 10.04) If you can&#8217;t &#8230; </p><p><a class="more-link block-button" href="http://geekery.the-kid.org/2011/09/20/amv-files-in-linux-revisited/">Continue reading &#187;</a>]]></description>
			<content:encoded><![CDATA[<p>I just did a re-write of one of my most popular hits on this blog. It was all documented in <a href="http://geekery.the-kid.org/myscripts/linux-avi-amv-converter/#comments">the comments</a> of the script&#8217;s page but it&#8217;s a bit of a mess so here&#8217;s the definitive step-by-step walkthrough to converting your videos to AMV format in Linux (I use Ubuntu 10.04) If you can&#8217;t make out the pictures in this post click on them to make them bigger &#8211; remember, they&#8217;re only pictures, not real dialog windows&#8230; ;oP</p>
<ol>
<li>Open a terminal window</li>
<li><code>sudo apt-get install subversion<br />
svn checkout http://amv-codec-tools.googlecode.com/svn/trunk/ amv-codec-tools<br />
cd amv-codec-tools/AMVmuxer<br />
make build<br />
</code>Allow this to finish, it takes a good few minutes</li>
<li><code>sudo apt-get install nautilus-actions</code></li>
<li><code>cd<br />
gedit</code></li>
<li>Paste the following code into that file<br />
<code>#!/bin/bash<br />
for uri in $@; do<br />
    INFILE=$uri<br />
    FORMAT=${INFILE:(-4)}<br />
    OUTFILE=${INFILE/$FORMAT/.amv}<br />
    cd ~/amv-codec-tools/AMVmuxer ;<br />
    ./ffmpeg/ffmpeg -i "$INFILE" -f amv -r 16 -s 160x120 -ac 1 -ar 22050 -qmin 3 -qmax 3 "$OUTFILE" ;<br />
    zenity --title "$FORMAT to .amv File Conversion Complete" --info --text="${INFILE/file:\/\// } has converted \n\nCheck ${OUTFILE/file:\/\// }";<br />
done</code><br />
&#8230;save file as &#8216;convert to amv&#8217; and close the file</li>
<li>back in the terminal&#8230;<code>nautilus-actions-config-tool</code></li>
<li>In the window that pops up, click new and make it look like this (don&#8217;t worry about the shred file and wipe free space stuff, we&#8217;re only interested in the Convert to amv stuff):<a href="http://geekery.the-kid.org/files/2011/09/ss-143.png" rel="lightbox[967]"><img src="http://geekery.the-kid.org/files/2011/09/ss-143-300x155.png" alt="" title="nautilus-actions-config-tool" width="300" height="155" class="aligncenter size-medium wp-image-975" /></a><br/><a href="http://geekery.the-kid.org/files/2011/09/ss-144.png" rel="lightbox[967]"><img src="http://geekery.the-kid.org/files/2011/09/ss-144-300x155.png" alt="" title="nautilus-actions-config-tool" width="300" height="155" class="aligncenter size-medium wp-image-978" /></a><br/><a href="http://geekery.the-kid.org/files/2011/09/ss-145.png" rel="lightbox[967]"><img src="http://geekery.the-kid.org/files/2011/09/ss-145-300x155.png" alt="" title="nautilus-actions-config-tool" width="300" height="155" class="aligncenter size-medium wp-image-979" /></a><br/><a href="http://geekery.the-kid.org/files/2011/09/ss-146.png" rel="lightbox[967]"><img src="http://geekery.the-kid.org/files/2011/09/ss-146-300x155.png" alt="" title="nautilus-actions-config-tool" width="300" height="155" class="aligncenter size-medium wp-image-981" /></a>note the different tabs that are open, also note where quotation marks have been used</li>
<li>Save the configuration</li>
<li>Close the nautilus actions configuration tool window</li>
<li>Close the terminal window</li>
<li>In nautilus navigate to a file you want converted</li>
<li>Right click on it, you should see this menu item<a href="http://geekery.the-kid.org/files/2011/09/ss-147.png" rel="lightbox[967]"><img src="http://geekery.the-kid.org/files/2011/09/ss-147-300x219.png" alt="" title="New menu item!" width="300" height="219" class="aligncenter size-medium wp-image-983" /></a>go ahead and select that</li>
<li>After some time, how long depends on the size of the file, you&#8217;ll get a dialog box looking something like this<a href="http://geekery.the-kid.org/files/2011/09/ss-148.png" rel="lightbox[967]"><img src="http://geekery.the-kid.org/files/2011/09/ss-148-300x114.png" alt="" title="complete" width="300" height="114" class="aligncenter size-medium wp-image-984" /></a></li>
<li>Go ahead and play the file (I use GNOME MPlayer for amv files &#8220;sudo apt-get install gnome-mplayer&#8221; but vlc plays them too. You may need codecs.)<a href="http://geekery.the-kid.org/files/2011/09/ss-155.png" rel="lightbox[967]"><img src="http://geekery.the-kid.org/files/2011/09/ss-155.png" alt="" title="AMV playing" width="166" height="201" class="aligncenter size-full wp-image-985" /></a></li>
</ol>
<p>Hopefully that&#8217;ll be you sorted but there are a few points to note&#8230;</p>
<ol>
<li>Spaces in file or path names &#8211; it can&#8217;t handle them</li>
<li>You can do multiple files on the one click, it&#8217;ll do them one at a time</li>
<li>Some file types won&#8217;t convert without messing with ffmpeg &#8211; notably mp4/mp3/3gp &#8211; these can be made to work but that&#8217;s outside the scope of this, importantly flv files convert perfectly so your youtube downloads will work ;oP</li>
<li>This was written using Ubuntu &#8211; I can&#8217;t be certain it&#8217;ll work with other distros</li>
</ol>
<p>go stick your amv files onto your iteddy or ipod-esque thingy and play to your hearts content!</p>
<div class="googlePlusOneButton"><div class="g-plusone" data-href="http://geekery.the-kid.org/2011/09/20/amv-files-in-linux-revisited/"  size="medium"   ></div></div>
	<div style="">
		<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-text="AMV files in Linux - revisited" data-url="http://geekery.the-kid.org/2011/09/20/amv-files-in-linux-revisited/"  data-via="billythekid">Tweet</a>
	</div>
	<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>]]></content:encoded>
			<wfw:commentRss>http://geekery.the-kid.org/2011/09/20/amv-files-in-linux-revisited/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>NT News</title>
		<link>http://geekery.the-kid.org/2011/09/18/nt-news/</link>
		<comments>http://geekery.the-kid.org/2011/09/18/nt-news/#comments</comments>
		<pubDate>Sun, 18 Sep 2011 00:05:52 +0000</pubDate>
		<dc:creator>billy</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[My Scripts]]></category>
		<category><![CDATA[Requests]]></category>

		<guid isPermaLink="false">http://geekery.the-kid.org/?p=963</guid>
		<description><![CDATA[In a similar vein to my last post I&#8217;ve had a request from my very dear friend @Rantz to do something along the same lines for the Northern Territory&#8217;s favourite chip-wrapper. So I did&#8230; If anyone else would like their own piss-take re-branding of a site they like/loath feel free to drop me a line &#8230; </p><p><a class="more-link block-button" href="http://geekery.the-kid.org/2011/09/18/nt-news/">Continue reading &#187;</a>]]></description>
			<content:encoded><![CDATA[<p>In a similar vein to <a href="http://geekery.the-kid.org/2011/09/11/pee-and-what-now/" title="pee and what now" target="_blank">my last post</a> I&#8217;ve had a request from my very dear friend <a href="http://twitter.com/rantz" title="Rantz's tweetage" target="_blank">@Rantz</a> to do something along the same lines for the Northern Territory&#8217;s favourite chip-wrapper.</p>
<p>So I did&#8230;</p>
<p><a href="http://geekery.the-kid.org/files/2011/09/ss-140.png" rel="lightbox[963]"><img src="http://geekery.the-kid.org/files/2011/09/ss-140-262x300.png" alt="" title="empty chip wrapper?" width="262" height="300" class="aligncenter size-medium wp-image-964" /></a></p>
<p>If anyone else would like their own piss-take re-branding of a site they like/loath feel free to drop me a line but for now here&#8217;s the  NT News version&#8230;<br />
<a href="http://geekery.the-kid.org/downloads/mtnews">Download</a> (Downloaded 81 times)</p>
<div class="googlePlusOneButton"><div class="g-plusone" data-href="http://geekery.the-kid.org/2011/09/18/nt-news/"  size="medium"   ></div></div>
	<div style="">
		<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-text="NT News" data-url="http://geekery.the-kid.org/2011/09/18/nt-news/"  data-via="billythekid">Tweet</a>
	</div>
	<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>]]></content:encoded>
			<wfw:commentRss>http://geekery.the-kid.org/2011/09/18/nt-news/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Pee and what now?</title>
		<link>http://geekery.the-kid.org/2011/09/11/pee-and-what-now/</link>
		<comments>http://geekery.the-kid.org/2011/09/11/pee-and-what-now/#comments</comments>
		<pubDate>Sun, 11 Sep 2011 22:22:41 +0000</pubDate>
		<dc:creator>billy</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[My Scripts]]></category>

		<guid isPermaLink="false">http://geekery.the-kid.org/?p=950</guid>
		<description><![CDATA[I&#8217;ve created a quick tongue in cheek user script to help folks remember what the P&#38;J is all about. Install it and navigate to any P&#38;J page&#8230; Download (Downloaded 171 times) The download link should ask to install it on Chrome. In Firefox with Greasemonkey installed it should show the script with a button on &#8230; </p><p><a class="more-link block-button" href="http://geekery.the-kid.org/2011/09/11/pee-and-what-now/">Continue reading &#187;</a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve created a quick tongue in cheek user script to help folks remember what the P&amp;J is all about. Install it and navigate to <a href="http://pressandjournal.co.uk" target="_blank">any P&amp;J page</a>&#8230;</p>
<p><a href="http://geekery.the-kid.org/files/2011/09/ss-135.png" rel="lightbox[950]"><img src="http://geekery.the-kid.org/files/2011/09/ss-135-216x300.png" alt="" title="Pee and Chay?" width="216" height="300" class="aligncenter size-medium wp-image-961" /></a></p>
<p><a href="http://geekery.the-kid.org/downloads/peeandjay">Download</a> (Downloaded 171 times)</p>
<p>The download link should ask to install it on Chrome.<br />
In Firefox with <a title="Greasemonkey" href="https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/" target="_blank">Greasemonkey</a> installed it should show the script with a button on the top right to install.<br />
If that above doesn&#8217;t happen save it to the desktop then drag it onto an open firefox window and greasemonkey should sort it out then.</p>
<p>(update 1/Feb/2012 now changes the words from page body too(on any site [<a href="http://p.twimg.com/AkkV7fBCIAAbz5Q.png:large" target="_blank">screenshot</a>]))</p>
<div class="googlePlusOneButton"><div class="g-plusone" data-href="http://geekery.the-kid.org/2011/09/11/pee-and-what-now/"  size="medium"   ></div></div>
	<div style="">
		<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-text="Pee and what now?" data-url="http://geekery.the-kid.org/2011/09/11/pee-and-what-now/"  data-via="billythekid">Tweet</a>
	</div>
	<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>]]></content:encoded>
			<wfw:commentRss>http://geekery.the-kid.org/2011/09/11/pee-and-what-now/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Custom smilies</title>
		<link>http://geekery.the-kid.org/2011/08/29/custom-smilies/</link>
		<comments>http://geekery.the-kid.org/2011/08/29/custom-smilies/#comments</comments>
		<pubDate>Mon, 29 Aug 2011 13:54:34 +0000</pubDate>
		<dc:creator>billy</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[My Scripts]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://geekery.the-kid.org/?p=942</guid>
		<description><![CDATA[{EAV_BLOG_VER:6e99e91f183f7014} I use my own smilies around the web but I always forget the full link to the pics whenever I&#8217;m posting to a forum or whatever. I don&#8217;t need to remember them though as a long time ago I made the script below, saved it as index.php and put it in the folder where &#8230; </p><p><a class="more-link block-button" href="http://geekery.the-kid.org/2011/08/29/custom-smilies/">Continue reading &#187;</a>]]></description>
			<content:encoded><![CDATA[<p><span id="empireavenue-claim" style="display:none;">{EAV_BLOG_VER:6e99e91f183f7014}</span><br />
I use my own smilies around the web but I always forget the full link to the pics whenever I&#8217;m posting to a forum or whatever. I don&#8217;t need to remember them though as a long time ago I made the script below, saved it as index.php and put it in the folder where I hold my smilies&#8230; Now I just click a bookmark and open <a href="http://the-kid.org/images/smilies/" target="_blank">that page</a> for a quick copy/paste. Feel free to use for your own uses, it&#8217;s essentially making a list of files in the directory and displaying them as per the html in the echo statements&#8230;<br />
<img src='http://the-kid.org/images/smilies/laugh.gif'/><img src='http://the-kid.org/images/smilies/embarassed.gif'/><img src='http://the-kid.org/images/smilies/grin.gif'/><img src='http://the-kid.org/images/smilies/undecided.gif'/><img src='http://the-kid.org/images/smilies/lipsrsealed.gif'/><img src='http://the-kid.org/images/smilies/rolleyes.gif'/><img src='http://the-kid.org/images/smilies/cheesy.gif'/><img src='http://the-kid.org/images/smilies/wink.gif'/><img src='http://the-kid.org/images/smilies/kiss.gif'/><img src='http://the-kid.org/images/smilies/cry.gif'/><img src='http://the-kid.org/images/smilies/sad.gif'/><img src='http://the-kid.org/images/smilies/shocked.gif'/><img src='http://the-kid.org/images/smilies/angry.gif'/><img src='http://the-kid.org/images/smilies/cool.gif'/><img src='http://the-kid.org/images/smilies/tongue.gif'/><img src='http://the-kid.org/images/smilies/huh.gif'/><img src='http://the-kid.org/images/smilies/smiley.gif'/></p>
<pre name="code" class="PHP">
&lt;script>
function SelectAll(element)
{
element.focus();
element.select();
}
&lt;/script>
&lt;?php
    $path = getcwd() ;
    $dir_handle = @opendir($path) or die("Error opening $path");
    echo "&lt;table style='text-align:center;font-family:sans-serif;'>&lt;tr>&lt;th>Image&lt;/th>&lt;th>Web Link&lt;/th>&lt;th>Forum Link&lt;/th>&lt;th>Image&lt;/th>&lt;/tr>\n";
    while ($file = readdir($dir_handle)) {
	    if ("$file" != "." &#038;&#038; "$file" != ".." &#038;&#038; "$file" != "index.php") {
			echo "&lt;tr>&lt;td>&lt;a href=\"http://the-kid.org/images/smilies/".htmlspecialchars(urlencode($file))." \">&lt;img src=\"".htmlspecialchars(urlencode($file))."\" />&lt;/a>&lt;/td>";
			echo "&lt;td>&lt;input onClick=\"SelectAll(this);\" size=\"50\" type=\"text\" value=\"&lt;img src='http://the-kid.org/images/smilies/".htmlspecialchars(urlencode($file))."'/>\" />&lt;/td>";
			echo "&lt;td>&lt;input onClick=\"SelectAll(this);\" size=\"50\" type=\"text\" value=\"[img]http://the-kid.org/images/smilies/".htmlspecialchars(urlencode($file))."[/img]\" />&lt;/td>
			&lt;td>&lt;a href=\"http://the-kid.org/images/smilies/".htmlspecialchars(urlencode($file))." \">&lt;img src=\"".htmlspecialchars(urlencode($file))."\" />&lt;/a>&lt;/td>
			&lt;/tr>\n";
    	}
    }
    echo "&lt;/table>";
    closedir($dir_handle);
?>
</pre>
<div class="googlePlusOneButton"><div class="g-plusone" data-href="http://geekery.the-kid.org/2011/08/29/custom-smilies/"  size="medium"   ></div></div>
	<div style="">
		<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-text="Custom smilies" data-url="http://geekery.the-kid.org/2011/08/29/custom-smilies/"  data-via="billythekid">Tweet</a>
	</div>
	<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>]]></content:encoded>
			<wfw:commentRss>http://geekery.the-kid.org/2011/08/29/custom-smilies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to make a simple web proxy in PHP</title>
		<link>http://geekery.the-kid.org/2011/08/21/how-to-make-a-simple-web-proxy-in-php/</link>
		<comments>http://geekery.the-kid.org/2011/08/21/how-to-make-a-simple-web-proxy-in-php/#comments</comments>
		<pubDate>Sun, 21 Aug 2011 21:17:07 +0000</pubDate>
		<dc:creator>billy</dc:creator>
				<category><![CDATA[My Scripts]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://geekery.the-kid.org/?p=925</guid>
		<description><![CDATA[I recently tried to follow this link and was met with the equivalent of a 403! I was like, &#8220;I&#8217;m not having that!&#8221; and was about to turn on my VPN when I thought, &#8220;my webserver&#8217;s located in the states, why not just make a proxy?&#8221; So I did a very, very, simple web proxy&#8230; &#8230; </p><p><a class="more-link block-button" href="http://geekery.the-kid.org/2011/08/21/how-to-make-a-simple-web-proxy-in-php/">Continue reading &#187;</a>]]></description>
			<content:encoded><![CDATA[<p>I recently tried to follow <a target="_balnk" href="http://www.bbc.com/travel/blog/20110811-space-travel-powered-by-helium-balloon">this link</a> and was met with the equivalent of a 403!</p>
<p><a href="http://geekery.the-kid.org/files/2011/08/ss-127.png" rel="lightbox[925]"><img src="http://geekery.the-kid.org/files/2011/08/ss-127-300x163.png" alt="" title="Denied!" width="300" height="163" class="aligncenter size-medium wp-image-926" /></a></p>
<p>I was like, &#8220;I&#8217;m not having that!&#8221; and was about to turn on my VPN when I thought, &#8220;my webserver&#8217;s located in the states, why not just make a proxy?&#8221;</p>
<p>So I did a very, <strong>very</strong>, simple web proxy&#8230;</p>
<pre name='code' class='php'>
&lt;!doctype html>
&lt;html lang="en">
    &lt;head>
        &lt;meta charset="utf-8">
        &lt;title>BTK's Web Proxy&lt;/title>
    &lt;/head>
    &lt;body>
        &lt;div style="text-align:center;">
            &lt;form method="GET" action="&lt;?=$_SERVER['REQUEST_URI']?>">
                &lt;input type="url" name="url" placeholder="Type URL of site"/>&lt;input type="submit" Value="Load url" />
            &lt;/form>
        &lt;/div>
        &lt;hr/>
        &lt;?php
            $url = $_GET['url'];
            if (!empty($url))
            {
                // check we're only getting files served by a website (i.e. not ../../../passwords.txt from this server etc.)
                if(preg_match('/^https?:/i', $url))
                {
                    $contents = file_get_contents($url);
                    if($contents === FALSE)
                    {
                        echo "&lt;h2>Sorry &lt;pre>{$url}&lt;/pre> cannot be read&lt;/h2>\n";
                    }
                    //display contents of url
                    else
                    { ?>
                        &lt;?=$contents?>
                        &lt;script>for (var i=0; i&lt;document.links.length; i++) document.links[i].href="&lt;?=$_SERVER['PHP_SELF']?>?url="+document.links[i].href;&lt;/script>
                    &lt;?php }
                }
                else
                {
                    echo "&lt;h2>&lt;pre>$url&lt;/pre> is an invalid URL&lt;/h2>\n";
                }
            }
        ?>
    &lt;/body>
&lt;/html>
</pre>
<p>Essentially this is a form that takes an url and displays the contents of the url. Using html5 we have the input type of &#8220;url&#8221; which handles our validating, though as this is down to the support of the client(non-supporting clients render this as a type=&#8221;text&#8221; field and do no validation) we have some validation on the server too. There&#8217;s also nothing to stop someone just editing the page URL in their address bar to try to access a local file etc.</p>
<p>So now I can <a href="http://geekery.the-kid.org/bbc.php?url=http%3A%2F%2Fwww.bbc.com%2Ftravel%2Fblog%2F20110811-space-travel-powered-by-helium-balloon" target="_blank">see the restricted content</a>. Result!</p>
<p>I added a little javascript for ease to rewrite all the links, so you can click through and have the pages parsed by the web proxy.</p>
<div class="googlePlusOneButton"><div class="g-plusone" data-href="http://geekery.the-kid.org/2011/08/21/how-to-make-a-simple-web-proxy-in-php/"  size="medium"   ></div></div>
	<div style="">
		<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-text="How to make a simple web proxy in PHP " data-url="http://geekery.the-kid.org/2011/08/21/how-to-make-a-simple-web-proxy-in-php/"  data-via="billythekid">Tweet</a>
	</div>
	<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>]]></content:encoded>
			<wfw:commentRss>http://geekery.the-kid.org/2011/08/21/how-to-make-a-simple-web-proxy-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to move Firebug to bottom of Firefox browser window</title>
		<link>http://geekery.the-kid.org/2011/08/19/how-to-move-firebug-to-bottom-of-firefox-browser-window/</link>
		<comments>http://geekery.the-kid.org/2011/08/19/how-to-move-firebug-to-bottom-of-firefox-browser-window/#comments</comments>
		<pubDate>Fri, 19 Aug 2011 09:47:41 +0000</pubDate>
		<dc:creator>billy</dc:creator>
				<category><![CDATA[Other Computery Things]]></category>

		<guid isPermaLink="false">http://geekery.the-kid.org/?p=922</guid>
		<description><![CDATA[A recent update to firebug moved the icon to open the console to the top right of firefox. Everyone hates it as far as I am aware and there&#8217;s no setting to alter it. However you can do the following&#8230; Right-click in the bottom bar or near the firebug icon to get a menu Select &#8230; </p><p><a class="more-link block-button" href="http://geekery.the-kid.org/2011/08/19/how-to-move-firebug-to-bottom-of-firefox-browser-window/">Continue reading &#187;</a>]]></description>
			<content:encoded><![CDATA[<p>A recent update to firebug moved the icon to open the console to the top right of firefox. Everyone hates it as far as I am aware and there&#8217;s no setting to alter it. However you can do the following&#8230;</p>
<ol>
<li>Right-click in the bottom bar or near the firebug icon to get a menu</li>
<li>Select &#8220;Customise&#8230;&#8221;</li>
<li>Ignoring the window that pops up, drag the firebug icon to the bottom pane</li>
<li>Click &#8220;Done&#8221; in the window that popped up</li>
</ol>
<p>&#8230;you&#8217;re welcome!</p>
<div class="googlePlusOneButton"><div class="g-plusone" data-href="http://geekery.the-kid.org/2011/08/19/how-to-move-firebug-to-bottom-of-firefox-browser-window/"  size="medium"   ></div></div>
	<div style="">
		<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-text="How to move Firebug to bottom of Firefox browser window" data-url="http://geekery.the-kid.org/2011/08/19/how-to-move-firebug-to-bottom-of-firefox-browser-window/"  data-via="billythekid">Tweet</a>
	</div>
	<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>]]></content:encoded>
			<wfw:commentRss>http://geekery.the-kid.org/2011/08/19/how-to-move-firebug-to-bottom-of-firefox-browser-window/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Random Letter Function</title>
		<link>http://geekery.the-kid.org/2011/08/03/php-random-letter-function/</link>
		<comments>http://geekery.the-kid.org/2011/08/03/php-random-letter-function/#comments</comments>
		<pubDate>Wed, 03 Aug 2011 03:01:52 +0000</pubDate>
		<dc:creator>billy</dc:creator>
				<category><![CDATA[My Scripts]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://geekery.the-kid.org/?p=919</guid>
		<description><![CDATA[I think the title says it best. A simple php function to produce a random letter or string of random letters&#8230; function randLetter($howMany=1) { for($i=0;$i]]></description>
			<content:encoded><![CDATA[<p>I think the title says it best. A simple php function to produce a random letter or string of random letters&#8230;</p>
<pre name='code' class='php'>
function randLetter($howMany=1)
{
    for($i=0;$i<$howMany;$i++)
    {
        if (rand(0,1)) $randStr .= chr(rand(97,122));
        else $randStr .= chr(rand(65, 90));
    }
    return $randStr;
}
</pre>
<div class="googlePlusOneButton"><div class="g-plusone" data-href="http://geekery.the-kid.org/2011/08/03/php-random-letter-function/"  size="medium"   ></div></div>
	<div style="">
		<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-text="PHP Random Letter Function" data-url="http://geekery.the-kid.org/2011/08/03/php-random-letter-function/"  data-via="billythekid">Tweet</a>
	</div>
	<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>]]></content:encoded>
			<wfw:commentRss>http://geekery.the-kid.org/2011/08/03/php-random-letter-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reading Apache logs with PHP in Ubuntu</title>
		<link>http://geekery.the-kid.org/2011/06/27/reading-apache-logs-with-php-in-ubuntu/</link>
		<comments>http://geekery.the-kid.org/2011/06/27/reading-apache-logs-with-php-in-ubuntu/#comments</comments>
		<pubDate>Mon, 27 Jun 2011 12:59:57 +0000</pubDate>
		<dc:creator>billy</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[My Scripts]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://geekery.the-kid.org/?p=897</guid>
		<description><![CDATA[I was recently the subject of a hacker, it used my servers to send spam emails via a web-script. To find the script I had to check out my server logs. Turns out that this is a bit of a pain to do. I decided to write a wee script to read them and display &#8230; </p><p><a class="more-link block-button" href="http://geekery.the-kid.org/2011/06/27/reading-apache-logs-with-php-in-ubuntu/">Continue reading &#187;</a>]]></description>
			<content:encoded><![CDATA[<p>I was recently the subject of a hacker, it used my servers to send spam emails via a web-script. To find the script I had to check out my server logs. Turns out that this is a bit of a pain to do. I decided to write a wee script to read them and display the contents for me online. A web-page that fills a table with the details.</p>
<p>Sounds simple right?</p>
<p>Well it *is*&#8230; kinda. There are a number of issues with this.</p>
<ol>
<li>The log file is <strong>huge</strong></li>
<li>Apache isn&#8217;t allowed to read it</li>
<li>The log files rotate</li>
</ol>
<p>&#8230;being the main ones. So this is how we handle that&#8230;</p>
<p>Firstly we don&#8217;t read the whole file, we choose how many calls we want to return (I found 500 to be adequate for my needs). To get this I decided to use the linux/unix <a href="http://www.computerhope.com/unix/utail.htm">tail command</a> rather than any file handling stuff within PHP.<br />
Secondly we alter permissions on the log file. Finding the log itself might be a bit problematic but on mine the log files are found in the /var/log/apache2/ directory. The file needing it&#8217;s permissions changed is other_vhosts_access.log on my installation, using the command:<br />
<code>sudo chmod 0644 /var/log/apache2/other_vhosts_access.log</code><br />
should sort that out. Doing a ls -l on the /var/log/apache2/ directory should show it as having -rw-r&#8211;r&#8211; privileges (owner read/write, group read, others read)<br />
The log rotation may not happen on your installation but I didn&#8217;t bother to address this on mine. Once it&#8217;s rotated I just redo that permissions change for the &#8220;new&#8221; log file to re-enable reading of it.</p>
<p>Here&#8217;s the script&#8230;</p>
<pre name='code' class='php'>
&lt;?php
$me = $_SERVER['REMOTE_ADDR'];
$self = $_SERVER['SERVER_ADDR'];
$output = shell_exec('tail /var/log/apache2/other_vhosts_access.log -n 500');
$stuff = explode("
",$output);
array_pop($stuff);
?&gt;
&lt;title&gt;Apache Logs&lt;/title&gt;
&lt;style&gt;
html {
    font-family:monospace;
}
.tbl {
        table-layout:fixed;
        border-top: 5px solid #333;
        border-collapse: collapse;
        background: #fff;
        width:100%;
         }
.tbl td {
        border-bottom: 1px dashed #333;
        padding: 2px 5px;
        text-overflow:ellipsis;
        overflow:hidden;
        white-space:nowrap;
 }
 &lt;/style&gt;
Visits from your current IP (&lt;?=$me?&gt;) are highlighted in &lt;span style="background:yellow;"&gt;yellow&lt;/span&gt;&lt;br/&gt;
Attempts to POST data (from other IPs) are highlighted in &lt;span style="background:pink;"&gt;pink&lt;/span&gt;&lt;br/&gt;
Jobs run from the server itself are &lt;span style="background:silver;color:grey;"&gt;greyed out&lt;/span&gt;&lt;br/&gt;
Showing the last &lt;strong&gt;&lt;?=count($stuff)?&gt;&lt;/strong&gt; site hits.
&lt;pre&gt;&lt;?php// echo $output ?&gt;&lt;/pre&gt;
&lt;table class="tbl" border="1" style='font-family:sans-serif;'&gt;
    &lt;tr&gt;
        &lt;th width="150px"&gt;Domain&lt;/th&gt;
        &lt;th width="150px"&gt;IP&lt;/th&gt;
        &lt;th width="200px"&gt;Date&lt;/th&gt;
        &lt;th&gt;Request&lt;/th&gt;
        &lt;th&gt;UserAgent&lt;/th&gt;
    &lt;/tr&gt;
&lt;?
    foreach($stuff as $line) {
        $linearray = explode(" ", $line);
        $array2 = explode('"', $line);
        $domain = $linearray[0];
        $ip = $linearray[1];
        $date = $linearray[4].$linearray[5];
        $request = $array2[1];
        $useragent = $array2[5];
        //var_dump($linearray);
        //var_dump($array2);
        $style = "";
        if ($ip == $me) $style = " style='background:yellow;'";
        elseif ($ip == $self) $style = " style='color:grey;background:silver;'";
        elseif ($linearray[6] == '"POST') $style = " style='background:pink;'";
        ?&gt;
    &lt;tr&lt;?=$style?&gt;&gt;
        &lt;td&gt;&lt;?=$domain?&gt;&lt;/td&gt;
        &lt;td&gt;&lt;?=$ip?&gt;&lt;/td&gt;
        &lt;td&gt;&lt;?=$date?&gt;&lt;/td&gt;
        &lt;td&gt;&lt;?=$request?&gt;&lt;/td&gt;
        &lt;td&gt;&lt;?=$useragent?&gt;&lt;/td&gt;
    &lt;/tr&gt;
        &lt;?
    }
?&gt;
&lt;/table&gt;
</pre>
<p>Which gives me output something like (click for bigger)&#8230;</p>
<p><a href="http://geekery.the-kid.org/files/2011/06/ss-123.png" rel="lightbox[897]"><img src="http://geekery.the-kid.org/files/2011/06/ss-123-300x98.png" alt="" title="Apache log output" width="300" height="98" class="aligncenter size-medium wp-image-901" /></a></p>
<p>Occasionally I&#8217;ll navigate to this file and it&#8217;ll be empty, saying it&#8217;s showing 0 site hits. This is after the logs have been rotated and I need to re-do the chmod command above. There&#8217;s no way I can see to script this, perhaps a cron job for root&#8230; That&#8217;s not a big enough issue for me to worry about. For my needs this works fine.</p>
<div class="googlePlusOneButton"><div class="g-plusone" data-href="http://geekery.the-kid.org/2011/06/27/reading-apache-logs-with-php-in-ubuntu/"  size="medium"   ></div></div>
	<div style="">
		<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-text="Reading Apache logs with PHP in Ubuntu" data-url="http://geekery.the-kid.org/2011/06/27/reading-apache-logs-with-php-in-ubuntu/"  data-via="billythekid">Tweet</a>
	</div>
	<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>]]></content:encoded>
			<wfw:commentRss>http://geekery.the-kid.org/2011/06/27/reading-apache-logs-with-php-in-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript countdown or countup timer&#8230;</title>
		<link>http://geekery.the-kid.org/2011/04/26/javascript-countdown-or-countup-timer/</link>
		<comments>http://geekery.the-kid.org/2011/04/26/javascript-countdown-or-countup-timer/#comments</comments>
		<pubDate>Tue, 26 Apr 2011 16:28:05 +0000</pubDate>
		<dc:creator>billy</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[My Scripts]]></category>

		<guid isPermaLink="false">http://geekery.the-kid.org/?p=849</guid>
		<description><![CDATA[Another one for the &#8220;why does everyone make it more difficult than it needs be&#8221; section, if that section existed&#8230; I wanted a simple countdown timer. It&#8217;s going to be used in a little thing I&#8217;m doing at blogshares and will essentially count down the time left before another event fires&#8230; All I want is &#8230; </p><p><a class="more-link block-button" href="http://geekery.the-kid.org/2011/04/26/javascript-countdown-or-countup-timer/">Continue reading &#187;</a>]]></description>
			<content:encoded><![CDATA[<p>Another one for the &#8220;why does everyone make it more difficult than it needs be&#8221; section, if that section existed&#8230;</p>
<p>I wanted a simple countdown timer. It&#8217;s going to be used in a little thing I&#8217;m doing at blogshares and will essentially count down the time left before another event fires&#8230; All I want is a number displaying how many seconds are left before the event fires. I can prime this number myself.</p>
<p>The internet has a plethora of countdown timers, but they all want an actual date to end on, not just a number of seconds. So here&#8217;s my offering using jQuery, just put the number from which you want to begin in the span. Simples&#8230;<br />
Count down:</p>
<pre name='code' class='javascript'>
    <script type="text/javascript">
        function countdown() 
        {
            var secs = jQuery("#countdown").text();
            if (secs > 0) { 
            secs--;
            jQuery("#countdown").html(secs); 
            }
        }
        setInterval('countdown()',1000);
    </script>
    <span id='countdown' style='font-size:2em'>10</span>
</pre>
<p>Count up:</p>
<pre name='code' class='javascript'>
    <script type="text/javascript">
        function countup() 
        {
            var secs = jQuery("#countup").text();
            if (secs < 10) { 
            secs++;
            jQuery("#countup").html(secs); 
            }
        }
        setInterval('countup()',1000);
    </script>
    <span id='countup' style='font-size:2em'>0</span>
</pre>
<p>...and here they are working (I've used 100 so that by the time you get here they might still be running, if not refresh and scroll!):</p>
<p>    <script type="text/javascript">
        function btkcountdown() 
        {
            var secs = jQuery("#btkcounter").text();
            if (secs > 0) { 
            secs--;
            jQuery("#btkcounter").html(secs); 
            }
        }
        function btkcountup() 
        {
            var upsecs = jQuery("#btkcountuper").text();
            if (upsecs < 100) { 
            upsecs++;
            jQuery("#btkcountuper").html(upsecs); 
            }
        }
        setInterval('btkcountdown()',1000);
        setInterval('btkcountup()',1000);
    </script><br />
    Counting down: <span id='btkcounter' style='font-size:2em'>100</span><br />
    Counting up: <span id='btkcountuper' style='font-size:2em'>0</span></p>
<div class="googlePlusOneButton"><div class="g-plusone" data-href="http://geekery.the-kid.org/2011/04/26/javascript-countdown-or-countup-timer/"  size="medium"   ></div></div>
	<div style="">
		<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-text="Javascript countdown or countup timer..." data-url="http://geekery.the-kid.org/2011/04/26/javascript-countdown-or-countup-timer/"  data-via="billythekid">Tweet</a>
	</div>
	<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>]]></content:encoded>
			<wfw:commentRss>http://geekery.the-kid.org/2011/04/26/javascript-countdown-or-countup-timer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Twitter @Anywhere PHP server-side validation</title>
		<link>http://geekery.the-kid.org/2010/09/21/twitter-anywhere-php-server-side-validation/</link>
		<comments>http://geekery.the-kid.org/2010/09/21/twitter-anywhere-php-server-side-validation/#comments</comments>
		<pubDate>Tue, 21 Sep 2010 12:54:42 +0000</pubDate>
		<dc:creator>billy</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://geekery.the-kid.org/?p=838</guid>
		<description><![CDATA[I&#8217;ve been working on a little twitter thing for blogshares. I was going to just use the regular API from twitter as I do for many other projects. However there&#8217;s one issue. Blogshares runs squid and it has issues with php5-curl. So there&#8217;s NO cURL functionality in blogshares. I know! Initially I was going to &#8230; </p><p><a class="more-link block-button" href="http://geekery.the-kid.org/2010/09/21/twitter-anywhere-php-server-side-validation/">Continue reading &#187;</a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working on a little twitter thing for blogshares. I was going to just use the regular API from twitter as I do for many other projects. However there&#8217;s one issue. Blogshares runs squid and it has issues with php5-curl. So there&#8217;s NO cURL functionality in blogshares.</p>
<p>I know!</p>
<p>Initially I was going to use readfile() instead, but that&#8217;s a huge PITA.  All existing libs assume you have cURL installed(and why not!) so I&#8217;d need to write my own classes and wrappers for the API. Not immediately but eventually. Even for a simple log-in it&#8217;s just a hideous workaround, imho&#8230;*headdesk*</p>
<p>Step in <a href="https://dev.twitter.com/docs/anywhere/welcome">Twitter&#8217;s @Anywhere service</a>. A javascript library hosted on twitter that allows access to the API client-side from, well, anywhere. It gets across the usual same-origin security issues by being hosted at twitter. But there are of course huge security issues with client-based POSTS. Anyone with firebug or greasemonkey can alter the javascript/html of your page on the fly and let your app post whatever they like.</p>
<p>When twitter signs in a user via @Anywhere they set a cookie on your site with user details. The format is userid:signature where the signature is a sha1 encoded string based on your app&#8217;s secret key, known only to you and twitter. This means when the javascript recognises the person&#8217;s back from twitter OAuthing it can post to some script on your site&#8230;</p>
<p>The only example twitter has for this validation checking is for Ruby, so here&#8217;s how in PHP&#8230;</p>
<pre name='code' class='php'>
    $consumer_secret = 'YOUR APP CONSUMER SECRET';
    $twituserid = explode(":",$_COOKIE['twitter_anywhere_identity']);
    $sha = sha1("{$twituserid[0]}{$consumer_secret}");
    if ($sha === $twituserid[1])
    {
        # Successful login... handle it here
    }
    else
    {
        # Unsuccessful login... reject user.
    }
</pre>
<p>The point here is that nobody else knows your secret key except twitter. So a scripter cannot easily spoof your app and mess with someone&#8217;s twitter account claiming to be you as they can&#8217;t create that signature without it. Even if they do crack your secret key you can generate a new one on twitter in about 5 seconds! </p>
<p>@Anywhere is a great tool and I&#8217;m well impressed with how well it&#8217;s integrated(ing). </p>
<div class="googlePlusOneButton"><div class="g-plusone" data-href="http://geekery.the-kid.org/2010/09/21/twitter-anywhere-php-server-side-validation/"  size="medium"   ></div></div>
	<div style="">
		<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-text="Twitter @Anywhere PHP server-side validation" data-url="http://geekery.the-kid.org/2010/09/21/twitter-anywhere-php-server-side-validation/"  data-via="billythekid">Tweet</a>
	</div>
	<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>]]></content:encoded>
			<wfw:commentRss>http://geekery.the-kid.org/2010/09/21/twitter-anywhere-php-server-side-validation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

