<?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>It's not a blog, It's a feature &#187; Linux</title>
	<atom:link href="http://javazquez.com/juan/category/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://javazquez.com/juan</link>
	<description>Juan A. Vazquez</description>
	<lastBuildDate>Wed, 16 Nov 2011 02:45:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Proxy/ReverseProxy and Apache2</title>
		<link>http://javazquez.com/juan/2008/08/16/proxyreverseproxy-and-apache2/</link>
		<comments>http://javazquez.com/juan/2008/08/16/proxyreverseproxy-and-apache2/#comments</comments>
		<pubDate>Sat, 16 Aug 2008 14:37:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[configuration]]></category>

		<guid isPermaLink="false">http://javazquez.com/juan/?p=13</guid>
		<description><![CDATA[I recently configured Apache2 to be a ReverseProxy/Proxy and thought I would share my experiences while it was still fresh. Having never configured any kind of proxy, I found this webpage very informative. The scenario I would like to use for my example is that I have three internal web servers called Site Local IP Remote [...]]]></description>
			<content:encoded><![CDATA[<p>I recently configured Apache2 to be a ReverseProxy/Proxy and thought I would share my experiences while it was still fresh. Having never configured any kind of proxy, I found <a href="http://httpd.apache.org/docs/2.0/mod/mod_proxy.html">this webpage </a> very informative.  The scenario I would like to use for my example is that I have three internal web servers called</p>
<table>
<th>Site</th>
<th>Local IP</th>
<th>Remote IP</th>
<th>Port</th>
<tr>
<td>www.reallycoolsite.com</td>
<td>192.168.1.102</td>
<td>10.15.22.1</td>
<td>80</td>
</tr>
<tr>
<td>www.justcoolsite.com</td>
<td>192.168.1.102 </td>
<td> 10.15.22.2 </td>
<td>80</td>
</tr>
<tr>
<td>www.reallylamesite.com</td>
<td> 192.168.1.44</td>
<td> 10.15.22.3</td>
<td>80</td>
</tr>
</table>
<p>Alright&#8230;pretty straight forward right? If you are in a situation that I was when I started, you haven&#8217;t done much more than install apache from source and added a few modules here and there occasionally. The way I solved the problem was to create <a href="http://httpd.apache.org/docs/1.3/vhosts/name-based.html">name-based virtual host</a> for each of the servers.<br />
our example would look like</p>
<p><code><br />
#you can listen on specific ports for requests if you like<br />
#(ex->Listen 192.168.1.102:80)<br />
#I use the below statement to listen on 80 for all requests<br />
Listen *:80<br />
#Because we have multiple names mapped to same ip<br />
NameVirtualHost 192.168.1.102:80</p>
<p>&lt;VirtualHost 192.168.1.102:80 &gt;<br />
ServerName www.reallycoolsite.com<br />
ProxyRequests Off<br />
ProxyPass / http://10.15.22.1/<br />
ProxyReverse / http://www.reallycoolsite.com/<br />
ProxyPreserveHost  On<br />
ErrorLog                 reallycoolsite_error_log<br />
<a href="http://httpd.apache.org/docs/2.0/mod/mod_log_config.html#customlog">CustomLog</a> reallycoolsite_access_logs<br />
&lt;/VirtualHost &gt;</p>
<p>&lt;VirtualHost 192.168.1.102:80 &gt;<br />
ServerName www.justcoolsite.com<br />
ProxyRequests Off<br />
ProxyPass / http://10.15.22.2/<br />
ProxyReverse / http://www.justcoolsite.com/<br />
ProxyPreserveHost  On<br />
ErrorLog                 justcoolsite_error_log<br />
<a href="http://httpd.apache.org/docs/2.0/mod/mod_log_config.html#customlog">CustomLog</a> justcoolsite_access_logs<br />
&lt;/VirtualHost &gt;</p>
<p>&lt;VirtualHost 192.168.1.44:80 &gt;<br />
ServerName www.reallylamesite.com<br />
ProxyRequests Off<br />
ProxyPass / http://10.15.22.3/<br />
ProxyReverse / http://www.reallylamesite.com/<br />
ProxyPreserveHost  On<br />
ErrorLog                 reallylamesite_error_log<br />
<a href="http://httpd.apache.org/docs/2.0/mod/mod_log_config.html#customlog">CustomLog</a> reallylamesite_access_logs<br />
&lt;/VirtualHost &gt;<br />
</code></p>
<p>If you receive errors during the communication of your proxy and your server, it may be a good idea to investigate if you have an http protocol error discussed at the bottom of this <a href="http://httpd.apache.org/docs/2.0/mod/mod_proxy.html">page</a><br />
The following two lines are pulled from the reference and fixed a problem I had with one of my IIS servers using SSL(for more info about the issue, go <a href="http://support.microsoft.com/kb/187504">here</a><br />
<strong><br />
SetEnv force-proxy-request-1.0 1<br />
SetEnv proxy-nokeepalive 1<br />
</strong><br />
My apache configuration file(httpd.conf) was the file I used to edit my settings.. Your file may be different depending on how new your apache version is. I found that some implementations called the configuration file apache.conf&#8230;. I hope this blog entry is helpful you, Happy Configuring!</p>
]]></content:encoded>
			<wfw:commentRss>http://javazquez.com/juan/2008/08/16/proxyreverseproxy-and-apache2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>BarCamp Omaha</title>
		<link>http://javazquez.com/juan/2008/07/01/omaha-barcamp/</link>
		<comments>http://javazquez.com/juan/2008/07/01/omaha-barcamp/#comments</comments>
		<pubDate>Tue, 01 Jul 2008 17:39:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[fun]]></category>
		<category><![CDATA[social]]></category>

		<guid isPermaLink="false">http://javazquez.com/juan/?p=11</guid>
		<description><![CDATA[I have just been informed/invited to Omaha&#8217;s BarCamp! According to the site, this is a &#8220;unconference born from the desire for people to share and learn in an open environment.&#8221; The list of topics that have been submitted thus far are already enough to get any developer&#8217;s inner geek super-charged. At this point I am [...]]]></description>
			<content:encoded><![CDATA[<p>I have just been informed/invited to Omaha&#8217;s <a href="http://barcampomaha.org">BarCamp</a>! According to the <a href="http://barcamp.org/TheRulesOfBarCamp">site</a>, this is a &#8220;unconference born from the desire for people to share and learn in an open environment.&#8221;</p>
<p>The list of <a href="http://barcamp.org/BarCampOmaha">topics</a> that have been submitted thus far are already enough to get any developer&#8217;s inner geek super-charged. At this point I am not sure what I will talk about, but here are a few ideas.</p>
<ol>
<li>uploading/updating multiple models in one form (ROR)</li>
<li>Groovy and flickr</li>
<li>Action Script 3 concepts</li>
<li>Linux Administration</li>
<li>Setting up <a href="http://twiki.org">Twiki</a></li>
</ol>
<p>Any suggestions or votes on what I could bring to the BarCamp would be awesome. If you can make it, I suggest checking this event out! After all, you don&#8217;t want to be sitting there listening to you fellow IT buddies raving about the great time they had learning at BarCamp&#8230;right?</p>
]]></content:encoded>
			<wfw:commentRss>http://javazquez.com/juan/2008/07/01/omaha-barcamp/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>File I/O Part 1</title>
		<link>http://javazquez.com/juan/2008/06/27/file-io-part-1/</link>
		<comments>http://javazquez.com/juan/2008/06/27/file-io-part-1/#comments</comments>
		<pubDate>Fri, 27 Jun 2008 22:30:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Groovy]]></category>

		<guid isPermaLink="false">http://javazquez.com/juan/?p=9</guid>
		<description><![CDATA[I love to learn and try new languages. Not only is learning a new language fun, many times it teaches me something new about a language that I am already familiar with. The only problem that I have with learning so many languages, is keeping them straight. I decided that I would take a few [...]]]></description>
			<content:encoded><![CDATA[<p>I love to learn and try new languages. Not only is learning a new language fun, many times it teaches me something new about a language that I am already familiar with. The only problem that I have with learning so many languages, is keeping them straight. I decided that I would take a few of the dynamic languages I use most often and compile a list of how to handle File I/O with each of them. If you have a Dynamic language(part 2 of this post will be on static languages) not represented below or have another method of File I/O with the represented languages, please add to the list with its respective File I/O code:D<br />
Without further ado&#8230;</p>
<blockquote>
<pre>//Groovy open file for writing
def target ="filename"
File wf= new File(target)
wf.write( "I am in your file eating your space" )

//Groovy open file for appending
def target ="filename"
File af= new File(target)
af.append("I have all of your base")

//Groovy read each line in file
new File("filename").eachLine{line-&gt; println line}

//Groovy read whole document and put into List

List lines = new File("filename").readLines()
//lines contains two lines that we need
println "first line  $lines[0]"
println "second line $lines[1]"

//Groovy reading one line
File rf= new File("filename") //open for reading
//read first line, trim, assign to tmp
rf.withReader { line -&gt;tmp = line.readLine().trim()}

//Groovy test if file exists
File src = new File(srcFile)
if (src.exists() ){ println "I exist"}
else{println "I don't exist"}

#Ruby openfile for reading
fh = File.new(path, "r")  # open file "path" for reading only
fh.close

#Ruby open file for writing
fout   = File.new(path, "w")  # open file "path" for writing only
fout.puts "Up, Up, Down, Down, Left, Right, Left, Right, B, A, Select, Start"
fout.close

#Ruby open file for apending
fa= File.new("DeleteMe.txt","a")
fa.puts "I am at the end of file"
fa.close

#Ruby read eachline in a file
File.open("file").each { |line| p line}

#Ruby read entire file to string
fh = File.new(filename)
str = fh.read

#Ruby read entire file into array(each line is an element in the array)
fh = File.new(filename)
str = fh.readlines

#Python Write a file
fout = open("DeletMe.txt", "w")
fout.write("Writing to fout\nCheck it out!")
fout.close()

#Python Read an entire file
fin = open("ReadingTest.txt", "r")
fin_text =  fin.read()
fin.close()
print fin_text

#Python read entire file into list
fin = open("ReadingTest.txt", "r")
txt= fin.readlines()
fin.close()
print txt[0]

#Python append to a file
fh= open ( 'DeleteMe.txt', 'a' )
fh.write ( '\n\n\nBottom line.' )
fh.close()

#Perl reading a file
open(FILE,  '&lt;', $file) or die "Can't read $file: $!\n";
while(&lt;FILE&gt;)
{
print ;
}

#Perl append to a file
open(FILE, '&gt;&gt;', $file) or    die "Can't append to $file: $!\n";
print FILE "text";
close(FILE);

#Perl read and write to a file
#+&lt; allows reading and writing, and keeps the data that was
#already in the file.  open() will fail if file doesn't exist.
open(FILE, "+&lt;$file" ) or die ("Can't  read|write: $file\n");
close(FILE);

#Perl read and write to a file
#+&gt;allows writing and reading, but replaces/overwrites the
#data in the file if the file exists. Creates it if it doesn't exist.
open(FILE, "+&gt;$file" ) or die ("Can't write or read:$file \n");

close(FILE);</pre>
</blockquote>
<p>PHP code doesn&#8217;t display properly within WordPress, so here is an image of the code</p>
<p><a href="http://javazquez.com/juan/wp-content/uploads/2008/06/phpcode.gif"><img class="alignnone size-full wp-image-10" title="phpcode" src="http://javazquez.com/juan/wp-content/uploads/2008/06/phpcode.gif" alt="PHP File I/O" width="340" height="233" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://javazquez.com/juan/2008/06/27/file-io-part-1/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Handling Ruby&#8217;s String.each_char Iterator</title>
		<link>http://javazquez.com/juan/2008/06/25/handling-rubys-stringeach_char-iterator/</link>
		<comments>http://javazquez.com/juan/2008/06/25/handling-rubys-stringeach_char-iterator/#comments</comments>
		<pubDate>Thu, 26 Jun 2008 05:50:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby code quirks]]></category>

		<guid isPermaLink="false">http://javazquez.com/juan/?p=7</guid>
		<description><![CDATA[Ahh the joys of iterators. I can&#8217;t say enough about how much they make my life easier. They are just so darn handy. Life was good in my Ruby world until I needed to iterate through the characters in a string. Thinking to myself, &#8220;there has got to be a method that does this,&#8221; I [...]]]></description>
			<content:encoded><![CDATA[<p>Ahh the joys of iterators. I can&#8217;t say enough about how much they make my life easier. They are just so darn handy. Life was good in my Ruby world until I needed to iterate through the characters in a string. Thinking to myself, &#8220;there has got to be a method that does this,&#8221; I looked up Ruby&#8217;s String class and saw just what the doctor ordered&#8230; <code>each_char</code>.</p>
<p> Feeling pretty proud that my favorite language had this baked right in, I was only to happy to inject it into my code and test it out. That is until I recieved the dreaded <strong>NoMethodError: undefined method `each_char&#8217; </strong>. Eeek, what did I do wrong? Did I mispell the method&#8230;..Nope, did I call it correctly&#8230;..Yep. Well, what the heck is going on? </p>
<p>After multiple attempts to find the answer on Google, I finally posted my problem to the <a href="http://groups.google.ca/group/rubyonrails-talk/browse_thread/thread/1fd48ddc22f6bfe6#">ruby-talk group. </a> I was told that the Ruby 1.8 String implementation that I was using only understood bytes and that I could use <strong>require &#8216;jcode&#8217;</strong> to get the iterator to work the way I wanted. I did some looking around and I am not sure this is a great solution, after all, I could have easily used the <strong>each_byte{|f|  f.chr}</strong> to iterate through and convert accordingly. I don&#8217;t understand why something that is documented as part of the class, does not work. </p>
<p>It would really help if there was an easy to search area on the net dedicated to language quirks for people trying to get a better grasp of their programming language of choice. Maybe that will be my next <a href="http://www.rubyonrails.org/">ROR </a>project.</p>
<p>As it turns out, my Ruby 1.8.7 installation on my <a href="http://fedoraproject.org/en/index">Fedora core 9 </a> works as advertised.</p>
]]></content:encoded>
			<wfw:commentRss>http://javazquez.com/juan/2008/06/25/handling-rubys-stringeach_char-iterator/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>su vs. &#8220;su -&#8221;  The Mystery Revealed</title>
		<link>http://javazquez.com/juan/2008/06/24/su-vs-su-the-mystery-revealed/</link>
		<comments>http://javazquez.com/juan/2008/06/24/su-vs-su-the-mystery-revealed/#comments</comments>
		<pubDate>Wed, 25 Jun 2008 03:25:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://javazquez.com/juan/?p=6</guid>
		<description><![CDATA[Inquiring minds want to know, what is this su - and why is it different than su? Well, if you are like me, you didn&#8217;t even know that su - existed. I ran into this problem when I was trying to add a new user to a new Linux machine. Remote root login was disabled(for [...]]]></description>
			<content:encoded><![CDATA[<p>Inquiring minds want to know, what is this <code>su - </code> and why is it different than <code>su</code>? Well, if you are like me, you didn&#8217;t even know that <code>su - </code>existed. I ran into this problem when I was trying to add a new user to a new Linux machine. Remote root login was disabled(for obvious reasons:D) and I was logged in with my regular non-privileged user account. Well, normally the story goes like this&#8230;</p>
<ol>
<li>su</li>
<li>Authenticate</li>
<li>useradd <em>account</em></li>
<li>set password</li>
<li>log out of privileged account</li>
<li>Take coffee break from all the hard work and call it a day</li>
</ol>
<p>No so today:( . When I attempted to run step three(<code>useradd</code>), I received a <code><strong>command not found</strong></code> error. &#8220;That&#8217;s weird&#8221; I thought. How could a machine not have this basic command. I looked in the bin directory to see if it was some kind of path error I was having. Thinking that this was the case, I was shocked to see that none of the user commands(adduser, usermod, deluser) where there.</p>
<p>After a few minutes of scratching my head, I asked someone more versed in Linux than I what they thought. After walking through each of the steps I had taken, my mistake was easily spotted. I hadn&#8217;t added the &#8216;-&#8217; to the <code>su</code> command. Thinking that the explanation was weird, I checked with google for the <code>su -</code> command. Sure enough, the <a href="http://en.wikipedia.org/wiki/Su_(Unix)">link</a> to Wikipedia had this to say about it,</p>
<blockquote><p>Optionally, you can use a hyphen with su to invoke a login shell and assume the target    user&#8217;s complete user environment:</p></blockquote>
<p>I am glad I had someone to point this out to me&#8230; It could have been a longer and very frustrating ordeal. It was also a lesson for me to refer more to the man pages(it had the answer there too). I hope this blog entry helps someone else who is confronted with this situation.</p>
]]></content:encoded>
			<wfw:commentRss>http://javazquez.com/juan/2008/06/24/su-vs-su-the-mystery-revealed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

