<?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>JoeJag :: Tech &#187; unix</title>
	<atom:link href="http://code.joejag.com/category/unix/feed/" rel="self" type="application/rss+xml" />
	<link>http://code.joejag.com</link>
	<description>Joe Wright&#039;s technology blog</description>
	<lastBuildDate>Tue, 01 Nov 2011 11:02:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.4</generator>
		<item>
		<title>Start a web server from your pwd using Ruby and Thin</title>
		<link>http://code.joejag.com/2011/start-a-web-server-from-your-pwd-using-ruby-and-thin/</link>
		<comments>http://code.joejag.com/2011/start-a-web-server-from-your-pwd-using-ruby-and-thin/#comments</comments>
		<pubDate>Tue, 01 Mar 2011 13:06:07 +0000</pubDate>
		<dc:creator>Joe Wright</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://code.joejag.com/?p=521</guid>
		<description><![CDATA[Occasionally I&#8217;m interested in grabbing files from a directory on a remote host. This could be for another process to consume or to look at on my local work station. The standard way of doing this is using scp, ftp or a file share. I prefer to start a short-lived web server that shares the [...]]]></description>
			<content:encoded><![CDATA[<p>Occasionally I&#8217;m interested in grabbing files from a directory on a remote host.  This could be for another process to consume or to look at on my local work station.</p>
<p>The standard way of doing this is using scp, ftp or a file share.  I prefer to start a short-lived web server that shares the file system.  </p>
<p>To make this simple I use a ruby script to allow me to start a webserver from the directory I&#8217;m currently in.</p>
<pre class="sh_ruby">
['rubygems', 'thin', 'rack', 'socket'].each {|file| require file }
Thin::Server.start(IPSocket.getaddress(Socket.gethostname), 7777) do
  use Rack::CommonLogger
  run Rack::Directory.new(Dir.pwd)
end
</pre>
<p>As an alias for ~/.bashrc it looks like this:</p>
<pre class="sh_sh">
alias rshare="ruby -rubygems -e \"['thin', 'rack', 'socket'].each {|file| require file };"\
" Thin::Server.start(IPSocket.getaddress(Socket.gethostname), 7777) {"\
" use Rack::CommonLogger; run Rack::Directory.new(Dir.pwd) }\""
</pre>
<p>This allows you to go to port 7777 on the host and retrieve the files you&#8217;re interested in.</p>
<pre class="sh_sh">
@joejag /tmp $ rshare
>> Thin web server (v1.2.7 codename No Hup)
>> Maximum connections set to 1024
>> Listening on 10.0.0.2:7777, CTRL+C to stop
10.0.0.8 - - [01/Mar/2011 07:45:15] "GET / HTTP/1.1" 200 2153 0.0038
</pre>
<p>You will need to have the &#8216;thin&#8217; and &#8216;rack&#8217; gems installed to do this.</p>
]]></content:encoded>
			<wfw:commentRss>http://code.joejag.com/2011/start-a-web-server-from-your-pwd-using-ruby-and-thin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automatically resolving jars for the Java classpath</title>
		<link>http://code.joejag.com/2009/automatically-adding-jars-to-the-java-classpath/</link>
		<comments>http://code.joejag.com/2009/automatically-adding-jars-to-the-java-classpath/#comments</comments>
		<pubDate>Mon, 03 Aug 2009 12:52:42 +0000</pubDate>
		<dc:creator>Joe Wright</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://code.joejag.com/?p=34</guid>
		<description><![CDATA[When you use the Java classpath (pre java 1.6) you have to manually list each jar on your classpath such as: java -cp lib/database.jar:lib/commons.jar:/lib/log.jar com.joejag.Main On Java 1.6 a little known feature is that you can now use wildcards, so the above command becomes: java -cp lib/*.jar com.joejag.Main I still have to use an earlier [...]]]></description>
			<content:encoded><![CDATA[<p>When you use the Java classpath (pre java 1.6) you have to manually list each jar on your classpath such as:</p>
<pre class="sh_sh">java -cp lib/database.jar:lib/commons.jar:/lib/log.jar com.joejag.Main</pre>
<p>On Java 1.6 a little known feature is that you can now use wildcards, so the above command becomes:</p>
<pre class="sh_sh">java -cp lib/*.jar com.joejag.Main</pre>
<p>I still have to use an earlier version of Java for some applications I handle.  To save having to list all the jars manually I use the following bash script which allows you to automatically list all the jars in a directory:</p>
<pre class="sh_sh">java -cp `find lib -name *.jar -exec printf :{} ';'` com.joejag.Main</pre>
]]></content:encoded>
			<wfw:commentRss>http://code.joejag.com/2009/automatically-adding-jars-to-the-java-classpath/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Using Ruby as an AWK replacement</title>
		<link>http://code.joejag.com/2009/using-ruby-as-an-awk-replacement/</link>
		<comments>http://code.joejag.com/2009/using-ruby-as-an-awk-replacement/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 18:47:25 +0000</pubDate>
		<dc:creator>Joe Wright</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://code.joejag.com/?p=3</guid>
		<description><![CDATA[Someone at work asked if you could use Ruby like AWK.  I did a little digging and found that you can. cat file &#124; ruby -n -a -e 'puts "#{$F[0] $F[1]}"' &#8216;-n&#8217; makes the Ruby iterate over all lines successively assigning them to $_ &#8216;-a&#8217; makes Ruby split $_ into its parts assigning the result [...]]]></description>
			<content:encoded><![CDATA[<p>Someone at work asked if you could use Ruby like AWK.  I did a little digging and found that you can.</p>
<pre class="sh_sh">
cat file | ruby -n -a -e 'puts "#{$F[0] $F[1]}"'
</pre>
<p>&#8216;-n&#8217; makes the Ruby iterate over all lines successively assigning them to $_<br />
&#8216;-a&#8217; makes Ruby split $_ into its parts assigning the result to $F which is an array of strings<br />
&#8216;-e&#8217; means that what follows is code to be executed.<br />
&#8216;-F&#8217; specifies the column separator</p>
<p>
I performed a speed comparison on some different size files and operations.  For files under 500kb lines Ruby has comparable performance to AWK.  For anything larger then Ruby (1.8.6) is at best twice as slow.  Though I wouldn&#8217;t expect a general purpose language to outperform a specialist tool.</p>
]]></content:encoded>
			<wfw:commentRss>http://code.joejag.com/2009/using-ruby-as-an-awk-replacement/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

