<?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>SamAuciello.com</title>
	<atom:link href="http://samauciello.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://samauciello.com</link>
	<description></description>
	<lastBuildDate>Sat, 31 Mar 2012 15:21:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Rapid Development in PHP</title>
		<link>http://samauciello.com/rapid-development-in-php/</link>
		<comments>http://samauciello.com/rapid-development-in-php/#comments</comments>
		<pubDate>Sat, 31 Mar 2012 15:19:00 +0000</pubDate>
		<dc:creator>Sam Auciello</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://samauciello.com/?p=310</guid>
		<description><![CDATA[Yesterday in programming workshop I decided to see if I could build a simple web application in PHP in a few hours. The project was one I had been thinking about for years that was inspired by a site I &#8230; <a href="http://samauciello.com/rapid-development-in-php/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Yesterday in programming workshop I decided to see if I could build a simple web application in PHP in a few hours.  The project was one I had been thinking about for years that was inspired by a site I had found a while ago.  The idea was a choose your own adventure story in-which readers add their own branches as they go.  The original allowed users to create pages and specify all of the options for those pages.  Whenever an option was chosen for the first time, the user was prompted to make a new page.  The app I built yesterday is slightly different in that users can add options to any page but they must specify the description of the page it goes to when they do.<span id="more-310"></span></p>
<p>The app can be found <a href="/story_game">here</a>.  It represents about 4-5 hours of coding, much of which was tuning the stylesheet.  The really cool thing about it is it&#8217;s simplicity.  Most of the app is in the <code>index.php</code> file.</p>

<div class="wp_codebox"><table><tr id="p3103"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
</pre></td><td class="code" id="p310code3"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ?php
&nbsp;
<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'functions.php'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$room</span> <span style="color: #339933;">=</span> validateRoomPath<span style="color: #009900;">&#40;</span><span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'room'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$room</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span> <span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'new_option'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'new_room'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">/* Add a new option and room */</span>
  <span style="color: #000088;">$new_room</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$room</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/'</span> <span style="color: #339933;">.</span> option2slug<span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'new_option'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>buildRoom<span style="color: #009900;">&#40;</span><span style="color: #000088;">$new_room</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'new_room'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <a href="http://www.php.net/header"><span style="color: #990000;">header</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Location: &quot;</span> <span style="color: #339933;">.</span> PATH_TO_WEBROOT <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$new_room</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #339933;">&lt;</span> <span style="color: #339933;">!</span>DOCTYPE html<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>html<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>head<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>title<span style="color: #339933;">&gt;</span>CHOOSE<span style="color: #339933;">/</span>BUILD YOUR OWN ADVENTURE<span style="color: #339933;">!&lt;/</span>title<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>link rel<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;stylesheet&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text/css&quot;</span> media<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;all&quot;</span> href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;/story_game/style.css&quot;</span> <span style="color: #339933;">/&gt;</span>
  <span style="color: #339933;">&lt;/</span>head<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>body<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;wrapper&quot;</span><span style="color: #339933;">&gt;</span>
      <span style="color: #339933;">&lt;</span> ?php
        <span style="color: #b1b100;">echo</span> formatRoomDescription<span style="color: #009900;">&#40;</span><span style="color: #000088;">$room</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
      <span style="color: #000000; font-weight: bold;">?&gt;</span>
      <span style="color: #339933;">&lt;</span>h3<span style="color: #339933;">&gt;</span>what <span style="color: #b1b100;">do</span> you <span style="color: #b1b100;">do</span>?<span style="color: #339933;">&lt;/</span>h3<span style="color: #339933;">&gt;</span>
      <span style="color: #339933;">&lt;</span> ?php
        <span style="color: #b1b100;">echo</span> formatRoomOptions<span style="color: #009900;">&#40;</span><span style="color: #000088;">$room</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
      <span style="color: #000000; font-weight: bold;">?&gt;</span>
      <span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;custom&quot;</span><span style="color: #339933;">&gt;</span>
		<span style="color: #339933;">&lt;</span>form method<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;post&quot;</span> action<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">&gt;</span>
		  <span style="color: #339933;">&lt;</span>label <span style="color: #b1b100;">for</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;new-option&quot;</span><span style="color: #339933;">&gt;</span>Custom action<span style="color: #339933;">&lt;/</span>label<span style="color: #339933;">&gt;</span>
		  <span style="color: #339933;">&lt;</span>input type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text&quot;</span> id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;new-option&quot;</span> name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;new_option&quot;</span> <span style="color: #339933;">/&gt;</span>
		  <span style="color: #339933;">&lt;</span>label <span style="color: #b1b100;">for</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;new-room&quot;</span><span style="color: #339933;">&gt;</span>Action result<span style="color: #339933;">&lt;/</span>label<span style="color: #339933;">&gt;</span>
		  <span style="color: #339933;">&lt;</span>textarea id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;new-room&quot;</span> name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;new_room&quot;</span> cols<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;80&quot;</span> rows<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;10&quot;</span><span style="color: #339933;">&gt;&lt;/</span>textarea<span style="color: #339933;">&gt;</span>
		  <span style="color: #339933;">&lt;</span>input type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;hidden&quot;</span> name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;room&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php echo <span style="color: #006699; font-weight: bold;">$room</span> ; ?/&gt;&quot;</span> <span style="color: #339933;">/&gt;</span>
		  <span style="color: #339933;">&lt;</span>input type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;submit&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;submit&quot;</span> <span style="color: #339933;">/&gt;</span>
		<span style="color: #339933;">&lt;/</span>form<span style="color: #339933;">&gt;</span>
	  <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;/</span>body<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>html<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>I&#8217;m omitting the <code>functions.php</code> file here for security reasons but suffice it to say it&#8217;s pretty short.  A single line of <code>mod_rewrite</code> in a <code>.htaccess</code> file redirects everything:</p>

<div class="wp_codebox"><table><tr id="p3104"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p310code4"><pre class="mod_rewrite" style="font-family:monospace;">Options +FollowSymlinks
RewriteEngine on
RewriteRule ^([0-9a-z\-/]*)$ /story_game/index.php?room=$1</pre></td></tr></table></div>

<p>One of the truly novel things about the app is that it avoids the need for a database by simply using the filesystem as a hierarchical data structure.  While this may not be the most robust solution and it did limit the app somewhat, it allowed me to set things up very quickly.</p>
]]></content:encoded>
			<wfw:commentRss>http://samauciello.com/rapid-development-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Computer Science Bananagrams</title>
		<link>http://samauciello.com/computer-science-bananagrams/</link>
		<comments>http://samauciello.com/computer-science-bananagrams/#comments</comments>
		<pubDate>Wed, 07 Mar 2012 06:35:07 +0000</pubDate>
		<dc:creator>Sam Auciello</dc:creator>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://samauciello.com/?p=262</guid>
		<description><![CDATA[One of the perils of studying Computers at a tiny liberal arts college is that you don&#8217;t usually have many peers to discuss the subject with. Lately I&#8217;ve been lucky as the department seems to be experiencing a surge of &#8230; <a href="http://samauciello.com/computer-science-bananagrams/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>One of the perils of studying Computers at a tiny liberal arts college is that you don&#8217;t usually have many peers to discuss the subject with.  Lately I&#8217;ve been lucky as the department seems to be experiencing a surge of student interest.  Today as I was playing <a href="https://en.wikipedia.org/wiki/Bananagrams">bananagrams</a> in the dining hall the group of players gradually evolved to consist entirely of CS students.  As we were playing, we kept remarking how nice it would be if we could use the sort of nonsense acronym/words that are so pervasive in computer science.<span id="more-262"></span></p>
<p>We decided to play a game of Banangrams in-which only CS related words were allowed.  It turned out to be much harder than I had expected but it was quite fun and I learned about a lot of things I&#8217;d never heard of.  Our crosswords are pictured and annotated below:</p>
<h2>My crossword:</h2>
<p><img src="/wp-content/files/banana-sam.jpg" title="My bananagram crossword" alt="My bananagram crossword" class="center" /></p>
<dl>
<dt>NOR</dt>
<dd><a href="https://en.wikipedia.org/wiki/Logical_NOR">Logical NOR</a> is the logical equivalent of neither.</dd>
<dt>Joomla</dt>
<dd><a href="https://en.wikipedia.org/wiki/Joomla">Joomla</a> is a terrible open source content management system.</dd>
<dt>my</dt>
<dd><a href="https://en.wikipedia.org/wiki/Local_variable#local_in_Perl">my</a> is the keyword to create a local lexically scoped variable in <a href="https://en.wikipedia.org/wiki/Perl">Perl</a>.</dd>
<dt>Java</dt>
<dd><a href="https://en.wikipedia.org/wiki/Java_%28programming_language%29">Java</a> is a popular object-oriented programming language.</dd>
<dt>.rar</dt>
<dd><a href="https://en.wikipedia.org/wiki/RAR">.rar</a> stands for Roshal ARchive.  It is a proprietary archive format.</dd>
<dt>rip</dt>
<dd>The <a href="https://en.wikipedia.org/wiki/Ripping">process</a> of copying media content from a CD or DVD onto a hard drive.</dd>
<dt>IP</dt>
<dd><a href="https://en.wikipedia.org/wiki/Internet_Protocol">Internet Protocol</a> is a system computers use to identify each other on the internet.</dd>
<dt>no-op</dt>
<dd><a href="https://en.wikipedia.org/wiki/No-op#NOP_code">no-op</a> stands for no operation and is a programming instruction that does nothing.</dd>
<dt>or</dt>
<dd><code>or</code> is a keyword in <a href="https://en.wikipedia.org/wiki/Ruby_%28programming_language%29">Ruby</a> which has lower precedence than the otherwise equivalent <code>||</code>.</dd>
<dt>GNU</dt>
<dd><a href="https://en.wikipedia.org/wiki/GNU">GNU</a> stands for GNU&#8217;s Not UNIX.  It is a successful project to replace <a href="https://en.wikipedia.org/wiki/Unix">UNIX</a> with <a href="https://en.wikipedia.org/wiki/Free_software">Free Software</a>.</dd>
<dt>IEEE</dt>
<dd>The <a href="https://en.wikipedia.org/wiki/IEEE">Institute of Electrical and Electronics Engineers</a> is a non-profit professional association that is responsible for many useful internet standards.</dd>
<dt>.exe</dt>
<dd><a href="https://en.wikipedia.org/wiki/Exe">.exe</a> is a common file extension denoting an executable file in the Microsoft Windows operating system.</dd>
<dt>eq</dt>
<dd><code>eq</code> is the shallow equality built-in function in <a href="https://en.wikipedia.org/wiki/Common_lisp">Common Lisp</a>.</dd>
<dt>quine</dt>
<dd>A <a href="https://en.wikipedia.org/wiki/Quine_%28computing%29">quine</a> is a computer program which takes no input and produces a copy of its own source code as its only output.  For example a quine in Ruby might be <code>print open($0).read</code></dd>
<dt>vi</dt>
<dd><a href="https://en.wikipedia.org/wiki/Vi">vi</a> is a primarily console-based text editor popular amongst programmers who have never tried <a href="https://en.wikipedia.org/wiki/Emacs">emacs</a>.</dd>
<dt>date</dt>
<dd><a href="http://php.net/manual/en/function.date.php">date</a> is a built-in function in <a href="https://en.wikipedia.org/wiki/Php">PHP</a> that formats a useful date/time string from a timestamp.</dd>
<dt>.cmd</dt>
<dd><a href="https://en.wikipedia.org/wiki/Cmd">.cmd</a> is a file extension designating a file to be runnable by the cmd.exe shell in the Microsoft Windows operating system.</dd>
<dt>nil</dt>
<dd><code>nil</code> is a keyword in Ruby which designates the empty value.</dd>
<dt>lock</dt>
<dd>A <a href="https://en.wikipedia.org/wiki/Lock_%28computer_science%29">lock</a> is a synchronization mechanism useful in concurrent programming.</dd>
<dt>fork</dt>
<dd>A <a href="https://en.wikipedia.org/wiki/Fork_%28software_development%29">fork</a> is a separate development branch of a piece of software never intended to be merged back into the original project</dd>
<dt>rm</dt>
<dd><a href="https://en.wikipedia.org/wiki/Rm_%28Unix%29">rm</a> is a UNIX command short for remove that permanently deletes a file.</dd>
<dt>fault</dt>
<dd>A <a href="https://en.wikipedia.org/wiki/Fault_%28computing%29">fault</a> is a type of hardware interupt.</dd>
<dt>GET</dt>
<dd><a href="https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods">GET</a> is the most common type of HTTP request.</dd>
<dt>.gz</dt>
<dd><a href="https://en.wikipedia.org/wiki/Gzip">.gz</a> is a file extension designating a file compressed with GNU zip.</dd>
</dl>
<h2>Isaac&#8217;s crossword</h2>
<p><img src="/wp-content/files/banana-isaac.jpg" title="My bananagram crossword" alt="My bananagram crossword" class="center" /></p>
<dl>
<dt>.sea</dt>
<dd>.sea designates a <a href="https://en.wikipedia.org/wiki/Self-extracting_archive">self-extracting archive</a> file: when run as an executable, it extracts.</dd>
<dt>nest</dt>
<dd><a href="https://en.wikipedia.org/wiki/Nesting_%28computing%29">Nesting</a> parentheses looks (like (this)).</dd>
<dt>try</dt>
<dd><code>try</code> is an <a href="https://en.wikipedia.org/wiki/Exception_handling_syntax">exception-handling keyword</a> in many programming languages.</dd>
<dt>real</dt>
<dd><a href="https://en.wikipedia.org/wiki/Real_mode">x86 real mode</a> is a legacy, rarely-used 16-bit mode of operation on your laptop&#8217;s processor.</dd>
<dt>lea</dt>
<dd>lea is an <a href="https://en.wikipedia.org/wiki/X86_instruction_listings">x86 opcode</a> that does addition and limited fixed-factor multiplication, originally created for addressing arrays.</dd>
<dt>AIX</dt>
<dd><a href="https://en.wikipedia.org/wiki/AIX">AIX</a> is an IBM implementation of UNIX.</dd>
<dt>XAA</dt>
<dd>The <a href="https://en.wikipedia.org/wiki/XFree86_Acceleration_Architecture">X Acceleration Architecture</a> is an old part of infrastructure for hardware-accelerated rendering in the X display system.</dd>
<dt>.bat</dt>
<dd><a href="https://en.wikipedia.org/wiki/.bat">.bat</a> is another file extension for Microsoft shell scripts.</dd>
<dt>TODO</dt>
<dd><a href="https://en.wikipedia.org/wiki/Comment_%28computer_programming%29#Tags">TODO</a> marks a comment that describes something that should be done.</dd>
<dt>UDF</dt>
<dd><a href="https://en.wikipedia.org/wiki/Universal_Disk_Format">Universal Disk Format</a> is the filesystem format on DVDs that is superior to ISO 9660.</dd>
<dt>of</dt>
<dd><code>of</code> is a <a href="http://zvon.org/other/haskell/Outputsyntax/caseQexpressions_reference.html">keyword in Haskell</a>: <code>case (some expression) of [...]</code></dd>
<dt>FFT</dt>
<dd><a href="https://en.wikipedia.org/wiki/Fast_Fourier_transform">Fast Fourier Transform</a> is an O(n log n) signal-processing algorithm.</dd>
<dt>this</dt>
<dd><a href="https://en.wikipedia.org/wiki/This_%28computer_programming%29">this</a> is a keyword in C++ that refers to the object a method is called on.</dd>
<dt>IVs</dt>
<dd>An <a href="https://en.wikipedia.org/wiki/Initialization_vector">initialization vector</a> is a fixed-size input to a cryptographic primitive that is typically required to be random or pseudorandom.</dd>
<dt>wide</dt>
<dd>The width of a <a href="https://en.wikipedia.org/wiki/Processor_register">CPU register</a> is how many bits it has.</dd>
<dt>GUID</dt>
<dd>A <a href="https://en.wikipedia.org/wiki/Globally_unique_identifier">Globally Unique IDentifier</a> is a 128-bit identifier for partitions in the GPT partition table format.</dd>
<dt>PUT</dt>
<dd><a href="https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods">PUT</a> is an HTTP request type that directs the server to store the attached file.</dd>
</dl>
<h2>Elias&#8217;s crossword:</h2>
<p><img src="/wp-content/files/banana-elias.jpg" title="My bananagram crossword" alt="My bananagram crossword" class="center" /></p>
<dl>
<dt>ith</dt>
<dd>The term ith is used to refer to an arbitrary element of a series.</dd>
<dt>.sit</dt>
<dd><a href="https://en.wikipedia.org/wiki/.sit">.sit</a> is a file extension used by the proprietary Stuffit expander family of compression programs.</dd>
<dt>hacks</dt>
<dd>A <a href="https://en.wikipedia.org/wiki/Hack_%28computer_science%29#In_computer_science">hack</a> is an inelegant but efficient solution to a programming problem</dd>
<dt>CE</dt>
<dd><a href="https://en.wikipedia.org/wiki/Windows_ce">Microsoft Windows CE</a> is an operating system developed by Microsoft for embedded systems.</dd>
<dt>sh</dt>
<dd>sh is a common abbreviation for <a href="https://en.wikipedia.org/wiki/Shell_%28computing%29">shell</a>, a console environment for interacting with a computer in plain text, especially in UNIX.</dd>
<dt>gs</dt>
<dd>gs is an obscure <a href="https://en.wikipedia.org/wiki/X86#32-bit">x86</a> register sometimes used as part of buffer-overflow protection.</dd>
<dt>log</dt>
<dd>A <a href="https://en.wikipedia.org/wiki/Computer_data_logging">log file</a> is a file used to log information about a program as it runs.</dd>
<dt>rel</dt>
<dd><a href="https://www.w3schools.com/TAGS/att_a_rel.asp">rel</a> is an HTML attribute that specifies the relationship between the current document and a linked document.</dd>
<dt>RE</dt>
<dd>A <a href="https://en.wikipedia.org/wiki/Regular_expression">Regular Expression</a> is a concise and flexible means for specifying and recognizing strings of text.</dd>
<dt>byte</dt>
<dd>A <a href="https://en.wikipedia.org/wiki/Byte">byte</a> is unit of information equal 8 bits.  There are 256 unique bytes.</dd>
<dt>.bz</dt>
<dd><a href="http://en.wikipedia.org/wiki/.bz">.bz</a> is a the top level domain for Belize.</dd>
<dt>None</dt>
<dd><code>None</code> is a keyword in <a href="http://en.wikipedia.org/wiki/Python_%28programming_language%29">Python</a> which designates the empty value.</dd>
<dt>Oo</dt>
<dd><a href="https://en.wikipedia.org/wiki/Object-oriented_programming">Object-Oriented programming</a> is a programming paradigm that is the basis for many modern scripting languages such as Ruby and JavaScript.</dd>
<dt>NAT</dt>
<dd>A <a href="https://en.wikipedia.org/wiki/Network_address_translation">Network Address Translation</a> is the process of modifying IP address information in IP packet headers while in transit across a traffic routing device.
<dt>ADD</dt>
</dd>
<dd>Add is a thing that all Turing complete machines can do.</dd>
<dt>.edu</dt>
<dd><a href="https://en.wikipedia.org/wiki/.edu">.edu</a> is a sponsored top-level domain intended for accredited post-secondary educational U.S. institutions.</dd>
<dt>use</dt>
<dd><code>use</code> is a built-in keyword in <a href="https://en.wikipedia.org/wiki/Perl">Perl</a> which includes an external package.</dd>
<dt>wine</dt>
<dd><a href="https://en.wikipedia.org/wiki/Wine_%28software%29">Wine</a> is a free and open source software application that aims to allow computer programs written for the Microsoft Windows operating system to run on Unix-like operating systems</dd>
<dt>NaN</dt>
<dd>NaN stands for <a href="https://en.wikipedia.org/wiki/NaN">Not a Number</a>.  It is a numeric data type that is part of the IEEE 754 floating-point standard.</dd>
<dt>web</dt>
<dd>Web is another name for the internet.  It is particularly used to refer to internet applications that use HTTP.</dd>
<dt>br</dt>
<dd><a href="http://www.w3schools.com/TAGS/tag_br.asp">&lt;br /&gt;</a> is an HTML tag used to designate a line break.</dd>
</dl>
]]></content:encoded>
			<wfw:commentRss>http://samauciello.com/computer-science-bananagrams/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Where Ruby and Python collide</title>
		<link>http://samauciello.com/where-ruby-and-python-collide/</link>
		<comments>http://samauciello.com/where-ruby-and-python-collide/#comments</comments>
		<pubDate>Fri, 02 Mar 2012 22:25:13 +0000</pubDate>
		<dc:creator>Sam Auciello</dc:creator>
				<category><![CDATA[Languages]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://samauciello.com/?p=252</guid>
		<description><![CDATA[I had an idea to make a file that was simultaneously a valid ruby script and a valid python script. I&#8217;m not sure what prompted this idea but I wanted to know if it was possible and I eventually came &#8230; <a href="http://samauciello.com/where-ruby-and-python-collide/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I had an idea to make a file that was simultaneously a valid ruby script and a valid python script.  I&#8217;m not sure what prompted this idea but I wanted to know if it was possible and I eventually came up with the following:<span id="more-252"></span></p>

<div class="wp_codebox"><table><tr id="p2528"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code" id="p252code8"><pre class="python" style="font-family:monospace;"><span style="color: #483d8b;">&quot;&quot;&quot; &quot;
=begin
&quot;&quot;&quot;</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># BOF python code #</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;This is an arbitrary Python program&quot;</span>
&nbsp;
fib = <span style="color: #ff7700;font-weight:bold;">lambda</span> n: <span style="color: #ff4500;">1</span> <span style="color: #ff7700;font-weight:bold;">if</span> n <span style="color: #66cc66;">&lt;</span> <span style="color: #ff4500;">2</span> <span style="color: #ff7700;font-weight:bold;">else</span> fib<span style="color: black;">&#40;</span>n - <span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span> + fib<span style="color: black;">&#40;</span>n - <span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;, &quot;</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span><span style="color: #008000;">map</span><span style="color: black;">&#40;</span><span style="color: #ff7700;font-weight:bold;">lambda</span> x: <span style="color: #008000;">str</span><span style="color: black;">&#40;</span>fib<span style="color: black;">&#40;</span>x<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>, <span style="color: #008000;">range</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">10</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># EOF python code #</span>
&nbsp;
<span style="color: #483d8b;">&quot;&quot;&quot;</span></pre></td></tr></table></div>

</pre>

<div class="wp_codebox"><table><tr id="p2529"><td class="line_numbers"><pre>15
16
17
18
19
20
21
22
23
24
25
26
</pre></td><td class="code" id="p252code9"><pre class="ruby" style="font-family:monospace;">=<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># BOF ruby code #</span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;This is an arbitrary Ruby program&quot;</span>
&nbsp;
fib = <span style="color:#CC0066; font-weight:bold;">lambda</span> <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>n<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#006600; font-weight:bold;">&#40;</span>n <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#006666;">2</span><span style="color:#006600; font-weight:bold;">&#41;</span> ? <span style="color:#006666;">1</span> : fib.<span style="color:#9900CC;">call</span><span style="color:#006600; font-weight:bold;">&#40;</span>n <span style="color:#006600; font-weight:bold;">-</span> <span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">+</span> fib.<span style="color:#9900CC;">call</span><span style="color:#006600; font-weight:bold;">&#40;</span>n <span style="color:#006600; font-weight:bold;">-</span> <span style="color:#006666;">2</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#125;</span>
<span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#006666;">10</span>.<span style="color:#9900CC;">times</span>.<span style="color:#9900CC;">map</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&amp;</span>fib<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">join</span> <span style="color:#996600;">&quot;, &quot;</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># EOF ruby code #</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># &quot;&quot;&quot;</span></pre></td></tr></table></div>

<p>I've split the code up into two blocks here because my code block system was built with the entirely reasonable assumption that each block would have only one language.  I made a simple Fibonacci implementation to demonstrate that I can in fact run arbitrary ruby and python code in the same file.</p>
<p>Line #1 is where the real magic happens.  Ruby interprets the line as two string literals <code>""</code> and <code>" "</code>.  In Ruby two string literals next to each other like this get concatenated.  So the entirety of line one is interpreted by Ruby as the string <code>" "</code> and since nothing is done with it is simply evaluated and thrown out.  Python on the other hand does something completely different.  In Python, <code>"""</code> marks the beginning of a multi-line string and since the fourth <code>"</code> is separated by a space it is simply interpreted as part of the string.</p>
<p>On line #2 Ruby sees the beginning of a multi-line comment and Python just sees more of the string.  Line #3 is part of the comment for Ruby and the end of the multi-line string for Python.  As with the concatenated string literal with Ruby before, Python simply evaluates this multi-line string and throws it away.</p>
<p>At this point we are in a comment in Ruby and ready to evaluate things in Python so we put our Python program here.</p>
<p>Finally Python evaluates lines #14 - #26 as another multiline string which just happens to contain ruby code.</p>
<p>I tried to get Perl in here as well but the problem seems to come down to the first line.  Because this line is valid in both Ruby and Python but starts a comment in one and not in the other, the whole thing works.  Since this is just an error to Perl, nothing really works.  Incidentally Ruby and Perl aren't terribly hard simply because <code>=begin</code> is the start of a multi-line comment in both languages that is terminated differently in each:</p>
</pre>

<div class="wp_codebox"><table><tr id="p25210"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code" id="p252code10"><pre class="text" style="font-family:monospace;">=begin
=cut
&nbsp;
# BOF perl code #
&nbsp;
print &quot;This is an arbitrary Perl program\n&quot; ;
&nbsp;
# EOF perl code #
&nbsp;
=head
=end
&nbsp;
# BOF ruby code #
&nbsp;
puts &quot;This is an arbitrary Ruby program&quot;
&nbsp;
# EOF ruby code #
&nbsp;
&quot;
=cut
# &quot;</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://samauciello.com/where-ruby-and-python-collide/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zsh Customization and Beautification</title>
		<link>http://samauciello.com/zsh-customization-and-beautification/</link>
		<comments>http://samauciello.com/zsh-customization-and-beautification/#comments</comments>
		<pubDate>Thu, 16 Feb 2012 17:16:32 +0000</pubDate>
		<dc:creator>Sam Auciello</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://samauciello.com/?p=243</guid>
		<description><![CDATA[So I was working on a project in Ruby with my friend Isaac when I noticed that his terminal looked really cool. I asked him about it and he said it was zsh with a plugin called zsh-syntax-highlighting. I found &#8230; <a href="http://samauciello.com/zsh-customization-and-beautification/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>So I was working on a project in Ruby with my friend Isaac when I noticed that his terminal looked really cool.  I asked him about it and he said it was <code>zsh</code> with a plugin called <code>zsh-syntax-highlighting</code>.  I found the project&#8217;s <a href="https://github.com/zsh-users/zsh-syntax-highlighting">github page</a> and tried setting it up but it didn&#8217;t immediately work.<span id="more-243"></span></p>
<p>Following the instructions in the project&#8217;s <code>README.md</code> file, I cloned the project</p>

<div class="wp_codebox"><table><tr id="p24318"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p243code18"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> clone https:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>zsh-users<span style="color: #000000; font-weight: bold;">/</span>zsh-syntax-highlighting.git</pre></td></tr></table></div>

<p>then I added the line</p>

<div class="wp_codebox"><table><tr id="p24319"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p243code19"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">source</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>zsh-syntax-highlighting<span style="color: #000000; font-weight: bold;">/</span>zsh-syntax-highlighting.zsh</pre></td></tr></table></div>

<p>to my <code>.zshrc</code> file.</p>
<p>Unfortunately, when I tried re-instantiating my terminal, I got the following error message</p>

<div class="wp_codebox"><table><tr id="p24320"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p243code20"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>olleicua<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>zsh<span style="color: #000000; font-weight: bold;">/</span>zsh-syntax-highlighting<span style="color: #000000; font-weight: bold;">/</span>zsh-syntax-highlighting.zsh:<span style="color: #000000;">76</span>: parse error near <span style="color: #000000; font-weight: bold;">`</span><span style="color: #000000; font-weight: bold;">done</span><span style="color: #ff0000;">'</span></pre></td></tr></table></div>

<p>I spent a good forty-five minutes googling variations on &#8220;zsh-syntax-highlighting parse error near `done&#8217;&#8221; with and without my <code>zsh</code> version and OS.  Finally it occurred to me to try the search without <code>zsh-syntax-highlighting</code> since it my be an issue with my <code>zsh</code> setup specifically and I found <a href="http://www.zsh.org/mla/users/1998/msg00228.html">this</a> mailing list archive.  The mailing list suggested that one of the built-in <code>zsh</code> keywords that was being used in a control structure had been overwritten by an alias, in this case <code>fi</code>.  I reviewed the section of the plugin that was bugging out and noticed that it was using the keyword <code>do</code> in its control structures and recalled that I had aliased <code>do</code> to <code>cd</code> into my downloads directory.  I changed the alias to <code>dow</code> and now the plugin works fine.</p>
<p>The moral of this story is to always use <code>which</code> before naming an alias or binary in your path.  <code>which</code> looks for the specified name in it&#8217;s list of built-in commands, in your defined aliases and in your path.  It then tells you if it found it and if so where.  In this case</p>

<div class="wp_codebox"><table><tr id="p24321"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p243code21"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">which</span> <span style="color: #000000; font-weight: bold;">do</span>
<span style="color: #000000; font-weight: bold;">do</span>: shell reserved word</pre></td></tr></table></div>

<p>It doesn&#8217;t complain when you overwrite things with aliases because you want to be able to do things like</p>

<div class="wp_codebox"><table><tr id="p24322"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p243code22"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">rm</span>=<span style="color: #ff0000;">&quot;rm -rf&quot;</span></pre></td></tr></table></div>

<p>if you&#8217;re feeling foolhardy.</p>
<h2>Coloring zsh</h2>
<p>Once I had gotten this to work, I was so happy with myself that I decided to make my <code>zsh</code> more colorful in general.  I had to do a bit of trial and error because I&#8217;m using both a prompt and a right-prompt. Before this change my shell looked like this</p>
<p><img src="/wp-content/themes/samauciello/images/zsh-screenshot-1.png" /></p>
<p>and was generated by the following in my <code>.zshrc</code> file</p>

<div class="wp_codebox"><table><tr id="p24323"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p243code23"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">PROMPT</span>=<span style="color: #ff0000;">'
$ '</span>
&nbsp;
<span style="color: #007800;">RPROMPT</span>=<span style="color: #ff0000;">'| %~ | %D{%k:%M} | %h | Jack |'</span></pre></td></tr></table></div>

<p>I was able to add colors by changing this to</p>

<div class="wp_codebox"><table><tr id="p24324"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p243code24"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">PROMPT</span>=<span style="color: #ff0000;">'%F{green}
$ %f'</span>
&nbsp;
<span style="color: #007800;">RPROMPT</span>=<span style="color: #ff0000;">'%F{green}|%f %F{cyan}%~%f %F{green}|%f %F{cyan}%D{%k:%M}%f %F{green}|%f %F{cyan}%h%f %F{green}|%f %F{cyan}Jack%f %F{green}|%f'</span></pre></td></tr></table></div>

<p>In this case <code>%F{COLOR}TEXT%f</code> is the syntax for coloring text in <code>zsh</code> prompts.  The result was</p>
<p><img src="/wp-content/themes/samauciello/images/zsh-screenshot-2.png" /></p>
]]></content:encoded>
			<wfw:commentRss>http://samauciello.com/zsh-customization-and-beautification/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Semester Studying Open Source Software</title>
		<link>http://samauciello.com/a-semester-studying-open-source-software/</link>
		<comments>http://samauciello.com/a-semester-studying-open-source-software/#comments</comments>
		<pubDate>Sat, 17 Dec 2011 02:00:51 +0000</pubDate>
		<dc:creator>Sam Auciello</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://samauciello.com/?p=227</guid>
		<description><![CDATA[This post is the final paper I wrote for my self-taught open source software class this semester. This semester, in an attempt further my education in the art of making great software, I began looking at how software is made &#8230; <a href="http://samauciello.com/a-semester-studying-open-source-software/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div style="text-align:center;"><span class="pren">This post is the final paper I wrote for my self-taught open source software class this semester.</span></div>
<p>This semester, in an attempt further my education in the art of making great software, I began looking at how software is made in the open source world.  I chose to look at this field for several reasons.  I’ve been quite interested in open source software as long as I’ve known about it.  I appreciate the social/economic benefits of software that is made by individuals who want it to be of quality as opposed to corporations that simply want to make money (and are therefore frequently motivated to compromise quality for business reasons e.g. planned obsolescence etc.).  My experience with academic vs. professional programming also leads me to believe that people are far more likely to cut corners when they’re getting paid.  Another reason for looking into open source was that large-scale software is often made in teams.  I had had very little experience working on software with a group and, being at tiny isolated liberal arts school with a similarly tiny computer science department, I realized that this was a key missing component of my education.  This would also give me an opportunity to compare my coding to others’ so as to get a sense of how I need to improve.<span id="more-227"></span></p>
<p>I began the semester thinking I would be contributing to <a href="http://www.mozilla.org/">Mozilla</a> <a href="http://www.mozilla.org/en-US/firefox/">Firefox</a> and I spent the first few weeks looking into this.  In the process I was exposed the <a href="https://developer.mozilla.org/En/XUL"><code>XUL</code></a> and was able to build a very simple Firefox extension as well and getting a glimpse at the guts of Firefox.  I quickly realized that my lack of familiarity with <code>XUL</code>, <code>C++</code>, and Firefox development in general was going to make contributing difficult and that I would likely spend more time exploring these technologies than learning about open source.  For this reason, I switched my focus to <a href="http://wordpress.org/">WordPress</a>, a project I was already much more familiar with.  I had previously dabbled in creating plug-ins for WordPress so contributing to the core in <code>PHP</code> (a language I am quite familiar with) seemed far less daunting.  Although I would still love to someday learn <code>C++</code> and <code>XUL</code> and explore the Mozilla community, I’m glad I made this decision because it allowed me to actually engage with a community the maintains a popular <a href="http://en.wikipedia.org/wiki/Content_management_system">CMS</a> used by millions of bloggers.  I made several small contributions to the swiftly approaching release of <a href="http://codex.wordpress.org/Version_3.3">WordPress 3.3</a> (as of the time of this writing there is a <a href="http://core.trac.wordpress.org/ticket/19475">single ticket impeding the release</a>).  My contributions included three major patches and a bug report.  I got the opportunity to interact with several of the movers and shakers of the community and the experience was, on a whole, intimidating yet gratifying.  I intend to continue contributing to WordPress.</p>
<p>I also spent a some time exploring some of the tools of open source software such as version control systems.  Although WordPress uses Subversion, the software world at large seems to be slowly moving towards distributed version control systems like Git and Mercurial.  I’ve become somewhat familiar with Mercurial and I hope to find more excuses to work with it in the future.  I also looked a bit at software licenses.  In particular, I looked at the differences between restrictively open “free” licenses like GPL and LGPL and much simpler ones like the MIT license.  I didn’t spend much time on this subject as it doesn’t directly relate to programming and would probably be more interesting to a law student but it was good to get a sense of what exactly is meant by terms like open and free when they are applied to software.</p>
<p>I also spent some time this semester looking at subjects tangential to open source but directly related to becoming a well rounded programmer.  For example, I began formally acquainting myself with <code>Perl</code>.  <code>Perl</code> seems to be quite powerful though intimidatingly open-ended.  I’ve also begun learning <code>Ruby</code>, which I feel will soon replace <code>Python</code> as my go-to scripting language.  Finally I dove into Emacs which is increasingly my default text-editor.  I’ve spent the semester continuing to improve my general coding skills and using open source as focal point.  I set out to get exposure to a larger world of software technology specifically in the open source community and I feel that I have done this.  This is of course not to say that I’m done; the software world is enormous and there will always be more to learn.</p>
<h2>Contributing</h2>
<p>I did make some initial attempts to contribute to Mozilla Firefox.  I found the process inviting, with many helpful tutorials on how to get started.  The main barrier to entry for me was that most of the tickets marked as <a href="https://bugzilla.mozilla.org/buglist.cgi?quicksearch=sw:[good%20first%20bug]">“Good first bugs”</a> in Bugzilla were like Greek to me.  They often referred to aspects of <code>C++</code> or the Mozilla core that I wasn’t familiar with and assumed that I was.  There were a couple of bugs that I was able to understand well enough to reproduce.  The first was one involving Firefox’s handling of <code>&lt;wbr /&gt;</code> tags, which was inconsistent with other browsers.  There was some disagreement as to whether the behavior of Firefox was in fact incorrect.  Given the clear lack of agreement this seemed like a bad place to start.  The other bug involved a button in the bookmark interface that needed to be disabled in a certain circumstance.  This seemed like something that I might be able to fix but before I got the chance to a patch was submitted by someone else.  This was about the time I decided to switch to looking at WordPress.</p>
<p>WordPress was slightly less initially inviting.  Unlike with Firefox, there was no “so you want to contribute to WordPress” page with helpful step by step instructions.  There was a general description of how to get involved, which I followed.  The main difference was my familiarity with the underlying technologies.  About half of the tickets in <a href="http://core.trac.wordpress.org/">trac</a> were clear enough that I could begin looking into them without much trouble at all and the other half would become more straight forward if I looked at them more.  My first contribution was to <a href="http://core.trac.wordpress.org/ticket/18989">ticket #18314</a> which was about cleaning up duplicate entries in the admin style-sheet.  I took a look a the offending <code>CSS</code> file and quickly found a section where a large block of identical rules was being applied separately to three different selectors.  I merged the identical rules into one block, made a patch using <code>svn diff</code> and submitted it to trac.  My patch was soon committed and so I decided to do a once over of the <code>CSS</code>ticket #18866.  It referred to a bug in the error page displayed if the <code>wp-config.php</code> file is missing.  Another bug having to do with certain situations where the <code>URL</code> of the appropriate style-sheet for the error page might not be accessible had necessitated putting the <code>CSS</code> rules for the page in-line in the <code>HTML</code> head.  A couple of rules had been forgotten so I tracked down the file that was generating the page and added the necessary rules.  I found it necessary to include a reference to a background gradient image, causing the same problem as including a style-sheet would have, except that the difference between the page with and without this gradient was barely noticeable so this seemed like the solution most likely to work most of the time.  Another contributor suggested using <code>CSS</code> gradients but, as they are not supported by Microsoft Internet Explorer prior to version 10, my patch was used.</p>
<p>I also fixed a bug in the “Press This” interface, <a href="http://core.trac.wordpress.org/ticket/18989">ticket #18989</a>.  Press This is a bookmarklet that opens a pop-up window allowing bloggers to easily post about content they find while browsing other sites.  In addition to automatically pasting a link to the site into the post the bookmarklet grabs any selected text as well as providing an interface to include in-line images from the page.  A change from another ticket had caused a bug in the image including functionality.  Everything seemed to work fine but the image was not pasted into the post.  Another contributor had pointed to the offending bit of code.  It seems that an <code>HTML</code> input tag with the same id had been added to the interface and the <code>Jquery</code> selector that got the image <code>URL</code> to insert it into the post was now no longer specific enough.  I added a more specific selector but this didn’t fix the problem.  By adding <code>console.log()</code> statements, I was able to follow a relatively complex chain of seemingly unnecessary functions and discover a place where the <code>HTML</code> to be inserted into the post was being passed as the only argument to function that expected it as the second argument.  Not wanting to break another aspect of the application, I passed the parameter as both the first and second arguments and the bug was fixed.  If I had been more comfortable with general workings of the editing interface I’d have looked further to see why this was so excessively complex but this felt like a much larger project so I just made it work in a way that was unlikely to cause conflicts.  It strikes me that this sort of apathy is probably what allows this code to remain as complex as it is.  Perhaps I will look into cleaning it up for the next release.</p>
<p>I also found a bug and created <a href="http://core.trac.wordpress.org/ticket/19119">ticket #19119</a>.  A major feature had been added creating fly-out menus for the main admin navigation in <a href="http://core.trac.wordpress.org/ticket/18382">ticket #18382</a>.  I noticed relatively early that the changes being made had caused the collapsed menu fly-outs to be off by one pixel.  Since there were a lot of developers working on this at the time I assumed that someone was on it and was worried that too many cooks might spoil the sauce.  Apparently I was wrong because ticket #18382 was closed with the notice “If you encounter any bugs, please open a new ticket.”  The bug was still there so I opened a new ticket.  I tried submitting a patch to it but a better one was used by someone with a better understanding of the <code>CSS</code> involved.  I also made several smaller contributions in the form of testing patches and commenting on discussions.</p>
<h2>The Open Source Community</h2>
<p>My initial reaction to the communities I looked at was that they were very inviting.  This was unsurprising as it seems like a necessity to an organization fueled by volunteers.  It was interested to see how decision were made within these communities.  The Mozilla approach is a complex hierarchical structure that rewards longstanding contributors with the ability to make more serious decisions.  WordPress being smaller, has a much simpler approach.  There is a core WordPress team that has commit access to the Subversion repository.  Anyone else can check out the repository and submit changes to Trac in the form of patches (anyone can create an account in Trac).  Because WordPress is relatively small, it’s rather trivial for the core team to keep track of tickets with patches in them and commit things that need to be committed.</p>
<p>It was interesting to see the varying quality of documentation in WordPress code.  Any function intended to be used by plug-in/theme developers is described in detail in the <a href="http://codex.wordpress.org/">WordPress Codex</a> in terms that can be understood by someone who has very little programming experience.  Anything internal is lucky to have more than basic in-line comments next to it in the code.  This also varies widely from file to file.  Most of the files have a comment block at the top explaining the file’s purpose but this is often all you get and you have to hope the code is well written (which it only sometimes is).  It’s not clear to me why there is such a discrepancy between end user documentation and developer documentation.  It seems reasonable that user documentation would be prioritized as it is part of making the product usable but it seems like it would be just as important to provide support to developers so to help developers improve the core.</p>
<p>One thing that surprised me that seemed to be a major feature of the community was a general sense of inertia.  A debate came up in the <a href="http://codex.wordpress.org/Mailing_Lists#Hackers">wp-hackers email list</a> about a month ago about the differences between relative and absolute URLs.  Whenever an internal image or link is added to a post or page on a WordPress site, the editor stores an absolute URL in the database.  The strongest argument for this seems to be that absolute URLs will fully specify the correct location in any context and since the pages therefore always want to be served that way, they shouldn’t need to be processed for every page load.  The strongest argument against this seemed to be the issue of portability.  If development is at dev.example.com and a production is at example.com we shouldn’t need to fix the database any time we push the database to production.  Various other arguments were made and things got a bit out of hand at times but the end result was that since the core team was mostly in the former camp nothing was going to change in the WordPress core but it was fine to implement relative URLs in a plug-in (this was not particularly satisfactory for the proponents of relative URLs since the plug-in solution turned out the be somewhat clunky).  “Make it a plug-in” seems to be an unfortunately common answer to feature requests that don’t seem necessary to the use case that the core team has in mind.  For example re-arranging the order of your pages is an annoyingly complex task of meticulously changing a number in a field on each page.  There is a plug-in called <a href="http://wordpress.org/extend/plugins/my-page-order/">my page order</a> that provides a nice drag-and-drop interface for this but no one has considered incorporating it into the core.  It strikes me as unfortunate that this sort of inertia exists and I hope that it isn’t as prevalent in the open source community at large as it is in WordPress as it seems like a key barrier to competition with commercial software.</p>
<h2>Gaining Programming Skills</h2>
<p>One of my main goals for the semester was to gain skills in group development.  To this end, I spent a good deal of time acquainting myself with the relevant tools.  One of the most important tools in group development is version control.  The three version control systems I looked at were Subversion, Mercurial, and Git.  Subversion was clearly a vast improvement on its predecessor CVS, but it seems to be somewhat outdated at this point because the advantages of distributed version control are significant.  Unfortunately it is still quite prevalent.  Mercurial seems to be a really nice solution as it is fast, powerful, distributed, and relatively easy to learn.  Git seems to be the most powerful of the three but is harder to learn.  My current preference is for Mercurial which I have started using for some of my own projects.</p>
<p>The experience of working with other people’s code was helpful in general.  My experience with ticket #18989 in particular drove home the importance of keeping code simple and easy to follow.  It also re-affirmed my appreciation for the value of debug statements.</p>
<p>I also spent some time looking at Software licenses.  Particularly I looked at the differences between GPL, LGPL, and more permissive licenses like the MIT license.  GPL is restrictively free.  This sounds like a contradiction but the idea is basically that if a piece of software is licensed under GPL then any software built on top of it must also be GPL.  This ensures that the use of this code will never be subject to proprietary endeavors.  LGPL is less restrictive.  It allows proprietary software to be built on top of it so long as the licensed software is unmodified.  LGPL is common for programming languages and other situations where GPL would severely limit the products usability</p>
<p>I gained a lot of general knowledge/skills this semester that will help me in my goal of becoming a great software developer.  In addition to gaining familiarity to the WordPress core, I got exposure to <code>XUL</code>, Version Control, software licenses, <code>Perl</code>, and <code>Ruby</code>.  Although my semester was not as focused on contributing to open source as I originally intended it to be, I don’t see this as having been a problem.  The nature of software is that making it well is often as much about knowing how to use the tools as it is about understanding the concepts.  I feel like this semester gave me the opportunity to become acquainted with a number of powerful tools of the trade.  Even though it didn’t necessarily coalesce into a clearly structured curriculum, it gave me a chance to learn what I need to learn.</p>
]]></content:encoded>
			<wfw:commentRss>http://samauciello.com/a-semester-studying-open-source-software/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Image Processing with Convolution Functions</title>
		<link>http://samauciello.com/image-processing-with-convolution-functions/</link>
		<comments>http://samauciello.com/image-processing-with-convolution-functions/#comments</comments>
		<pubDate>Thu, 24 Nov 2011 02:12:54 +0000</pubDate>
		<dc:creator>Sam Auciello</dc:creator>
				<category><![CDATA[Algorithms]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://samauciello.com/?p=215</guid>
		<description><![CDATA[We&#8217;ve been working with convolution functions in my AI class and I&#8217;ve written a nifty little program in PHP to run convolutions of arbitrary 3&#215;3 kernels on gifs, pngs, and jpegs. You can try it out here. Be warned that &#8230; <a href="http://samauciello.com/image-processing-with-convolution-functions/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve been working with convolution functions in my AI class and I&#8217;ve written a nifty little program in PHP to run convolutions of arbitrary 3&#215;3 kernels on gifs, pngs, and jpegs.  You can try it out <a href="/image_processing/">here</a>.  Be warned that the page has no stylesheet.  I got immersed in the JQuery/AJAX/PHP coding and forgot to make the page look nice. In the end I decided that it had a cool retro feel to it and kept it.<span id="more-215"></span></p>
<h2>Convolutions</h2>
<p>I will herein describe convolution functions, if you are already familiar with the topic, feel free to skip ahead to the next heading.</p>
<p>The basic idea of a convolution is to combine to mathematical functions in a particular way.  The concept (like most things in mathematics) is described quite well on its <a href="http://en.wikipedia.org/wiki/Convolution">Wikipedia page</a>, so I won&#8217;t go into enormous detail here.  As it applies to image processing, convolution is a process of applying a grid of numerical values called a kernel to an image.  A simple example of a kernel is:</p>
<table class="centered kernel">
<tr>
<td>1</td>
<td>2</td>
<td>1</td>
</tr>
<tr>
<td>2</td>
<td>3</td>
<td>2</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>1</td>
</tr>
</table>
<p>The process is quite simple: look at each pixel in the input image and set the corresponding output pixel to the weighted sum/average of the neighboring pixels where the weights are determined by the values in the kernel.  So for example, with the above kernel, each pixel diagonally adjacent to a given pixel will be given a weight of 1, each pixel orthogonally adjacent to the pixel will be given a weight of 2, and the pixel itself will be given a weight of 3.  This particular kernel has the effect of blurring the image.</p>
<p>All sorts of things can be done with different kernels.  One interesting use is finding edges which can be done with a kernel like:</p>
<table class="centered kernel">
<tr>
<td>-1</td>
<td>-2</td>
<td>-1</td>
</tr>
<tr>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>1</td>
</tr>
</table>
<h2>AJAX without AJAX</h2>
<p>The thing that excited me most in building this little program was the realization that although it uses JQuery to communicate with the server without reloading the page without using <code>AJAX</code>, at least not in the traditional sense.  It is technically still asynchronous, and it doesn&#8217;t use <code>XML</code> (but modern <code>AJAX</code> rarely does).</p>
<p>When you click the process image button, a couple of things happen.  First the image you selected is asynchronously uploaded using a JQuery plugin called <a href="http://lagoscript.org/jquery/upload">JQuery.upload</a>.  As it turns out the only way to asynchronously upload a file is using an iframe, which is exactly what this plugin does.  So not really <code>AJAX</code> as we typically think of it.  The second thing that happens is the <code>src</code> attribute of the modified image on the page is set to a php script that processes the newly uploaded image and spits out an image, definitely not <code>AJAX</code> as we normally think of it.</p>
<p>That&#8217;s basically it, besides boring implementation details (personally I find implementation details fascinating but this is a blog post not documentation).</p>
]]></content:encoded>
			<wfw:commentRss>http://samauciello.com/image-processing-with-convolution-functions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Contributing to WordPress</title>
		<link>http://samauciello.com/contributing-to-wordpress/</link>
		<comments>http://samauciello.com/contributing-to-wordpress/#comments</comments>
		<pubDate>Thu, 03 Nov 2011 14:47:07 +0000</pubDate>
		<dc:creator>Sam Auciello</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://samauciello.com/?p=207</guid>
		<description><![CDATA[I&#8217;ve been making some contributions to WordPress.org for my Open Source Software course. I&#8217;ve been helping out with the upcoming release of version 3.3 scheduled for the end of November. I&#8217;ll use this post to talk about some of the &#8230; <a href="http://samauciello.com/contributing-to-wordpress/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been making some contributions to WordPress.org for my Open Source Software course. I&#8217;ve been helping out with the upcoming release of version 3.3 <a href="http://wpdevel.wordpress.com/version-3-3-project-schedule/">scheduled</a> for the end of November.  I&#8217;ll use this post to talk about some of the tickets I&#8217;ve been working on.<span id="more-207"></span></p>
<h2>Press This and Images</h2>
<p>WordPress has a feature called &#8220;Press This&#8221;, which allows bloggers to easily share content that they might find while browsing the web.  Using the &#8220;Press This&#8221; <a href="http://en.wikipedia.org/wiki/Bookmarklet">bookmarklet</a> pops up a new window which allows the user to post new content including anything highlighted on the page you were on.  One nice feature is that when you click the add images button from this new post interface, it loads all of the images from the page you were on and gives you the option of inserting them into your post.</p>
<p>There was a bug created however by some unrelated change leading up to the 3.3 release.  You see when you select an image from the page to insert into your post, you are prompted to add a description and then click the &#8220;insert photo&#8221; button to insert it.  This button uses the JQuery to determine the url and description of the image to insert with something like:</p>

<div class="wp_codebox"><table><tr id="p20727"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p207code27"><pre class="javascript" style="font-family:monospace;">url <span style="color: #339933;">=</span> JQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#this_photo'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
desc <span style="color: #339933;">=</span> JQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#this_photo_description'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>The problem was that another change had created two unrelated DOM objects with the ids <code>this_photo</code> and <code>this_photo_description</code>.  Consequently the JQuery, assuming that ids are unique <span class="pren">(as they should be)</span> grabbed the wrong DOM objects, found no values and then promptly failed.  To fix this I found the id of the parent div to the two DOM objects I wanted and replaced the code with something like this:</p>

<div class="wp_codebox"><table><tr id="p20728"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p207code28"><pre class="javascript" style="font-family:monospace;">url <span style="color: #339933;">=</span> JQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#parent_div #this_photo'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
desc <span style="color: #339933;">=</span> JQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#parent_div #this_photo_description'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>This is probably not ideal but since I wasn&#8217;t sure where else these objects might be referenced by JavaScript and I didn&#8217;t want to create more bugs that might not be caught this close to a release I didn&#8217;t want to mess with changing the ids themselves.</p>
]]></content:encoded>
			<wfw:commentRss>http://samauciello.com/contributing-to-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>More adversarial search, Tic-Tac-Toe and Othello</title>
		<link>http://samauciello.com/more-adversarial-search-tic-tac-toe-and-othello/</link>
		<comments>http://samauciello.com/more-adversarial-search-tic-tac-toe-and-othello/#comments</comments>
		<pubDate>Tue, 25 Oct 2011 21:46:45 +0000</pubDate>
		<dc:creator>Sam Auciello</dc:creator>
				<category><![CDATA[Algorithms]]></category>
		<category><![CDATA[Lisp]]></category>

		<guid isPermaLink="false">http://samauciello.com/?p=174</guid>
		<description><![CDATA[For my midterm project in the Artificial Intelligence course I applied the adversarial search program in Lisp that I started here to Tic-Tac-Toe and Othello. Dynamic Functions The API system I had set up involved using functions to represent moves &#8230; <a href="http://samauciello.com/more-adversarial-search-tic-tac-toe-and-othello/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>For my midterm project in the Artificial Intelligence course I applied the adversarial search program in Lisp that I started <a href="http://samauciello.com/alpha-beta-min-max-search/">here</a> to <a href="http://en.wikipedia.org/wiki/Tic-tac-toe">Tic-Tac-Toe</a> and <a href="http://en.wikipedia.org/wiki/Othello_%28game%29">Othello</a>.<span id="more-174"></span></p>
<h3>Dynamic Functions</h3>
<p>The API system I had set up involved using functions to represent moves and both of these games have more possible moves than it would be sensible to define individually. Fortunately Lisp is great at generating code dynamically. It took a while to find the right syntax for this and what the method I eventually used was the back-tick quoting mechanism that <a href="http://www.marlboro.edu/academics/faculty/mahoney_jim/">Jim Mahoney</a> pointed me to. The following code generates the possible moves for my Tic-Tac-Toe program:</p>

<div class="wp_codebox"><table><tr id="p17437"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code" id="p174code37"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">setf</span> all-moves
      '<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>top-left <span style="color: #66cc66;">.</span> <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span>top-center <span style="color: #66cc66;">.</span> <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span>top-right <span style="color: #66cc66;">.</span> <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span>middle-left <span style="color: #66cc66;">.</span> <span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span>center <span style="color: #66cc66;">.</span> <span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span>middle-right <span style="color: #66cc66;">.</span> <span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span>bottom-left <span style="color: #66cc66;">.</span> <span style="color: #cc66cc;">6</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span>bottom-center <span style="color: #66cc66;">.</span> <span style="color: #cc66cc;">7</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span>bottom-right <span style="color: #66cc66;">.</span> <span style="color: #cc66cc;">8</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">dolist</span> <span style="color: #66cc66;">&#40;</span>move all-moves<span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">let</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">name</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">car</span> move<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span>num <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">cdr</span> move<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">eval</span> `<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">defun</span> <span style="color: #66cc66;">,</span><span style="color: #b1b100;">name</span> <span style="color: #66cc66;">&#40;</span>state<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span>mark-square <span style="color: #66cc66;">,</span>num state<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></td></tr></table></div>

<p>The backtick <code>`</code> notation here lets me quote the list and still add in evaluated pieces later with <code>,</code> so that I can construct the <code>defun</code> statement as I want it before evaluating the whole thing with <code>eval</code>.</p>
<h3>Side effects and Pointers</h3>
<p>Another issue I found was that while the adversarial search worked fine for my <a href="http://samauciello.com/alpha-beta-min-max-search/">stone game</a>. I had made a fundamental assumption. A given game state for the stone game is represented by and integer and as such making a function that returns a modified copy of the game state without affecting the original <span class="pren">(something I do a lot)</span> is simple and requires no thought. Unfortunately this is not the case with more complicated data structures like lists.</p>
<p>For both tic-tac-toe and othello, my games states were represented by lists and as such I needed to use <code>copy-list</code>. My tic-tac-toe games states are encoded as a list of length 10 with the first element being the current player <span class="pren">(X or O)</span> followed by the contents of each square in left to right top to bottom order. So for example the start state is:</p>

<div class="wp_codebox"><table><tr id="p17438"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p174code38"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>X <span style="color: #b1b100;">NIL</span> <span style="color: #b1b100;">NIL</span> <span style="color: #b1b100;">NIL</span> <span style="color: #b1b100;">NIL</span> <span style="color: #b1b100;">NIL</span> <span style="color: #b1b100;">NIL</span> <span style="color: #b1b100;">NIL</span> <span style="color: #b1b100;">NIL</span> <span style="color: #b1b100;">NIL</span><span style="color: #66cc66;">&#41;</span></pre></td></tr></table></div>

<p>and if <code>X</code> goes in the center the state would become</p>

<div class="wp_codebox"><table><tr id="p17439"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p174code39"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>X <span style="color: #b1b100;">NIL</span> <span style="color: #b1b100;">NIL</span> <span style="color: #b1b100;">NIL</span> <span style="color: #b1b100;">NIL</span> X <span style="color: #b1b100;">NIL</span> <span style="color: #b1b100;">NIL</span> <span style="color: #b1b100;">NIL</span> <span style="color: #b1b100;">NIL</span><span style="color: #66cc66;">&#41;</span></pre></td></tr></table></div>

<p>A naive version of my <code>mark-square</code> function referenced in the above code might look like this:</p>

<div class="wp_codebox"><table><tr id="p17440"><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code" id="p174code40"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">defun</span> mark-square <span style="color: #66cc66;">&#40;</span>square state<span style="color: #66cc66;">&#41;</span>
  <span style="color: #ff0000;">&quot;Mark the designated square with the symbol of the current player's turn and toggle the turn&quot;</span>
  <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">let</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>player <span style="color: #66cc66;">&#40;</span>first state<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span>board <span style="color: #66cc66;">&#40;</span>rest state<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">setf</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">nth</span> square board<span style="color: #66cc66;">&#41;</span> player<span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">cons</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">eq</span> 'x player<span style="color: #66cc66;">&#41;</span> 'y 'x<span style="color: #66cc66;">&#41;</span>
          board<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></td></tr></table></div>

<p>The problem with this is that <code>(rest state)</code> doesn&#8217;t return a copy of the <code>state</code> list starting with the second element, but rather it returns a pointer to the second cons cell in the <code>state</code> list. This means that we are dealing with same data in memory that was passed in and when we call <code>setf</code>, we modify the original <code>state</code>. More concretely if we try:</p>

<div class="wp_codebox"><table><tr id="p17441"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p174code41"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">setf</span> state '<span style="color: #66cc66;">&#40;</span>x <span style="color: #b1b100;">nil</span> <span style="color: #b1b100;">nil</span> <span style="color: #b1b100;">nil</span>
                <span style="color: #b1b100;">nil</span> <span style="color: #b1b100;">nil</span> <span style="color: #b1b100;">nil</span>
                <span style="color: #b1b100;">nil</span> <span style="color: #b1b100;">nil</span> <span style="color: #b1b100;">nil</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">setf</span> new-state <span style="color: #66cc66;">&#40;</span>mark-square <span style="color: #cc66cc;">4</span> state<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>format t <span style="color: #ff0000;">&quot;old state: ~a~%&quot;</span> state<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>format t <span style="color: #ff0000;">&quot;new state: ~a~%&quot;</span> new-state<span style="color: #66cc66;">&#41;</span></pre></td></tr></table></div>

<p>we will get:</p>

<div class="wp_codebox"><table><tr id="p17442"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p174code42"><pre class="lisp" style="font-family:monospace;">old state<span style="color: #66cc66;">:</span> <span style="color: #66cc66;">&#40;</span>X <span style="color: #b1b100;">NIL</span> <span style="color: #b1b100;">NIL</span> <span style="color: #b1b100;">NIL</span> <span style="color: #b1b100;">NIL</span> X <span style="color: #b1b100;">NIL</span> <span style="color: #b1b100;">NIL</span> <span style="color: #b1b100;">NIL</span> <span style="color: #b1b100;">NIL</span><span style="color: #66cc66;">&#41;</span>
new state<span style="color: #66cc66;">:</span> <span style="color: #66cc66;">&#40;</span>O <span style="color: #b1b100;">NIL</span> <span style="color: #b1b100;">NIL</span> <span style="color: #b1b100;">NIL</span> <span style="color: #b1b100;">NIL</span> X <span style="color: #b1b100;">NIL</span> <span style="color: #b1b100;">NIL</span> <span style="color: #b1b100;">NIL</span> <span style="color: #b1b100;">NIL</span><span style="color: #66cc66;">&#41;</span></pre></td></tr></table></div>

<p>This is what is known as a side-effect, a function that does something other than just return a value. It is a result of our using Common Lisp which is not a purely functional language. In a purely functional language this would not be possible. The fixed version of my <code>mark-square</code> function is:</p>

<div class="wp_codebox"><table><tr id="p17443"><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code" id="p174code43"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">defun</span> mark-square <span style="color: #66cc66;">&#40;</span>square state<span style="color: #66cc66;">&#41;</span>
  <span style="color: #ff0000;">&quot;Mark the designated square with the symbol of the current player's turn and toggle the turn&quot;</span>
  <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">let</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>player <span style="color: #66cc66;">&#40;</span>first <span style="color: #66cc66;">&#40;</span>copy-<span style="color: #b1b100;">list</span> state<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span>board <span style="color: #66cc66;">&#40;</span>rest <span style="color: #66cc66;">&#40;</span>copy-<span style="color: #b1b100;">list</span> state<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">setf</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">nth</span> square board<span style="color: #66cc66;">&#41;</span> player<span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">cons</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">eq</span> 'x player<span style="color: #66cc66;">&#41;</span> 'y 'x<span style="color: #66cc66;">&#41;</span>
          board<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></td></tr></table></div>

<p>The <code>copy-list</code> function creates new cons cells so the changes affect a new copy of the list.</p>
<h3>My Code</h3>
<p>I&#8217;m really happy with my code right now for this. You can download a copy of it by clicking <a href="/wp-content/files/adversarial.zip">here</a>.</p>
<p>You can run it at the command line with:</p>

<div class="wp_codebox"><table><tr id="p17444"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
</pre></td><td class="code" id="p174code44"><pre class="lisp" style="font-family:monospace;">$ cd /path/to/downloaded/directory
&nbsp;
$ clisp
<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&amp;</span>gt<span style="color: #808080; font-style: italic;">; (load &quot;tic-tac-toe.lisp&quot;)</span>
T
<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&amp;</span>gt<span style="color: #808080; font-style: italic;">; (play-game tic-tac-toe 10 'computer 'sam) ; the 10 here is maximum depth for adversarial search</span>
It is X's turn
 -----
&nbsp;
 -----
computer<span style="color: #66cc66;">:</span> <span style="color: #555;">BOTTOM-RIGHT</span>
&nbsp;
SAM's turn
It is Y's turn
 -----
&nbsp;
     X
 -----
&nbsp;
choose a move from
<span style="color: #66cc66;">&#40;</span>TOP-RIGHT BOTTOM-LEFT TOP-RIGHT TOP-LEFT CENTER MIDDLE-LEFT BOTTOM-CENTER
 MIDDLE-RIGHT TOP-CENTER<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">:</span> <span style="color: #555;">top-left</span>
It is X's turn
 -----
 Y    
&nbsp;
     X
 -----
computer<span style="color: #66cc66;">:</span> <span style="color: #555;">TOP-RIGHT</span>
&nbsp;
SAM's turn
It is Y's turn
 -----
 Y   X
&nbsp;
     X
 -----
&nbsp;
choose a move from <span style="color: #66cc66;">&#40;</span>BOTTOM-LEFT CENTER MIDDLE-LEFT BOTTOM-CENTER MIDDLE-RIGHT TOP-CENTER<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">:</span> <span style="color: #555;">middle-right</span>
It is X's turn
 -----
 Y   X
     Y
     X
 -----
computer<span style="color: #66cc66;">:</span> <span style="color: #555;">BOTTOM-LEFT</span>
&nbsp;
SAM's turn
It is Y's turn
 -----
 Y   X
     Y
 X   X
 -----
&nbsp;
choose a move from <span style="color: #66cc66;">&#40;</span>CENTER MIDDLE-LEFT BOTTOM-CENTER TOP-CENTER<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">:</span> <span style="color: #555;">center</span>
It is X's turn
 -----
 Y   X
   Y Y
 X   X
 -----
computer<span style="color: #66cc66;">:</span> <span style="color: #555;">BOTTOM-CENTER</span>
It is Y's turn
 -----
 Y   X
   Y Y
 X X X
 -----
COMPUTER wins
<span style="color: #b1b100;">NIL</span>
<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&amp;</span>gt<span style="color: #808080; font-style: italic;">; ^D</span>
&nbsp;
$ clisp
<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&amp;</span>gt<span style="color: #808080; font-style: italic;">; (load &quot;othello&quot;)</span>
T
<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&amp;</span>gt<span style="color: #808080; font-style: italic;">; (play-game othello 5 'computer 'sam) ; the 5 here is maximum depth for adversarial search</span>
&nbsp;
SAM's turn
It is BLACK's turn
 ---------------
&nbsp;
       W B
       B W      
&nbsp;
 ---------------
&nbsp;
choose a move from <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">3</span>-<span style="color: #cc66cc;">4</span> <span style="color: #cc66cc;">4</span>-<span style="color: #cc66cc;">3</span> <span style="color: #cc66cc;">5</span>-<span style="color: #cc66cc;">6</span> <span style="color: #cc66cc;">6</span>-<span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">:</span> <span style="color: #cc66cc;">3</span>-<span style="color: #cc66cc;">4</span>
It is WHITE's turn
 ---------------
&nbsp;
       B
       B B
       B W      
&nbsp;
 ---------------
computer<span style="color: #66cc66;">:</span> <span style="color: #cc66cc;">3</span>-<span style="color: #cc66cc;">3</span>
&nbsp;
SAM's turn
It is BLACK's turn
 ---------------
&nbsp;
     W B
       W B
       B W      
&nbsp;
 ---------------
&nbsp;
choose a move from <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">3</span>-<span style="color: #cc66cc;">2</span> <span style="color: #cc66cc;">4</span>-<span style="color: #cc66cc;">3</span> <span style="color: #cc66cc;">5</span>-<span style="color: #cc66cc;">6</span> <span style="color: #cc66cc;">6</span>-<span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">:</span> <span style="color: #cc66cc;">5</span>-<span style="color: #cc66cc;">6</span>
It is WHITE's turn
 ---------------
&nbsp;
     W B
       W B
       B B B    
&nbsp;
 ---------------
computer<span style="color: #66cc66;">:</span> <span style="color: #cc66cc;">3</span>-<span style="color: #cc66cc;">5</span>
&nbsp;
SAM's turn
It is BLACK's turn
 ---------------
&nbsp;
     W W W
       W B
       B B B    
&nbsp;
 ---------------
&nbsp;
choose a move from <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2</span>-<span style="color: #cc66cc;">2</span> <span style="color: #cc66cc;">2</span>-<span style="color: #cc66cc;">3</span> <span style="color: #cc66cc;">2</span>-<span style="color: #cc66cc;">4</span> <span style="color: #cc66cc;">2</span>-<span style="color: #cc66cc;">5</span> <span style="color: #cc66cc;">4</span>-<span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">:</span>
&nbsp;
<span style="color: #555;">etc</span><span style="color: #66cc66;">..</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://samauciello.com/more-adversarial-search-tic-tac-toe-and-othello/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hard boiled eggs and the magic of shell scripts</title>
		<link>http://samauciello.com/hard-boiled-eggs-and-the-magic-of-shell-scripts/</link>
		<comments>http://samauciello.com/hard-boiled-eggs-and-the-magic-of-shell-scripts/#comments</comments>
		<pubDate>Mon, 24 Oct 2011 21:36:40 +0000</pubDate>
		<dc:creator>Sam Auciello</dc:creator>
				<category><![CDATA[Shell Scripts]]></category>

		<guid isPermaLink="false">http://samauciello.com/?p=169</guid>
		<description><![CDATA[The fridge in the Science building at Marlboro College occasionally contains hard boiled eggs which can be obtained for 50¢ a piece. I say &#8220;occasionally&#8221; but sadly it would be more accurate to say &#8220;when Allison remembers to bring them&#8221;. &#8230; <a href="http://samauciello.com/hard-boiled-eggs-and-the-magic-of-shell-scripts/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The fridge in the Science building at Marlboro College occasionally contains hard boiled eggs which can be obtained for 50¢ a piece.  I say &#8220;occasionally&#8221; but sadly it would be more accurate to say &#8220;when Allison remembers to bring them&#8221;.  It occurred to me one day as I emailed her to remind her that I was doing something rather inefficient.  I remembered that I now live in a dorm with a nice kitchen.  I could purchase my own eggs for about $2 a dozen <span class="pren">(a 66% savings)</span> and boil them myself.  I finally got to town to buy eggs and today I have boiled a dozen eggs.  Just as the water was about to boil I realized I did not have an egg timer, so I made one.<span id="more-169"></span></p>
<p>There is of course nothing terribly exciting or new about the sleep command but the ability to quickly solve a practical problem with simple tools is always gratifying.  My egg timer is the following simple text file with executable bit set:</p>

<div class="wp_codebox"><table><tr id="p16946"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p169code46"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #000000;">600</span>;
osascript <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'beep 3'</span>
osascript <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'tell app &quot;System Events&quot; to display dialog &quot;Eggs Done!&quot;'</span></pre></td></tr></table></div>

<p>Yay eggs!</p>
]]></content:encoded>
			<wfw:commentRss>http://samauciello.com/hard-boiled-eggs-and-the-magic-of-shell-scripts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Alias fun and key bindings in zsh</title>
		<link>http://samauciello.com/alias-fun-and-key-bindings-in-zsh/</link>
		<comments>http://samauciello.com/alias-fun-and-key-bindings-in-zsh/#comments</comments>
		<pubDate>Sun, 09 Oct 2011 19:10:10 +0000</pubDate>
		<dc:creator>Sam Auciello</dc:creator>
				<category><![CDATA[Shell Scripts]]></category>
		<category><![CDATA[ZSH]]></category>

		<guid isPermaLink="false">http://samauciello.com/?p=150</guid>
		<description><![CDATA[I use my terminal for everything. I use a program called Visor that keeps me a keystroke away from my terminal at all times. It is for this reason that I spend a considerable portion of my time customizing my &#8230; <a href="http://samauciello.com/alias-fun-and-key-bindings-in-zsh/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I use my terminal for everything.  I use a program called <a href="http://visor.binaryage.com/">Visor</a> that keeps me a keystroke away from my terminal at all times.  It is for this reason that I spend a considerable portion of my time customizing my shell.  I use <code>zsh</code> because it has some great features like considerably more helpful and customizable tab completion, and my personal favorite <code>autocd</code>.<span id="more-150"></span>  All you have to do is add the following to your <code>~/.zshrc</code> file:</p>

<div class="wp_codebox"><table><tr id="p15053"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p150code53"><pre class="bash" style="font-family:monospace;">setopt autocd</pre></td></tr></table></div>

<p>And suddenly instead of:</p>

<div class="wp_codebox"><table><tr id="p15054"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p150code54"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">cd</span> some-directory<span style="color: #000000; font-weight: bold;">/</span>some-subdirectory</pre></td></tr></table></div>

<p>you can just use:</p>

<div class="wp_codebox"><table><tr id="p15055"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p150code55"><pre class="bash" style="font-family:monospace;">$ some-directory<span style="color: #000000; font-weight: bold;">/</span>some-subdirectory</pre></td></tr></table></div>

<p>and <code>zsh</code> will notice that it&#8217;s a directory and do the only sensible thing: go to it.</p>
<p>I also have a sizable number of time saving aliases:</p>

<div class="wp_codebox"><table><tr id="p15056"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p150code56"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">l</span>=<span style="color: #ff0000;">&quot;ls -lahG&quot;</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">mkd</span>=<span style="color: #ff0000;">&quot;mkdir -pv&quot;</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">dir</span>=<span style="color: #ff0000;">&quot;open ./&quot;</span></pre></td></tr></table></div>

<p><code>ls -lahG</code> is nice because it gives me so much information.  The <code>-l</code> flag formats the output into a vertical list that tells me more about each file.  The <code>-a</code> includes hidden files and directories that start with <code>.</code> like <code>.zshrc</code>.  The <code>-h</code> flag displays file sizes in a more readable format so if a file is 2262261 bytes long it will say <code>2.2M</code> instead of <code>2262261</code>.  The <code>-G</code> flag colors my files using a custom colorings scheme that I define in my <code>.zshenv</code> file.</p>
<p><code>mkdir -pv</code> is pretty straight forward.  The <code>-p</code> flag allows me to create nested directories with a single command so that if <code>~/foo</code> doesn&#8217;t exist then <code>mkd ~/foo/bar</code> will create both the foo and bar directories with one inside the other.  The <code>-v</code> just generates verbose output.</p>
<p><code>open ./</code> is a nifty Mac OS only command.  On a mac the open command will do the same thing as double clicking the file in the Finder.  It&#8217;s a handy link between my terminal and the rest of my mac.  In this case I can use it to quickly switch to the mac GUI interface for this directory if I need to for some reason.</p>
<p>I also have a number of alias that are simply shorter names for commands that I use all the time:</p>

<div class="wp_codebox"><table><tr id="p15057"><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code" id="p150code57"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">m</span>=<span style="color: #ff0000;">&quot;less&quot;</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">e</span>=<span style="color: #ff0000;">&quot;edit&quot;</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">t</span>=<span style="color: #ff0000;">&quot;touch&quot;</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">sq</span>=<span style="color: #ff0000;">&quot;sqlite3&quot;</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">o</span>=<span style="color: #ff0000;">&quot;open&quot;</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">ql</span>=<span style="color: #ff0000;">&quot;qlmanage -p&quot;</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">c</span>=<span style="color: #ff0000;">&quot;echo -n <span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #000099; font-weight: bold;">\&quot;</span> &gt;&quot;</span></pre></td></tr></table></div>

<p><code>edit</code> is a python script I made that determines my default text editor from a configuration file and then opens the file in that editor.  <code>qlmanage</code> is a mac specific program that does the same thing as pressing space-bar while highlighting a file in the Finder.</p>
<h3>Backspace vs. Delete</h3>
<p>Recently I had a problem with using <code>zsh</code> on certain ssh servers where my <code>delete</code> key <span class="pren">(the mac equivalent of windows&#8217; backspace)</span> was being mapped to the windows <code>del</code>.  That is to say it was deleting the next character instead of the previous.  I finally found <a href="http://macfreek.nl/mindmaster/Backspace_and_Delete_key_reversed">this wiki page</a> that explained the problem and how to fix it.  All I had to do was add the following to my <code>.zshrc</code> file:</p>

<div class="wp_codebox"><table><tr id="p15058"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p150code58"><pre class="bash" style="font-family:monospace;">bindkey <span style="color: #ff0000;">&quot;^?&quot;</span> backward-delete-char
bindkey <span style="color: #ff0000;">&quot;^[[3~&quot;</span> delete-char</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://samauciello.com/alias-fun-and-key-bindings-in-zsh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

