<?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>Moki Systems Blog &#187; Linux</title>
	<atom:link href="http://www.mokisystems.com/blog/category/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mokisystems.com/blog</link>
	<description>Addressing such topics as: web programming, design, ruby on rails, cake php, postgresql, linux, seo</description>
	<lastBuildDate>Thu, 19 Aug 2010 00:18:50 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Linux Clipboard Snippets</title>
		<link>http://www.mokisystems.com/blog/linux-clipboard-snippets/</link>
		<comments>http://www.mokisystems.com/blog/linux-clipboard-snippets/#comments</comments>
		<pubDate>Fri, 04 Sep 2009 18:13:34 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.mokisystems.com/blog/?p=63</guid>
		<description><![CDATA[Whenever I find myself typing the same thing over and over again, I have to come up with some way to avoid the repetition. And one thing I do a lot is fill out web forms that require things like credit card numbers and unique email addresses. For a while I tried using Parcellite (a [...]]]></description>
			<content:encoded><![CDATA[<p>Whenever I find myself typing the same thing over and over again, I have to come up with some way to avoid the repetition. And one thing I do a lot is fill out web forms that require things like credit card numbers and unique email addresses. For a while I tried using Parcellite (a clipboard manager) but it wasn&#8217;t really designed for what I wanted to use it for. Finally with the inspiration of <a href="http://bbs.archlinux.org/viewtopic.php?id=71938">this thread</a> I was able to cobble together a solution that does just what I want.<br />
<span id="more-63"></span><br />
First I created a snippets directory and filled it with files that contained the text to insert or scripts to generate the desired text:</p>

<div class="wp_syntax"><div class="code"><pre>$ cd ~/.snippets
$ ls -1
credit_card
email
@example.com
phone
RAILS_ENV=test
sql_create
sql_permissions
$ cat credit_card 
4111111111111111
$ cat sql_permissions 
GRANT ALL PRIVILEGES ON .* TO ''@'localhost' IDENTIFIED BY ''<SEMI>
$ cat phone 
#!/usr/bin/env ruby
print (1..12).map {<PIPE>i<PIPE> i == 4 <PIPE><PIPE> i == 8 ? '-' : rand(10).to_s}.join</pre></div></div>

<p>Then I put this little script in ~/bin:</p>

<div class="wp_syntax"><div class="code"><pre class="bash"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #666666; font-style: italic;"># http://bbs.archlinux.org/viewtopic.php?id=71938</span>
<span style="color: #007800;">DIR=</span><span style="color: #800000;">${HOME}</span><span style="color: #000000; font-weight: bold;">/</span>.snippets
<span style="color: #007800;">DMENU_ARGS=</span><span style="color: #ff0000;">&quot;-i -fn -*-terminal-*-*-*-*-18-*-*-*-*-*-*-*&quot;</span> <span style="color: #666666; font-style: italic;"># xfontsel to select font</span>
&nbsp;
<span style="color: #007800;">FILE=</span><span style="color: #000000; font-weight: bold;">`/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #007800;">$DIR</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>dmenu <span style="color: #800000;">${DMENU_ARGS}</span><span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> -x <span style="color: #800000;">${DIR}</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${FILE}</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span> <span style="color: #666666; font-style: italic;">#executable</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> -n <span style="color: #000000; font-weight: bold;">`</span><span style="color: #800000;">${DIR}</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${FILE}</span><span style="color: #000000; font-weight: bold;">`</span> <span style="color: #000000; font-weight: bold;">|</span> xsel -b -i
<span style="color: #000000; font-weight: bold;">elif</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> -f <span style="color: #800000;">${DIR}</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${FILE}</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
<span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #800000;">${DIR}</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${FILE}</span> <span style="color: #000000; font-weight: bold;">|</span> xsel -b -i
<span style="color: #000000; font-weight: bold;">fi</span>
xdotool key ctrl+v <span style="color: #666666; font-style: italic;"># for non-console</span>
xdotool key ctrl+<span style="color: #7a0874; font-weight: bold;">shift</span>+v <span style="color: #666666; font-style: italic;"># for console</span></pre></div></div>

<p>And then I mapped that script to a handy key combination in compiz. So now whenever I need a test credit card number, phone number, or email address I can just do <ctrl><alt>c, type the first few characters to select the right snippet, hit return and it gets pasted in to whatever I&#8217;m working on.</p>
<p>Notes and caveats:</p>
<ul>
<li>I had to aptitude install some packages to get dmenu and xdotool to work.</li>
<li>dmenu is ugly and has no mouse support.</li>
<li>Pasting into vim has occasional issues.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.mokisystems.com/blog/linux-clipboard-snippets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A few handy things to know about bash</title>
		<link>http://www.mokisystems.com/blog/a-few-handy-things-to-know-about-bash/</link>
		<comments>http://www.mokisystems.com/blog/a-few-handy-things-to-know-about-bash/#comments</comments>
		<pubDate>Fri, 15 May 2009 15:30:39 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.mokisystems.com/blog/?p=61</guid>
		<description><![CDATA[Pipes and Redirection
These are standard shell tools, but sometimes I get confused about which one I need. So my way of thinking about it is that pipes are a connection between programs while redirection always goes to (or from) a file.
So, for example, in order to find all my session routes I would connect the [...]]]></description>
			<content:encoded><![CDATA[<p>Pipes and Redirection</p>
<p>These are standard shell tools, but sometimes I get confused about which one I need. So my way of thinking about it is that pipes are a connection between programs while redirection always goes to (or from) a file.</p>
<p>So, for example, in order to find all my session routes I would connect the rake and grep commands via a pipe:</p>
<pre code="bash">
  rake routes | grep session
</pre>
<p>On the other hand, I would use redirection to save the output of a git diff to a file so as to be able to feed it in to the patch program (which expects its input on standard in).</p>
<pre code="bash">
  git diff > patchfile
  patch < patchfile
</pre>
<p>Braces</p>
<p>I just learned about these recently and they make renaming things so much easier!</p>
<pre code="bash">
  mv file.old file.new # old way
  mv file.{old,new} # does the same thing!
</pre>
<p>So creating your database.yml file from the example one is as easy as:</p>
<pre code="bash">
  mv config/database.yml{.example,}
</pre>
<p>Changing Directories</p>
<p>I assume everyone already knows that cd with arguments goes to your home directory (the contents of the $HOME environment variable), but did you know you can do 'cd -' to go to the previous directory you were in ($OLDPWD)?</p>
<pre code="bash">
  :/var/www$ cd /etc/apache2/sites-enabled/
  :/etc/apache2/sites-enabled$ cd -
  /var/www
  :/var/www$
</pre>
<p>History</p>
<p>!! # execute the previous command (great for when you forget to sudo something)<br />
!$ # The last argument of the previous command<br />
!^ # The first argument<br />
!* # All the previous arguments<br />
^old^new^ # Repeat the previous command replacing old for new</p>
<p>And lots, lots more! See 'man history' for details.</p>
<p>Keyboard shortcuts</p>
<p>Here are a few of the keyboard shortcuts that I use regularly (copied from the wikipedia article http://en.wikipedia.org/wiki/Bash):</p>
<p>CTRL + l : clears the screen content (equivalent to the command : clear).<br />
CTRL + u : clears the line content before the cursor and copy it in the clipboard.<br />
CTRL + k : clears thctrl alt copy pastee line content after the cursor and copy it in the clipboard.<br />
CTRL + w : clears the word before the cursor and copy it in the clipboard.<br />
CTRL + y : (yank) adds the clipboard content from the cursor position.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mokisystems.com/blog/a-few-handy-things-to-know-about-bash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SSH Host Aliases</title>
		<link>http://www.mokisystems.com/blog/ssh-host-aliases/</link>
		<comments>http://www.mokisystems.com/blog/ssh-host-aliases/#comments</comments>
		<pubDate>Tue, 18 Nov 2008 16:39:59 +0000</pubDate>
		<dc:creator>Wes Bangerter</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[System Administration]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://www.mokisystems.com/blog/?p=42</guid>
		<description><![CDATA[If you use SSH from the command line you can save yourself some typing by aliasing the servers hostname to something shorter. There&#8217;s a bunch of different ways to get similar results, but I prefer to use the built in SSH functionality for this. Create a ~/.ssh/config file. The syntax is:

Host server
HostName server.example.com
User username
&#160;
Host another
HostName [...]]]></description>
			<content:encoded><![CDATA[<p>If you use SSH from the command line you can save yourself some typing by aliasing the servers hostname to something shorter. There&#8217;s a bunch of different ways to get similar results, but I prefer to use the built in SSH functionality for this. Create a <code>~/.ssh/config</code> file. The syntax is:</p>

<div class="wp_syntax"><div class="code"><pre class="bash">Host server
HostName server.example.com
User username
&nbsp;
Host another
HostName another.example.com
User username</pre></div></div>

<p>Now you can just <code>ssh server</code> instead of <code>ssh username@example.server.com</code>. SCP also works great with these aliases, just <code>scp file.txt server:/path</code></p>
<p>You can leave the <code>User</code> part out of the config file if your local and remote usernames are the same.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mokisystems.com/blog/ssh-host-aliases/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How We&#8217;re Using VMWare Server</title>
		<link>http://www.mokisystems.com/blog/how-were-using-vmware-server/</link>
		<comments>http://www.mokisystems.com/blog/how-were-using-vmware-server/#comments</comments>
		<pubDate>Tue, 15 Jul 2008 18:23:47 +0000</pubDate>
		<dc:creator>mark</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[System Administration]]></category>
		<category><![CDATA[VMWare]]></category>

		<guid isPermaLink="false">http://beta.mokisystems.com/blog/?p=9</guid>
		<description><![CDATA[VMWare releasing a free version of their server virtualization product opened up some possibilities for us. Moki Systems had multiple servers performing a variety of tasks but there were things we didn&#8217;t have. We didn&#8217;t have a split between production and development servers and we didn&#8217;t have good utilization. Low CPU and memory utilization offers [...]]]></description>
			<content:encoded><![CDATA[<p>VMWare releasing a free version of their server virtualization product opened up some possibilities for us. Moki Systems had multiple servers performing a variety of tasks but there were things we didn&#8217;t have. We didn&#8217;t have a split between production and development servers and we didn&#8217;t have good utilization. Low CPU and memory utilization offers a comfort level but it adds costs, especially when you need more servers that cost money, use electricity, and generate heat.</p>
<p>Free VMWare server limits running virtual servers to 4. Our solution was to purchase new servers  equipped with 1 SATA disk for the OS and 4 SCSI disks, 1 for each virtual machine (VM). While VMWare offers an option to write to the disk directly I opted not to do that because the virtual disk files VMWare uses make your VM&#8217;s highly portable and easy to duplicate. Disaster recovery practice becomes far easier when you can easily make a duplicate of your production server.</p>
<p>This architecture&#8217;s utility was brought to light when one of your servers died. We were able to pull the disks containing our production servers, copy the VM&#8217;s to another server, then get those servers running again quickly. There was no need for OS reinstall or recovery from backup and because of this portability downtime was minimized.</p>
<p>I have VMWare server installed on my Windows workstation with a Centos 5 VM running in the background. I use it for some MySQL and PHP stuff so it isn&#8217;t used a whole lot but I hardly know it&#8217;s there. The beauty of this that the Windows guys can have a Linux VM and the Linux guys can have a Windows VM. That can help quite a bit when testing browser compatibility on a website or getting access to a tool not available for your OS of choice.</p>
<p>VMWare server has helped us utilize our server resources better at a very minimal cost. Running 4 servers for the price of one saves us time and money. What else could you ask for?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mokisystems.com/blog/how-were-using-vmware-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
