<?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>Tully Rankin</title>
	<atom:link href="http://www.tullyrankin.com/feed" rel="self" type="application/rss+xml" />
	<link>http://www.tullyrankin.com</link>
	<description>My blog includes various articles on Linux, PHP, BASH, Programming, Security, and other technology related topics.</description>
	<lastBuildDate>Wed, 08 May 2013 05:13:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Linux svn diff in color</title>
		<link>http://www.tullyrankin.com/linux-svn-diff-in-color</link>
		<comments>http://www.tullyrankin.com/linux-svn-diff-in-color#comments</comments>
		<pubDate>Wed, 08 May 2013 05:11:13 +0000</pubDate>
		<dc:creator>Tully</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.tullyrankin.com/?p=397</guid>
		<description><![CDATA[I&#8217;ve been looking at changes on files from the command line in SVN. Normally I can just open up the history in Netbeans when working on a project, but there are times when I&#8217;m logged into a server and want to see changes. The svn diff command works well, but I wanted to see if [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.tullyrankin.com%2Flinux-svn-diff-in-color"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.tullyrankin.com%2Flinux-svn-diff-in-color&amp;source=tullyrankin&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>I&#8217;ve been looking at changes on files from the command line in SVN. Normally I can just open up the history in Netbeans when working on a project, but there are times when I&#8217;m logged into a server and want to see changes. The <strong>svn diff</strong> command works well, but I wanted to see if there was a way of displaying the <strong>difference in color</strong> as I see it in Netbeans or other merge tools. So I did a quick search on Google and came across an answer. You can pipe the output to a binary app called <strong>colordiff</strong>. This will take the output of SVN diff command and make it colorful.</p>
<p><img title="svn diff in color example" src="/images/svn-diff-color-example.png" alt="svn diff in color example" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tullyrankin.com/linux-svn-diff-in-color/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Centos Chrome can&#8217;t exit full screen</title>
		<link>http://www.tullyrankin.com/centos-chrome-cant-exit-full-screen</link>
		<comments>http://www.tullyrankin.com/centos-chrome-cant-exit-full-screen#comments</comments>
		<pubDate>Wed, 17 Apr 2013 06:39:04 +0000</pubDate>
		<dc:creator>Tully</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.tullyrankin.com/?p=394</guid>
		<description><![CDATA[I just recently switched from Ubuntu 12.04 LTS to Centos 6.3 x64. Everything is working perfect, except I ran into one problem with Google Chrome. Every time I launch Chrome, it will maximize into full screen mode. The screen would display &#8220;Press f11 to exit full screen&#8221;. However, pressing f11 would not close Google Chrome. [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.tullyrankin.com%2Fcentos-chrome-cant-exit-full-screen"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.tullyrankin.com%2Fcentos-chrome-cant-exit-full-screen&amp;source=tullyrankin&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>I just recently switched from Ubuntu 12.04 LTS to <strong>Centos 6.3</strong> x64. Everything is working perfect, except I ran into one problem with <strong>Google Chrome</strong>. Every time I launch Chrome, it will maximize into <strong>full screen mode</strong>. The screen would display &#8220;Press f11 to exit full screen&#8221;. However, pressing f11 would not close Google Chrome. I started searching Google for an answer, and found tons of answers with incorrect information. Most of the answers were to delete your Google Chrome data under your home directory. This is a bad answer, as it will remove your preferences as well as your bookmarks / settings and not fix the problem. I kept searching, and could not find the answer. I soon starting going through the Centos keyboard short-cuts. I found that under Window Management the &#8220;Toggle fullscreen mode&#8221; was disabled. This is the default setting. I tried switching this to use f11 and magically Chrome could exit and re-enter full screen mode.</p>
<p><strong>Steps to fix:</strong><br />
Go to System -&gt; Preferences -&gt; Keyboard Shortcuts</p>
<p>Scroll down to &#8220;Toggle full screen mode&#8221; under Window Management.</p>
<p>Set the shortcut to f11.</p>
<p>This will fix the full screen problem.</p>
<p><img src="/images/centos-chrome-full-screen-fix.png" alt="" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tullyrankin.com/centos-chrome-cant-exit-full-screen/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Node.JS Twitter Client Example</title>
		<link>http://www.tullyrankin.com/node-js-twitter-client-example</link>
		<comments>http://www.tullyrankin.com/node-js-twitter-client-example#comments</comments>
		<pubDate>Fri, 01 Mar 2013 17:58:00 +0000</pubDate>
		<dc:creator>Tully</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.tullyrankin.com/?p=377</guid>
		<description><![CDATA[Lately I have been working a lot with Node.JS. Today I wanted to build a simple twitter command line search. To get the code below working, you will need to download the colors module. You can do this easily by either adding it to your packages.json file and running the command npm install. If you [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.tullyrankin.com%2Fnode-js-twitter-client-example"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.tullyrankin.com%2Fnode-js-twitter-client-example&amp;source=tullyrankin&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Lately I have been working a lot with <strong>Node.JS.</strong> Today I wanted to build a simple <strong>twitter command line search</strong>. To get the code below working, you will need to download the <span style="text-decoration: underline;">colors module</span>. You can do this easily by either adding it to your packages.json file and running the command <strong>npm install.</strong> If you do not have a packages.json file, you can run the command <strong>npm install colors</strong>.</p>
<pre name="code" class="javascript">var http = require('http');
var colors = require('colors');

var getTweets = function(query, cb) {
    var data = "";
    var options = {
        host: 'search.twitter.com',
        port: 80,
        path: '/search.json?q=' + query,
        method: 'GET'
    }

    var request = http.request(options, function(response) {
        response.on('data', function(chunk) {
            data += chunk.toString();
        });

        response.on('end' , function() {
            if (JSON.parse(data) &amp;&amp; data.length) {
                data = JSON.parse(data);
            }
            cb(data);
        });
    });
    request.end();
}

if (!process.argv[2]) {
    console.log('Usage: node ' + process.argv[1] + ' search_query');
    process.exit(0);
}

var searchQuery = encodeURIComponent(process.argv.splice(2).join(' '));

var tweets = getTweets(searchQuery, function(data) {
    if (data.results.length) {
        console.log('Search Completed in: ' + data.completed_in + ' seconds.');
    } else {
        console.log('No Results found for "' + decodeURIComponent(searchQuery) + '"');
        process.exit(0);
    }

    var tweet, out;
    for (i in data.results) {
        var tweet = data.results[i];
        out = "[" + tweet.created_at + "]\n";
        out += tweet.text.green;
        console.log(out + "\n");
    }
});
</pre>
<p><a rel="facebox" href="/images/nodejs-twitter-search.png"><br />
 <img src="/images/nodejs-twitter-search.png" width="500" /><br />
</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tullyrankin.com/node-js-twitter-client-example/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>State Pattern in PHP</title>
		<link>http://www.tullyrankin.com/state-pattern-in-php</link>
		<comments>http://www.tullyrankin.com/state-pattern-in-php#comments</comments>
		<pubDate>Sun, 04 Dec 2011 21:44:28 +0000</pubDate>
		<dc:creator>Tully</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.tullyrankin.com/?p=365</guid>
		<description><![CDATA[The state pattern is a behavioural software design pattern. It is used to allow an object to changes it&#8217;s behaviour when it&#8217;s internal state changes. Below is an example of the state pattern in PHP. I have taken a stop watch with 2 buttons and implemented the code using the state pattern. The first button [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.tullyrankin.com%2Fstate-pattern-in-php"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.tullyrankin.com%2Fstate-pattern-in-php&amp;source=tullyrankin&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>The state pattern is a behavioural software design pattern. It is used to allow an object to changes it&#8217;s behaviour when it&#8217;s internal state changes. Below is an example of the <strong>state pattern in PHP</strong>. I have taken a stop watch with 2 buttons and implemented the code using the state pattern. The first button will be the start/stop for the timer. The second button will reset the timer back to 0. Each time you hit stop, the code will output the time since it started in milliseconds.<br />
</p>
<pre name="code" class="php">
interface State {
    function press(StopWatchContext $context);
}

class StopState implements State {
    public function press(StopWatchContext $context) {
        $time = (microtime(TRUE) * 1000) - $context->getStartTime();
        printf("The stop watch is stopped. [Time] %d MS ", $time);;
        $context->setState($context->getStartState());
    }
}

class StartState implements State {
    public function press(StopWatchContext $context) {
        echo "The stop watch is running..";
        $context->setState($context->getStopState());
    }
}

class ResetState implements State {
    public function press(StopWatchContext $context) {
        echo "The stop watch is reset. ";
        $context->setStartTime(microtime(TRUE) * 1000);
        $context->setState($context->getStartState());
    }
}

class StopWatchContext {
    private $state;
    private $startTime;

    private $startState;
    private $stopState;
    private $resetState;

    public function __construct() {
        $this->setStartTime();
        $this->startState = new StartState();
        $this->stopState = new StopState();
        $this->resetState = new ResetState();
        $this->state = $this->startState;
    }

    public function setState(State $state) {
        $this->state = $state;
    }

    public function pressButton() {
        $this->state->press($this);
    }

    public function resetButton() {
        $this->setState(new ResetState());
        $this->pressButton();
    }

    public function getStartTime() {
        return $this->startTime;
    }

    public function setStartTime() {
        $this->startTime = microtime(TRUE) * 1000;
    }

    public function getStartState() {
        return $this->startState;
    }

    public function getStopState() {
        return $this->stopState;
    }

    public function getResetState() {
        return $this->resetState;
    }
}

$timer = new StopWatchContext();
$timer->pressButton(); //started
usleep(1200 * 1000); // sleeping 1.2 seconds
$timer->pressButton(); //stopped

$timer->pressButton(); //started
usleep(2000 * 1000); //sleeping 1.7 seconds (3200 MS)
$timer->pressButton();//stopped

$timer->resetButton(); //reset
$timer->pressButton();//started
sleep(2);//sleeping 2 seconds
$timer->pressButton(); //stopped
?>
</pre>
<p>
:: Output: :<br />
The stop watch is running.. <br />
The stop watch is stopped. [Time] 1200 MS<br />
The stop watch is running..<br />
The stop watch is stopped. [Time] 3200 MS <br />
The stop watch is reset. <br />
The stop watch is running.. <br />
The stop watch is stopped. [Time] 2000 MS </p>
]]></content:encoded>
			<wfw:commentRss>http://www.tullyrankin.com/state-pattern-in-php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java RSS Reader Example</title>
		<link>http://www.tullyrankin.com/java-rss-reader-example</link>
		<comments>http://www.tullyrankin.com/java-rss-reader-example#comments</comments>
		<pubDate>Mon, 07 Nov 2011 18:26:23 +0000</pubDate>
		<dc:creator>Tully</dc:creator>
				<category><![CDATA[JAVA]]></category>

		<guid isPermaLink="false">http://www.tullyrankin.com/?p=361</guid>
		<description><![CDATA[Today I was working with the DOM in Java and decided to write a simple RSS reader. The code below is an example of a Java RSS Reader. You just give it an instance of URL through the setURL assessor. Then call the writeFeed() method which outputs the title/description/link of each item in the feed. [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.tullyrankin.com%2Fjava-rss-reader-example"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.tullyrankin.com%2Fjava-rss-reader-example&amp;source=tullyrankin&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Today I was working with the DOM in Java and decided to write a simple RSS reader. The code below is an example of a Java RSS Reader. You just give it an instance of URL through the setURL assessor. Then call the writeFeed() method which outputs the title/description/link of each item in the feed.</p>
<pre name="code" class="java">
import java.net.URL;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class RSSReader {

   private static RSSReader instance = null;

   private URL rssURL;

   private RSSReader() {}

   public static RSSReader getInstance() {
      if (instance == null)
         instance = new RSSReader();
      return instance;
   }

   public void setURL(URL url) {
      rssURL = url;
   }

   public void writeFeed() {
      try {
         DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
         Document doc = builder.parse(rssURL.openStream());

         NodeList items = doc.getElementsByTagName("item");

         for (int i = 0; i &lt; items.getLength(); i++) {
            Element item = (Element)items.item(i);
            System.out.println(getValue(item, "title"));
            System.out.println(getValue(item, "description"));
            System.out.println(getValue(item, "link"));
            System.out.println();
         }
      } catch (Exception e) {
         e.printStackTrace();
      }
   }

   public String getValue(Element parent, String nodeName) {
      return parent.getElementsByTagName(nodeName).item(0).getFirstChild().getNodeValue();
   }

   public static void main(String[] args) {
      try {
         RSSReader reader = RSSReader.getInstance();
         reader.setURL(new URL("http://www.tullyrankin.com/feed/rss"));
         reader.writeFeed();
      } catch (Exception e) {
         e.printStackTrace();
      }
   }
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.tullyrankin.com/java-rss-reader-example/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHPDOC For Vim</title>
		<link>http://www.tullyrankin.com/phpdoc-for-vim</link>
		<comments>http://www.tullyrankin.com/phpdoc-for-vim#comments</comments>
		<pubDate>Wed, 19 Oct 2011 18:20:04 +0000</pubDate>
		<dc:creator>Tully</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.tullyrankin.com/?p=357</guid>
		<description><![CDATA[My editor of choice for development has always been Vim. When I&#8217;m coding, I always leave PHPDOC comments for all classes, properties, and methods. I have been using a macro to include the basic PHPDOC comment header. This has worked fine for me so far. However, today I stumbled upon PHPDOC.vim plug-in. The plugin automatically [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.tullyrankin.com%2Fphpdoc-for-vim"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.tullyrankin.com%2Fphpdoc-for-vim&amp;source=tullyrankin&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>My editor of choice for development has always been Vim. When I&#8217;m coding, I always leave PHPDOC comments for all classes, properties, and methods. I have been using a macro to include the basic PHPDOC comment header. This has worked fine for me so far. However, today I stumbled upon PHPDOC.vim plug-in. The plugin automatically creates the PHPDOC comment for you the second it sees you creating a class, method, or adding a class property.</p>
<p>To install just download the plugin from the following link:<br />
<a href="http://markus.fischer.name/vim/phpdoc/phpdoc.vim">http://markus.fischer.name/vim/phpdoc/phpdoc.vim</a></p>
<p>Place the file in your plug in directory for vim.<br />
This can be found at <strong>~/.vim/plugin</strong></p>
<p>Once the plug in is installed, just open a PHP document and start creating a class, method, or property.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tullyrankin.com/phpdoc-for-vim/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Keywords API PHP</title>
		<link>http://www.tullyrankin.com/google-keywords-api-php</link>
		<comments>http://www.tullyrankin.com/google-keywords-api-php#comments</comments>
		<pubDate>Tue, 10 May 2011 17:44:17 +0000</pubDate>
		<dc:creator>Tully</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.tullyrankin.com/?p=348</guid>
		<description><![CDATA[I wrote a PHP script that connects to Google Ananlytics API and retreives your top keywords. Google Analytics has a scheduler that can send you emails of your keywords, but this script can be used to return various formats and then be sent to another program or logged for further processing. The first couple lines [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.tullyrankin.com%2Fgoogle-keywords-api-php"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.tullyrankin.com%2Fgoogle-keywords-api-php&amp;source=tullyrankin&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>I wrote a PHP script that connects to Google Ananlytics API and retreives your top keywords. Google Analytics has a scheduler that can send you emails of your keywords, but this script can be used to return various formats and then be sent to another program or logged for further processing.</p>
<p>The first couple lines have to do with the start-date and end-date of the statistics to return. Currently it&#8217;s set-up to run on a cron on the first of every month and send me a report of the last months keywords. This can easily be changed by modifying the startDate and endDate variables.</p>
<p>The Table ID which is the ID of your site in analytics, is set to retrieve it&#8217;s value as the first param given on the command line. So if your table id was 123456, you would call the script as &#8220;php googleAnalyticsFeed ga:123456&#8243;.</p>
<pre name="code" class="php">
define("GoogleNameSpace", "http://schemas.google.com/analytics/2009");
define("GoogleClientLoginURL", "https://www.google.com/accounts/ClientLogin");
define("GoogleUserEmail", "YOUR_EMAIL_HERE");
define("GoogleUserPass", "YOUR_PASSWORD_HERE");
define("GoogleFeedURL", "https://www.google.com/analytics/feeds/data");

#(First/Last day of previous month)
$lastDayOfMonth = date('Y-m-d', strtotime("-1 second ".date('m').'/01/'.date('Y')));
$firstDayOfMonth = date('Y-m-01', strtotime("-1 second ".date('m').'/01/'.date('Y')));

$table = $argv[1];              # Table ID for Site
$startDate = $firstDayOfMonth;  #Start Date to Search
$endDate = $lastDayOfMonth;     # End Date to Search
$max = 100;                     # Max-results to display

#Auth String
$auth = googleAuth(GoogleUserEmail, GoogleUserPass);

#Get XML Keyword Data
$xml = getKeywords($auth, $table, $startDate, $endDate, $max);

#Loop Through Results and Display (Count - Keyword)
$dom = new DomDocument();
$dom->loadXML($xml);
$entries = $dom->getElementsByTagName('entry');

foreach ($entries as $entry) {
    $keyword = $entry->getElementsByTagNameNS(GoogleNameSpace, 'dimension')->item(0)->getAttribute('value');
    $total = $entry->getElementsByTagNameNS(GoogleNameSpace, 'metric')->item(0)->getAttribute('value');
    printf("%5d - %s\n", $total, $keyword);
}

#Get Google Auth
function googleAuth($email, $pass) {
    $ch = curl_init(GoogleClientLoginURL);
    $postParams = array(
                    "Email"         =>  $email,
                    "Passwd"        =>  $pass,
                    "accountType"   =>  "GOOGLE",
                    "source"        =>  "curl-dataFeed-v2",
                    "service"       =>  "analytics");
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postParams));
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $data = curl_exec($ch);
    preg_match('/Auth=.*/', $data, $auth);
    return $auth[0];
}

#Get Google Keywords
function getKeywords($auth, $table, $startDate, $endDate, $max) {
    $getParams = array(
                    "ids"           =>  $table,
                    "start-date"    =>  $startDate,
                    "end-date"      =>  $endDate,
                    "dimensions"    =>  "ga:keyword",
                    "metrics"       =>  "ga:visits",
                    "sort"          =>  "-ga:visits",
                    "max-results"   =>  $max,
                    "prettyprint"   =>  "false");
    $ch = curl_init(GoogleFeedURL.'?'.http_build_query($getParams));
    $header[0] = "Authorization: GoogleLogin $auth";
    $header[1] = "GData-Version: 2";

    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_POST, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $data = curl_exec($ch);
    return $data;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.tullyrankin.com/google-keywords-api-php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>keywords from apache logs</title>
		<link>http://www.tullyrankin.com/keywords-from-apache-logs</link>
		<comments>http://www.tullyrankin.com/keywords-from-apache-logs#comments</comments>
		<pubDate>Fri, 04 Mar 2011 19:48:14 +0000</pubDate>
		<dc:creator>Tully</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.tullyrankin.com/?p=335</guid>
		<description><![CDATA[I wrote a quick 1 liner last week to get the Google keywords/phrases people were searching to get to my site from the apache logs. The script parses the apache logs and searches for users coming from Google. It then parses each line and outputs the urldecoded version with the number of hits for each [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.tullyrankin.com%2Fkeywords-from-apache-logs"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.tullyrankin.com%2Fkeywords-from-apache-logs&amp;source=tullyrankin&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>I wrote a quick 1 liner last week to get the Google keywords/phrases people were searching to get to my site from the apache logs. The script parses the apache logs and searches for users coming from Google. It then parses each line and outputs the urldecoded version with the number of hits for each keyword/phrase.<br />
</p>
<pre name="code" class="php">cat access_log access_ssl_log | grep --line-buffered 'www.google.com' | egrep --line-buffered -o 'q=.*\&amp;' | tr -d 'q=' | cut -d\&amp; -f1 | egrep --line-buffered '[a-zA-Z0-9]{1}\r' | php -R 'echo urldecode($argn) . "\n";' | sed -e 's/^[ \t]*//g' | sort | uniq -c | sort -n</pre>
<p>
<strong>&#8211;Sample Output&#8211;<br />
</strong><br />
2 java program to count freuency of letters<br />
2 letter freuency in java<br />
2 myslimport csv<br />
2 php bubble sort<br />
2 rand with vectors c++<br />
2 which logical unit of the computer retains information<br />
2 zend_form_element select<br />
4 google weather api<br />
4 php developer resume<br />
4 selection sort example<br />
5 six logical units of a computer</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tullyrankin.com/keywords-from-apache-logs/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MOV Files on PS3</title>
		<link>http://www.tullyrankin.com/mov-files-on-ps3</link>
		<comments>http://www.tullyrankin.com/mov-files-on-ps3#comments</comments>
		<pubDate>Mon, 21 Feb 2011 06:48:26 +0000</pubDate>
		<dc:creator>Tully</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.tullyrankin.com/?p=329</guid>
		<description><![CDATA[Learn how to play .MOV files on the PS3. This article uses FFMPEG to re-encode the video files to work on a PS3. Can be used over a media server.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.tullyrankin.com%2Fmov-files-on-ps3"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.tullyrankin.com%2Fmov-files-on-ps3&amp;source=tullyrankin&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>This last weekend I bought a new HD ZI8 camcorder. I wanted to play the movies files on my PS3. I run a media server using ushare on my Linux box. The ZI8 camcorder saves the recorded videos in .mov format. These files would not play on my PS3. After some research, I found a solution using ffmpeg. The command I use to convert these files to work on the PS3 using my media server is below.</p>
<pre name="code" class="php">
ffmpeg -i original_file.mov -acodec mp2 -ar 32000 -vcodec mpeg1video -qscale 14 new_file.mpg
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.tullyrankin.com/mov-files-on-ps3/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend Form Element Select Helper</title>
		<link>http://www.tullyrankin.com/zend-form-element-select-helper</link>
		<comments>http://www.tullyrankin.com/zend-form-element-select-helper#comments</comments>
		<pubDate>Thu, 27 Jan 2011 01:27:16 +0000</pubDate>
		<dc:creator>Tully</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[zend form]]></category>
		<category><![CDATA[zend framework]]></category>

		<guid isPermaLink="false">http://www.tullyrankin.com/?p=324</guid>
		<description><![CDATA[Today I wrote a small helper that will transform an array to work with Zend Form Element Select. Zend Form Element Select uses the key of an array as the value, and the value as the key. I&#8217;m not sure why Zend did this, but I wrote a small helper class that can be used [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.tullyrankin.com%2Fzend-form-element-select-helper"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.tullyrankin.com%2Fzend-form-element-select-helper&amp;source=tullyrankin&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Today I wrote a small helper that will transform an array to work with Zend Form Element Select. Zend Form Element Select uses the key of an array as the value, and the value as the key. I&#8217;m not sure why Zend did this, but I wrote a small helper class that can be used to re-arrange an array to work properly with the Zend Element Select. To use the class, just give it the array, the key you would like to use as the name, and the key you&#8217;d like to use for the value.</p>
<pre name="code" class="php">
class Helpers_FormHelper {

    public static function createNewArrayWithGivenKeyValuePairs(Array $data, $key, $value) {
        $transformedData = array();
        foreach ($data as $row) {
                    $transformedData[$row[$value]] = $row[$key];
        }
        return $transformedData;
    }
}
</pre>
<p>Example:</p>
<pre name="code" class="php">
Helpers_FormHelper::createNewArrayWithGivenKeyValuePairs($colors, 'name', 'id');
</pre>
<p>
<strong>Before</strong><br />
</p>
<pre name="code" class="php">
array
  0 =>
    array
      'id' => string '1' (length=1)
      'name' => string 'Red' (length=3)
  1 =>
    array
      'id' => string '2' (length=1)
      'name' => string 'Blue' (length=4)
  2 =>
    array
      'id' => string '3' (length=1)
      'name' => string 'Yellow' (length=6)
  3 =>
    array
      'id' => string '4' (length=1)
      'name' => string 'Orange' (length=6)
  4 =>
    array
      'id' => string '5' (length=1)
      'name' => string 'Green' (length=5)
</pre>
<p>
<strong>After</strong><br />
</p>
<pre name="code" class="php">
array
  1 => string 'Red' (length=8)
  2 => string 'Blue' (length=7)
  3 => string 'Yellow' (length=7)
  4 => string 'Orange' (length=6)
  5 => string 'Green' (length=8)
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.tullyrankin.com/zend-form-element-select-helper/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
