<?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>chaoscontrol.org</title>
	<atom:link href="http://chaoscontrol.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://chaoscontrol.org</link>
	<description></description>
	<lastBuildDate>Wed, 13 Apr 2011 22:05:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>String Conversion Functions</title>
		<link>http://chaoscontrol.org/php/string-conversion-functions/</link>
		<comments>http://chaoscontrol.org/php/string-conversion-functions/#comments</comments>
		<pubDate>Wed, 13 Apr 2011 22:00:19 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://chaoscontrol.org/?p=67</guid>
		<description><![CDATA[I&#8217;ve been doing some nerdy spring cleaning lately. Found this while digging through the &#8216;junk&#8217; folder. Still useful so I&#8217;m posting it here for all the world to enjoy. // Convert ASCII Text to Binary function text2bin($string) { $string_array = explode(&#34;\r\n&#34;, chunk_split($string, 1)); for ($n = 0; $n &#60; count($string_array) - 1; $n++) { $newstring [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been doing some nerdy spring cleaning lately. Found this while digging through the &#8216;junk&#8217; folder. Still useful so I&#8217;m posting it here for all the world to enjoy.</p>
<pre class="brush: php; title: ;">

// Convert ASCII Text to Binary
function text2bin($string) {
    $string_array = explode(&quot;\r\n&quot;, chunk_split($string, 1));
    for ($n = 0; $n &lt; count($string_array) - 1; $n++) {
        $newstring .= substr(&quot;0000&quot;.base_convert(ord($string_array[$n]), 10, 2), -8);
    }
    $newstring = chunk_split($newstring, 8, &quot; &quot;);
    return $newstring;
}

// Convert Binary to ASCII Text
function bin2text($string) {
    $string = str_replace(&quot; &quot;, &quot;&quot;, $string);
    $string_array = explode(&quot;\r\n&quot;, chunk_split($string, 8));
    for ($n = 0; $n &lt; count($string_array) - 1; $n++) {
        $newstring .= chr(base_convert($string_array[$n], 2, 10));
    }
    return $newstring;
}

// Convert ASCII Text to Hexadecimal
function ascii2hex($string) {
    return chunk_split(bin2hex($string), 2, &quot; &quot;);
}	

// Convert Hexadecimal to ASCII Text
function hex2ascii($string) {
    $string = str_replace(&quot; &quot;, &quot;&quot;, $string);
    for ($n=0; $n&lt;strlen($string); $n+=2) {
        $newstring .=  pack(&quot;C&quot;, hexdec(substr($string, $n, 2)));
    }
    return $newstring;
}

// Convery Binary to Hexadecimal
function binary2hex($string) {
    $string = str_replace(&quot; &quot;, &quot;&quot;, $string);
    $string_array = explode(&quot;\r\n&quot;, chunk_split($string, 8));
    for ($n = 0; $n &lt; count($string_array) - 1; $n++) {
        $newstring .= base_convert($string_array[$n], 2, 16);
    }
    $newstring = chunk_split($newstring, 2, &quot; &quot;);
    return $newstring;
}

// Convert Hexadecimal to Binary
function hex2binary($string) {
    $string = str_replace(&quot; &quot;, &quot;&quot;, $string);
    $string_array = explode(&quot;\r\n&quot;, chunk_split($string, 2));
    for ($n = 0; $n &lt; count($string_array) - 1; $n++) {
        $newstring .= substr(&quot;0000&quot;.base_convert($string_array[$n], 16, 2), -8);
    }
    $newstring = chunk_split($newstring, 8, &quot; &quot;);
    return $newstring;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://chaoscontrol.org/php/string-conversion-functions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Uninstall MySQL on OS X</title>
		<link>http://chaoscontrol.org/os-x/uninstall-mysql-on-os-x/</link>
		<comments>http://chaoscontrol.org/os-x/uninstall-mysql-on-os-x/#comments</comments>
		<pubDate>Wed, 13 Apr 2011 21:48:47 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[OS X]]></category>

		<guid isPermaLink="false">http://chaoscontrol.org/?p=60</guid>
		<description><![CDATA[If you look through the MySQL support docs, there is no clear description for uninstalling MySQL in OS X. Here&#8217;s how: &#160; Make sure MySQL isn&#8217;t running. If you have the preference pane installed, stop the server. Otherwise you can stop it from the terminal: sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop Edit /etc/hostconfig sudo nano /etc/hostconfig Password: AFPSERVER=-NO- [...]]]></description>
			<content:encoded><![CDATA[<p>If you look through the <a href="http://dev.mysql.com/doc/">MySQL support docs</a>, there is no clear description for uninstalling MySQL in OS X. Here&#8217;s how:<br />
&nbsp;</p>
<p>Make sure MySQL isn&#8217;t running. If you have the preference pane installed, stop the server. Otherwise you can stop it from the terminal:</p>
<pre class="brush: plain; title: ;">
sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop
</pre>
<p><strong>Edit /etc/hostconfig</strong></p>
<pre class="brush: plain; title: ;">
sudo nano /etc/hostconfig
Password:

AFPSERVER=-NO-
AUTHSERVER=-NO-
TIMESYNC=-NO-
QTSSERVER=-NO-
MYSQLCOM=-YES-
</pre>
<p>Remove or comment out (# marks the line as a comment) the line that says “MYSQLCOM=-YES-”.<br />
&nbsp;<br />
<strong>Remove MySQL</strong><br />
Still in the terminal&#8230;.</p>
<pre class="brush: plain; title: ;">
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /var/db/receipts/com.mysql.*
sudo rm /etc/my.cnf
</pre>
<p>That&#8217;s it. MySQL gone.</p>
]]></content:encoded>
			<wfw:commentRss>http://chaoscontrol.org/os-x/uninstall-mysql-on-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>php5 Cookie Class (mmm&#8230;. cookies!)</title>
		<link>http://chaoscontrol.org/php/php5-cookie-class-mmm-cookies/</link>
		<comments>http://chaoscontrol.org/php/php5-cookie-class-mmm-cookies/#comments</comments>
		<pubDate>Wed, 06 Apr 2011 14:47:22 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Freebies]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://chaoscontrol.org/?p=53</guid>
		<description><![CDATA[Freebie of the day. A php5 class for dealing with cookies. Technically it requires php 5.2 because of the added &#8216;httponly&#8217; option but removing any reference to it will allow it to run under any 5.x build. Example usage: require 'cookies.class.php'; $cookie = new cookies('360000'); // Pass expiration value if ($cookie-&#62;set('example', 'example') === TRUE) { [...]]]></description>
			<content:encoded><![CDATA[<p>Freebie of the day. A php5 class for dealing with cookies. Technically it requires php 5.2 because of the added &#8216;httponly&#8217; option but removing any reference to it will allow it to run under any 5.x build.</p>
<p>Example usage:</p>
<pre class="brush: php; title: ;">
require 'cookies.class.php';
$cookie = new cookies('360000'); // Pass expiration value

if ($cookie-&gt;set('example', 'example') === TRUE) { // Pass cookie name and value
echo 'Cookie is set!';
 }
echo $cookie-&gt;value('example');
</pre>
<p>Here&#8217;s the full code:</p>
<pre class="brush: php; title: ;">
&lt;?php

/**
 * ------------------------------------------------------------------------------------------------
 * php class for cookie manipulation.
 *  - Sets, deletes, checkes existance of, and returns values from cookies.
 * ------------------------------------------------------------------------------------------------
 * This program is free software: you can redistribute it and/or modify it under the terms of the
 * GNU General Public License as published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
 * the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with this program. If
 * not, see &lt;http://www.gnu.org/licenses/lgpl.html&gt;
 * ------------------------------------------------------------------------------------------------
 * @author          Chris Sprague (chris@chaoscontrol.org)
 * @license         LGPL http://www.gnu.org/licenses/lgpl.html
 * @link            http://chaoscontrol.org
 * @version    	    1.0.0
 * @requires        php 5.2.0
 * ------------------------------------------------------------------------------------------------
 */

 class cookies {

    /* Class Variables ------------------------------------------------------------------------- */

    /**
     * Name of the cookie
     * @var $mixed
     */
    public $name;

    /* Public Methods -------------------------------------------------------------------------- */

    /**
     * Class constructor
     *
     * @param int $expires Number of seconds until cookie expires
     * @param mixed $path
     * @param bool $secure
     * @param bool $httponly
     * @access public
     */
    public function __construct($expires, $path = '/', $secure = FALSE, $httponly = FALSE) {
        $this-&gt;expiration = $expires;
        $this-&gt;path = $path;
        $this-&gt;domain = '.' . $_SERVER[&quot;SERVER_NAME&quot;];
        $this-&gt;secure = $secure;
        $this-&gt;httponly = $httponly;
    }

    /**
     * Deletes a cookie
     *
     * @param mixed $name
     * @return bool
     * @access public
     */
    public function delete($name) {
        if (headers_sent() === FALSE) {

           setcookie (
                $name,
                &quot;&quot;,
                time() - 3600 * 25,
                $this-&gt;path,
                $this-&gt;domain,
                $this-&gt;secure,
                $this-&gt;httponly);

            // Confirm Deletion
            if ($this-&gt;check($name) === FALSE) {
                return TRUE;
            }
        }
        return FALSE;
    }

    /**
     * Creates a cookie
     *
     * @param mixed $name
     * @param mixed $data
     * @return bool
     * @access public
     */
    public function set($name, $data = '') {
        if (headers_sent() === FALSE) {

            setcookie (
                $name,
                serialize($data),
                time() + $this-&gt;expiration,
                $this-&gt;path,
                $this-&gt;domain,
                $this-&gt;secure,
                $this-&gt;httponly);

            // Set $_COOKIE value for same page load
            $_COOKIE[$name] = serialize($data);

            // Confirm Set
            if ($this-&gt;check($name) === TRUE) {
                return TRUE;
            }
        }
        return FALSE;
    }

    /**
     * Returns the value of a cookie
     *
     * @param mixed $name
     * @return mixed
     * @access public
     */
    public function value($name) {
        if ($this-&gt;check($name) === TRUE) {
            return unserialize($_COOKIE[$name]);
        }
        return FALSE;
    }

    /**
     * Check the existance of a cookie
     *
     * @param mixed $name
     * @return bool
     * @access public
     */
    public function check($name) {
        return isset($_COOKIE[$name]);
    }

    /* Private Methods ------------------------------------------------------------------------- */

    /* Protected Methods ----------------------------------------------------------------------- */

}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://chaoscontrol.org/php/php5-cookie-class-mmm-cookies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Last.FM Top Albums WP Plugin</title>
		<link>http://chaoscontrol.org/php/lastfm-top-albums-wp-plugin/</link>
		<comments>http://chaoscontrol.org/php/lastfm-top-albums-wp-plugin/#comments</comments>
		<pubDate>Mon, 04 Apr 2011 15:29:07 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[Freebies]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://chaoscontrol.org/?p=37</guid>
		<description><![CDATA[I&#8217;ve been meaning to package this into a proper WordPress plugin but have been too lazy/busy/etc. In the meantime, here it is in it&#8217;s raw form. &#160; Oh, what it does is get your top albums from Last.FM and displays the album art in a pretty table. The XML file gets cached so it wont [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been meaning to package this into a proper WordPress plugin but have been too lazy/busy/etc. In the meantime, here it is in it&#8217;s raw form.</p>
<p>&nbsp;</p>
<p>Oh, what it does is get your top albums from <a href="http://last.fm" target="blank">Last.FM</a> and displays the album art in a pretty table. The XML file gets cached so it wont make an API call to the Last.FM servers on each page load.</p>
<p>&nbsp;</p>
<p>It uses simplexml so you&#8217;ll need to be running at least php 5.</p>
<p>&nbsp;</p>
<p>Dirty Install: Add your username and API key, create a folder in your wordpress plugins directory called CCO-LastFM_Top_Albums and save the below code in index.php of said directory. Call the function in your template.</p>
<pre class="brush: php; title: ;">
&lt;?php
/*
Plugin Name: Last.FM Top Albums
Plugin URI: http://www.chaoscontrol.org/wordpress/lastfm-top-albums-wp-plugin
Description: Gets your top played albums (with art) from last.fm
Version: 1.0
Author: Chris Sprague
Author URI: http://www.chaoscontrol.org/about
License: GPL2
*/

/*  Copyright 2011  Chris Sprague  (email : chris@chaoscontrol.org)

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License, version 2, as
    published by the Free Software Foundation.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/
function last_fm_top_albums() {

    // Your Last.FM Username
    $user = '';
    // Last.FM API Key (http://www.last.fm/api/account)
    $api = '';
     // overall | 7day | 3month | 6month | 12month
    $period = &quot;7day&quot;;
    // Number of albums to pull
    $limit = '10';
    // Number of rows to display on
    $rows = '2';                               

    $as = 'http://ws.audioscrobbler.com/2.0/';
    $method = '?method=user.gettopalbums';

    $uri = $as;
    $uri .= $method;
    $uri .= '&amp;user=' . $user;
    $uri .= '&amp;period=' . $period;
    $uri .= '&amp;limit=' . $limit;
    $uri .= '&amp;api_key=' . $api;

    $cachedFile = WP_PLUGIN_DIR . '/CCO-LastFM_Top_Albums/' . $user . '.xml';
    $cachedTTL = '300'; // Number of seconds

    if (!file_exists($cachedFile) OR (filemtime($cachedFile) &lt; time() - $cachedTTL)) {
            $xml = file_get_contents($uri);
            $fh = fopen($cachedFile, 'wb+');
            fwrite($fh, $xml);
            fclose($fh);
    }

    $xml = simplexml_load_file($cachedFile);
    $div = $limit / $rows;
    $i = 1;

    echo '&lt;p&gt;';
    foreach ($xml-&gt;topalbums-&gt;album as $album) {
        echo '
        &lt;a href=&quot;' . $album-&gt;url . '&quot;&gt;
            &lt;img src=' . $album-&gt;image . ' class=&quot;album_art&quot; /&gt;
        &lt;/a&gt;';

        if ($i &gt;= $div) {
            echo '&lt;/p&gt;&lt;p&gt;';
            $i = 1;
        } else {
            $i++;
        }
    }
    echo '&lt;/p&gt;';
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://chaoscontrol.org/php/lastfm-top-albums-wp-plugin/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>B&#8217;ak&#8217;tun Countdown Widget</title>
		<link>http://chaoscontrol.org/freebies/baktun-countdown-widget/</link>
		<comments>http://chaoscontrol.org/freebies/baktun-countdown-widget/#comments</comments>
		<pubDate>Sun, 27 Mar 2011 16:21:12 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Freebies]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Dashboard]]></category>

		<guid isPermaLink="false">http://chaoscontrol.org/?p=23</guid>
		<description><![CDATA[Displays a countdown to December 21st 2012, marking the end of the 13th b&#8217;ak&#8217;tun of the Mayan long count calendar. AKA, the end of the world for the doomsdayists! &#160; Download Here:  Mac OS X 10.4 Tiger is required. If you’re using Safari, click the download link. When the widget download is complete, show Dashboard, [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">Displays a countdown to December 21st 2012, marking the end of the 13th b&#8217;ak&#8217;tun of the Mayan long count calendar. AKA, the end of the world for the doomsdayists!</p>
<p style="text-align: left;">&nbsp;</p>
<p style="text-align: center;"><img class="alignnone size-full wp-image-11" title="baktun_countdown" src="http://chaoscontrol.org/wp-content/uploads/baktun_countdown.tif" alt="baktun_countdown" /></p>
<p>Download Here: <a class="downloadlink" href="http://chaoscontrol.org/downloads/BaktunCountdown.wdgt_1.zip" title="Version1.0 downloaded 20 times" >B'ak'tun Countdown Widget (20)</a></p>
<p><em>Mac OS X 10.4 Tiger is required. If you’re using Safari, click the download link. When the widget download is complete, show Dashboard, click the Plus sign to display the Widget Bar and click the widget’s icon in the Widget Bar to open it. If you’re using a browser other than Safari, click the download link. When the widget download is complete, unarchive it and place it in /Library/Widgets/ in your home folder. show Dashboard, click the Plus sign to display the Widget Bar and click the widget’s icon in the Widget Bar to open it.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://chaoscontrol.org/freebies/baktun-countdown-widget/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hello world!</title>
		<link>http://chaoscontrol.org/uncategorized/hello-world/</link>
		<comments>http://chaoscontrol.org/uncategorized/hello-world/#comments</comments>
		<pubDate>Wed, 23 Mar 2011 20:46:30 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://chaoscontrol.org/?p=1</guid>
		<description><![CDATA[Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!]]></description>
			<content:encoded><![CDATA[<p>Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!</p>
]]></content:encoded>
			<wfw:commentRss>http://chaoscontrol.org/uncategorized/hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

