<?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>SHOCM &#187; Development</title>
	<atom:link href="http://www.shocm.com/category/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.shocm.com</link>
	<description>Open Source, Cloud, Scotch, Baseball, Family, and Programming since the 1900&#039;s</description>
	<lastBuildDate>Fri, 27 Apr 2012 15:24:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Powerful Validation from Respect</title>
		<link>http://www.shocm.com/2011/04/powerful-validation-from-respect/</link>
		<comments>http://www.shocm.com/2011/04/powerful-validation-from-respect/#comments</comments>
		<pubDate>Fri, 01 Apr 2011 18:50:16 +0000</pubDate>
		<dc:creator>Shocm</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Validation]]></category>

		<guid isPermaLink="false">http://www.shocm.com/2011/04/powerful-validation-from-respect/</guid>
		<description><![CDATA[<p>All developers have had to, and one time or another, write a validation class. Over the years, I&#8217;ve personally tweaked my own validation class and it has become a pretty standard part of all my coding project; However that may all change now.</p> <p>Respect is not the first PHP validation class to hit the tubes [...]]]></description>
			<content:encoded><![CDATA[<div class='posterous_autopost'>
<p>All developers have had to,  and one time or another,  write a validation class.  Over the years,  I&#8217;ve personally tweaked my own validation class and it has become a pretty standard part of all my coding project; However that may all change now.</p>
<p>Respect is not the first PHP validation class to hit the tubes of the Net but it does appear to be one of the better implemented and flexible ones out there.</p>
<p>More powerful Validation from Respect &#8211; <a href="http://pulsene.ws/1atzk">http://pulsene.ws/1atzk</a></p>
<p style="font-size: 10px;">  <a href="http://posterous.com">Posted via email</a>   from <a href="http://blog.shocm.me/powerful-validation-from-respect">shocm</a>  </p>
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.shocm.com/2011/04/powerful-validation-from-respect/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting Git to work in Textmate, Resolving &#8220;sh: git: command not found&#8221; error</title>
		<link>http://www.shocm.com/2011/02/getting-git-to-work-in-textmate-resolving-sh-git-command-not-found-error/</link>
		<comments>http://www.shocm.com/2011/02/getting-git-to-work-in-textmate-resolving-sh-git-command-not-found-error/#comments</comments>
		<pubDate>Tue, 22 Feb 2011 03:52:29 +0000</pubDate>
		<dc:creator>Shocm</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[OSX]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[textmate]]></category>

		<guid isPermaLink="false">http://www.shocm.com/2011/02/getting-git-to-work-in-textmate-resolving-sh-git-command-not-found-error/</guid>
		<description><![CDATA[<p>I&#8217;ve been doing a lot of work with Git lately and its great. I downloaded and installed the Git Bundle for Textmate but it didn&#8217;t  seem to work, always returning the error message &#8220;sh: git: command not found&#8221;. Since I did most of my Git work from the command line I just ignored it but for [...]]]></description>
			<content:encoded><![CDATA[<div class="posterous_autopost">
<p>I&#8217;ve been doing a lot of work with Git lately and its great. I downloaded and installed the Git Bundle for Textmate but it didn&#8217;t  seem to work, always returning the error message &#8220;sh: git: command not found&#8221;. Since I did most of my Git work from the command line I just ignored it but for some reason tonight I decided I needed to fix.</p>
<p>Since I knew Git worked on my system, it must have been something with the way Textmate was configured. I couldn&#8217;t figure out how to confiugre Textmate to point to my Git install so I guess I cheated and I created a symbolic link on my system to point to my Git install. It seems to have corrected my issue with Textmate.</p>
<p>The command I ran was pretty simple</p>
<pre class="brush: bash; title: ; notranslate">
sudo ln -s /usr/local/git/bin/git /usr/bin/git
</pre>
<p>That&#8217;s it, Textmate is now happy with my Git install.</p>
<p style="font-size: 10px;"><a href="http://posterous.com">Posted via email</a> from <a href="http://blog.shocm.me/getting-git-to-work-in-textmate-resolving-sh">shocm</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.shocm.com/2011/02/getting-git-to-work-in-textmate-resolving-sh-git-command-not-found-error/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>I need a web site</title>
		<link>http://www.shocm.com/2010/07/i-need-a-web-site/</link>
		<comments>http://www.shocm.com/2010/07/i-need-a-web-site/#comments</comments>
		<pubDate>Thu, 01 Jul 2010 23:43:37 +0000</pubDate>
		<dc:creator>Shocm</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Funny]]></category>
		<category><![CDATA[Geek Stuff]]></category>
		<category><![CDATA[Video]]></category>

		<guid isPermaLink="false">http://www.shocm.com/?p=645</guid>
		<description><![CDATA[<p>All to common of a conversation.</p> <p></p>]]></description>
			<content:encoded><![CDATA[<p>All to common of a conversation.</p>
<p><object width="480" height="390"><param name="movie" value="http://www.xtranormal.com/site_media/players/jwplayer.swf"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><param name="flashvars"value="height=390&#038;width=480&#038;file=http://newvideos.xtranormal.com/web_final_lo/9f56c044-83af-11df-a9c4-003048d6740d_1_web_final_lo_web_finallo-flv.flv&#038;image=http://newvideos.xtranormal.com/iphone_final/9f56c044-83af-11df-a9c4-003048d6740d_1_iphone_final_poster.jpg&#038;link=http://www.xtranormal.com/watch/6723127&#038;searchbar=false&#038;autostart=false"/><embed src="http://www.xtranormal.com/site_media/players/jwplayer.swf" width="480" height="390" allowscriptaccess="always" allowfullscreen="true" flashvars="height=390&#038;width=480&#038;file=http://newvideos.xtranormal.com/web_final_lo/9f56c044-83af-11df-a9c4-003048d6740d_1_web_final_lo_web_finallo-flv.flv&#038;image=http://newvideos.xtranormal.com/iphone_final/9f56c044-83af-11df-a9c4-003048d6740d_1_iphone_final_poster.jpg&#038;link=http://www.xtranormal.com/watch/6723127&#038;searchbar=false&#038;autostart=false"></embed></object><object width="480" height="390"><param name="movie" value="http://www.xtranormal.com/site_media/players/embedded-xnl-stats.swf"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.xtranormal.com/site_media/players/embedded-xnl-stats.swf" width="1" height="1" allowscriptaccess="always"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.shocm.com/2010/07/i-need-a-web-site/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>&#8216;report_activate_error&#8217;: RubyGem version error</title>
		<link>http://www.shocm.com/2010/03/report_activate_error-rubygem-version-error/</link>
		<comments>http://www.shocm.com/2010/03/report_activate_error-rubygem-version-error/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 05:55:19 +0000</pubDate>
		<dc:creator>Shocm</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Geek Stuff]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[RoR]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.vanjohnson.com/2010/report_activate_error-rubygem-version-error/</guid>
		<description><![CDATA[<p>So from time to time I will post small things to my blog that I just want to keep track of or remember how I did something. This is one of those post. I should prefix this post to anyone who happens to come across it and read it, I am by no means a [...]]]></description>
			<content:encoded><![CDATA[<p>So from time to time I will post small things to my blog that I just want to keep track of or remember how I did something. This is one of those post. I should prefix this post to anyone who happens to come across it and read it, I am by no means a &#8220;Rails Developer&#8221; and as a matter of fact, I ran into this problem working through a &#8220;How to&#8221; books.</p>
<p><strong>The issue</strong></p>
<p>I am running OSX 10.6.2 and although I had Ruby on Rails working on it at one time, some how, some where it broke. Now there is nothing more frustrating to a n00b who is trying to work through a tutorial on how to learn a new programming language and not being able to get past the first chapter because something about the base install of the programming language that you don&#8217;t know anything about and you&#8217;re trying to learn, wont work.</p>
<p><strong>The Actual Error</strong></p>
<p>When I try to create my first controller this is what happens</p>
<pre class="brush: bash; title: ; notranslate">
ruby script/generate controller main welcome
</pre>
<p>And this is what the system kicked out to me</p>
<pre class="brush: bash; title: ; notranslate">
/Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/initializer.rb:271:in `require_frameworks': RubyGem version error: rack(1.0.0 not ~&amp;gt; 1.0.1) (RuntimeError)

from /Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/initializer.rb:134:in `process'
from /Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/initializer.rb:113:in `send'
from /Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/initializer.rb:113:in `run'
from /Users/eric/Dropbox/Code/Rails/r4music1/config/environment.rb:9
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
from /Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/commands/generate.rb:1
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
from script/generate:3
</pre>
<p><strong>Sidebar</strong><br />
Naturally, the first thing I do is start hitting Google and start clicking on links. A lot of similar issues with a wide variety of solutions. From just doing a simple &#8216;sudo gem update&#8217;, to making sure rake is installed, to making sure you have the correct rake version installed. None of which worked for me. Finally, I stumbled onto <a id="aptureLink_gSZtw9Nlmz" href="http://christopher.wojno.com/2010/02/14/ruby-on-rails-rack-1-0-0-not-rack-1-0-1-c">Wojno&#8217; Site</a> and following the steps in his <a href="http://christopher.wojno.com/2010/02/14/ruby-on-rails-rack-1-0-0-not-rack-1-0-1-c">post</a> I manage to resolve my problem.</p>
<p><strong>The Fix</strong><br />
If you didn&#8217;t want to click on <a href="http://christopher.wojno.com/2010/02/14/ruby-on-rails-rack-1-0-0-not-rack-1-0-1-c">Wonjno&#8217;s link</a> here are the steps that fixed my problem. Had to change a couple of things because my install paths were a little different since I was running a different OS.<br />
We begin by uninstalling the problem package </p>
<pre class="brush: bash; title: ; notranslate">
sudo gem uninstall rack
</pre>
<p>When prompted, make sure you remove all versions of the rack packages. Now this is one place where my experience differed a little. I ended up getting prompted to uninstall rails itself. I&#8217;m a brave soul, that didn&#8217;t scare me, so yeah I uninstalled it.<br />
Here is what that looked like</p>
<pre class="brush: bash; title: ; notranslate">
sudo gem uninstall rack
Remove executables: rackup in addition to the gem? [Yn]  Y
Removing rackup
You have requested to uninstall the gem: rack-1.0.0
actionpack-2.3.3 depends on [rack (~&amp;gt; 1.0.0)]
actionpack-2.3.5 depends on [rack (~&amp;gt; 1.0.0)]
If you remove this gems, one or more dependencies will not be met.
Continue with Uninstall? [Yn]  Y
</pre>
<p>OK, that was a little scary but we will fix it.<br />
I did manually remove the directory for the older version of rack</p>
<pre class="brush: bash; title: ; notranslate">
sudo rm -rf /Library/Ruby/Gems/1.8/gems/rack-1.0.1/
</pre>
<p>Now we reinstall things. Don&#8217;t forget we need to reinstall the rails itself</p>
<pre class="brush: bash; title: ; notranslate">
sudo gem install -v=2.3.5 rails
sudo gem install rack
</pre>
<p>After that, life was good, at least for me. If you found this article and actually read it in hopes that it helped fix your issue, well then I hope you had some success as well.</p>
<p style="font-size: 10px;"><a href="http://posterous.com">Posted via web</a> from <a href="http://shocm.posterous.com/reportactivateerror-rubygem-version-error">shocm</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.shocm.com/2010/03/report_activate_error-rubygem-version-error/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Microsoft and Zend</title>
		<link>http://www.shocm.com/2006/11/microsoft-and-zend/</link>
		<comments>http://www.shocm.com/2006/11/microsoft-and-zend/#comments</comments>
		<pubDate>Fri, 10 Nov 2006 22:56:30 +0000</pubDate>
		<dc:creator>Shocm</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[F/OSS]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.vanjohnson.com/?p=95</guid>
		<description><![CDATA[<p>More for my geek friends. This is old news but if you haven&#8217;t heard.<br /> <a href="http://www.zend.com/company/zend_news/announcements/2006/10/microsoft_and_zend_technologies_announce_technical_collaboration_to_improve_interoperability_of_php_on_the_windows_server_platform">Microsoft and Zend Technologies Announce Technical Collaboration to Improve Interoperability of PHP on the Windows Server Platform / 10 / 2006 / Announcements / Zend News / Company / Zend.com</a> <br /> REDMOND, Wash., and CUPERTINO, Calif. â€” Oct. [...]]]></description>
			<content:encoded><![CDATA[<p>More for my geek friends. This is old news but if you haven&#8217;t heard.<br />
<blockquote><a href="http://www.zend.com/company/zend_news/announcements/2006/10/microsoft_and_zend_technologies_announce_technical_collaboration_to_improve_interoperability_of_php_on_the_windows_server_platform">Microsoft and Zend Technologies Announce Technical Collaboration to Improve Interoperability of PHP on the Windows Server Platform / 10 / 2006 / Announcements / Zend News / Company / Zend.com</a> <br />
<blockquote>REDMOND, Wash., and CUPERTINO, Calif. â€” Oct. 31, 2006 â€” Microsoft Corp. and Zend Technologies Inc. today announced a technical collaboration to enhance the experience of running the PHP scripting language on Windows ServerÂ® 2003. The parties expect to extend the collaboration to the next version of Windows Server, code-named â€œLonghorn.â€ The resulting technology enhancements and ongoing interaction with the PHP community is expected to enable customers to take advantage of the Windows Server platform. The cooperative effort seeks to provide customers with richer functionality and better integration, resulting in improved performance and increased reliability.</p></blockquote>
</blockquote>
<p><span id="more-95"></span></p>
<p>The technology engagement between the two companies will include the following:</p>
<p>    * Technical improvements for PHP deploying on the Windows Server platform will be submitted under the PHP license to the PHP community for feedback and contribution.<br />
    * Microsoft plans to develop and release an Internet Information Services (IIS) add-on component, FastCGI, that will serve as the interface between PHP and the IIS Web server. Microsoft expects that this FastCGI component will be made freely available from Microsoft on http://www.iis.net for users of MicrosoftÂ® WindowsÂ® XP, Windows Server 2003, Windows Vistaâ„¢ and Windows Server â€œLonghorn.â€<br />
    * Zend will establish a Windows testing lab and conduct regular tests and performance improvements to maintain high performance of PHP on the Windows Server platform as PHP evolves.<br />
    * Microsoft and Zend will work to help ensure a production-quality PHP runtime environment for IIS 5.1 (Windows XP), IIS 6.0 (Windows Server 2003) and IIS 7.0 (Windows Vista and Windows Server â€œLonghornâ€).<br />
    * Zend and Microsoft will actively participate in the PHP community, ensuring open discussion to help developers planning to deploy PHP applications on the Windows Server platform.</p>
<p>â€œInteroperability continues to be an important requirement for our customers, particularly when it comes to open source applications that run on Windows. This announcement today continues our commitment to making it easier for partners and developers â€” regardless of the development model they employ â€” to take advantage of increased reliability of the Microsoft Windows Server platform,â€ said Bill Hilf, general manager of Technical Platform Strategy at Microsoft. â€œZend is a clear leader in the PHP community, and we are excited to be working with it on this joint collaboration effort designed to provide developers using PHP with the best possible experience within a Microsoft environment.â€</p>
<p>â€œWith a majority of PHP developers developing on the Windows platform, we saw a great opportunity to work together with Microsoft to improve the overall experience for our joint customers,â€ said Andi Gutmans, co-founder and chief technology officer at Zend. â€œSince our preliminary work with Microsoft, we have already seen a better than 100 percent performance gain with some PHP applications on Windows Server 2003.â€</p>
<p>Zend and Microsoft will contribute the PHP improvements to the PHP community under the PHP license. Starting in the first quarter of 2007, Zend intends to use the improved technology in its Zend Core product line. A technology preview of the updated Windows version of Zend Core is available today at http://www.zend.com. Zend will also use the technology for its Zend Platform product line to enable its customers to support business-critical PHP production environments on the Windows Server platform.</p>
<p>â€œIn February we announced a technical collaboration with Microsoft to enable our customers to optimize their existing Windows infrastructure,â€ said John Roberts, chairman and chief executive officer of SugarCRM Inc., a leading open source application company employing PHP. â€œThis announcement underscores the demand from open source developers to take advantage of the Windows Sever platform and Microsoftâ€™s commitment to make that happen.â€</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shocm.com/2006/11/microsoft-and-zend/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Vi for programmers</title>
		<link>http://www.shocm.com/2004/08/vi-for-programmers/</link>
		<comments>http://www.shocm.com/2004/08/vi-for-programmers/#comments</comments>
		<pubDate>Sat, 07 Aug 2004 20:42:41 +0000</pubDate>
		<dc:creator>Shocm</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[vi]]></category>

		<guid isPermaLink="false">http://www.vanjohnson.com/?p=6</guid>
		<description><![CDATA[<p>This is a great article that shows you how to really harness some of the power of VIM. I snagged it from <a href="http://builder.com.com/5100-6372_14-5253006.html">Builder.com.</a></p> <p>It was a multiple part article so this is going to be kind of long but really filled with a lot of great information.</p> <p>If you&#8217;re a developer working on a [...]]]></description>
			<content:encoded><![CDATA[<p>This is a great article that shows you how to really harness some of the power of VIM. I snagged it from <a href="http://builder.com.com/5100-6372_14-5253006.html">Builder.com.</a></p>
<p>It was a multiple part article so this is going to be kind of long but really filled with a lot of great information.</p>
<p>If you&#8217;re a developer working on a UNIX/Linux platform, you&#8217;ve already encountered vi. Vi users fall into one of two categories: those who hate it and continually curse its finger-twisting key combinations and hard-to-remember commands, and those who love the flexibility and power it offers. For a long time, I was in the former category. However, continuous usage has led to a gradual appreciation for the speed and power under the cryptic interface, and I&#8217;ve since learnt a bunch of shortcuts and key combinations that ease the task of writing code in the editor. This article discusses my personal top ten features. Before proceeding, ensure that you have a copy of ViM (that&#8217;s Vi iMproved) installed and working on your system. You can download both binaries and sources from <a target="_blank" href="http://www.vim.org/" title="link">vim.org</a>.</p>
<p> <span id="more-6"></span></p>
<h3>Automatic indenting </h3>
<p>Let&#8217;s start with the basics: making your code readable. Most of the time, you do this through the careful use of indentation around nested code blocks (and, of course, lots of comments!). ViM isn&#8217;t smart enough to write the comments for you, but it can certainly help with the indenting through its very powerful auto-indenting feature. </p>
<p>To control the indenting of your code, there are two important variables in ViM: <em>tabstop </em> and <em>autoindent </em>. The first one controls the number of spaces a &lt;tab&gt; represents. If you want a &lt;tab&gt; to equal two spaces, you can use this command (executed from within vi): </p>
<blockquote>
<p><strong><font color="#000033">:set tabstop=2<br />
  </font> </strong></p>
</blockquote>
<p>Now, every time you press the &lt;tab&gt; key for an indent, ViM will move the cursor forward two spaces. </p>
<p>You can also have ViM automatically indent your code blocks for you, so that you never (well, almost never) need to manually hit the &lt;tab&gt; key. To do this, turn on auto-indenting: </p>
<blockquote>
<p><strong><font color="#000033">:set autoindent<br />
  </font></strong> </p>
</blockquote>
<p>With this option turned on, ViM will automatically tab a new line to the same indenting level used by the previous line. If you&#8217;re starting a loop, a conditional block or any other nested structure, this ensures that each line of code is correctly indented and in sync with the lines above it. </p>
<p>You won&#8217;t usually regret turning this feature on, but if you ever find it annoyingâ€”say, you switch from writing a script to writing a letter and a &lt;tab&gt; no longer indicates the beginning of a code blockâ€”you can turn it off with this command: </p>
<blockquote>
<p><strong><font color="#000033">:set noautoindent<br />
  </font></strong> </p>
</blockquote>
<h3>Syntax highlighting </h3>
<p>You know how all those Windows editors can color-code your scripts so that they look pretty? Well, ViM can do that too; the editor comes with a very powerful syntax-highlighting module that supports most common programming languages such as Perl, PHP, JavaScript, HTML, XML, and JSP. </p>
<p>To activate syntax highlighting on your script, type: </p>
<blockquote>
<p><strong><font color="#000033">:syntax enable<br />
  </font></strong> </p>
</blockquote>
<p>ViM automatically detects the file type and loads the appropriate set of colors. To turn syntax highlighting off (because it can sometimes cause things to slow down), use: </p>
<blockquote>
<p><strong><font color="#000033">:syntax off<br />
  </font></strong> </p>
</blockquote>
<p>If the colors are not to your liking, you can change them to something more suitable. ViM has a ready-made solution for you here tooâ€”a number of custom color schemes ship with the distribution, and you can activate any of them with the <em>colorscheme </em> command, like this: </p>
<blockquote>
<p><strong><font color="#000033">:colorscheme elflord<br />
  </font></strong> </p>
</blockquote>
<p>For a complete list of available schemes, look in the <em>colors/ </em> directory of the ViM shared areas (personally, I like <em>pablo </em>, <em>elflord </em> and the interestingly-named <em>peachpuff </em> the most). </p>
<h3>Reading linked files </h3>
<p>Like most programmers, you probably make it a point to create reusable code libraries that are abstracted out of your main scripts and brought in where needed through <em>include() </em> or <em>require() </em> statements. But what happens when you open up a script you wrote a few months back, and have no idea what all the <em>include() </em>s at the top refer to? </p>
<p>With ViM, finding out is a snap. If, for example, you have the following line of code at the top of your script: </p>
<blockquote>
<p><strong><font color="#000033">#include &lt;mydefs.h&gt;<br />
  </font></strong> </p>
</blockquote>
<p>And, you want to look inside <em>mydefs.h </em> to see what it contains, simply place your ViM cursor under the filename and type: </p>
<blockquote>
<p><strong><font color="#000033">gf<br />
  </font></strong> </p>
</blockquote>
<p>ViM will search for the file in the search path (set via the <em>path </em> variable) and display the file in the window immediately. This capability is a very useful one, especially when dealing with applications that have a large code tree and many internal links. </p>
<h3> Exploring the file system </h3>
<p>Speaking of files, ViM comes with a powerful file explorer that significantly eases the task of finding and opening files for editing. To see how it works, type: </p>
<blockquote>
<p><strong><font color="#000033">:edit .<br />
  </font></strong> </p>
</blockquote>
<p>in the ViM editor, and watch as a file listing for the current directory is generated for you. This file listing is part of a basic but fully-functional file manager that is built in to ViM, and it&#8217;s great for quickly finding and opening a file in another directory on the file system (especially if you&#8217;re not completely sure of the exact file name). </p>
<p>Once the file manager has popped up, you can use the arrow keys to navigate between files and directories, and select a file for editing with the [Enter] key. While in the file explorer, use the &#8220;i&#8221; key shortcut to toggle display of file timestamps and dates&#8230;very useful if you&#8217;re looking for the most recently-edited file. </p>
<h3>Using line numbers </h3>
<p>Often, the error messages generated by your scripts include line numbers indicating the source of the error. By default, however, ViM does not automatically print line numbers next to each line in edit mode. To fix this, use: </p>
<blockquote>
<p><strong><font color="#000033">:set number<br />
  </font></strong> </p>
</blockquote>
<p>command to have ViM prefix a line number before each line in the file. I have found this feature most useful when testing and debugging code simultaneously on two consoles; it&#8217;s very handy to quickly jump to &#8220;bad&#8221; lines of code. </p>
<p>To find out which line you&#8217;re currently editing in a file, type <em>&lt;CTRL&gt;-g </em> and look at the status bar. ViM prints a message containing statistics on the total number of lines in the file, as well as the current line number. </p>
<p>Even with line numbers on, you can save your &lt;page up&gt; and &lt;page down&gt; keys a bit of wear and tear by using ViM&#8217;s built-in key shortcuts to quickly jump to specific lines of your script: </p>
<ul>
<li> To jump to a particular line, type the line number then <em>&lt;SHIFT&gt;-g </em>. For example, to jump to line 26, type <em>26&lt;SHIFT&gt;-g </em>. </li>
<li> To jump to the beginning of the file, type <em>gg </em>. </li>
<li> To jump to the end of the file, use <em>&lt;SHIFT&gt;-g </em>. </li>
</ul>
<p>To turn off line number display, use: </p>
<blockquote>
<p><strong><font color="#000033">:set nonumber<br />
  </font></strong> </p>
</blockquote>
<p>And things will go back to normal. </p>
<h3>Multiple-window editing </h3>
<p>When you&#8217;re writing code, it&#8217;s common to switch back and forth between multiple files, either for reference or to copy/paste lines of code. On the Windows platform, this is simpleâ€”as the name suggests, all you need to do is open multiple windows and work on them simultaneously.<br />
But what happens in a UNIX console? Like all the best text editors, ViM supports viewing and editing files in different windows.<br />
To see how this works, simply type </p>
<blockquote>
<p><font color="#000033"><strong>:split<br />
  </strong> </font></p>
</blockquote>
<p>from inside vi and watch as your window subdivides horizontally into two. Each subwindow will display the contents of the selected file, and you can move around independently in each one. To move from one window to the other, type </p>
<blockquote>
<p><strong><font color="#000033">&lt;CTRL&gt;-w-w. </font></strong></p>
</blockquote>
<p>To open a new blank window, type </p>
<blockquote>
<p><strong><font color="#000033">:new<br />
  </font></strong> </p>
</blockquote>
<p>Instead of having the same file appear in each window, you can tell ViM to open a different file in the new window by adding the file path and name after the <em>split </em> command, as below: </p>
<blockquote>
<p><strong><font color="#000033">:split /tmp/test.c<br />
  </font></strong> </p>
</blockquote>
<p>The cut, copy, and paste commandsâ€”d, y, and pâ€”work as usual and can be used to move text from one window to another. If your console and ViM build support &#8220;visual mode,&#8221; you can even &#8220;select&#8221; blocks of text and &#8220;drag and drop&#8221; them between windows. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.shocm.com/2004/08/vi-for-programmers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Backing Up and Restoring Your MySQL Database</title>
		<link>http://www.shocm.com/2004/06/backing-up-and-restoring-your-mysql-database/</link>
		<comments>http://www.shocm.com/2004/06/backing-up-and-restoring-your-mysql-database/#comments</comments>
		<pubDate>Thu, 10 Jun 2004 21:25:53 +0000</pubDate>
		<dc:creator>Shocm</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[F/OSS]]></category>
		<category><![CDATA[Geek Stuff]]></category>
		<category><![CDATA[Backups]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[QuickTip]]></category>
		<category><![CDATA[Restore]]></category>

		<guid isPermaLink="false">http://www.vanjohnson.com/?p=11</guid>
		<description><![CDATA[<p>Do you need to change your web host or switch your database server? This is probably the only time when you really think of backing up your MySQL data. If you&#8217;ve got a website with a database or your custom database running for your applications, it is imperative that you make regular backups of the [...]]]></description>
			<content:encoded><![CDATA[<p>Do you need to change your web host or switch your database server? This is probably the only time when you really think of backing up your MySQL data. If you&#8217;ve got a website with a database or your custom database running for your applications, it is imperative that you make regular backups of the database. In this article, I will outline two easy ways of backing up and restoring databases in MySQL.<br />
The easiest way to backup your database would be to telnet to the your database server machine and use the mysqldump command to dump your whole database to a backup file. If you do not have telnet or shell access to your server, don&#8217;t worry about it; I shall outline a method of doing so using the PHPMyAdmin web interface, which you can setup on any web server which executes PHP scripts.</p>
<p><strong><br />
Playing with mysqldump</strong></p>
<p>If you have either a shell or telnet access to your database server, you can backup the database using mysqldump. By default, the output of the command will dump the contents of the database in SQL statements to your console. This output can then be piped or redirected to any location you want. If you plan to backup your database, you can pipe the output to a sql file, which will contain the SQL statements to recreate and populate the database tables when you wish to restore your database. There are more adventurous ways to use the output of mysqldump.</p>
<p>A Simple Database Backup:</p>
<p>You can use mysqldump to create a simple backup of your database using the following syntax.</p>
<p>mysqldump -u [username] -p [password] [databasename]> [backupfile.sql]</p>
<p>[username] &#8211; this is your database username<br />
[password] &#8211; this is the password for your database<br />
[databasename] &#8211; the name of your database<br />
[backupfile.sql] &#8211; the file to which the backup should be written.</p>
<p>The resultant dump file will contain all the SQL statements needed to create the table and populate the table in a new database server. To backup your database &#8216;Customers&#8217; with the username &#8216;sadmin&#8217; and password &#8216;pass21&#8242; to a file custback.sql, you would issue the command:</p>
<p>mysqldump -u sadmin -p pass21 Customers> custback.sql</p>
<p><span id="more-11"></span><br />
You can also ask mysqldump to add a drop table command before every create command by using the option &#8211;add-drop-table. This option is useful if you would like to create a backup file which can rewrite an existing database without having to delete the older database manually first.</p>
<p>mysqldump &#8211;add-drop-table -u sadmin -p pass21 Customers> custback.sql</p>
<p>Backing up only specified tables</p>
<p>If you&#8217;d like restrict the backup to only certain tables of your database, you can also specify the tables you want to backup. Let&#8217;s say that you want to backup only customer_master &#038; customer_details from the Customers database, you do that by issuing</p>
<p>mysqldump &#8211;add-drop-table -u sadmin -p pass21 Customers customer_master customer_details> custback.sql</p>
<p>So the syntax for the command to issue is:</p>
<p>mysqldump -u [username] -p [password] [databasename] [table1 table2 ....]</p>
<p>[tables] &#8211; This is a list of tables to backup. Each table is separated by a space.</p>
<p>If you are a database administrator who has to look after multiple databases, you&#8217;ll need to back up more than one database at a time. Here&#8217;s how you can backup multiple databases in one shot.</p>
<p>If you want to specify the databases to backup, you can use the &#8211;databases parameter followed by the list of databases you would like to backup. Each database name has to be separated by at least one space when you type in the command. So if you have to backup 3 databases, let say Customers, Orders and Comments, you can issue the following command to back them up. Make sure the username you specify has permissions to access the databases you would like to backup.</p>
<p>mysqldump -u root -p pass21 &#8211;databases Customers Orders Comments> multibackup.sql</p>
<p>This is okay if you have a small set of databases you want to backup. Now how about backing up all the databases in the server? That&#8217;s an easy one, just use the &#8211;all-databases parameter to backup all the databases in the server in one step.</p>
<p>mysqldump &#8211;all-databases> alldatabases.sql</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shocm.com/2004/06/backing-up-and-restoring-your-mysql-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Configuring Apache to use a .htaccess file</title>
		<link>http://www.shocm.com/2003/10/configuring-apache-to-use-a-htaccess-file/</link>
		<comments>http://www.shocm.com/2003/10/configuring-apache-to-use-a-htaccess-file/#comments</comments>
		<pubDate>Fri, 10 Oct 2003 21:33:01 +0000</pubDate>
		<dc:creator>Shocm</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[F/OSS]]></category>
		<category><![CDATA[Geek Stuff]]></category>
		<category><![CDATA[Administration]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[QuickTip]]></category>

		<guid isPermaLink="false">http://www.vanjohnson.com/?p=13</guid>
		<description><![CDATA[<p>Just a good step by step on how to configure Apache to use a .htaccess file. I rarely ever use this method except in testing so I always forget.</p> <p>First, get your web administrator to enable your use of .htaccess files. This requires a stanza in ServerRoot/conf/access.conf like this:</p> <p>AllowOverride AuthConfig</p> <p>where /home/webber is replaced [...]]]></description>
			<content:encoded><![CDATA[<p>Just a good step by step on how to configure Apache to use a .htaccess file. I rarely ever use this method except in testing so I always forget.</p>
<p>First, get your web administrator to enable your use of .htaccess files. This requires a stanza in ServerRoot/conf/access.conf like this:</p>
<p>AllowOverride AuthConfig</p>
<p>where /home/webber is replaced by your home directory. Without this, the usual default is AllowOverride None, which means that .htaccess files are ignored. The above stanza allows .htaccess control in all subdirectories of the specified Directory.</p>
<p>Set up a reasonably secure directory for the password (and optionally the group) files. This directory should not be in the web document tree! If it is, someone who can learn or guess the URL of the password file can fetch it and try to crack the passwords. (This refers to visitors from elsewhere on the Internet. There is no simple way to prevent users with accounts on the web server host itself from snooping in the password file, so we will have to settle for security by obscurity and trust them not to try too hard.)<br />
Let us name this directory http-etc by analogy to the Unix /etc directory where the system passwd and group files reside. Place it in your home directory (not in public_html) so that it is outside URL space. Give it permission 701 = rwx&#8212;&#8211;x meaning you the owner can do anything, and the web server, running as the ordinary user apache, can access the directory but cannot list it (so it must know the file names in advance).1</p>
<p><span id="more-13"></span><br />
In the http-etc directory, create the password file. It can have any name. A usual choice is htpasswd. Give it permission 644 = rw-r&#8211;r&#8211;. This file can be created empty by the touch command, or created with one initial entry by using the -c option when you run the htpasswd command the first time.</p>
<p>Add users to the password file using the htpasswd command. From your home directory, the command would be something like:<br />
htpasswd http-etc/htpasswd guest</p>
<p>In this example, the htpasswd program will prompt you for the password for user guest. After you type the password, you will have to re-type it for verification. The format of the password file is like this:</p>
<p>guest:IA22a/FU48faw<br />
janeuser:kyxFwALyFbsPw<br />
joeuser:rjyJsqbtXCvXo</p>
<p>The gibberish after each user&#8217;s name is the encrypted password. The plaintext passwords are not stored, for obvious security reasons. You cannot edit this file to change the passwords, unless you are the kind of person the NSA is very interested in hiring. The only way to update it is with the htpasswd program.</p>
<p>If you want to organize your users into groups, create a groups file, in the same directory as the password file. Its usual name is htgroup. Give it the same permissions as the password file. It contains a list of group names, with each group name followed by the user names belonging to the group. Create it using any text editor. The format is like:<br />
guest: guest<br />
users: janeuser joeuser</p>
<p>In any directory in your web page area that is to be protected, create a file named .htaccess, with contents like this:<br />
AuthType Basic<br />
AuthName &#8220;Restricted Directory&#8221;<br />
AuthUserFile /home/webber/http-etc/htpasswd<br />
AuthGroupFile /home/webber/http-etc/htgroup<br />
Require group users guest</p>
<p>Alternatively the require directive can say:<br />
Require user guest joeuser</p>
<p>or<br />
Require valid-user</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shocm.com/2003/10/configuring-apache-to-use-a-htaccess-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Backup files with tar</title>
		<link>http://www.shocm.com/2003/10/backup-files-with-tar/</link>
		<comments>http://www.shocm.com/2003/10/backup-files-with-tar/#comments</comments>
		<pubDate>Fri, 10 Oct 2003 21:30:57 +0000</pubDate>
		<dc:creator>Shocm</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Backups]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[commandline]]></category>
		<category><![CDATA[Restore]]></category>

		<guid isPermaLink="false">http://www.vanjohnson.com/?p=12</guid>
		<description><![CDATA[<p>[NOTE]<br /> I don&#8217;t remember where I got this article from but it is full of some good information<br /> [/NOTE]</p> <p>TAR is the Unix Tape ARchive utility. It can be used to either store data on a streaming tape device like a DAT drive, or store files in what is commonly called a tarball [...]]]></description>
			<content:encoded><![CDATA[<p>[NOTE]<br />
I don&#8217;t remember where I got this article from but it is full of some good information<br />
[/NOTE]</p>
<p>TAR is the Unix Tape ARchive utility. It can be used to either store data on a streaming tape device like a DAT drive, or store files in what is commonly called a tarball file- somewhat like a pkzip file, only compression is optional.</p>
<p><strong>[The basics]</strong></p>
<p>In these examples, I will use the following file structure: a top level directory called DIR1 containing the files picture.jpg, document.doc and database.db.</p>
<p>DIR1/<br />
DIR1/picture.jpg<br />
DIR1/document.doc<br />
DIR1/database.db</p>
<p><strong>[Creating a tarball]</strong></p>
<p>If we were in the directory DIR1 and wanted to backup all the files to a tarball called backup.tar, we could issue this command:</p>
<p>$ tar cvf backup.tar .<br />
./<br />
picture.jpg<br />
doucment.doc<br />
database.db<br />
tar: backup.tar is the archive; not dumped</p>
<p>Note:<br />
c=create (an archive)<br />
v=verbose (just because)<br />
f=filename (the name of our tarball)<br />
.=current directory (what&#8217;s going to be backed up)</p>
<p>Also worth mentioning is that by default tar is recursive- meaning it will back up all files and subdirectories recursively unless you otherwise specify with the n flag (non-recursive)</p>
<p><strong>[Displaying the Contents of a Tarball]</strong></p>
<p>The current directory will now contain a file called backup.tar. To display the contents of the tarball file, we could issue this command:</p>
<p>$ tar tvf backup.tar<br />
drwxr-xr-x root/gci 0 Jun 29 10:10 ./<br />
-rw-r&#8211;r&#8211; root/gci 1 Jun 29 10:10 picture.jpg<br />
-rw-r&#8211;r&#8211; root/gci 1 Jun 29 10:10 document.doc<br />
-rw-r&#8211;r&#8211; root/gci 1 Jun 29 10:10 databse.db<br />
<span id="more-12"></span></p>
<p>Note:<br />
t=table of contents (list)<br />
v=verbose (display all info)<br />
f=filename (backup.tar)</p>
<p>[Extracting Data from a Tarball]<br />
To extract the entire contents of the tarball to the current directory, we can type:<br />
$ tar xvf backup.tar<br />
./<br />
picture.jpg<br />
doucment.doc<br />
database.db</p>
<p>Note:<br />
x=extract<br />
v=verbose<br />
f=filename (backup.tar)</p>
<p>To extract only the picture.jpg file from the archive, type the following command:</p>
<p>$ tar xvf backup.tar picture.jpg</p>
<p>Alternatively, you can use wild cards in either the creation or extraction of a tarball. To extract all jpg files from our archive, we can use a command like this:</p>
<p>$ tar xvf backup.tar *.jpg<br />
<strong><br />
[Using Compression]</strong></p>
<p>If you would also like to add compression to your tarballs, you can combine the gzip utility with tar on the command line by adding the z switch to the command. Usually when this is done, we change the suffix of our tarball filename from .tar to either .tgz or .tar.gz. This will let whoever sees the file know that it is a gzipped tarball.</p>
<p>$ tar zcvf tarball.tgz .</p>
<p>Note:<br />
z=gzip compression<br />
c=create<br />
v=verbose<br />
f=filename (backup.tgz)<br />
.=current directory (what to backup)</p>
<p><strong>[Permissions with tar]</strong></p>
<p>If you would like to preserve the permissions of the files you backup, use the p option with the tar command. This will save the uid, gid as well as the specific permission attributes of the files (read, write, execute etc.)</p>
<p>$ tar pzcvf tarball.tgz .</p>
<p>You should also use the p option with the tar extraction command:</p>
<p>$ tar pxvf tarball.tgz .</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shocm.com/2003/10/backup-files-with-tar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Learning to Use Regular Expressions by Example</title>
		<link>http://www.shocm.com/2003/08/learning-to-use-regular-expressions-by-example/</link>
		<comments>http://www.shocm.com/2003/08/learning-to-use-regular-expressions-by-example/#comments</comments>
		<pubDate>Sun, 10 Aug 2003 21:47:19 +0000</pubDate>
		<dc:creator>Shocm</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[regex]]></category>

		<guid isPermaLink="false">http://www.vanjohnson.com/?p=14</guid>
		<description><![CDATA[<p><a href="http://www.phpbuilder.com/contact.php3?contact=dario_at_who.net">Dario F. Gomes</a></p> <p>This site I&#8217;m working on relies heavily on user input through forms, and all that data needs to be checked before being sent a database. I knew PHP3&#8242;s regular expression functions should solve my problem, but I didn&#8217;t know how to form the regular expressions in the first place. What I [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.phpbuilder.com/contact.php3?contact=dario_at_who.net">Dario F. Gomes</a></p>
<p>This site I&#8217;m working on relies heavily on user input through forms, and all that data needs to be checked before being sent a database. I knew PHP3&#8242;s regular expression functions should solve my problem, but I didn&#8217;t know how to form the regular expressions in the first place. What I needed were some sample strings&#8211;obviously the first places I looked were the PHP3 manual and the POSIX 1002.3 specification, but they don&#8217;t help much in the way of exemplifying.<br />
Adding to that, I had a really hard time finding good literature on the Web about the subject. I eventually got to know how to do it, mostly through experimenting, and seeing there wasn&#8217;t much to it, I decided to write down this straight-out introduction to the syntax and a step-by-step on building regular expressions to validate money and e-mail address strings. I just hope it manages to clear the fog around the subject for all you fellow programmers.
</p>
<p><span id="more-14"></span><br />
Basic Syntax of Regular Expressions</p>
<p>First of all, let&#8217;s take a look at two special symbols: &#8216;^&#8217; and &#8216;$&#8217;. What they do is indicate the <em>start</em> and the <em>end</em> of a string, respectively, like this:</p>
<ul>
<li>&#8220;<tt>^The</tt>&#8220;: matches any string that starts with<br />
    &#8220;The&#8221;;</p>
<li>&#8220;<tt>of despair$</tt>&#8220;: matches a string that ends in the<br />
    substring &#8220;of despair&#8221;;</p>
<li>&#8220;<tt>^abc$</tt>&#8220;: a string that starts and ends with &#8220;abc&#8221;<br />
    &#8212; that could only be &#8220;abc&#8221; itself!</p>
<li>&#8220;<tt>notice</tt>&#8220;: a string that has the text &#8220;notice&#8221;<br />
    in it.</li>
</li>
</li>
</li>
</ul>
<p>you don&#8217;t use either of the two characters we mentioned, as in the last example, you&#8217;re saying that the pattern may occur anywhere inside the string &#8212; you&#8217;re not &#8220;hooking&#8221; it to any of the edges.</p>
<p>There are also the symbols &#8216;*&#8217;, &#8216;+&#8217;, and &#8216;?&#8217;, which denote the number of times a character or a sequence of characters may occur. What they mean is:<br />
&#8220;zero or more&#8221;, &#8220;one or more&#8221;, and &#8220;zero or one.&#8221;</p>
<p>Here are some examples:</p>
<ul>
<li>&#8220;<tt>ab*</tt>&#8220;: matches a string that has an <i>a</i> followed<br />
    by zero or more <i>b</i>&#8216;s (&#8220;a&#8221;, &#8220;ab&#8221;, &#8220;abbb&#8221;,<br />
    etc.);</p>
<li>&#8220;<tt>ab+</tt>&#8220;: same, but there&#8217;s at least one <i>b</i> (&#8220;ab&#8221;,<br />
    &#8220;abbb&#8221;, etc.);</p>
<li>&#8220;<tt>ab?</tt>&#8220;: there might be a <i>b</i> or not;
<li>&#8220;<tt>a?b+$</tt>&#8220;: a possible <i>a</i> followed by one or more <i>b</i>&#8216;s ending a string.</li>
</li>
</li>
</li>
</ul>
<p>>bounds, which come inside braces and indicateranges in the number of occurences:</p>
<ul>
<li>&#8220;<tt>ab{2}</tt>&#8220;: matches a string that has an <i>a</i> followed<br />
    by exactly two <i>b</i>&#8216;s (&#8220;abb&#8221;);</p>
<li>&#8220;<tt>ab{2,}</tt>&#8220;: there are at least two <i>b</i>&#8216;s (&#8220;abb&#8221;,<br />
    &#8220;abbbb&#8221;, etc.);</p>
<li>&#8220;<tt>ab{3,5}</tt>&#8220;: from three to five <i>b</i>&#8216;s (&#8220;abbb&#8221;,<br />
    &#8220;abbbb&#8221;, or &#8220;abbbbb&#8221;).</li>
</li>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.shocm.com/2003/08/learning-to-use-regular-expressions-by-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

