<?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>Blog of Auzigog - Jeremy Blanchard &#187; Featured</title>
	<atom:link href="http://auzigog.com/category/featured/feed/" rel="self" type="application/rss+xml" />
	<link>http://auzigog.com</link>
	<description>ideas and guides from a nerdy college student</description>
	<lastBuildDate>Tue, 27 Jul 2010 00:53:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Creating a MediaWiki API Instance Outside Installation Directory</title>
		<link>http://auzigog.com/2009/01/11/creating-a-mediawiki-api-instance-outside-installation-directory/</link>
		<comments>http://auzigog.com/2009/01/11/creating-a-mediawiki-api-instance-outside-installation-directory/#comments</comments>
		<pubDate>Sun, 11 Jan 2009 08:24:15 +0000</pubDate>
		<dc:creator>Auzigog</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Guides]]></category>
		<category><![CDATA[Photography]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[mediawiki]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://auzigog.com/?p=222</guid>
		<description><![CDATA[
I&#8217;m in the process of writing mediawiki2wordpress&#8212;a plugin to allow WordPress to access and display content from a MediaWiki installation. I spent a bit of the evening figuring out how to get MediaWiki to let me trick it into thinking I was making a standard request. The method I explain here gives you access to [...]
]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m in the process of writing <a href="http://github.com/auzigog/mediawiki2wordpress/tree/master">mediawiki2wordpress</a>&mdash;a plugin to allow <a href="http://wordpress.org/">WordPress</a> to access and display content from a <a href="http://www.mediawiki.org/wiki/MediaWiki">MediaWiki</a> installation. I spent a bit of the evening figuring out how to get MediaWiki to let me trick it into thinking I was making a standard request.</p>
<p>The method I explain here gives you access to the <a href="http://www.mediawiki.org/wiki/API">MediaWiki API class</a> as opposed to the standard MediaWiki rendering class. Most of this code came from MediaWiki&#8217;s <span class="code">api.php</span> which you can find in <a href="http://download.wikimedia.org/mediawiki/1.13/mediawiki-1.13.3.tar.gz">MediaWiki 1.13</a>.</p>
<p>Here&#8217;s what the API output will look like for the <a href="http://en.wikipedia.org/w/api.php?action=parse&#038;page=Foobar">Foobar page on Wikipedia</a> (in XML).</p>
<p>I spent quite a bit of time poking around in the MediaWiki /includes directory and trying different hack-ish methods before <a href="http://www.mediawiki.org/wiki/API:Calling_internally#Using_API_internally_by_other_code">this page</a> that had exactly what I needed! It did need updating, but I <a href="http://www.mediawiki.org/w/index.php?title=API:Calling_internally&#038;diff=232400&#038;oldid=214333">was happy to oblige</a>. I even had this whole post written up using a sloppier approach before finding the <span class="code">FauxRequest</span> class that I explain below.<br />
<span id="more-222"></span></p>
<h3>The code</h3>
<p>Let&#8217;s start with the sample code, then go over the details.</p>
<pre lang="php" line="1">$mediawiki_root = '/Users/eyeRmonkey/www/mediawiki-test';
putenv("MW_INSTALL_PATH=$mediawiki_root");
// Initialise common code
require ($mediawiki_root . '/includes/WebStart.php');

class MediaWikiAPIWrapper {
	public function make_fake_request($params) {
		$request = new FauxRequest($params, true);

		$api = new ApiMain($request);

		// Process data &#038; use an output buffer to capture the resutls
		$api->execute();
		$result = $api->getResult();
		$data = &#038;$result->getData();

		return $data;
	}
}</pre>
<h3>Initializing</h3>
<p>The first matter of business is <strong>lines 1 through 4</strong>. These <em>need</em> to be called outside of any function or class. I spent some time trying to figure out why none of MediaWiki&#8217;s global variables were showing up in <span class="code">print_r($GLOBALS)</span> before thinking to <span class="code">require_once()</span> it outside of any functions. Duh. Make sure you get the path to your MediaWiki installation root correct (no trailing slash, obviously).</p>
<p>Most of the work get&#8217;s done on <strong>line 4</strong>. This get&#8217;s all the code ready for a standard API call from the web. This whole approach is meant to be used by an <a href="http://www.mediawiki.org/wiki/Extension_Matrix">extension</a>, so we need to play catchup by initializing the core MediaWiki code.</p>
<h3>Faking the Request</h3>
<p>The good folks at MediaWiki were are kind enough to provide us with a class specifically meant for faking an API request! Joy! It&#8217;s called <span class="code">FauxRequest</span> and it extends the <span class="code">WebRequest</span> object that is used by default for API calls. The <span class="code">FauxRequest</span> class takes an array of keys and values that represent what would&#8217;ve been passed in the URL.</p>
<p>The API manual has more information on  <a href="http://www.mediawiki.org/wiki/API:Data_formats">formats</a> and different <a href="http://www.mediawiki.org/wiki/API:Query">queries</a> you can make to the API.</p>
<p>Here is what your <span class="code">$params</span> array might look like to grab the Main Page:</p>
<pre lang="php">$data = array(
		'action' => 'parse',
		'page' => 'Main_Page'
	);</pre>
<h3>Running the API</h3>
<p><strong>Lines 10 through 15</strong> create an instance of the API and pass in our <span class="code">FauxRequest</span> object to get things rolling!</p>
<p>The <span class="code">$data</span> array will hold all of the information that you would get from a <span class="code">format=php</span> API call. As always, you could use <span class="code">print_r()</span> to display the Array for debugging purposes.</p>
<p><em>That&#8217;s it!</em></p>
<h3>mod_rewrite Issues</h3>
<p>On <a href="http://wiki.auzigog.com">my wiki</a>, the .htaccess mod_rewrite rules that I have seem to be preventing the API from functioning totally correctly. A workaround I discovered is to use the following API call: <a href="http://en.wikipedia.org/w/api.php?action=parse&#038;title=Main_Page&#038;text=%7B%7B%3AMain_Page%7D%7D"><span class="code">/api.php?action=parse&#038;title=Main_Page&#038;text={{:Main_Page}}</span></a>. This works by asking the API to translate the <span class="code">text</span> parameter into rendered text. The <span class="code">{{:Main_Page}}</span> says that the text is actually a <a href="http://en.wikipedia.org/wiki/Wikipedia:Transclusion">transclusion-ed</a> page. It&#8217;s definitely a hack, but it works on servers with weird rewrite rules for <a href="http://www.mediawiki.org/wiki/Manual:Short_URL">pretty URLs</a>.</p>
<h3>Further reading</h3>
<ul>
<li><a href="http://www.mediawiki.org/wiki/API:Query_-_Properties">API: Query Properties</a>
</li>
<li><a href="http://www.mediawiki.org/wiki/API:Expanding_templates_and_rendering">API: Expanding templates and rendering</a> &#8211; Relevant to the transclusion workaround.
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://auzigog.com/2009/01/11/creating-a-mediawiki-api-instance-outside-installation-directory/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Quicksilver Trigger: &#8220;Show Current Track&#8221; in iTunes</title>
		<link>http://auzigog.com/2009/01/08/quicksilver-trigger-show-current-track-in-itunes/</link>
		<comments>http://auzigog.com/2009/01/08/quicksilver-trigger-show-current-track-in-itunes/#comments</comments>
		<pubDate>Fri, 09 Jan 2009 05:08:44 +0000</pubDate>
		<dc:creator>Auzigog</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Guides]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[applescript]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[quicksilver]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://auzigog.com/?p=181</guid>
		<description><![CDATA[
A while back I throw together this AppleScript to trigger Quicksilver to not only go to iTunes, but to automatically focus on the current track. (Note: When iTunes is already the front window, the command to do this is ⌘L. Features Brings iTunes to the front if it isn&#8217;t already the front window Highlights the [...]
]]></description>
			<content:encoded><![CDATA[<p>A while back I throw together this AppleScript to trigger <a href="http://docs.blacktree.com/quicksilver/what_is_quicksilver">Quicksilver</a> to not only go to iTunes, but to automatically focus on the current track. (<em>Note:</em> When iTunes is already the front window, the command to do this is ⌘L.</p>
<h3>Features</h3>
<ul>
<li>Brings iTunes to the front if it isn&#8217;t already the front window
</li>
<li>Highlights the track that is currently playing (if one is playing)
</li>
<li>If iTunes is already the front window, this script will hide the window (similar to using ⌘H
</li>
</ul>
<p><span id="more-181"></span></p>
<h3>Steps</h3>
<ol>
<li>Make sure <a href="http://docs.blacktree.com/quicksilver/what_is_quicksilver">Quicksilver</a> is installed.
</li>
<li>Copy the code below into a text file.
</li>
<li>Save that file in a directory (preferably somewhere in your home directory). Mine is saved at <span class="code">/Users/auzigog/Apple Scripts/showplayingtrack.scpt</span>.
</li>
<li>Open quicksilver by pressing your hot key (likely ⌘L) and press the arrow in the top right to open the menu. Select <em>Triggers</em>
</li>
<li>Press the + button to add a new hot key.
<ol>
<li>Into the first box, type <span class="code">~/Apple Scripts/showplayingtrack.scpt</span> (modify this if you saved it somewhere else).
</li>
<li>Press save
</li>
</ol>
</li>
<li>Assign a hot key
<ol>
<li>Select the item you just added and double-click the area that says &#8220;none&#8221;.
</li>
<li>Put your curson in the &#8220;Hot Key&#8221; box and press the keys you want to use to trigger this script. I chose ^⌘L (Ctrl + Apple + L) to mimic the built in iTunes command
</li>
</ol>
</li>
</ol>
<h3>You&#8217;re done!</h3>
<p>That&#8217;s it! Leave a comment if you find this helpful!</p>
<h3>The code</h3>
<p><br class="clear" /></p>
<pre lang="applescript">on run
	tell application "iTunes"
		if frontmost is true then
			tell application "System Events"
				set app_name to name of the first process whose frontmost is true
				set visible of process app_name to false
			end tell
		else
			set frontmost to true
			if player state is playing then
				reveal current track
			end if
		end if
	end tell
end run</pre>
]]></content:encoded>
			<wfw:commentRss>http://auzigog.com/2009/01/08/quicksilver-trigger-show-current-track-in-itunes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting Up Apache, MySQL and PHP on OS X Leopard</title>
		<link>http://auzigog.com/2009/01/03/setting-up-apache-mysql-and-php-on-os-x-leopard/</link>
		<comments>http://auzigog.com/2009/01/03/setting-up-apache-mysql-and-php-on-os-x-leopard/#comments</comments>
		<pubDate>Sat, 03 Jan 2009 12:50:18 +0000</pubDate>
		<dc:creator>Auzigog</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Guides]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[leopard]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://auzigog.com/?p=135</guid>
		<description><![CDATA[
I recently had to setup MySQL on Mac OS X Leopard (I was using 10.5.6). I can never find a guide that gets Apache, MySQL and PHP working using the binaries that come packaged with Leopard. I also don&#8217;t like using pre-packaged installers like XAMPP and MAMP. This guide is intended for advanced users as [...]
]]></description>
			<content:encoded><![CDATA[<p><img src="http://auzigog.com/wp-content/uploads/2009/01/mamp-300x169.jpg" alt="mamp" title="mamp" width="300" height="169" class="alignright size-medium wp-image-262" />I recently had to setup MySQL on Mac OS X Leopard (I was using 10.5.6). I can never find a guide that gets Apache, MySQL and PHP working using the binaries that come packaged with Leopard. I also don&#8217;t like using pre-packaged installers like <a href="http://www.apachefriends.org/en/xampp-macosx.html">XAMPP</a> and <a href="http://www.mamp.info/en/mamp.html">MAMP</a>. This guide is intended for advanced users as very little explanation is given for each step.</p>
<p>Please add a comment if you have any suggestions for improvement.</p>
<p><span id="more-135"></span></p>
<h3>Apache</h3>
<p>Apache comes with Leopard. Enable it by going to <em>System Preferences > Sharing > check “Web Sharing”</em></p>
<p>Edit <strong>/etc/apache2/httpd.conf</strong> in your favorite text editor.<br />
To change your root web directory from the default (<strong>/Library/WebServer/Documents</strong>), Modify your DocumentRoot on <em>line 163</em>:</p>
<pre lang="apache">DocumentRoot "/Users/yourUserNameHere/workspace"</pre>
<p>&#8230; and change your Directory settings near <em>line 190</em>:</p>
<pre lang="apache"><Directory "/Users/yourUserNameHere/workspace">
<pre>
   ...
   AllowOverride All
   ...
</pre>
<p></Directory></pre>
<p>To activate the PHP module, uncomment this near <em>line 114</em>:</p>
<pre lang="apache">LoadModule php5_module libexec/apache2/libphp5.so </pre>
<p>&#8230; and add this near <em>line 383</em> to make Apache handle .php files:</p>
<pre lang="apache">AddType application/x-httpd-php .php</pre>
<h3>MySQL</h3>
<p><a href="http://dev.mysql.com/downloads/mysql/5.0.html#macosx-dmg">Download</a> and install MySQL. Install the <strong>MySQLStartupItem.pkg</strong> package as well. Go to <em>System Preferences > MySQL</em>, start MySQL and check the box to &#8220;Automatically Start MySQL Server on Startup&#8221;.</p>
<p>Change the MySQL root password:</p>
<pre lang="bash">$ mysqladmin -u root password NEWPASSWORD</pre>
<p>Fix permissions for root account</p>
<pre lang="bash">$ mysql -u root -p</pre>
<pre lang="mysql">mysql> grant all on *.* to 'root'@'%' identified by 'NEWPASSWORD';</pre>
<p>Fix the missing mysql.sock file:</p>
<pre lang="bash">$ sudo mkdir /var/mysql
$ sudo chown _mysql /var/mysql
$ sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock</pre>
<h3>PHP</h3>
<p>PHP is already installed at <strong>/user/bin/php</strong>.</p>
<p>Create a configuration file:</p>
<pre lang="bash">$ sudo cp /etc/php.ini.default /etc/php.ini</pre>
<h3>phpMyAdmin</h3>
<p><a href="http://www.phpmyadmin.net/home_page/downloads.php">Download phpMyAdmin</a> and extract it to <strong>~/workspace/pma</strong>. Rename <strong>config.sample.inc.php</strong> to <strong>config.inc.php</strong> and open it in a text editor.</p>
<p>Near <em>line 17</em>, change your blowfish secret.</p>
<h3>PEAR</h3>
<pre lang="bash">$ curl http://pear.php.net/go-pear > go-pear.php
$ sudo php -q go-pear.php
$ sudo mkdir /usr/bin/pear
</pre>
<p>In the installer, choose to edit option and change it to <strong>/usr/bin/pear</strong></p>
<p>Edit <em>line 469</em> in <strong>/etc/php.ini</strong> to add PEAR to PHP&#8217;s include path:</p>
<pre lang="ini">include_path = ".:/usr/bin/pear"</pre>
<h3>Sources</h3>
<p>Guides I used to get this all straightened out</p>
<ul>
<li><a href="http://www.klauskomenda.com/archives/2008/10/07/installing-apache-mysql-and-php-on-leopard/">OS X Apache, MySQL, PHP guide</a>
</li>
<li><a href="http://www.procata.com/blog/archives/2007/10/28/working-with-php-5-in-mac-os-x-105/">OS X PHP/PEAR guide</a>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://auzigog.com/2009/01/03/setting-up-apache-mysql-and-php-on-os-x-leopard/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

