<?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"
	>

<channel>
	<title>markmcb</title>
	<atom:link href="http://markmcb.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://markmcb.com</link>
	<description>a username with its own domain</description>
	<pubDate>Fri, 20 Feb 2009 05:49:00 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
	<language>en</language>
			<item>
		<title>Blogs / Articles on OmniNerd</title>
		<link>http://markmcb.com/2009/02/16/blogs-articles-on-omninerd/</link>
		<comments>http://markmcb.com/2009/02/16/blogs-articles-on-omninerd/#comments</comments>
		<pubDate>Mon, 16 Feb 2009 21:07:52 +0000</pubDate>
		<dc:creator>markmcb</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://markmcb.com/?p=267</guid>
		<description><![CDATA[I know, I know, I can&#8217;t make up my mind on where to write.  I started using WordPress because I didn&#8217;t like OmniNerd (which I wrote), and then I got annoyed with WordPress so I re-wrote the OmniNerd authoring system.  I now like OmniNerd again.
If you want to read what I&#8217;m writing, you can read [...]]]></description>
			<content:encoded><![CDATA[<p>I know, I know, I can&#8217;t make up my mind on where to write.  I started using WordPress because I didn&#8217;t like OmniNerd (which I wrote), and then I got annoyed with WordPress so I re-wrote the OmniNerd authoring system.  I now like OmniNerd again.</p>
<p>If you want to read what I&#8217;m writing, you can <a href="http://www.omninerd.com/nerds/markmcb/articles">read all of my articles on OmniNerd</a>.  I&#8217;m not sure if I&#8217;ll be putting much on markmcb.com anytime soon.  But then again, I change my mind a lot.</p>
]]></content:encoded>
			<wfw:commentRss>http://markmcb.com/2009/02/16/blogs-articles-on-omninerd/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Install markItUp! in Ruby on Rails</title>
		<link>http://markmcb.com/2008/11/08/install-markitup-in-ruby-on-rails/</link>
		<comments>http://markmcb.com/2008/11/08/install-markitup-in-ruby-on-rails/#comments</comments>
		<pubDate>Sat, 08 Nov 2008 18:43:57 +0000</pubDate>
		<dc:creator>markmcb</dc:creator>
		
		<category><![CDATA[Web Development]]></category>

		<category><![CDATA[jquery]]></category>

		<category><![CDATA[maritup]]></category>

		<category><![CDATA[rails]]></category>

		<category><![CDATA[redcloth]]></category>

		<category><![CDATA[textile]]></category>

		<guid isPermaLink="false">http://markmcb.com/?p=256</guid>
		<description><![CDATA[If you&#8217;re torn between a WYSIWYG editor and something clean like Textile/Redcloth, then markItUp! will provide you with some nice middle ground.  The tool is well documented, but there are a few &#8220;notes&#8221; for installing it in Rails that aren&#8217;t in the docs.
1. Initial setup
Since there&#8217;s overhead associated with markItUp!, I set a variable [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re torn between a WYSIWYG editor and something clean like Textile/Redcloth, then <a href="http://markitup.jaysalvat.com/">markItUp!</a> will provide you with some nice middle ground.  The tool is well documented, but there are a few &#8220;notes&#8221; for installing it in Rails that aren&#8217;t in the <a href="http://markitup.jaysalvat.com/documentation/">docs</a>.</p>
<h3>1. Initial setup</h3>
<p>Since there&#8217;s overhead associated with markItUp!, I set a variable <code>@content_submission</code> to true so that my standard layout template can skip all of the extra javascript when it&#8217;s not necessary.  To keep things simple, I&#8217;m going to follow the markItUp! hierarchy, which means it&#8217;s stylesheets will be in your javascripts path.</p>
<div class="geshi no html">
<ol>
<li class="li1">
<div class="de1">&lt;%- unless @content_submission.nil? -%&gt;
</div>
</li>
<li class="li1">
<div class="de1">&lt;%= javascript_include_tag &quot;jquery-1.2.6.min&quot; %&gt;
</div>
</li>
<li class="li1">
<div class="de1">&lt;%= javascript_include_tag &quot;markitup/jquery.markitup&quot; %&gt;
</div>
</li>
<li class="li1">
<div class="de1">&lt;%= javascript_include_tag &quot;markitup/sets/textile/set&quot; %&gt;
</div>
</li>
<li class="li1">
<div class="de1">&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;/javascripts/markitup/skins/markitup/style.css&quot; /&gt;
</div>
</li>
<li class="li1">
<div class="de1">&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;/javascripts/markitup/sets/textile/style.css&quot; /&gt;
</div>
</li>
<li class="li1">
<div class="de1">&lt;%- end -%&gt;</div>
</li>
</ol>
</div>
<p>Install jQuery into your javascripts folder along with markItUp!.  Download whatever markItUp! set you want to use (I&#8217;m using textile above, which assumes you&#8217;ve already ran <code>sudo gem install redcloth</code>) and drop that in the sets folder.  All of this is documented in the standard <a href="http://markitup.jaysalvat.com/documentation/">markItUp! docs</a>.</p>
<p>You only need to make one edit to the standard markItUp! file.  In jquery.markitup.js, edit <code> previewTemplatePath</code> to the following:</p>
<div class="geshi no javascript">
<ol>
<li class="li1">
<div class="de1">previewTemplatePath: <span class="st0">&#39;/javascripts/markitup/templates/preview.html&#39;</span></div>
</li>
</ol>
</div>
<h3>2. Add an action to parse the text</h3>
<p>I&#8217;ve got a controller called <code>content_controller</code> that will handle my Textile processing with Redcloth.  I&#8217;ve defined an action as follows:</p>
<div class="geshi no rails">
<ol>
<li class="li1">
<div class="de1"><span class="kw1">def</span> parse_textile</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw5">render</span> <span class="re3">:text</span> <span class="sy0">=&gt;</span> RedCloth.<span class="kw5">new</span><span class="br0">&#40;</span>params<span class="br0">&#91;</span><span class="re3">:data</span><span class="br0">&#93;</span><span class="br0">&#41;</span>.<span class="me1">to_html</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">end</span></div>
</li>
</ol>
</div>
<p>You may want to add more to this action to provide security.</p>
<h3>3. Add a route to for your new action</h3>
<p>Assuming you&#8217;re using RESTful routes, just modify your existing route:</p>
<div class="geshi no rails">
<ol>
<li class="li1">
<div class="de1">map.<span class="me1">resources</span> <span class="re3">:content</span>, <span class="re3">:member</span> <span class="sy0">=&gt;</span> <span class="br0">&#123;</span>:parse_textile <span class="sy0">=&gt;</span> <span class="re3">:post</span><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
<h3>4. Tell markItUp! about your route</h3>
<p>Lastly, edit your set file and tell it about the route:</p>
<div class="geshi no javascript">
<ol>
<li class="li1">
<div class="de1">previewParserPath: <span class="st0">&#39;/content/parse_textile&#39;</span></div>
</li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://markmcb.com/2008/11/08/install-markitup-in-ruby-on-rails/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Ruby on Rails Diff Text to HTML &#60;ins&gt; and &#60;del&gt;</title>
		<link>http://markmcb.com/2008/11/04/ruby-on-rails-diff-text-to-html-ins-and-del/</link>
		<comments>http://markmcb.com/2008/11/04/ruby-on-rails-diff-text-to-html-ins-and-del/#comments</comments>
		<pubDate>Wed, 05 Nov 2008 00:12:11 +0000</pubDate>
		<dc:creator>markmcb</dc:creator>
		
		<category><![CDATA[Web Development]]></category>

		<category><![CDATA[del]]></category>

		<category><![CDATA[diff]]></category>

		<category><![CDATA[html]]></category>

		<category><![CDATA[ins]]></category>

		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://markmcb.com/?p=243</guid>
		<description><![CDATA[This code is perfect if you have 2 text objects in your Rails application and you want to compare their differences in one of your HTML views.  It&#8217;s 99% pure Ruby too, so if you alter the first line, you can use it for other purposes.
Only one thing to note: you must have diff [...]]]></description>
			<content:encoded><![CDATA[<p>This code is perfect if you have 2 text objects in your Rails application and you want to compare their differences in one of your HTML views.  It&#8217;s 99% pure Ruby too, so if you alter the first line, you can use it for other purposes.</p>
<p>Only one thing to note: you must have diff installed.  I&#8217;m using: diff (GNU diffutils) 2.8.1.</p>
<div class="geshi no ruby">
<ol>
<li class="li1">
<div class="de1"><span class="co1">#set up some variables to reference later</span></div>
</li>
<li class="li1">
<div class="de1">temporary_directory = <span class="kw4">File</span>.<span class="me1">join</span><span class="br0">&#40;</span>Rails.<span class="me1">root</span>, <span class="st0">&quot;tmp&quot;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">max_lines = <span class="nu0">9999999</span> <span class="co1">#needs to be larger than the most lines you&#39;ll consider</span></div>
</li>
<li class="li1">
<div class="de1">diff_header_length = <span class="nu0">3</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1"># text_old and text_new should be the values of the string objects to compare</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1"># these are just example strings to show it works</span></div>
</li>
<li class="li1">
<div class="de1">text_old &nbsp; &nbsp; &nbsp;= <span class="st0">&quot;line1<span class="es0">\n</span>deleted line2<span class="es0">\n</span>line3<span class="es0">\n</span><span class="es0">\n</span>line4<span class="es0">\n</span>line5&quot;</span></div>
</li>
<li class="li1">
<div class="de1">text_new &nbsp; &nbsp; &nbsp;= <span class="st0">&quot;line1<span class="es0">\n</span>inserted line2<span class="es0">\n</span>line3<span class="es0">\n</span><span class="es0">\n</span>line4<span class="es0">\n</span>line5&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1"># since we&#39;re using diff on the file system, we&#39;ll save the text we want to compare</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1"># and then run diff against the two files</span></div>
</li>
<li class="li1">
<div class="de1">file_old_name = <span class="kw4">File</span>.<span class="me1">join</span><span class="br0">&#40;</span>temporary_directory,<span class="st0">&quot;file_old&quot;</span><span class="sy0">+</span><span class="kw3">rand</span><span class="br0">&#40;</span><span class="nu0">1000000</span><span class="br0">&#41;</span>.<span class="me1">to_s</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">file_new_name = <span class="kw4">File</span>.<span class="me1">join</span><span class="br0">&#40;</span>temporary_directory,<span class="st0">&quot;file_new&quot;</span><span class="sy0">+</span><span class="kw3">rand</span><span class="br0">&#40;</span><span class="nu0">1000000</span><span class="br0">&#41;</span>.<span class="me1">to_s</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">file_old &nbsp; &nbsp; &nbsp;= <span class="kw4">File</span>.<span class="me1">new</span><span class="br0">&#40;</span>file_old_name, <span class="st0">&quot;w+&quot;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">file_new &nbsp; &nbsp; &nbsp;= <span class="kw4">File</span>.<span class="me1">new</span><span class="br0">&#40;</span>file_new_name, <span class="st0">&quot;w+&quot;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">file_old.<span class="me1">write</span><span class="br0">&#40;</span>text_old<span class="sy0">+</span><span class="st0">&quot;<span class="es0">\n</span>&quot;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">file_new.<span class="me1">write</span><span class="br0">&#40;</span>text_new<span class="sy0">+</span><span class="st0">&quot;<span class="es0">\n</span>&quot;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">file_old.<span class="me1">close</span></div>
</li>
<li class="li1">
<div class="de1">file_new.<span class="me1">close</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1"># diff will give provide a string showing insertions and deletions. &nbsp;We will</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1"># split this string out by newlines if there are difference, and mark it up</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1"># accordingly with html</span></div>
</li>
<li class="li1">
<div class="de1">lines = <span class="sy0">%</span>x<span class="br0">&#40;</span>diff <span class="sy0">-</span>­<span class="sy0">-</span>­­­­­­unified=<span class="co1">#{max_lines} #{file_old_name} #{file_new_name})</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">if</span> lines.<span class="me1">empty</span>?</div>
</li>
<li class="li1">
<div class="de1">&nbsp; lines = text_new.<span class="kw3">split</span><span class="br0">&#40;</span><span class="sy0">/</span>\n<span class="sy0">/</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">else</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; lines = lines.<span class="kw3">split</span><span class="br0">&#40;</span><span class="sy0">/</span>\n<span class="sy0">/</span><span class="br0">&#41;</span><span class="br0">&#91;</span>diff_header_length..<span class="me1">max_lines</span><span class="br0">&#93;</span>.</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="me1">collect</span> <span class="kw1">do</span> <span class="sy0">|</span>i<span class="sy0">|</span> </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">if</span> i.<span class="me1">empty</span>? &nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="st0">&quot;&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">else</span> </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw1">case</span> i<span class="br0">&#91;</span><span class="nu0">0</span>,<span class="nu0">1</span><span class="br0">&#93;</span> </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw1">when</span> <span class="st0">&quot;+&quot;</span>; <span class="kw1">then</span> <span class="st0">&quot;&lt;ins&gt;&quot;</span><span class="sy0">+</span>i<span class="br0">&#91;</span><span class="nu0">1</span>..<span class="me1">i</span>.<span class="me1">length</span><span class="nu0">-1</span><span class="br0">&#93;</span><span class="sy0">+</span><span class="st0">&quot;&lt;/ins&gt;&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw1">when</span> <span class="st0">&quot;-&quot;</span>; <span class="kw1">then</span> <span class="st0">&quot;&lt;del&gt;&quot;</span><span class="sy0">+</span>i<span class="br0">&#91;</span><span class="nu0">1</span>..<span class="me1">i</span>.<span class="me1">length</span><span class="nu0">-1</span><span class="br0">&#93;</span><span class="sy0">+</span><span class="st0">&quot;&lt;/del&gt;&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw1">else</span>; i<span class="br0">&#91;</span><span class="nu0">1</span>..<span class="me1">i</span>.<span class="me1">length</span><span class="nu0">-1</span><span class="br0">&#93;</span> </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw1">end</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">end</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">end</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">end</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">#clean up the temporary diff files we created</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw4">File</span>.<span class="me1">delete</span><span class="br0">&#40;</span>file_new_name<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw4">File</span>.<span class="me1">delete</span><span class="br0">&#40;</span>file_old_name<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">#return marked up text</span></div>
</li>
<li class="li1">
<div class="de1">lines.<span class="me1">join</span><span class="br0">&#40;</span><span class="st0">&quot;<span class="es0">\n</span>&quot;</span><span class="br0">&#41;</span></div>
</li>
</ol>
</div>
<p>If you fire up RAILS_ROOT/script/console and paste that code in, it will return a nicely marked up string like this:</p>
<div class="geshi no html">
<ol>
<li class="li1">
<div class="de1">line1
</div>
</li>
<li class="li1">
<div class="de1">&lt;del&gt;deleted line2&lt;/del&gt;
</div>
</li>
<li class="li1">
<div class="de1">&lt;ins&gt;inserted line2&lt;/ins&gt;
</div>
</li>
<li class="li1">
<div class="de1">line3
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">line4
</div>
</li>
<li class="li1">
<div class="de1">line5</div>
</li>
</ol>
</div>
<p>Use CSS to make your ins and del tags render however you like.</p>
]]></content:encoded>
			<wfw:commentRss>http://markmcb.com/2008/11/04/ruby-on-rails-diff-text-to-html-ins-and-del/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Ruby Script to Search Apache Logs for High Frequency Clients</title>
		<link>http://markmcb.com/2008/10/29/ruby-script-to-search-apache-logs-for-high-frequency-clients/</link>
		<comments>http://markmcb.com/2008/10/29/ruby-script-to-search-apache-logs-for-high-frequency-clients/#comments</comments>
		<pubDate>Wed, 29 Oct 2008 23:05:10 +0000</pubDate>
		<dc:creator>markmcb</dc:creator>
		
		<category><![CDATA[Server Administration]]></category>

		<category><![CDATA[apache]]></category>

		<category><![CDATA[log]]></category>

		<category><![CDATA[ruby]]></category>

		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://markmcb.com/?p=226</guid>
		<description><![CDATA[I wrote a quick Ruby script to scour through my Apache access logs and look for IPs that are hitting my site too frequently, e.g., bad bots, etc.  The command line arguments are simple:

$ ruby find-frequent-clients.rb \
--apache-access-log=/path/to/your/log \
--seconds=3600 \
--request-limit=7200 \
--log-time-zone=PST

That command is going to find any client IPs that are hitting my web server [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote a quick Ruby script to scour through my Apache access logs and look for IPs that are hitting my site too frequently, e.g., bad bots, etc.  The command line arguments are simple:</p>
<pre>
$ ruby find-frequent-clients.rb \
--apache-access-log=/path/to/your/log \
--seconds=3600 \
--request-limit=7200 \
--log-time-zone=PST
</pre>
<p>That command is going to find any client IPs that are hitting my web server in the last 10 minutes more twice or more per second.  The output will be a line separated list of IP addressess (optionally with a hit count if <code>--show-count=1</code> is added).  Here&#8217;s how it works:</p>
<div class="geshi no ruby">
<div class="head">File: find-frequent-clients.rb</div>
<ol>
<li class="li1">
<div class="de1"><span class="kw3">require</span> <span class="st0">&#39;date&#39;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">require</span> <span class="st0">&#39;time&#39;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1"># Process command line arguments. &nbsp;Filter only args starting with &#8211;</span></div>
</li>
<li class="li1">
<div class="de1">args = <span class="br0">&#123;</span><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">$<span class="sy0">*</span>.<span class="me1">each</span> <span class="kw1">do</span> <span class="sy0">|</span>arg<span class="sy0">|</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; spl=arg.<span class="kw3">split</span><span class="br0">&#40;</span><span class="st0">&quot;=&quot;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">if</span> spl<span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="nu0">0</span>..<span class="nu0">1</span><span class="br0">&#93;</span> == <span class="st0">&quot;&#8211;&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; args<span class="br0">&#91;</span>spl<span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="nu0">2</span>..<span class="me1">spl</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span>.<span class="me1">length</span><span class="nu0">-1</span><span class="br0">&#93;</span>.<span class="kw3">gsub</span><span class="br0">&#40;</span><span class="st0">&quot;-&quot;</span>,<span class="st0">&quot;_&quot;</span><span class="br0">&#41;</span>.<span class="me1">intern</span><span class="br0">&#93;</span>=spl<span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">end</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">end</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1"># Check that we have the bare essentials to proceed</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">raise</span> <span class="st0">&quot;You must specify the full path to an Apache access log file with &#8211;apache-access-log&quot;</span> <span class="kw1">unless</span> args<span class="br0">&#91;</span><span class="re3">:apache_access_log</span><span class="br0">&#93;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">raise</span> <span class="st0">&quot;You must specify the maximum amount of recent seconds to consider with &#8211;seconds&quot;</span> <span class="kw1">unless</span> args<span class="br0">&#91;</span><span class="re3">:seconds</span><span class="br0">&#93;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">raise</span> <span class="st0">&quot;You must specify the maximum requests allowed per #{args[:seconds]} seconds with &#8211;request-limit&quot;</span> <span class="kw1">unless</span> args<span class="br0">&#91;</span><span class="re3">:request_limit</span><span class="br0">&#93;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">raise</span> <span class="st0">&quot;You must specify the time zone of the Apache logs with &#8211;log-time-zone e.g., EST&quot;</span> <span class="kw1">unless</span> args<span class="br0">&#91;</span><span class="re3">:log_time_zone</span><span class="br0">&#93;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">raise</span> <span class="st0">&quot;The Apache access log file specified does not exist or is not readable: #{args[:apache_access_log]}&quot;</span> <span class="kw1">unless</span> <span class="kw4">FileTest</span>.<span class="me1">readable</span>?<span class="br0">&#40;</span>args<span class="br0">&#91;</span><span class="re3">:apache_access_log</span><span class="br0">&#93;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1"># Open the file and read the lines in reverse; exit once time stamps are beyond our time threshold</span></div>
</li>
<li class="li1">
<div class="de1">file = <span class="kw4">File</span>.<span class="kw3">open</span><span class="br0">&#40;</span>args<span class="br0">&#91;</span><span class="re3">:apache_access_log</span><span class="br0">&#93;</span>, <span class="st0">&quot;r&quot;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">log_array = <span class="br0">&#91;</span><span class="br0">&#93;</span></div>
</li>
<li class="li1">
<div class="de1">log_snapshot = file.<span class="kw3">readlines</span></div>
</li>
<li class="li1">
<div class="de1">file.<span class="me1">close</span></div>
</li>
<li class="li1">
<div class="de1">start_time = <span class="kw4">Time</span>.<span class="me1">now</span>.<span class="me1">to_i</span></div>
</li>
<li class="li1">
<div class="de1">log_snapshot.<span class="me1">reverse_each</span> <span class="kw1">do</span> <span class="sy0">|</span>line<span class="sy0">|</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; line_array = line.<span class="kw3">split</span><span class="br0">&#40;</span><span class="st0">&quot; &quot;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; date_time = line_array<span class="br0">&#91;</span><span class="nu0">3</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="nu0">1</span>..<span class="me1">line_array</span><span class="br0">&#91;</span><span class="nu0">3</span><span class="br0">&#93;</span>.<span class="me1">length</span><span class="nu0">-1</span><span class="br0">&#93;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; date_time<span class="br0">&#91;</span><span class="nu0">11</span><span class="br0">&#93;</span> = <span class="st0">&quot; &quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; date_time = <span class="kw4">Time</span>.<span class="me1">iso8601</span><span class="br0">&#40;</span><span class="kw4">DateTime</span>.<span class="me1">parse</span><span class="br0">&#40;</span>date_time<span class="sy0">+</span><span class="st0">&quot; &quot;</span><span class="sy0">+</span>args<span class="br0">&#91;</span><span class="re3">:log_time_zone</span><span class="br0">&#93;</span><span class="br0">&#41;</span>.<span class="me1">to_s</span><span class="br0">&#41;</span>.<span class="me1">to_i</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">if</span> date_time <span class="sy0">&amp;</span>gt; <span class="br0">&#40;</span>start_time <span class="sy0">-</span> args<span class="br0">&#91;</span><span class="re3">:seconds</span><span class="br0">&#93;</span>.<span class="me1">to_i</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; log_array <span class="sy0">&amp;</span>lt;<span class="sy0">&amp;</span>lt; <span class="br0">&#91;</span>line_array<span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span>, date_time<span class="br0">&#93;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">else</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">break</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">end</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">end</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1"># Use a hash to collect the counts of the IPs</span></div>
</li>
<li class="li1">
<div class="de1">log_hash = <span class="kw4">Hash</span>.<span class="me1">new</span><span class="br0">&#40;</span><span class="nu0">0</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">log_array.<span class="me1">each</span> <span class="kw1">do</span> <span class="sy0">|</span>log<span class="sy0">|</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; log_hash<span class="br0">&#91;</span>log<span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span><span class="br0">&#93;</span><span class="sy0">+</span>=<span class="nu0">1</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">end</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1"># collect the offenders in an array</span></div>
</li>
<li class="li1">
<div class="de1">offenders = log_hash.<span class="me1">to_a</span>.<span class="me1">collect</span><span class="br0">&#123;</span><span class="sy0">|</span>h<span class="sy0">|</span> h <span class="kw1">if</span> h<span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span> <span class="sy0">&amp;</span>gt; args<span class="br0">&#91;</span><span class="re3">:request_limit</span><span class="br0">&#93;</span>.<span class="me1">to_i</span><span class="br0">&#125;</span>.<span class="me1">compact</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1"># output the offending IPs, 1 per line; optionally show the offending count</span></div>
</li>
<li class="li1">
<div class="de1">offenders.<span class="me1">each</span><span class="br0">&#123;</span><span class="sy0">|</span>o<span class="sy0">|</span> <span class="kw3">puts</span> o<span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span>.<span class="me1">to_s</span><span class="sy0">+</span><span class="st0">&quot;#{&quot;</span> <span class="sy0">=&gt;</span> <span class="st0">&quot;+o[1].to_s if args[:show_count]}&quot;</span><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
<p>Note: This makes the assumption that your logs are in the format: aa.bb.cc.dd - - [datetime]</p>
]]></content:encoded>
			<wfw:commentRss>http://markmcb.com/2008/10/29/ruby-script-to-search-apache-logs-for-high-frequency-clients/feed/</wfw:commentRss>
		</item>
		<item>
		<title>3 Reasons to Switch to Git from Subversion</title>
		<link>http://markmcb.com/2008/10/18/3-reasons-to-switch-to-git-from-subversion/</link>
		<comments>http://markmcb.com/2008/10/18/3-reasons-to-switch-to-git-from-subversion/#comments</comments>
		<pubDate>Sat, 18 Oct 2008 23:12:18 +0000</pubDate>
		<dc:creator>markmcb</dc:creator>
		
		<category><![CDATA[Server Administration]]></category>

		<category><![CDATA[Web Development]]></category>

		<category><![CDATA[git]]></category>

		<category><![CDATA[subversion]]></category>

		<category><![CDATA[workflow]]></category>

		<guid isPermaLink="false">http://markmcb.com/?p=178</guid>
		<description><![CDATA[Dozens of articles outline the detailed technical reasons Git is better than Subversion, but if you&#8217;re like me, you don&#8217;t necessarily care about minor speed differences, the elegance of back-end algorithms, or all of the hardcore features that you may only ever use once.  You want to see clear, major differences in your day-to-day interaction [...]]]></description>
			<content:encoded><![CDATA[<p>Dozens of articles outline the detailed technical reasons Git is better than Subversion, but if you&#8217;re like me, you don&#8217;t necessarily care about minor speed differences, the elegance of back-end algorithms, or all of the hardcore features that you may only ever use once.  You want to see clear, major differences in your day-to-day interaction with software before you switch to something new.  After several weeks of trials, Git seems to offer major improvements over Subversion.  These are my reasons for jumping on the Git bandwagon.</p>
<p>Let&#8217;s start with a few assumptions for the scenarios we&#8217;ll walk through:</p>
<ul>
<li>you&#8217;re one of many developers for a project</li>
<li>all changes going into production must first be peer-reviewed</li>
<li>you all use simple GUI text editors like TextMate or an equivalent</li>
<li>you have 4 features that you&#8217;re working that are due soon</li>
</ul>
<p>Let&#8217;s get to work.</p>
<h3>Endless, Easy, Non-File-System-Based, Local Branches</h3>
<p>You&#8217;d like to work on each of your 4 features A, B, C, and D independently and somewhat in parallel, though B looks like a quick win.  Let&#8217;s compare the branching features offered by both Git and Subversion side-by-side as we get going:</p>
<table class="codetable" border="0">
<tbody>
<tr>
<th>Task</th>
<th>Git</th>
<th>Subversion</th>
</tr>
<tr>
<td>1. Get a copy of the project on your local machine.</td>
<td class="precell">git clone /srv/repos /local/copy</td>
<td class="precell">svn checkout /srv/repos /local/copy</td>
</tr>
<tr>
<td>2. Create branches A-D to represent the features you&#8217;re working on.</td>
<td class="precell">git checkout -b A<br />
git checkout -b B<br />
git checkout -b C<br />
git checkout -b D</td>
<td class="precell">svn copy /srv/repos/trunk /srv/repos/branches/A; svn checkout /srv/repos/branches/A /local/copy/branches/A</p>
<p>svn copy /srv/repos/trunk /srv/path/repos/branches/B; svn checkout /srv/repos/branches/B /local/copy/branches/B</p>
<p>svn copy /srv/repos/trunk /srv/path/repos/branches/C; svn checkout /srv/repos/branches/C /local/copy/branches/C</p>
<p>svn copy /srv/repos/trunk /srv/path/repos/branches/D; svn checkout /srv/repos/branches/D /local/copy/branches/D</td>
</tr>
<tr>
<td>3. Feature B is very simple and you want to knock it out and get it into production ASAP.</td>
<td class="precell">git checkout B<br />
[work in editor]<br />
git commit -a</p>
<p>[peer review]<br />
git format-patch<br />
git send-email [options will vary]<br />
[peer gives you "thumbs up"]</p>
<p>git checkout master<br />
git merge B<br />
git push</td>
<td class="precell">[open text editor for branch B]<br />
[work in editor]<br />
svn commit</p>
<p>[peer review]<br />
[send email to peer with branch name]<br />
[peer checks out your branch locally to review]<br />
[peer gives you "thumbs up"]</p>
<p>cd /local/copy/trunk<br />
svn merge /local/copy/branches/B .<br />
svn commit</td>
</tr>
<tr>
<td>4. Get rid of unnecessary branch B.</td>
<td class="precell">git branch -d B</td>
<td class="precell">svn delete /srv/repos/branches/B<br />
svn update</td>
</tr>
</tbody>
</table>
<p>Note the key advantages Git offered in each step:</p>
<ol>
<li>Git creates a full repository with this command.  With Subversion, you&#8217;re just checking out the files in the repository.</li>
<li>With each branch, no new files are created in the project file hierarchy on your system.  Since you have a full local repository, Git creates the files you need on the fly by processing the recorded changes.  With Subversion, you have to create every branch remotely on the server.  This can get messy depending on the size of your team.  If you decide to control branching to keep things clean, you forfeit the power branching offers.</li>
<li>With Git, we only push our work to the server AFTER collaboration (more below).  With Subversion, it all hits the server.</li>
<li>Again, no file system work.  Since we&#8217;re using a local repository, we let Git handle the details of removing the branch.  With Subversion, you still have the old copy until you update.  You either have to clean up manually, or &#8220;update&#8221; to clean up local and remote copies.</li>
</ol>
<p>In addition, try to do this scenario on your laptop while not connected to the Internet.  With Git, no issues, the repository is local; however, with Subversion, you&#8217;re out of luck.  Your new branches will have to wait. The advantages of Git for branching are clear in this simple branching scenario.  Let&#8217;s continue to look at our scenario with non-trivial features A, C, and D that we&#8217;re working on.</p>
<h3>Stashing Temporary Work</h3>
<p>You start working on A and you&#8217;re about 100 lines of code into it when you get stumped on a math function.  The math wiz on your team is out for the day and you&#8217;d rather not continue until you consult him.  You&#8217;ve got some ideas for C, so you decide shift gears and get started.</p>
<table class="codetable" border="0">
<tbody>
<tr>
<th style="width: 75px;">Task</th>
<th>Git</th>
<th>Subversion</th>
</tr>
<tr>
<td>1. Switch to branch A, write 100 lines of code</td>
<td class="precell">git checkout A</td>
<td class="precell">[open text editor for branch A]</td>
</tr>
<tr>
<td>2. Switch to branch C  while waiting on a co-worker&#8217;s advise for A</td>
<td class="precell">git stash<br />
git checkout C</td>
<td class="precell">[close text editor for branch A]<br />
[open text editor for branch C]</td>
</tr>
<tr>
<td>3. Work on C for a while, get advise from co-worker and resume work on A</td>
<td class="precell">git stash<br />
git checkout A<br />
git stash list<br />
git stash apply [stash name]</td>
<td class="precell">[close text editor for branch C]<br />
[open text editor for branch A]</td>
</tr>
</tbody>
</table>
<p>At a glance, you might get the impression that Subversion is simpler, and you&#8217;re probably right.  However, this is one case where simple may not be what you&#8217;re looking for.  Let&#8217;s look at each step:</p>
<ol>
<li>The key thing to note in this and every step is how we switch between branches.  In Git, the repository handles this. With Subversion, you&#8217;re literally just working on a separate set of files.  Ultimately, it&#8217;s up to you to manage retrieving and editing these files.  If you&#8217;re using TextMate, you&#8217;ll probably save a TextMate project file every time you branch simply to give you quick access to the branch.  If you branch a lot, this quickly becomes annoying, time consuming, and non-productive.  With Git, when you checkout a separate branch, it &#8220;magically&#8221; changes all of the files on your file system for you.  That means 1 project file is all you ever need.  Git handles the rest.</li>
<li>Git will &#8220;float&#8221; uncommitted changes.  This means that if simply did a &#8220;git checkout C,&#8221; you&#8217;d bring with you all of the uncommitted work you did for A.  However, you don&#8217;t want to commit A because it&#8217;s not in a good working state.  Instead, you &#8220;stash&#8221; your work.  Stash is like a work in process commit.  Using it will tuck away your WIP changes without a formal commit, which allows you to change to C without &#8220;floating&#8221; any of your A changes.  The Subversion method is simpler, but you could potentially end up with several half-baked branches and no record of when you abandoned them.  Git&#8217;s stash allows you to list all stashes, and even write a message when you stash.  It is far more powerful in this scenario.</li>
<li>Same as 2, but shows the &#8220;git stash list&#8221; feature.</li>
</ol>
<p>So now we can work smoothly between multiple branches without worry of the consequences of interruption.  Git thus far has shown immense strength in two key areas, but let&#8217;s revisit collaboration to seal the deal.</p>
<h3>Collaboration Before Public Commits</h3>
<p>It&#8217;s now weeks later and you&#8217;re working on D.  After some round table discussions with the team, you all agree that D may not be the best approach.  A co-worker starts working on his own branch E and a few days later wants to review it with you.</p>
<table class="codetable" border="0">
<tbody>
<tr>
<th style="width: 75px;">Task</th>
<th>Git</th>
<th>Subversion</th>
</tr>
<tr>
<td>1. Review co-workers suggested changes in his branch E</td>
<td class="precell">[check your email for patch]<br />
[review patch]</td>
<td class="precell">svn checkout /srv/repos/branches/E /local/copy/branches/E<br />
[open text editor for branch E]<br />
svn log [to find changes]<br />
svn diff [to view changes]<br />
[review branch]</td>
</tr>
<tr>
<td>2. Agree that E is better and destroy your branch D</td>
<td class="precell">git branch -D D</td>
<td class="precell">svn delete /srv/repos/branches/D<br />
svn update</td>
</tr>
</tbody>
</table>
<p>Git offers power by putting collaboration up front before commits are public for all to see.  Consider in each step:</p>
<ol>
<li>Git has a nice feature to create &#8220;patches.&#8221;  They are simply changes to code, very similar to a diff.  The idea is that you create patches from commits you&#8217;ve only made on your local copy of the repository.  When your co-worker sent you the patch for E, no one else on the team had to see his commit logs, branches, etc., in the public repository because they never existed there.  You are collaborating about E via emailed patches.  With Subversion, it&#8217;s all on the server, all the time.</li>
<li>With Git, deleting an abandoned branch is simple and clean.  The work done in D will never be seen by the public, i.e., your team.  You&#8217;ve spared the team clutter both in the logs and on their file systems.  With Subversion, the clean up is on you.  Should you forget to delete D, it&#8217;s has the potential to get used and that could be bad.  Conversely, someone else may have quietly checked out D and been working on something.  When you delete it from the public repository, their commit will surely fail.</li>
</ol>
<h3>Conclusion</h3>
<p>There are literally hundreds of features for both Git and Subversion.  While you may have detailed reasons to choose one over the other, I think these 3 high level reasons are strongly convincing in favor of Git.  If you have differing opinions, I&#8217;d love to hear them.</p>
]]></content:encoded>
			<wfw:commentRss>http://markmcb.com/2008/10/18/3-reasons-to-switch-to-git-from-subversion/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Skip All Rails Filters</title>
		<link>http://markmcb.com/2008/10/14/skip-all-rails-filters/</link>
		<comments>http://markmcb.com/2008/10/14/skip-all-rails-filters/#comments</comments>
		<pubDate>Wed, 15 Oct 2008 04:45:31 +0000</pubDate>
		<dc:creator>markmcb</dc:creator>
		
		<category><![CDATA[Web Development]]></category>

		<category><![CDATA[filters]]></category>

		<category><![CDATA[rails]]></category>

		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://markmcb.com/?p=169</guid>
		<description><![CDATA[It took me a while to figure this out, but it&#8217;s quite simple.  If you want to skip all of the filters a Rails controller will run, simply put the following at the top of your controller:



skip_filter filter_chain #both documented in the Rails API



For example, if your application controller defines a filter to check if [...]]]></description>
			<content:encoded><![CDATA[<p>It took me a while to figure this out, but it&#8217;s quite simple.  If you want to skip all of the filters a Rails controller will run, simply put the following at the top of your controller:</p>
<div class="geshi no rails">
<ol>
<li class="li1">
<div class="de1">skip_filter filter_chain <span class="co1">#both documented in the Rails API</span></div>
</li>
</ol>
</div>
<p>For example, if your application controller defines a filter to check if a user is logged in, it makes sense that this filter might run for all controllers, except in rare cases.  In my case, I have a dynamic image controller that doesn&#8217;t require all of the overhead that most controllers do.  For that controller, I use the above to skip all of the filters.</p>
]]></content:encoded>
			<wfw:commentRss>http://markmcb.com/2008/10/14/skip-all-rails-filters/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Backpack Picnic: Farmer Dinner</title>
		<link>http://markmcb.com/2008/09/22/backpack-picnic-farmer-dinner/</link>
		<comments>http://markmcb.com/2008/09/22/backpack-picnic-farmer-dinner/#comments</comments>
		<pubDate>Tue, 23 Sep 2008 03:02:29 +0000</pubDate>
		<dc:creator>markmcb</dc:creator>
		
		<category><![CDATA[Comedy]]></category>

		<category><![CDATA[backpack picnic]]></category>

		<category><![CDATA[farmer dinner]]></category>

		<category><![CDATA[on networks]]></category>

		<guid isPermaLink="false">http://markmcb.com/?p=144</guid>
		<description><![CDATA[
A comedy group I&#8217;ve gotten into recently has a show called Backpack Picnic that can be found on the ON Networks site.  If you&#8217;re looking for something new/funny/smart, check them out.
My favorite episode so far is called &#8220;Farmer Dinner,&#8221; in which a genius farmer son named &#8220;Ma jr.&#8221; argues with his farmer dad about [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; padding: 0px 0px 10px 10px"><a title="Farmer Dinner" rel="lightbox[pics144]" href="http://www.onnetworks.com/videos/backpack-picnic/farmer-dinner"><img class="attachment wp-att-145 alignleft" src="http://markmcb.com/wp-content/uploads/2008/09/farmer_dinner.png" alt="Farmer Dinner" width="301" height="176" /></a></div>
<p>A comedy group I&#8217;ve gotten into recently has a show called <a href="http://www.onnetworks.com/videos/backpack-picnic">Backpack Picnic</a> that can be found on the ON Networks site.  If you&#8217;re looking for something new/funny/smart, check them out.</p>
<p>My favorite episode so far is called &#8220;<a href="http://www.onnetworks.com/videos/backpack-picnic/farmer-dinner">Farmer Dinner</a>,&#8221; in which a genius farmer son named &#8220;Ma jr.&#8221; argues with his farmer dad about the physical definition of work until they&#8217;re interrupted by &#8220;Pa jr.&#8221; who has just returned from returned from his new life as a fisherman.  What could be funnier than that?</p>
]]></content:encoded>
			<wfw:commentRss>http://markmcb.com/2008/09/22/backpack-picnic-farmer-dinner/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Multiple Remote Git Branches With Different Local Names</title>
		<link>http://markmcb.com/2008/09/21/multiple-remote-git-branches-with-different-local-names/</link>
		<comments>http://markmcb.com/2008/09/21/multiple-remote-git-branches-with-different-local-names/#comments</comments>
		<pubDate>Sun, 21 Sep 2008 20:50:30 +0000</pubDate>
		<dc:creator>markmcb</dc:creator>
		
		<category><![CDATA[Server Administration]]></category>

		<category><![CDATA[Web Development]]></category>

		<category><![CDATA[branching]]></category>

		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://markmcb.com/?p=131</guid>
		<description><![CDATA[I pounded my head against the wall for a bit when trying to play out this scenario in Git:

Remote repository has two branches: master and some-long-complex-name
Locally, I have cloned master
I have set up my config to refer to the remote master as &#8220;origin&#8221;
I have checked out some-long-complex-name using the following:


$ git checkout --track -b simple-name [...]]]></description>
			<content:encoded><![CDATA[<p>I pounded my head against the wall for a bit when trying to play out this scenario in Git:</p>
<ul>
<li>Remote repository has two branches: master and some-long-complex-name</li>
<li>Locally, I have cloned master</li>
<li>I have set up my config to refer to the remote master as &#8220;origin&#8221;</li>
<li>I have checked out some-long-complex-name using the following:</li>
</ul>
<pre>
$ git checkout --track -b simple-name origin/some-long-complex-name
</pre>
<p>The key thing to note is that my local branch has a different name than the remote branch, i.e., &#8220;simple-name&#8221; is my local branch that&#8217;s tracking the remote branch &#8220;some-long-complex-name&#8221;.  I&#8217;ve used pseudo-branch-names in this example, but in practice I like my local branch names to be 3 characters or so such that they&#8217;re easy to type, and I like the remote branches to have long names such that there is no ambiguity about what they are.</p>
<p>My initial .git/config looked like this after the aforementioned checkout command:</p>
<pre>
[remote "origin"]
        url = ssh://myserv/srv/git/proj.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master
[branch "simple-name"]
        remote = origin
        merge = refs/heads/some-long-complex-name
</pre>
<p>Now, this isn&#8217;t too bad.  All pull related commands work, but push only works for the master branch.  What I wanted was git to push to &#8220;some-long-complex-name&#8221; whenever I ran &#8220;git push&#8221; from my local &#8220;simple-name&#8221; branch.</p>
<p>I changed .git/config to look like this:</p>
<pre>
[remote "origin"]
    url = ssh://myserv/srv/git/proj.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
[remote "simple_origin"]
        url = ssh://myserv/srv/git/proj.git
        fetch = +refs/heads/*:refs/remotes/origin/*
        push = simple-name:some-long-complex-name
[branch "simple-name"]
        remote = simple_origin
        merge = refs/heads/some-long-complex-name
</pre>
<p>Note the additional &#8220;remote&#8221; section and the &#8220;push&#8221; reference.  Now, when I&#8217;m in my simple-name branch, I can just type &#8220;git push&#8221; and this branch will push out to the remote branch names &#8220;some-long-complex-name&#8221;.</p>
<p>Thanks to those who offered help on the <a href="http://freenode.net/irc_servers.shtml">freenode IRC</a> <a href="http://colabti.org/irclogger/irclogger_log/git">#git</a> channel, namely <a href="http://colabti.org/irclogger/irclogger_log/git?date=2008-09-21,Sun#l125">RandalSchwartz</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://markmcb.com/2008/09/21/multiple-remote-git-branches-with-different-local-names/feed/</wfw:commentRss>
		</item>
		<item>
		<title>College Reporters on Facebook Style Change</title>
		<link>http://markmcb.com/2008/09/20/college-reporters-on-facebook-style-change/</link>
		<comments>http://markmcb.com/2008/09/20/college-reporters-on-facebook-style-change/#comments</comments>
		<pubDate>Sat, 20 Sep 2008 22:50:08 +0000</pubDate>
		<dc:creator>markmcb</dc:creator>
		
		<category><![CDATA[Observations]]></category>

		<category><![CDATA[college]]></category>

		<category><![CDATA[facebook]]></category>

		<category><![CDATA[reporters]]></category>

		<guid isPermaLink="false">http://markmcb.com/?p=119</guid>
		<description><![CDATA[
I like the Internet.  I like web sites.  I spend significant hours of my life with my computer.  (I view it as my slave, forced to do my hardest work. But that&#8217;s another post.)  Despite all of my time and interest, I don&#8217;t get the social networking fanatics.  I saw [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; padding: 10px"><a title="Reporters" rel="lightbox[pics119]" href="http://www.ireport.com/docs/DOC-90591"><img src="http://markmcb.com/wp-content/uploads/2008/09/reporters.png" alt="Reporters" width="244" height="198" /></a></div>
<p>I like the Internet.  I like web sites.  I spend significant hours of my life with my computer.  (I view it as my slave, forced to do my hardest work. But that&#8217;s another post.)  Despite all of my time and interest, I don&#8217;t get the social networking fanatics.  I saw an iReport video on CNN about some <a href="http://www.ireport.com/docs/DOC-90591">kids trying to petition the new style and layout on Facebook</a> and I couldn&#8217;t help but think, &#8220;what?&#8221;  (Seriously, watch it.)</p>
<p>Is it just me, or were you thinking, &#8220;college student?&#8221; when that second guy came on?  And what about the first kid?  He seems like he should be joking, but he&#8217;s not.  Best of all is when they start talking about the attention the college kid has now with his group.  The college kids says it&#8217;s annoying because people disagree with him.  Ah, a good ol&#8217; dose of reality.  Some advise for this kid: when you protest a $15B company&#8217;s actions, don&#8217;t expect it to be easy.  You might actual have to *gasp* work to get what you want if you feel it&#8217;s that important.</p>
<p>On the flipside, I hope it works out for him.  I hate the new Facebook layout too.</p>
]]></content:encoded>
			<wfw:commentRss>http://markmcb.com/2008/09/20/college-reporters-on-facebook-style-change/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Installing Gitweb on Fedora Linux and Apache</title>
		<link>http://markmcb.com/2008/09/19/installing-gitweb-on-fedora-linux-and-apache/</link>
		<comments>http://markmcb.com/2008/09/19/installing-gitweb-on-fedora-linux-and-apache/#comments</comments>
		<pubDate>Sat, 20 Sep 2008 01:54:24 +0000</pubDate>
		<dc:creator>markmcb</dc:creator>
		
		<category><![CDATA[Server Administration]]></category>

		<category><![CDATA[Web Development]]></category>

		<category><![CDATA[apache]]></category>

		<category><![CDATA[git]]></category>

		<category><![CDATA[gitweb]]></category>

		<guid isPermaLink="false">http://markmcb.com/?p=100</guid>
		<description><![CDATA[My next natural step after getting my projects up and running with Git was to install a web interface.  Gitweb was my choice because:

it&#8217;s available via yum with Fedora
it provides up-to-date diff information
it&#8217;s part of the overall Git package, so it&#8217;s tightly integrated

Installation was ultimately quite simple, but I found the install docs to [...]]]></description>
			<content:encoded><![CDATA[<p>My next natural step after getting my projects up and running with Git was to install a web interface.  Gitweb was my choice because:</p>
<ul>
<li>it&#8217;s available via yum with Fedora</li>
<li>it provides up-to-date diff information</li>
<li>it&#8217;s part of the overall Git package, so it&#8217;s tightly integrated</li>
</ul>
<p>Installation was ultimately quite simple, but I found the install docs to be less than helpful for people like me who want immediate functionality and will get to the tweaks and details later.</p>
<h3>Step 1: Install Gitweb</h3>
<pre>sudo yum install gitweb</pre>
<p>This will install a few files at /var/www/git.  You shouldn&#8217;t need to do anything to them.</p>
<h3>Step 2: Create /etc/gitweb.conf</h3>
<p>You need a configuration file to tell Gitweb where to look for your project.  You can change this folder to wherever your project will be.</p>
<pre>$ echo "\$projectroot = '/srv/git/';" &gt; /etc/gitweb.conf</pre>
<h3>Step 3: Edit Apache Configuration File</h3>
<p>This configuration file assumes you are running your site as a virtual host.</p>
<div class="geshi no apache">
<div class="head">/etc/httpd/conf.d/git.conf</div>
<ol>
<li class="li1">
<div class="de1">&lt;VirtualHost *:<span class="nu0">80</span>&gt;</div>
</li>
<li class="li1">
<div class="de1">    <span class="kw1">DocumentRoot</span> /var/www/git</div>
</li>
<li class="li1">
<div class="de1">    <span class="kw1">ServerName</span> git.yourproject.com</div>
</li>
<li class="li1">
<div class="de1">     &lt;Directory /var/www/git&gt;</div>
</li>
<li class="li1">
<div class="de1">         &nbsp;<span class="kw1">Allow</span> <span class="kw1">from</span> <span class="kw1">all</span></div>
</li>
<li class="li1">
<div class="de1">          <span class="kw1">AllowOverride</span> <span class="kw1">all</span></div>
</li>
<li class="li1">
<div class="de1">          <span class="kw1">Order</span> <span class="kw1">allow</span>,<span class="kw1">deny</span></div>
</li>
<li class="li1">
<div class="de1">          <span class="kw1">Options</span> ExecCGI</div>
</li>
<li class="li1">
<div class="de1">          &lt;Files gitweb.cgi&gt;</div>
</li>
<li class="li1">
<div class="de1">               <span class="kw1">SetHandler</span> cgi-<span class="kw1">script</span></div>
</li>
<li class="li1">
<div class="de1">          &lt;/Files&gt;</div>
</li>
<li class="li1">
<div class="de1">     &lt;/Directory&gt;</div>
</li>
<li class="li1">
<div class="de1">     <span class="kw1">DirectoryIndex</span> gitweb.cgi</div>
</li>
<li class="li1">
<div class="de1">     <span class="kw1">SetEnv</span>  GITWEB_CONFIG  /etc/gitweb.conf</div>
</li>
<li class="li1">
<div class="de1">&lt;/VirtualHost&gt;</div>
</li>
</ol>
</div>
<h3>Step 3: Tweak Your Repository&#8217;s Config File</h3>
<p>Gitweb lists two key elements at the start of your project&#8217;s page: description and owner.  To have these display something appropriate, edit /srv/git/yourproject/.git/description:</p>
<pre>My Awesome Project</pre>
<p>&#8230; and add this to /srv/git/yourproject/.git/config:</p>
<pre>[gitweb]
        owner = "Mark McBride"</pre>
<h3>Step 4: Restart Apache</h3>
<p>That&#8217;s it.  Just restart Apache and you should find Gitweb running at the domain you&#8217;ve specified.</p>
<p>References:</p>
<ul>
<li><a href="http://www.philsergi.com/">Phil Sergi</a>, <a href="http://www.philsergi.com/2008/04/gitweb-apache-gentoo.html">http://www.philsergi.com/2008/04/gitweb-apache-gentoo.html</a></li>
<li>Gitweb Wiki, <a href="http://git.or.cz/gitwiki/Gitweb">http://git.or.cz/gitwiki/Gitweb</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://markmcb.com/2008/09/19/installing-gitweb-on-fedora-linux-and-apache/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
