<?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>waves in the aether</title>
	<atom:link href="http://blogs.openaether.org/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://blogs.openaether.org</link>
	<description></description>
	<lastBuildDate>Sat, 23 Feb 2013 19:25:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Fun with org mode and ssh</title>
		<link>http://blogs.openaether.org/?p=257</link>
		<comments>http://blogs.openaether.org/?p=257#comments</comments>
		<pubDate>Sat, 23 Feb 2013 05:00:00 +0000</pubDate>
		<dc:creator>Justin Kirby</dc:creator>
				<category><![CDATA[emacs]]></category>

		<guid isPermaLink="false">http://blogs.openaether.org/?p=257</guid>
		<description><![CDATA[Quick org mode hack]]></description>
			<content:encoded><![CDATA[<div id="outline-container-1" class="outline-2">
<h2 id="sec-1">Problem</h2>
<div class="outline-text-2" id="text-1">
<p>   There are a lot of machines that I have ssh acces to; virtual   machines (both in vmware and virtualbox), linodes (personal, work,   projects), production systems, etc..  All told there are probably   over 200 systems out there which I will need to ssh into at some   point in the future. Sometimes I go years without logging in. </p>
<p>   Some of these systems have domain names, but most are just random   IPs over some vpn.  I can never remember how to get in and have to   spend time figuring out what box it is that I need to access </p>
</p></div>
</p></div>
<div id="outline-container-2" class="outline-2">
<h2 id="sec-2">Failed Solutions</h2>
<div class="outline-text-2" id="text-2">    </div>
<div id="outline-container-2-1" class="outline-3">
<h3 id="sec-2-1">~/.ssh/config</h3>
<div class="outline-text-3" id="text-2-1">
<p>  Of course I have ssh keys setup and I use different key pairs for   different roles and uses. This has created a rather complex   ~/.ssh/config. </p>
<p>   I have tried to keep a list of systems in the config with an alias: </p>
<pre class="example">Host abc123
HostName 127.0.0.1
Port 1234
User username
</pre>
<p>   Substitute sane values and about 200 of these and you rapidly   create a large unmanageable mess. </p>
</p></div>
</p></div>
<div id="outline-container-2-2" class="outline-3">
<h3 id="sec-2-2">/etc/hosts</h3>
<div class="outline-text-3" id="text-2-2">
<p>   Try to manage a large /etc/hosts file and you see first hand why dns   was invented. </p>
<p>   I even tried using scripts to pull information from puppet sources,   linode api&#8217;s and even systems posting back on my public IP. </p>
<p>   Obviously it became a mess </p>
</p></div>
</p></div>
</p></div>
<div id="outline-container-3" class="outline-2">
<h2 id="sec-3">emacs to the rescue.</h2>
<div class="outline-text-2" id="text-3">
<p>   One day after being particularly frustrated when I couldn&#8217;t get into   a box, I was adding yet another entry to ~/.ssh/config only to   realize it was in there twice already, I decided to turn this   problem into a nail so I could use my universal hammer, emacs. </p>
<pre class="src src-elisp">(<span style="color: #b5bd68;">defun</span> <span style="color: #81a2be;">jgk/xterm-ssh</span> (host)
  <span style="color: #b294bb;">"Spawn a xterm with a ssh to the host"</span>
  (start-process-shell-command <span style="color: #8abeb7;">"*org-xterm-ssh*"</span> <span style="color: #8abeb7;">"ssh-xterm"</span> <span style="color: #8abeb7;">"xterm"</span> <span style="color: #8abeb7;">"-e"</span>
                               (concat <span style="color: #8abeb7;">"'ssh -AY "</span>  host <span style="color: #8abeb7;">"'"</span>)))
</pre>
<p>   I now have an org file for each project I work on and can create   links that will let me ssh into a system with a &#8216;click&#8217; </p>
<pre class="example">[[elisp:(jgk/xterm-ssh "username@192.168.15.218")][Magical Mystery Machine]]
</pre>
<p>   Since it is in org mode I can now categorize and tag these links. I   can take notes and use tramp to open directories. </p>
<p>   I am slowly adding systems in as I need them. I have found the   ability to keep notes and a basic log of what and why I was there to   be invaluable. </p>
<p>   If you need to access a lot of random systems you should try this,   it has made my life sane </p>
</div></div>
]]></content:encoded>
			<wfw:commentRss>http://blogs.openaether.org/?feed=rss2&#038;p=257</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Usability and Programming</title>
		<link>http://blogs.openaether.org/?p=255</link>
		<comments>http://blogs.openaether.org/?p=255#comments</comments>
		<pubDate>Sun, 04 Dec 2011 04:48:00 +0000</pubDate>
		<dc:creator>Justin Kirby</dc:creator>
				<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://blogs.openaether.org/?p=255</guid>
		<description><![CDATA[The Problem The holidays are coming and my wonderful wife, Adrienne, has started thinking about gifts for the family. One of the problems we have is that our entire life is digital, but it is not a promiscuous one. No facebook, flickr, twitter or any of the other numerous places on the net that give [...]]]></description>
			<content:encoded><![CDATA[<div id="outline-container-1" class="outline-2">
<h2 id="sec-1">The Problem</h2>
<div class="outline-text-2" id="text-1">
<p>  The holidays are coming and my wonderful wife, <a href="http://adriennekirby.com">Adrienne</a>, has started   thinking about gifts for the family. One of the problems we have is   that our entire life is digital, but it is not a promiscuous one. No   facebook, flickr, twitter or any of the other numerous places on the   net that give you a bit of convenience in return for turning you   into a product. We are digital homebodies. </p>
<p>   One of the inconvenient consequences of being a digital homebody is   that grandparents do not have access to photos of their grand   children. None of those services would allow us to share videos and   photos with the analog generation either. So Adrienne decided to   start creating a photobook on <a href="http://lulu.com">lulu</a>. </p>
<p>   She spent some time culling our giant photo library down to only   about 80 images then tried to upload them to lulu. Only 40 of them   made it. </p>
<p>   Many years ago when I was a poor student wandering the country I was   crashing at a friends house. She was trying to change a light bulb,   with her room mate, in a chandelier (technically an electrolier)   that was not built to have its light bulbs changed. Ladders, chairs,   tables, screwdrivers, hammers and loud swearing were all part of   this elaborate process. I was leaning against a wall watching with   great amusement as this scene unfolded before me. Being   simultaneously relieved and embarrassed at my lack of participation,   I was befuddled when my friend thanked me for not   interfering. Indicating that was an unusual but welcome trait. </p>
<p>   The extreme juxtaposition between her perception of the situation   and mine made that stay with me. Not only because it has often been   my job to interfere when people are having problems, but because   like so many geeks it is in my nature to solve problems wherever   they occur. </p>
</p></div>
</p></div>
<div id="outline-container-2" class="outline-2">
<h2 id="sec-2">Discovery</h2>
<div class="outline-text-2" id="text-2">
<p>   Combine the accidental lesson learned so many years ago with the   inherently tense situation caused when trying to help a frustrated   person you can perhaps understand the trepidation I felt when I   offered assistance to my wife. </p>
<p>   Lulu&#8217;s book creation software is a giant flash monstrosity. As such   it does not perform well on under powered &#8216;eco&#8217; laptops. Another   side effect is that all UI widgets must be non-native and enter into   the <a href="http://en.wikipedia.org/wiki/Uncanny_valley">uncanny valley</a>. This combination makes all flash apps cumbersome   at best and unusable at worst, lulu is no exception. </p>
<p>   After trying to upload the images a couple times, which created   duplicates of the same 40 I wondered if the images were   corrupt. Investigation demonstrated that numerous image viewer apps   could load them just fine without issue. Trying another book   service, <a href="http://blurb.com">blurb</a>, had the same problem, the same images did not get   uploaded. What the hell was going on? </p>
<p>   I can&#8217;t remember the exact moment I saw this, the file dialog box   had &#8216;*.jpg, *.jpeg, *.png&#8217; as a file filter. Inspecting the files we   were trying to upload I noticed the following extensions, &#8216;*.jpg&#8217;,   &#8216;*.JPG&#8217;. Spot the problem? </p>
<p>   No? </p>
<p>   It took me a while. Longer than I care to admit. </p>
<p>   The filesystem on my wife&#8217;s laptop is case sensitive. Unlike FAT32   where jpg is the same as JPG, jPg, Jpg, etc.  jpg is NOT the same as   JPG. In fact they are fundamentally different extensions. </p>
<p>   With numerous cell phones and digital cameras all creating various   file naming conventions one of them creates JPG instead of jpg. I   have yet to track down the culprit. </p>
</p></div>
</p></div>
<div id="outline-container-3" class="outline-2">
<h2 id="sec-3">Solution</h2>
<div class="outline-text-2" id="text-3">
<p>   Now that I have found the reason why half the images were not   uploading. How to solve this? I couldn&#8217;t imagine going through 40+   files and renaming them individually. Being a professional geek I   pulled out my trusty bash shell. </p>
<p>   Being the good geek I write my bash one liners incrementally, so the   first attempt is a simple loop: </p>
<pre class="src src-sh"><span style="font-weight: bold;">for</span> f<span style="font-weight: bold;"> in</span> <span style="color: #cdcd00;">`find -name '*.JPG'`</span>; <span style="font-weight: bold;">do </span><span style="color: #729fcf;">echo</span> $<span style="color: #ef2929;">f</span>; <span style="font-weight: bold;">done</span>
</pre>
<p>   As any seasoned bash scripter can tell, there is only one thing that   could have made this approach untenable, spaces. Yes, spaces. For   time immemorial I and every person who has ever written a shell   script has despised spaces in file names. There are ways to deal   with this, but it was approaching 11pm, I was tired and I just   wanted to get this done. </p>
<p>   For the past couple of weeks I had been steeped neck deep in   erlang. While erlang is probably the last language one should think   of when trying to solve this problem, I couldn&#8217;t help it. In less   than a minute I whipped up the following: </p>
<pre class="src src-erlang">#!/usr/bin/env escript
%%<span style="font-style: italic;">! -noshell -noinput
</span><span style="color: #edd400; font-weight: bold;">main</span>(<span style="color: #ef2929;">_</span>) -&gt;
    <span style="font-weight: bold;">filelib</span>:<span style="font-weight: bold;">fold_files</span>(<span style="color: #ad7fa8;">"."</span>,<span style="color: #ad7fa8;">".*\.JPG$"</span>, false,
                       <span style="font-weight: bold;">fun</span>(<span style="color: #ef2929;">F</span>,<span style="color: #ef2929;">A</span>) -&gt;
                               <span style="color: #ef2929;">Base</span> = <span style="font-weight: bold;">filename</span>:<span style="font-weight: bold;">basename</span>(<span style="color: #ef2929;">F</span>),
                               <span style="color: #ef2929;">Ext</span> = <span style="font-weight: bold;">filename</span>:<span style="font-weight: bold;">extension</span>(<span style="color: #ef2929;">F</span>),
                               <span style="font-weight: bold;">file</span>:<span style="font-weight: bold;">rename</span>(<span style="color: #ef2929;">F</span>,<span style="color: #ef2929;">Base</span>++<span style="color: #ef2929;">Ext</span>)
                                   <span style="font-weight: bold;">end</span>,[]).
</pre>
<p>   This worked! </p>
<p>   It does have one minor bug that did not affect the desired outcome,   e.g. changing extension from JPG to jpg. I will leave this as an   exercise for the reader to find the bug. </p>
</p></div>
</p></div>
<div id="outline-container-4" class="outline-2">
<h2 id="sec-4">Aftermath</h2>
<div class="outline-text-2" id="text-4">
<p>   When all 80 of the images were finally uploaded to lulu, my wife   asked a very reasonable question: &#8220;And I was suppose to do that   how?&#8221; </p>
<p>   A very reasonable question. </p>
<ul>
<li>you would first have to understand the quirks of whatever file     system you are using. </li>
<li>you would have to notice that the file selection dialog box was     not giving you the &#8216;All Files&#8217; option. </li>
<li>you would then have to be able and/or willing to rename 40 files </li>
</ul>
<p>   I have been lucky enough to spend the last ten years creating and   solving these problems. Since these problems are so prolific there   is a pattern recognition machine in my head that can wade through   the confusing errors and silent failures.
<p>   Software is incomprehensibly complex. No one has figured out how to   manage that complexity yet. There are best practices, tools and   methodologies available to mitigate the failures caused by   software&#8217;s inherent complexity. However, they are all just that, a   mitigation not a solution. </p>
<p>   Given software&#8217;s predilection towards failure and its near ubiquity   in modern life I am left to wonder how non-developers cope. My heart   truly goes out to them. </p>
</div></div>
</p></div>
<p> </body> </html> </p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.openaether.org/?feed=rss2&#038;p=255</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>exprecs, making json usable.</title>
		<link>http://blogs.openaether.org/?p=253</link>
		<comments>http://blogs.openaether.org/?p=253#comments</comments>
		<pubDate>Tue, 08 Nov 2011 14:51:00 +0000</pubDate>
		<dc:creator>Justin Kirby</dc:creator>
				<category><![CDATA[erlang]]></category>

		<guid isPermaLink="false">http://blogs.openaether.org/?p=253</guid>
		<description><![CDATA[Erlang and Syntax Many flames have been ignited over erlang&#8217;s syntax. Erlang as a system is exceptional; easy concurrency, clustering and OTP design principles to name just a few. However, its syntax has a lot to be desired. There are minor annoyances, like the comma (&#8220;,&#8221;), period (&#8220;.&#8221;) and semicolon (&#8220;;&#8221;), which make diffs larger [...]]]></description>
			<content:encoded><![CDATA[<div id="outline-container-1" class="outline-2">
<h2 id="sec-1">Erlang and Syntax</h2>
<div class="outline-text-2" id="text-1">
<p> Many flames have been ignited over erlang&#8217;s syntax. Erlang as a system is exceptional; easy concurrency, clustering and OTP design principles to name just a few. However, its syntax has a lot to be desired. </p>
<p> There are minor annoyances, like the comma (&#8220;,&#8221;), period (&#8220;.&#8221;) and semicolon (&#8220;;&#8221;), which make diffs larger and harder to read than they should be, and cause irritating compile errors after a quick edit. </p>
<p> A simple contrived example: </p>
<pre class="src src-erlang"><span style="color: #edd400; font-weight: bold;">add</span>(<span style="color: #ef2929;">First</span>, <span style="color: #ef2929;">Second</span>) -&gt;
    <span style="color: #ef2929;">Result</span> = <span style="color: #ef2929;">First</span> + <span style="color: #ef2929;">Second</span>.
</pre>
<p> Now if you want to store the result </p>
<pre class="src src-erlang"><span style="color: #edd400; font-weight: bold;">add</span>(<span style="color: #ef2929;">First</span>, <span style="color: #ef2929;">Second</span>) -&gt;
    <span style="color: #ef2929;">Result</span> = <span style="color: #ef2929;">First</span> + <span style="color: #ef2929;">Second</span>,
    <span style="font-weight: bold;">store_and_return</span>(<span style="color: #ef2929;">Result</span>).
</pre>
<p> And now there is a two line diff, instead of one: </p>
<pre class="src src-diff"><span style="background-color: #2e3436;">--- </span><span style="color: #eeeeec; background-color: #2e3436;">add1.erl    2011-09-20 11:19:18.000000000 -0400</span><span style="background-color: #2e3436;">
+++ </span><span style="color: #eeeeec; background-color: #2e3436;">add2.erl    2011-09-20 11:20:34.000000000 -0400</span><span style="background-color: #2e3436;">
</span><span style="font-weight: bold;">@@ -1,2 +1,3 @@</span>
<span style="color: #babdb6;"> add(First,Second) -&gt;
</span><span style="color: #ef2929;">-</span><span style="color: #ef2929;">    Result = First + Second.
</span><span style="color: #73d216;">+</span><span style="color: #73d216;">    Result = First + Second,
</span><span style="color: #73d216;">+</span><span style="color: #73d216;">    store_and_return(Result).
</span></pre>
<p> This is a minor nuisance, but the number of times I have forgotten to change a period to a comma approaches infinity. </p>
</p></div>
<div id="outline-container-1_1" class="outline-3">
<h3 id="sec-1_1">Records</h3>
<div class="outline-text-3" id="text-1_1">
<p> While I lack a rigorous statistical analysis, you would be hard pressed to find an erlang programmer who enjoys records. Records are essentially syntactic sugar on top of tagged tuples. This sugar does not taste good. </p>
<p> Defining records is easy and straight forward: </p>
<pre class="src src-erlang"><span style="color: #7fffd4;">-record</span>(<span style="font-weight: bold;">poetry</span>, {
          style  :: <span style="color: #729fcf;">string</span>(),
          line   :: <span style="color: #729fcf;">string</span>(),
          author :: <span style="color: #729fcf;">string</span>()
          }).
</pre>
<p> However, using them is another story. </p>
<pre class="src src-erlang"><span style="color: #edd400; font-weight: bold;">vogon_example</span>() -&gt;
    #<span style="font-weight: bold;">poetry</span>{style = <span style="color: #ad7fa8;">"vogon"</span>,
            line = <span style="color: #ad7fa8;">"Oh freddled gruntbuggly/thy micturations are to me/As plurdled gabbleblotchits on a lurgid bee."</span>,
            author = <span style="color: #ad7fa8;">"Jeltz"</span>
            }.

<span style="color: #edd400; font-weight: bold;">echo_poem</span>(<span style="color: #ef2929;">Poem</span> = #<span style="font-weight: bold;">poetry</span>{}) -&gt;
    <span style="font-weight: bold;">io</span>:<span style="font-weight: bold;">format</span>(<span style="color: #ad7fa8;">"~s~nby ~s"</span>,[<span style="color: #ef2929;">Poem</span>#<span style="font-weight: bold;">poetry</span>.line,<span style="color: #ef2929;">Poem</span>#<span style="font-weight: bold;">poetry</span>.author]).
</pre>
<p> The need to specify the record type on a variable before using the element accessor can lead to some fairly ugly code </p>
<pre class="src src-erlang"><span style="color: #edd400; font-weight: bold;">contrived</span>(<span style="color: #ef2929;">Collection</span>) -&gt;
    %% <span style="font-style: italic;">in R14 you do not need the parens
</span>    (<span style="color: #ef2929;">Collection</span>#<span style="font-weight: bold;">collection</span>.vogon)#<span style="font-weight: bold;">poetry</span>.author.
</pre>
<p> If the need to specify the record type was removed you could do </p>
<pre class="src src-erlang"><span style="color: #edd400; font-weight: bold;">contrived</span>(<span style="color: #ef2929;">Collection</span>) -&gt;
    <span style="color: #ef2929;">Collection</span>.vogon.author.
</pre>
<p> Which looks much cleaner. However, ugly syntax is a trivial annoyance and is primarily a subjective aesthetic concern. </p>
<p> The need to specify the record type is a more pragmatic problem. Writing generic code that consumes records conforming to a pattern or interface is impossible. </p>
<p> While it is true that erlang:element/2 can be used to access records as tuples, the usability of named fields is lost. If the record definition is changed, your code that uses erlang:element/2 may break in interesting ways. (note: that is not a Good Thing[tm]) </p>
</p></div>
</p></div>
</p></div>
<div id="outline-container-2" class="outline-2">
<h2 id="sec-2">exprecs to the rescue</h2>
<div class="outline-text-2" id="text-2">
<p> I stumbled onto an interesting chunk of code by <a href="http://ulf.wiger.net/weblog/">Ulf Wiger</a> called <a href="http://forum.trapexit.org/viewtopic.php?p=21790">exprecs</a>. Exprecs is a parse transform that allows you to work magic, freeing your code from the constraints of the erlang record while still maintaining the benefits derived from named fields. </p>
<p> At this point it may be beneficial for you to read over the exprecs edoc. To make things simple I have generated the edoc html. <a href="http://blogs.openaether.org/data/exprecs.html ">Go have a quick read</a>, I will wait. </p>
<p> &hellip; </p>
<p> While it doesn&#8217;t remove the need to scatter # all over your code, exprecs does enable the ability to treat records as discoverable and fungible entities. This opens the door to more generic and reusable code. </p>
</p></div>
<div id="outline-container-2_1" class="outline-3">
<h3 id="sec-2_1">The Problem</h3>
<div class="outline-text-3" id="text-2_1">
<p>    I have written a lot of erlang code dealing with json, primarily in    REST interfaces built with <a href="http://webmachine.basho.com/">webmachine</a>. The json validation and    parsing into erlang terms is made extremely easy thanks to    <a href="https://github.com/mochi/MochiWeb">mochijson2</a>. mochijson2 has a lot of benefits: roundtrips are    consistent, json strings are parsed to erlang binaries and a single    line of code is generally all you need. </p>
<p>    However, I do find the resulting erlang terms produced by    mochijson2 to be confusing and difficult to remember. Recursing    down a proplist tree is not my most favorite activity and one can    easily get lost in large data structures. This makes changing the    data structure difficult, error prone and tedious, even with good    unit tests. </p>
<p>    The appropriate representation of large or complex data structures    in erlang is a record. Due to the problems outlined above,    abstracting out the mochijson2 code to create a generic json to    record parser is impossible. </p>
<p>    This means that I found myself writing json to record parsers    frequently. I was violating DRY and becoming more and more    frustrated. </p>
</p></div>
</p></div>
<div id="outline-container-2_2" class="outline-3">
<h3 id="sec-2_2">The Solution</h3>
<div class="outline-text-3" id="text-2_2">
<p>    Thanks to the awesomeness that is exprecs, I was able to write a    module that would take the erlang terms produced by    mochijson2:decode/1 and transform them into a record. The code can    even roundtrip from a record to json. </p>
<p>    I no longer have to write yet another proplist walker in order to    get json into mnesia. I am quite excited about this. </p>
<p>    The json_rec.erl module exports two functions; to_rec/3 and    to_json/2. The following code is example usage to illustrate the    interface: </p>
<pre class="src src-erlang"><span style="color: #edd400; font-weight: bold;">store_vogon_json</span>(<span style="color: #ef2929;">HttpBody</span>) -&gt;
    <span style="color: #ef2929;">Json</span> = <span style="font-weight: bold;">mochijson2</span>:<span style="font-weight: bold;">decode</span>(<span style="color: #ef2929;">HttpBody</span>),
    <span style="color: #ef2929;">Record</span> = <span style="font-weight: bold;">json_rec</span>:<span style="font-weight: bold;">to_rec</span>(<span style="color: #ef2929;">Json</span>, vogon_model, <span style="font-weight: bold;">vogon_model</span>:<span style="font-weight: bold;">new</span>(&lt;&lt;<span style="color: #ad7fa8;">"poetry"</span>&gt;&gt;)),
    <span style="font-weight: bold;">vogon_model</span>:<span style="font-weight: bold;">create</span>(<span style="color: #ef2929;">Record</span>).

<span style="color: #edd400; font-weight: bold;">get_vogon</span>(<span style="color: #ef2929;">Author</span>) -&gt;
    <span style="color: #ef2929;">Record</span> = <span style="font-weight: bold;">vogon_model</span>:<span style="font-weight: bold;">read</span>(<span style="color: #ef2929;">Author</span>),
    <span style="font-weight: bold;">json_rec</span>:<span style="font-weight: bold;">to_json</span>(<span style="color: #ef2929;">Record</span>, vogon_model).
</pre></div>
</p></div>
<div id="outline-container-2_3" class="outline-3">
<h3 id="sec-2_3">exprecs Explained</h3>
<div class="outline-text-3" id="text-2_3">
<p>    In order to give some example usage of exprecs, I am going to provide    lots of contrived examples. If you want a real world use case, see    the code for json_rec. </p>
<p>    We have two modules, poetry.erl and book.erl that each have their    own record defined in poetry.hrl and book.hrl </p>
<pre class="src src-erlang">%% <span style="font-style: italic;">include/poetry.hrl
</span><span style="color: #7fffd4;">-record</span>(<span style="font-weight: bold;">poetry</span>, {
          style      :: <span style="color: #729fcf;">atom</span>(),
          excerpt    :: <span style="color: #729fcf;">string</span>(),
          author     :: <span style="color: #729fcf;">string</span>(),
          available  :: <span style="color: #729fcf;">boolean</span>(),
          count      :: <span style="color: #729fcf;">integer</span>()
         }).

%% <span style="font-style: italic;">include/book.hrl
</span><span style="color: #7fffd4;">-record</span>(<span style="font-weight: bold;">book</span>, {
          style      :: <span style="color: #729fcf;">atom</span>(),
          count      :: <span style="color: #729fcf;">integer</span>(),
          available  :: <span style="color: #729fcf;">boolean</span>(),
          pages      :: <span style="color: #729fcf;">integer</span>(),
          excerpt    :: <span style="color: #729fcf;">string</span>(),
          author     :: <span style="color: #729fcf;">string</span>()
         }).
</pre>
<p>    Now you have a massive inefficient database of 100 book records and    100 poetry records. Someone has just snuck in and stolen your entire    library and you are pedantic enough to want to update this fact. </p>
<p>    Since the two records have an different number of fields and they    are in a different order, using element/2 is not an option. This is    where exprecs comes in. </p>
</p></div>
<div id="outline-container-2_3_1" class="outline-4">
<h4 id="sec-2_3_1">Housekeeping</h4>
<div class="outline-text-4" id="text-2_3_1">
<p>     First some basic housekeeping. The record needs to be &#8216;exported&#8217;     from a module </p>
<pre class="src src-erlang"><span style="color: #7fffd4;">-module</span>(poetry).

%% <span style="font-style: italic;">include the record definition or put it inline
</span><span style="color: #7fffd4;">-include</span>(<span style="color: #ad7fa8;">"poetry.hrl"</span>).

<span style="color: #7fffd4;">-compile</span>({parse_transform, exprecs}).
<span style="color: #7fffd4;">-export_records</span>([poetry]).
</pre>
<p>     To make the above <code>-compile</code> work, exprecs.erl needs to be in your     erlang path. For simplicity I have put exprecs.erl in a basic     erlang app that all our erlang projects depend on, that way I am     certain to have it available. ( I need a better way to do this     besides having a &#8216;utils&#8217;/'misc&#8217; app.) </p>
<p>     <code>-export_records</code> is created by the exprecs parse transform. This is      what generates and exports the funky &#8216;#get-&#8217; functions and makes      the records usable. </p>
<p>     ..and the same for the book.erl module </p>
</p></div>
</p></div>
<div id="outline-container-2_3_2" class="outline-4">
<h4 id="sec-2_3_2">update function</h4>
<div class="outline-text-4" id="text-2_3_2">
<p>    Now we need to write a function that updates the count field to     zero in all records, since our collection has been stolen. </p>
<pre class="src src-erlang"><span style="color: #7fffd4;">-type</span> <span style="font-weight: bold;">count_record</span>() :: #<span style="font-weight: bold;">poetry</span>{} | #<span style="font-weight: bold;">book</span>{}.
<span style="color: #7fffd4;">-spec</span> <span style="font-weight: bold;">reset_count</span>(<span style="color: #ef2929;">Module</span> :: <span style="color: #729fcf;">atom</span>(), <span style="color: #ef2929;">Record</span> :: <span style="font-weight: bold;">count_record</span>() ) -&gt;
                                   {error, <span style="color: #729fcf;">string</span>()} | {ok, <span style="font-weight: bold;">count_record</span>()}.
<span style="color: #edd400; font-weight: bold;">reset_count</span>(<span style="color: #ef2929;">Module</span>, <span style="color: #ef2929;">Record</span>) -&gt;
    %% <span style="font-style: italic;">crash if there is not a count field
</span>    true = <span style="font-weight: bold;">lists</span>:<span style="font-weight: bold;">member</span>(count, <span style="color: #ef2929;">Module</span>:<span style="color: #ad7fa8;">'#info-'</span>(fields,<span style="color: #ef2929;">Record</span>)),

    %% <span style="font-style: italic;">get the count value by specifying the field we want. notice how
</span>    %% <span style="font-style: italic;">there is no explicit mention of what record is being used. We
</span>    %% <span style="font-style: italic;">just care that there is a count.
</span>    <span style="font-weight: bold;">case</span> <span style="color: #ef2929;">Module</span>:<span style="color: #ad7fa8;">'#get-'</span>(count, <span style="color: #ef2929;">Record</span>) <span style="font-weight: bold;">of</span>
        0 -&gt;
            <span style="color: #ef2929;">Record</span>;
        <span style="color: #ef2929;">_N</span> -&gt;
            <span style="color: #ef2929;">Module</span>:<span style="color: #ad7fa8;">'#set-'</span>([{count, 0}, {available, false}], <span style="color: #ef2929;">Record</span>)
    <span style="font-weight: bold;">end</span>.
</pre>
<p>     In order to use this we write a simple loop over all books and     poetry available, specifying the module and record. </p>
<pre class="src src-erlang"><span style="color: #edd400; font-weight: bold;">reset_all</span>() -&gt;
    %% <span style="font-style: italic;">loop over all modules
</span>    <span style="font-weight: bold;">lists</span>:<span style="font-weight: bold;">foreach</span>(<span style="font-weight: bold;">fun</span>(<span style="color: #ef2929;">Module</span>) -&gt;
                          %% <span style="font-style: italic;">reset the count of all records in the module
</span>                          <span style="font-weight: bold;">lists</span>:<span style="font-weight: bold;">foreach</span>(<span style="font-weight: bold;">fun</span>(<span style="color: #ef2929;">Record</span>) -&gt;
                                                <span style="color: #ef2929;">New</span> = <span style="font-weight: bold;">reset_count</span>(<span style="color: #ef2929;">Module</span>, <span style="color: #ef2929;">Record</span>),
                                                <span style="color: #ef2929;">Module</span>:<span style="font-weight: bold;">update</span>(<span style="color: #ef2929;">New</span>)
                                        <span style="font-weight: bold;">end</span>, <span style="color: #ef2929;">Module</span>:<span style="font-weight: bold;">all</span>())
                  <span style="font-weight: bold;">end</span>, [poetry, book]).
</pre>
<p>     The bane of all example code is that bad code can be easier to     read. I hope the above illustrates the benefit of exprecs, namely,     that it opens the door to generic record-based code. </p>
</p></div>
</p></div>
</p></div>
</p></div>
<div id="outline-container-3" class="outline-2">
<h2 id="sec-3">json_rec, a walk through</h2>
<div class="outline-text-2" id="text-3">
<p>   As with all code, there are quite few bits missing, namely internal   documentation. It may prove difficult for others to hack on this   until I get to that. The good news is that I have extensively   documented the exported functions and even written an example model. </p>
<p>   You can pull the current code from   <a href="https://github.com/justinkirby/json_rec">https://github.com/justinkirby/json_rec</a> </p>
</p></div>
<div id="outline-container-3_1" class="outline-3">
<h3 id="sec-3_1">Using</h3>
<div class="outline-text-3" id="text-3_1">
<p>    The goal of json_rec is to take json and provide a record    ultimately destined for some type of datastore; mnesia, riak,    couch, etc..  As such json_rec assumes that you have a model for    interacting with the store, e.g. standard MVC. </p>
<p>    json_rec places a few very simple requirements on your model&#8217;s    interface: </p>
<ul>
<li>it MUST export new/1 </li>
<li>it MUST export rec/1 </li>
<li>it MUST export the exprecs transforms or the record. </li>
</ul>
<p>    At this point, if you have not read the exprecs <a href="http://blogs.openaether.org/data/exprecs.html">edoc</a> I highly    recommend that you do. </p>
<p>    Keeping with the above example, let&#8217;s make book.erl a json_rec    compatible module. </p>
<pre class="src src-erlang"><span style="color: #7fffd4;">-module</span>(book).

<span style="color: #7fffd4;">-export</span>([
         <span style="font-weight: bold;">new/1</span>,
         <span style="font-weight: bold;">rec/1</span>
        ]).

<span style="color: #7fffd4;">-record</span>(<span style="font-weight: bold;">book</span>, {
          style      :: <span style="color: #729fcf;">atom</span>(),
          count      :: <span style="color: #729fcf;">integer</span>(),
          available  :: <span style="color: #729fcf;">boolean</span>(),
          pages      :: <span style="color: #729fcf;">integer</span>(),
          excerpt    :: <span style="color: #729fcf;">string</span>(),
          author     :: <span style="color: #729fcf;">string</span>()
         }).

%% <span style="font-style: italic;">the exprecs export of the record interface
</span><span style="color: #7fffd4;">-compile</span>({parse_transform, exprecs}).
<span style="color: #7fffd4;">-export_records</span>([book]).

%% <span style="font-style: italic;">here we provide a mapping of the json key to a record.
</span><span style="color: #edd400; font-weight: bold;">new</span>(&lt;&lt;<span style="color: #ad7fa8;">"book"</span>&gt;&gt;) -&gt;
    <span style="color: #ad7fa8;">'#new-book'</span>();

%% <span style="font-style: italic;">if the key is unknown, return undefined.
</span><span style="color: #edd400; font-weight: bold;">new</span>(<span style="color: #ef2929;">_RecName</span>) -&gt;
    undefined.

%% <span style="font-style: italic;">return true for the #book{} indicating that we support it.
</span><span style="color: #edd400; font-weight: bold;">rec</span>(#<span style="font-weight: bold;">book</span>{}) -&gt;<span style="color: #edd400; font-weight: bold;"> </span>true;
<span style="color: #edd400; font-weight: bold;">rec</span>(<span style="color: #ef2929;">_</span>) -&gt;<span style="color: #edd400; font-weight: bold;"> </span>false.
</pre>
<p>    At this point we can take the following json and transform it into the #book{} record. </p>
<pre class="src src-javascript">{
    <span style="color: #ad7fa8;">"style"</span>: <span style="color: #ad7fa8;">"fiction"</span>,
    <span style="color: #ad7fa8;">"count"</span>: 1,
    <span style="color: #ad7fa8;">"available"</span>: <span style="color: #73d216;">true</span>,
    <span style="color: #ad7fa8;">"pages"</span>: 42,
    <span style="color: #ad7fa8;">"excerpt"</span>: <span style="color: #ad7fa8;">"Good bye and thanks for all the fish."</span>,
    <span style="color: #ad7fa8;">"author"</span>:<span style="color: #ad7fa8;">"Adams, Douglas"</span>
}
</pre>
<p>    We can get a #book{} record from the above with </p>
<pre class="src src-erlang"><span style="color: #7fffd4;">-spec</span> <span style="font-weight: bold;">json_to_rec</span>(<span style="color: #ef2929;">Json</span> :: <span style="color: #729fcf;">string</span>()) -&gt;<span style="color: #edd400; font-weight: bold;"> </span>#<span style="font-weight: bold;">book</span>{}.
<span style="color: #edd400; font-weight: bold;">json_to_rec</span>(<span style="color: #ef2929;">Json</span>) -&gt;
    <span style="color: #ef2929;">ErlJson</span> = <span style="font-weight: bold;">mochijson2</span>:<span style="font-weight: bold;">decode</span>(<span style="color: #ef2929;">Json</span>),
    <span style="color: #ef2929;">Record</span> = <span style="font-weight: bold;">book</span>:<span style="font-weight: bold;">new</span>(&lt;&lt;<span style="color: #ad7fa8;">"book"</span>&gt;&gt;),
    <span style="font-weight: bold;">json_rec</span>:<span style="font-weight: bold;">to_rec</span>(<span style="color: #ef2929;">ErlJson</span>, book, <span style="color: #ef2929;">Record</span>).
</pre>
</p></div>
</p></div>
<div id="outline-container-3_2" class="outline-3">
<h3 id="sec-3_2">Other features</h3>
<div class="outline-text-3" id="text-3_2">
<p>    json_rec will try its best to transform into known records,    e.g. ones exported from the module. However, if Module:new/1    returns &#8216;undefined&#8217;, then it will fall back to a proplist. The    major downside of this is that it loses the clean round trip that    mochijson2 gives you. </p>
<p>    json_rec also supports nested records. Whenever a json dictionary    key has a dictionary as a value json_rec will call Module:new/1 to    determine if it is a known record type. If it is json_rec will    create a record and make it the value of the parent record field. </p>
<p>    json_rec supports a list of dictionaries as well. </p>
<p>    In summary I have tried to support all reasonable data structure    combinations. json_rec does a best effort to do what you    expect. However, it is not an AI or Turing-complete so I am sure    there are various combinations of lists and dicts that will not    work. </p>
</p></div>
</p></div>
<div id="outline-container-3_3" class="outline-3">
<h3 id="sec-3_3">Summary</h3>
<div class="outline-text-3" id="text-3_3">
<p>    json_rec is an 80% solution that has saved me a ton of copy/paste    coding. I have found it extremely useful in saving my sanity when    transforming json into useable data. </p>
<p>    I would like to thank Ulf Wiger for creating exprecs, making    json_rec possible. </p>
</p></div>
</p></div>
</p></div>
</p></div>
<p> </body> </html> </p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.openaether.org/?feed=rss2&#038;p=253</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Identi.ca Updates for 2011-03-30</title>
		<link>http://blogs.openaether.org/?p=252</link>
		<comments>http://blogs.openaether.org/?p=252#comments</comments>
		<pubDate>Thu, 31 Mar 2011 03:59:59 +0000</pubDate>
		<dc:creator>Justin Kirby</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blogs.openaether.org/?p=252</guid>
		<description><![CDATA[trying ditz on a project: http://gitorious.org/ditz looks promising #]]></description>
			<content:encoded><![CDATA[<ul class="aktt_tweet_digest">
<li>trying ditz on a project: <a href="http://gitorious.org/ditz" rel="nofollow">http://gitorious.org/ditz</a>  looks promising <a href="http://identi.ca/notice/68562691">#</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blogs.openaether.org/?feed=rss2&#038;p=252</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Entertaining the kid</title>
		<link>http://blogs.openaether.org/?p=247</link>
		<comments>http://blogs.openaether.org/?p=247#comments</comments>
		<pubDate>Sat, 29 Jan 2011 03:16:00 +0000</pubDate>
		<dc:creator>Justin Kirby</dc:creator>
				<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://blogs.openaether.org/?p=247</guid>
		<description><![CDATA[I have a 15 month old daughter that simply loves to play on the laptop. Pressing random keys until I notice. Because of this I have gotten into the habit of closing my laptop while not using it. This has saved me from sending lots of random messages to random people. Closing and opening my [...]]]></description>
			<content:encoded><![CDATA[<p>I have a 15 month old daughter that simply loves to play on the laptop. Pressing random keys until I notice.  Because of this I have gotten into the habit of closing my laptop while not using it. This has saved me from sending lots of random messages to random people. </p>
<p> Closing and opening my laptop all day is quite tedious. The best way to resolve this problem is to place a greater temptation in front of her. The only quesiton is what is that? </p>
<p> I found an old netbook laying around that I haven&#8217;t used in months. So I wrote a game.  </p>
<p> I have been meaning to play with pygame for a while now and this gave me the perfect excuse to do so. The &#8216;requirements&#8217; for the game were: </p>
<ul>
<li> it must be simple enough to do in about an hour </li>
<li> it should do something on any input
<ul>
<li> the input is any keypress. </li>
</ul>
</li>
<li> it should entertain a 15 month old toddler  </li>
</ul>
<p>Solution: </p>
<ul>
<li> display an image </li>
<li> hide that image behind a grid of 4&#215;4 black rectangles </li>
<li> on any key press remove a random rectangle
<ul>
<li> this causes a section of the hidden image to be displayed </li>
</ul>
</li>
<li> if the entire image is shown, next keypress will cycle to the next image. </li>
<li> repeat  </li>
</ul>
<p>The above is extremely rudimentary. However, the audience has not acquired sophisticated tastes as of yet. </p>
<p> I wrote the pygame app last night and tested it out this afternoon. She loves it.  She now has her very own laptop. She can bash the hell out of the keys and mommy and daddy do not stop her. Also, something happens on the screen too! Most exciting ;) </p>
<p> Usage is simple: </p>
<ol>
<li> mkdir -p ~/.phoebe/images </li>
<li> put as many images as you want in the above dir </li>
<li> python phoebe.py  </li>
</ol>
<p>Problems and Known limitiations: </p>
<ul>
<li> I wrote this in an hour while learning pygame </li>
<li> I assume a lot and if you aren&#8217;t on the latest ubuntu w/ pygame it will probably throw exceptions and crash.  Sorry </li>
<li> I did get it working on an old debian install with python2.5, see comment in World.__init__  </li>
</ul>
<p>If I do more with this I will throw it up on github. </p>
<p> Here is the python source: </p>
<pre class="src src-python"><span style="color: #5F5A60;">#!/usr/bin/env python
</span>
<span style="color: #CDA869;">import</span> os
<span style="color: #CDA869;">import</span> sys
<span style="color: #CDA869;">import</span> glob
<span style="color: #CDA869;">import</span> itertools
<span style="color: #CDA869;">import</span> random
<span style="color: #CDA869;">import</span> datetime
<span style="color: #CDA869;">import</span> pygame
<span style="color: #CDA869;">from</span> pygame.locals <span style="color: #CDA869;">import</span> *

<span style="color: #7587A6;">world</span> = <span style="color: #CF6A4C;">None</span>

<span style="color: #CDA869;">def</span> <span style="color: #9B703F;">init</span>():
    pygame.init()

    <span style="color: #CDA869;">global</span> world
    world = World()

<span style="color: #CDA869;">class</span> <span style="color: #9B703F;">World</span>:
    <span style="color: #CDA869;">def</span> <span style="color: #9B703F;">__init__</span>(<span style="color: #CDA869;">self</span>):
        <span style="color: #5F5A60;"># this might not be available in older versions of python. If
</span>        <span style="color: #5F5A60;"># that is the case, simply hard code the resolution to your
</span>        <span style="color: #5F5A60;"># screen size.
</span>        vid_info = pygame.display.Info()
        <span style="color: #CDA869;">self</span>.size = <span style="color: #CDA869;">self</span>.width,<span style="color: #CDA869;">self</span>.height = vid_info.current_w/2,vid_info.current_h/2

        <span style="color: #CDA869;">self</span>.screen = pygame.display.set_mode(<span style="color: #CDA869;">self</span>.size)

        images_files = glob.glob(os.environ[<span style="color: #8F9D6A;">"HOME"</span>]+<span style="color: #8F9D6A;">"/.phoebe/images/*.jpg"</span>)

        <span style="color: #CDA869;">self</span>.images = itertools.cycle(images_files)
        <span style="color: #CDA869;">self</span>.image = <span style="color: #CF6A4C;">None</span>

        <span style="color: #CDA869;">self</span>.grid_size = 4

        <span style="color: #CDA869;">self</span>.masks = <span style="color: #CDA869;">self</span>._get_masks()

        <span style="color: #CDA869;">self</span>._to_blit = []

        random.seed(datetime.datetime.now())

    <span style="color: #CDA869;">def</span> <span style="color: #9B703F;">_get_masks</span>(<span style="color: #CDA869;">self</span>):
        black_mask = pygame.Surface((<span style="color: #CDA869;">self</span>.width/<span style="color: #CDA869;">self</span>.grid_size, <span style="color: #CDA869;">self</span>.height/<span style="color: #CDA869;">self</span>.grid_size))
        black_mask.fill((0,0,0,0))

        rv = []
        <span style="color: #CDA869;">for</span> y <span style="color: #CDA869;">in</span> <span style="color: #CACACA;">range</span>(0,<span style="color: #CDA869;">self</span>.grid_size):
            ay = y * black_mask.get_height()
            <span style="color: #CDA869;">for</span> x <span style="color: #CDA869;">in</span> <span style="color: #CACACA;">range</span>(0,<span style="color: #CDA869;">self</span>.grid_size):
                ax = x * black_mask.get_width()
                rv.append((black_mask.copy(),(ax,ay)))
        <span style="color: #CDA869;">return</span> rv

    <span style="color: #CDA869;">def</span> <span style="color: #9B703F;">_next_image</span>(<span style="color: #CDA869;">self</span>):
        img = <span style="color: #CDA869;">self</span>.images.next()
        img_surface = pygame.image.load(img).convert()

        <span style="color: #CDA869;">self</span>.image = (pygame.transform.scale(img_surface,<span style="color: #CDA869;">self</span>.size),(0,0))

    <span style="color: #CDA869;">def</span> <span style="color: #9B703F;">next</span>(<span style="color: #CDA869;">self</span>):

        <span style="color: #CDA869;">self</span>._to_blit = []

        <span style="color: #CDA869;">if</span> <span style="color: #CDA869;">not</span> <span style="color: #CACACA;">len</span>(<span style="color: #CDA869;">self</span>.masks) <span style="color: #CDA869;">or</span> <span style="color: #CDA869;">not</span> <span style="color: #CDA869;">self</span>.image:
            <span style="color: #5F5A60;">#no more masks, setup the next image
</span>            <span style="color: #CDA869;">self</span>._next_image()
            <span style="color: #CDA869;">self</span>.masks = <span style="color: #CDA869;">self</span>._get_masks()

        <span style="color: #CDA869;">else</span>:
            <span style="color: #5F5A60;"># we have masks remove on
</span>            <span style="color: #CDA869;">if</span> <span style="color: #CACACA;">len</span>(<span style="color: #CDA869;">self</span>.masks) &gt; 1:
                <span style="color: #5F5A60;">#if there is only one mask left, then range is 0 to 0, and randrange complains
</span>                to_r = random.randrange(0,<span style="color: #CACACA;">len</span>(<span style="color: #CDA869;">self</span>.masks)-1)
                <span style="color: #CDA869;">self</span>.masks.pop(to_r)
            <span style="color: #CDA869;">else</span>:
                <span style="color: #5F5A60;">#this is the last mask,
</span>                <span style="color: #CDA869;">self</span>.masks.pop()

        <span style="color: #5F5A60;">#put the image into the blit list
</span>        <span style="color: #CDA869;">self</span>._to_blit.append(<span style="color: #CDA869;">self</span>.image)
        <span style="color: #CDA869;">self</span>._to_blit += <span style="color: #CDA869;">self</span>.masks

    <span style="color: #CDA869;">def</span> <span style="color: #9B703F;">blit</span>(<span style="color: #CDA869;">self</span>):
        screen = pygame.display.get_surface()
        <span style="color: #CDA869;">for</span> s,p <span style="color: #CDA869;">in</span> <span style="color: #CDA869;">self</span>._to_blit:
            screen.blit(s,p)

<span style="color: #CDA869;">def</span> <span style="color: #9B703F;">main</span>():
    <span style="color: #CDA869;">global</span> world

    init()

    world.next()

    clock = pygame.time.Clock()

    done = <span style="color: #CDA869;">False</span>
    <span style="color: #CDA869;">while</span> <span style="color: #CDA869;">not</span> done:

        clock.tick(30)

        world.blit()

        pygame.display.flip()

        <span style="color: #CDA869;">for</span> event <span style="color: #CDA869;">in</span> pygame.event.get():
            <span style="color: #CDA869;">if</span> event.type == pygame.QUIT:
                done = <span style="color: #CDA869;">True</span>
            <span style="color: #CDA869;">elif</span> event.type == pygame.KEYDOWN:
                <span style="color: #CDA869;">if</span> event.key == pygame.K_ESCAPE:
                    done = <span style="color: #CDA869;">True</span>
                <span style="color: #CDA869;">else</span>:
                    world.next()

    pygame.quit()
    <span style="color: #CDA869;">return</span> 0

<span style="color: #CDA869;">if</span> <span style="color: #CACACA;">__name__</span> == <span style="color: #8F9D6A;">"__main__"</span>:
    sys.exit(main())
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blogs.openaether.org/?feed=rss2&#038;p=247</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Identi.ca Updates for 2011-01-20</title>
		<link>http://blogs.openaether.org/?p=246</link>
		<comments>http://blogs.openaether.org/?p=246#comments</comments>
		<pubDate>Fri, 21 Jan 2011 03:59:59 +0000</pubDate>
		<dc:creator>Justin Kirby</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blogs.openaether.org/?p=246</guid>
		<description><![CDATA[@trashbird1240 ha! I saw that conversation. I was entertained # @tius that just went into ~/.emacs thanks # finally made it to a LUG. been a while #]]></description>
			<content:encoded><![CDATA[<ul class="aktt_tweet_digest">
<li>@trashbird1240 ha! I saw that conversation. I was entertained <a href="http://identi.ca/notice/62571564">#</a></li>
<li>@tius that just went into ~/.emacs  thanks <a href="http://identi.ca/notice/62601261">#</a></li>
<li>finally made it to a LUG. been a while <a href="http://identi.ca/notice/62624153">#</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blogs.openaether.org/?feed=rss2&#038;p=246</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OrgMode and Firefox conversations</title>
		<link>http://blogs.openaether.org/?p=236</link>
		<comments>http://blogs.openaether.org/?p=236#comments</comments>
		<pubDate>Tue, 18 Jan 2011 18:26:00 +0000</pubDate>
		<dc:creator>Justin Kirby</dc:creator>
				<category><![CDATA[emacs]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[org]]></category>

		<guid isPermaLink="false">http://blogs.openaether.org/?p=236</guid>
		<description><![CDATA[I like to use OrgMode because I feel organized and in control. That is definitely an illusion, but it is a nice one. I am still using firefox to browse the web. Mainly because w3m doesn&#8217;t work well at all outside of plain text pages and ezbl is not yet ready. This means I am [...]]]></description>
			<content:encoded><![CDATA[<p>I like to use <a href="http://orgmode.org/">OrgMode</a> because I feel organized and in control. That is definitely an illusion, but it is a nice one.  </p>
<p> I am still using <a href="http://www.mozilla.com">firefox</a> to browse the web. Mainly because <a href="http://w3m.sourceforge.net/">w3m</a> doesn&#8217;t work well at all outside of plain text pages and <a href="https://github.com/haxney/ezbl">ezbl</a> is not yet ready. This means I am generating a lot of information; history, tabs, bookmarks that are outside of my massive org collection of stuff.  </p>
<p> When I find something I would like to read, but don&#8217;t have time for at that moment, I would like to store it in orgmode. However, copy/paste the url+title got really tedious. As with anything tedious I tend not to do it. So my firefox &#8216;to read later&#8217; bookmark folder got full and without a way to prioritize them it became a morass of unused links. </p>
<p> Wouldn&#8217;t it be nice if emacs could pull the current url and title from firefox and put that into org for me? </p>
<p> Queue <a href="http://www.emacswiki.org/emacs/MozRepl">MozRepl</a> stage right </p>
<p> MozRepl gives you a simple line oriented repl into the entire browser context. You could even use telnet if you really wanted to. </p>
<p> So I hacked up some quick primitive functions to ask MozRepl for the current url and title. </p>
<p> The function that will send a string to Firefox. The repl MUST be started already which you can do with M-x run-mozilla </p>
<pre class="src src-emacs-lisp">(<span style="color: #CDA869;">require</span> '<span style="color: #CF6A4C;">moz</span>)

(<span style="color: #CDA869;">defun</span> <span style="color: #9B703F;">jk/moz-get</span> (attr)
  (comint-send-string (inferior-moz-process) attr)
  <span style="color: #5F5A60;">;; </span><span style="color: #5F5A60;">try to give the repl a chance to respond
</span>  (sleep-for 0 100))
</pre>
<p> The sleep-for function is there because there is no flow control on the mozrepl. If you call jk/moz-get in succession too quickly you will get whatever the last result was multiple times. </p>
<p> Get the current url: </p>
<pre class="src src-emacs-lisp">(<span style="color: #CDA869;">defun</span> <span style="color: #9B703F;">jk/moz-get-current-url</span> ()
  (interactive)
  (jk/moz-get <span style="color: #8F9D6A;">"repl._workContext.content.location.href"</span>))
</pre>
<p> Get the current title: </p>
<pre class="src src-emacs-lisp">(<span style="color: #CDA869;">defun</span> <span style="color: #9B703F;">jk/moz-get-current-title</span> ()
  (interactive)
  (jk/moz-get <span style="color: #8F9D6A;">"repl._workContext.content.document.title"</span>))
</pre>
<p> The repl buffer will now have the results printed as a string. Not useful. So we work a little buffer walking magic that makes too many assumptions. </p>
<pre class="src src-emacs-lisp">(<span style="color: #CDA869;">defun</span> <span style="color: #9B703F;">jk/moz-get-current</span> (moz-fun)
  (funcall moz-fun)
  <span style="color: #5F5A60;">;; </span><span style="color: #5F5A60;">doesn't work if repl takes too long to output string
</span>  (<span style="color: #CDA869;">save-excursion</span>
                  (set-buffer (process-buffer (inferior-moz-process)))
                  (goto-char (point-max))
                  (previous-line)
                  (setq jk/moz-current (buffer-substring-no-properties
                                        (+ (point-at-bol) (length moz-repl-name) 3)
                                        (- (point-at-eol) 1))))
  (message <span style="color: #8F9D6A;">"%s"</span> jk/moz-current)
  jk/moz-current
)
</pre>
<p> This simply calls whatever func is passed in as moz-fun and grabs the last output line of the moz repl.  </p>
<p> The last bit for getting what we want is to put all the above together into a couple convenience functions: </p>
<pre class="src src-emacs-lisp">(<span style="color: #CDA869;">defun</span> <span style="color: #9B703F;">jk/moz-url</span> ()
  (interactive)
  (jk/moz-get-current 'jk/moz-get-current-url)
  )

(<span style="color: #CDA869;">defun</span> <span style="color: #9B703F;">jk/moz-title</span> ()
  (interactive)
  (jk/moz-get-current 'jk/moz-get-current-title)
  )
</pre>
<p> Now we can run (jk/moz-url) and it returns the url in whatever window/tab is currently active, same for (jk/moz-title) </p>
<p> Last step is to get this into org via org-capture using org-capture-templates.  </p>
<pre class="src src-emacs-lisp">(setq org-capture-templates
      '((<span style="color: #8F9D6A;">"t"</span> <span style="color: #8F9D6A;">"Todo"</span> entry (file+headline <span style="color: #8F9D6A;">"~/org/all.org"</span> <span style="color: #8F9D6A;">"Tasks"</span>)
         <span style="color: #8F9D6A;">"* TODO %?\n %i\n %a"</span>)
        (<span style="color: #8F9D6A;">"n"</span> <span style="color: #8F9D6A;">"Notes"</span> entry (file+datetree <span style="color: #8F9D6A;">"~/org/notes.org"</span>)
         <span style="color: #8F9D6A;">"* %?\nEntered on %U\n %i\n %a"</span>)
        (<span style="color: #8F9D6A;">"b"</span> <span style="color: #8F9D6A;">"Bookmark"</span> entry (file+datetree <span style="color: #8F9D6A;">"~/org/notes.org"</span>)
         <span style="color: #8F9D6A;">"* %(concat \"[[\" (jk/moz-url) \"][\" (jk/moz-title) \"]]\")\n Entered on %U\n"</span>)
        ))
</pre>
<p> The orgmode capture template has %(sexp) so you can run arbitrary elisp code to generate the content of the template. </p>
<p> Now all I have to do is C-c c b C-c C-c and I have a &#8216;bookmark&#8217; in org. I am finding this to be very useful. </p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.openaether.org/?feed=rss2&#038;p=236</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>dot emacs conf00.d</title>
		<link>http://blogs.openaether.org/?p=230</link>
		<comments>http://blogs.openaether.org/?p=230#comments</comments>
		<pubDate>Thu, 25 Nov 2010 02:49:00 +0000</pubDate>
		<dc:creator>Justin Kirby</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blogs.openaether.org/?p=230</guid>
		<description><![CDATA[Earlier I gave a brief overview of how my config file is loaded. The first directory loaded is ~/.emacs.lisp/conf00.d/ Where we find the following files: bbdb.el dired.el misc.el paren.el ui.el uniquify.el bbdb I do not have anything particularly interesting or fancy here. It loads bbdb and adds it to a hook. (add-to-list 'load-path "/usr/share/emacs/site-lisp/bbdb") (add-to-list [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blogs.openaether.org/?p=225">Earlier</a> I gave a brief overview of how my config file is loaded. The first directory loaded is ~/.emacs.lisp/conf00.d/ Where we find the following files: </p>
<ul>
<li> bbdb.el </li>
<li> dired.el </li>
<li> misc.el </li>
<li> paren.el </li>
<li> ui.el </li>
<li> uniquify.el </li>
</ul>
<div id="outline-container-1" class="outline-2">
<h2 id="sec-1">bbdb</h2>
<div class="outline-text-2" id="text-1">
<p> I do not have anything particularly interesting or fancy here. It loads bbdb and adds it to a hook. </p>
<pre class="src src-emacs-lisp">(add-to-list 'load-path <span style="color: #8F9D6A;">"/usr/share/emacs/site-lisp/bbdb"</span>)
(add-to-list 'load-path <span style="color: #8F9D6A;">"/usr/share/emacs/site-lisp/bbdb/bits"</span>)
(load <span style="color: #8F9D6A;">"bbdb-autoloads"</span>)
(bbdb-initialize)
(add-hook 'gnus-startup-hook 'bbdb-insinuate-gnus)
</pre>
<p> The only thing of note is the gnus startup hook. This lets me tab complete email addresses in gnus, as long as they are in bbdb. Unfortunately, that is all there is here. </p>
<p> I would like any addresses I send emails to be entered automatically in bbdb with an &#8216;auto&#8217; tag. However, I have been too lazy to look that up. </p>
<p> I would like to &#8216;reverse insinuate&#8217; my jabber rosters. Grab jids and info from the roster+vcard and place it in bbdb. That requires more &#8216;magic&#8217; than I know how todo now. </p>
</p></div>
</p></div>
<div id="outline-container-2" class="outline-2">
<h2 id="sec-2">dired</h2>
<div class="outline-text-2" id="text-2">
<p> I find myself using <code>C-x d</code> more than I ever thought I would. Combined with <code>C-s</code> it is a great way to quickly search for what you need. </p>
<pre class="src src-emacs-lisp">(<span style="color: #CDA869;">eval-after-load</span> <span style="color: #8F9D6A;">"gnus"</span>
  '(<span style="color: #CDA869;">progn</span>
     (<span style="color: #CDA869;">require</span> '<span style="color: #CF6A4C;">gnus-dired</span>)
     (add-hook 'dired-mode-hook 'turn-on-gnus-dired-mode)
     (define-key dired-mode-map <span style="color: #8F9D6A;">"a"</span> 'gnus-dired-attach)

     (add-hook 'dired-mode-hook
               (<span style="color: #CDA869;">lambda</span> ()
                 (define-key dired-mode-map <span style="color: #8F9D6A;">"\C-xm"</span> 'jgk/dired-w3m-find-file)))))

(<span style="color: #CDA869;">defun</span> <span style="color: #9B703F;">jgk/dired-w3m-find-file</span> ()
  (interactive)
  (<span style="color: #CDA869;">require</span> '<span style="color: #CF6A4C;">w3m</span>)
  (<span style="color: #CDA869;">let</span> ((file (dired-get-filename)))
    (<span style="color: #CDA869;">if</span> (y-or-n-p (format <span style="color: #8F9D6A;">"Open 'w3m' %s "</span> (file-name-nondirectory file)))
        (w3m-find-file file))))

(<span style="color: #CDA869;">defun</span> <span style="color: #9B703F;">jgk/w3m-browse-current-buffer</span> ()
  (interactive)
  (<span style="color: #CDA869;">let</span> ((filename (concat (make-temp-file <span style="color: #8F9D6A;">"w3m-"</span>) <span style="color: #8F9D6A;">".html"</span>)))
    (<span style="color: #CDA869;">unwind-protect</span>
        (<span style="color: #CDA869;">progn</span>
          (write-region (point-min) (point-max) filename)
          (w3m-find-file filename))
      (delete-file filename))))
</pre>
<p> This evals a few functions after gnus is loaded. The only feature in here which I still use occasionally is attaching from a dired buffer. Everything else is not exactly useful to be honest. (need to add to my todo) </p>
</p></div>
</p></div>
<div id="outline-container-3" class="outline-2">
<h2 id="sec-3">misc</h2>
<div class="outline-text-2" id="text-3">
<p>This file is a collection of random stuff that does not configure a package or is a simple setting tweaks.  Since the code is unrelated I will take it line by line. </p>
<pre class="src src-emacs-lisp">(global-font-lock-mode t)
</pre>
<p> Turns on font lock so things are pretty. </p>
<pre class="src src-emacs-lisp">(fset 'yes-or-no-p 'y-or-n-p)
</pre>
<p> This is very handy. It changes the yes/no to y/n. For every prompt that requires a yes or no input it becomes a single key stroke instead of typing out a whole word. </p>
<pre class="src src-emacs-lisp">(<span style="color: #CDA869;">require</span> '<span style="color: #CF6A4C;">mwheel</span>)
</pre>
<p> Simply turn on scrolling with the mouse wheel. </p>
<pre class="src src-emacs-lisp">(setq next-line-add-newline nil
      require-final-newline t
      use-file-dialog nil
      use-dialog-box nil
      transient-mark-mode t)
</pre>
<ul>
<li> next-line-add-newline: stop adding newlines when you move the cursor, only do it on enter </li>
<li> require-final-newline: always add a newline at the end of file, I find a lot of programs out there need this </li>
<li> use-file-dialog &amp; use-dialog-box: disable dialog boxes! </li>
<li> transient-mark-mode: highlight active regions  </li>
</ul>
<pre class="src src-emacs-lisp">(setq compilation-scroll-output t)
</pre>
<p> Automatically scroll output from compilation commands. I got this from <a href="http://egopoly.com/2007/10/31/how-to-scroll-compiler-output-in-emacs/">http://egopoly.com/2007/10/31/how-to-scroll-compiler-output-in-emacs/</a> </p>
<pre class="src src-emacs-lisp">(push '(<span style="color: #8F9D6A;">"."</span> . <span style="color: #8F9D6A;">"/home/justin/.emacs.backup"</span>) backup-directory-alist)
</pre>
<p> I got really sick of have ~ files all over the place and adding them to the ignore filters for various vcs (git,hg,etc..)  This puts them all into one place. The files that are created are unique since they have the full path in them, but with ! instead of / </p>
</p></div>
</p></div>
<div id="outline-container-4" class="outline-2">
<h2 id="sec-4">paren</h2>
<div class="outline-text-2" id="text-4">
<p>Enables paren-mode which makes the parens fade into the background and gives you great visual feedback as to where you are in the expressions. </p>
<pre class="src src-emacs-lisp">(show-paren-mode t)
(setq show-paren-style 'expression)
</pre>
</p></div>
</p></div>
<div id="outline-container-5" class="outline-2">
<h2 id="sec-5">ui</h2>
<div class="outline-text-2" id="text-5">
<p> I like a clean UI. I never use the toolbars or menus and the scroll bar is simply taking up space. The following turns them all off. </p>
<pre class="src src-emacs-lis">(if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
(if (fboundp 'menu-bar-mode) (menu-bar-mode -1))
(if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
</pre>
</p></div>
</p></div>
<div id="outline-container-6" class="outline-2">
<h2 id="sec-6">uniquify</h2>
<div class="outline-text-2" id="text-6">
<p> I often find myself working in multiple projects within the same emacs session. In fact I really only have a single emacs session for everything. uniquify makes the buffer names unique based on location. So when you have two files open of the same name, uniquify will walk up the directory tree until it finds the unique part of the path, it will then change the buffer name to be unique. This is simply awesome. </p>
<pre class="src src-emacs-lisp"><span style="color: #5F5A60;">;; </span><span style="color: #5F5A60;">from http://trey-jackson.blogspot.com/2008/01/emacs-tip-11-uniquify.html
</span>(<span style="color: #CDA869;">require</span> '<span style="color: #CF6A4C;">uniquify</span>)
(setq uniquify-buffer-name-style 'reverse
      uniquify-separator <span style="color: #8F9D6A;">"/"</span>
      uniquify-after-kill-buffer-p t <span style="color: #5F5A60;">;; </span><span style="color: #5F5A60;">rename after killing uniquified
</span>      uniquify-ignore-buffers-re <span style="color: #8F9D6A;">"^\\*"</span>) <span style="color: #5F5A60;">; </span><span style="color: #5F5A60;">don't muck with special buffers
</span></pre>
<p> The above settings should be obvious. I have / as the separator, all uniqified buffers are redone when one is killed and the scratch-like buffers are ignored. </p>
</p></div>
</p></div>
<div id="outline-container-7" class="outline-2">
<h2 id="sec-7"></h2>
<div class="outline-text-2" id="text-7">
<p> That is my first &#8216;runlevel&#8217; for emacs. Not much here so I took it all in one go. Any tips or improvments are most welcome. </p>
</div></div>
]]></content:encoded>
			<wfw:commentRss>http://blogs.openaether.org/?feed=rss2&#038;p=230</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>~.emacs</title>
		<link>http://blogs.openaether.org/?p=225</link>
		<comments>http://blogs.openaether.org/?p=225#comments</comments>
		<pubDate>Tue, 23 Nov 2010 04:34:00 +0000</pubDate>
		<dc:creator>Justin Kirby</dc:creator>
				<category><![CDATA[emacs]]></category>

		<guid isPermaLink="false">http://blogs.openaether.org/?p=225</guid>
		<description><![CDATA[I have been using emacs for a while now. I would guess about five years. I would classify myself as a power user and not really a true emacs user. To be a &#8216;true&#8217; emacs user you should at least be able to write elisp and generally hack emacs. Instead, I rely very heavily on [...]]]></description>
			<content:encoded><![CDATA[<p>I have been using emacs for a while now. I would guess about five years. I would classify myself as a power user and not really a true emacs user. To be a &#8216;true&#8217; emacs user you should at least be able to write elisp and generally hack emacs.  Instead, I rely very heavily on existing elisp code and blogs. Of course, you can not mention emacs without pointing to <a href="http://emacswiki.org">http://emacswiki.org</a>. </p>
<p> Writing about your dot emacs has become all the rage lately and I figured I would join in the fun. By writing about this I hope to do a few things; </p>
<ul>
<li> filter out the junk in my dot emacs </li>
<li> get tips and/or ideas about what I can do better </li>
<li> finally get the motivation to write some elisp </li>
</ul>
<div id="outline-container-1" class="outline-2">
<h2 id="sec-1">The ~.emacs</h2>
<div class="outline-text-2" id="text-1">
<pre class="src src-emacs-lisp">(setq my-init-dir <span style="color: #8F9D6A;">"~/.emacs.lisp"</span>
      my-pkg-dir (concat my-init-dir <span style="color: #8F9D6A;">"/pkg"</span>)
      my-site-dir (concat my-pkg-dir <span style="color: #8F9D6A;">"/share/emacs/site-lisp"</span>))
(load <span style="color: #8F9D6A;">"~/.emacs.lisp/init.el"</span>)
</pre>
<p> And the ~/.emacs.lisp/init.el </p>
<pre class="src src-emacs-lisp">(add-to-list 'load-path (expand-file-name <span style="color: #8F9D6A;">"~/.emacs.lisp"</span>))
(add-to-list 'load-path (expand-file-name (concat my-init-dir <span style="color: #8F9D6A;">"/pkg"</span>)))
(load <span style="color: #8F9D6A;">"safe-load"</span>)

(<span style="color: #CDA869;">dolist</span> (file  (reverse
                (mapcar 'file-name-sans-extension
                        (file-expand-wildcards
                         (concat my-init-dir <span style="color: #8F9D6A;">"/conf[0-9][0-9].d/[a-z-]*.el"</span>)))))
  (safe-load (expand-file-name file)))

(safe-load <span style="color: #8F9D6A;">"keys.el"</span>)
</pre>
<p> I can not recall where I got this idea from, but it has served me well so far. As any *nix user will note, this is inspired by the rc.d runlevel concept. I can have conf00.d to conf99.d as sub directories to the main .emacs.lisp directory. This allows for relatively easy control of &#8216;boot&#8217; order of various modes,apps,etc&hellip; </p>
<p> I have only been bitten by the implicit boot order a couple of times. Currently, I only have 0-3 and I am just thinking about adding a 4. </p>
<p> One thing to note is the keys.el file is at the bottom, I wanted a single place to find all my global key bindings.  </p>
<p> In later posts I will go over what is hiding in the conf00.d-conf03.d directories, but for now I will move on. </p>
<p> Here are some stats: </p>
<ul>
<li> 36 elisp files </li>
<li> 854 loc </li>
<li> 73 packages  </li>
</ul></div>
</p></div>
<div id="outline-container-2" class="outline-2">
<h2 id="sec-2">Packages</h2>
<div class="outline-text-2" id="text-2">
<p> I have still not found a way to deal with packages well at all. As the stat above shows, I have 73 of something via ls -l|wc -l. </p>
<p> I decided to put all pkgs under ~/.emacs.lisp/pkg Normally I just grab a release tarbal and extract it there. Then have the elisp file under conf??.d add the path to the load-path list and its working. Sometimes I do grab a clone of a repos and dump it in there too. </p>
<p> This works out ok, except that when the pkg needs to ./configure the parameters can get quite hairy, keeping the &#8216;install&#8217; under ~/.emacs.lisp/pkg is messy then.  </p>
</p></div>
</p></div>
<div id="outline-container-3" class="outline-2">
<h2 id="sec-3">DVCS</h2>
<div class="outline-text-2" id="text-3">
<p> Of course I keep the entire ~/.emacs.lisp dir under hg, pushed to a remote server.  This way I can pull onto my laptop or anyother random *nix and get my exact environment. </p>
<p> Does this work in practice? Not really. </p>
<p> Often times the ~/.emacs.lisp gets too far out of sync and I have to choose what to blow away. (I can be lazy with horrible merges.) Also having clones of other repos in ~/.emacs.lisp/pkg means I have to delete their .git or .hg and lose all of that info. (No I am not going to commit those dirs). Also, I get lazy and forget to commit and/or push and when I pull everything is ancient. </p>
</p></div>
</p></div>
<div id="outline-container-4" class="outline-2">
<h2 id="sec-4">I like it, kind of</h2>
<div class="outline-text-2" id="text-4">
<p> There are downsides to this method, finding where you configured something can be a pain, grep&#8217;ing files all the time does become tedious.  </p>
<p> I would say it is a win so far. At least I have not discovered a better method for managing a huge emacs config. </p>
<p> Ideas welcome. </p>
</div></div>
]]></content:encoded>
			<wfw:commentRss>http://blogs.openaether.org/?feed=rss2&#038;p=225</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Audio desires</title>
		<link>http://blogs.openaether.org/?p=217</link>
		<comments>http://blogs.openaether.org/?p=217#comments</comments>
		<pubDate>Tue, 16 Nov 2010 19:02:00 +0000</pubDate>
		<dc:creator>Justin Kirby</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blogs.openaether.org/?p=217</guid>
		<description><![CDATA[Current Situation I have a significant lack of audio options in my house and I love listening to music. I spend most of my time in my office which does have good audio. However, when I am in the rest of the house the options are severely limited. The wife and I both have laptops [...]]]></description>
			<content:encoded><![CDATA[<div id="outline-container-1" class="outline-2">
<h2 id="sec-1">Current Situation </h2>
<div class="outline-text-2" id="text-1">
<p>
I have a significant lack of audio options in my house and I love listening to music. I spend most of my time in my office which does have good audio.  However, when I am in the rest of the house the options are severely limited.
</p>
<p>
The <a href="http://adriennekirby.com">wife</a> and I both have laptops downstairs in the living room. On occasion we move them about when needed. My <a href="http://freemanlattin.com">son</a> has an iMac in the<br />
dining room. The iMac is our primary source of audio.
</p>
<p>
This situation can run into conflicts. When Freeman is playing stupid-flash-games[tm] I do NOT want the blips n bleeps injected haphazardly into my Bach.
</p>
</div>
</div>
<div id="outline-container-2" class="outline-2">
<h2 id="sec-2">The environment </h2>
<div class="outline-text-2" id="text-2">
<p>
I do not have a McMansion. In fact my house was built in the late late 19th century. This means that I have no idea what is in the walls, or how difficult it will be to run wires all over the place without making my house look like a mad scientist laboratory. This means that wireless is pretty much the only option for connectivity.
</p>
<p>
I have three rooms downstairs where I would like to play audio on the first floor. I would like to install this setup anywhere though. Listening to music while in the shower would be nice.
</p>
<p>
1st floor<br />
<a href="http://blogs.openaether.org/wp-content/uploads/2010/11/1stfloor.png"><img src="http://blogs.openaether.org/wp-content/uploads/2010/11/1stfloor-212x300.png" alt="" title="1stfloor" width="212" height="300" class="alignnone size-medium wp-image-218" /></a>
</p>
<p>
2nd floor<br />
<a href="http://blogs.openaether.org/wp-content/uploads/2010/11/2ndfloor.png"><img src="http://blogs.openaether.org/wp-content/uploads/2010/11/2ndfloor-212x300.png" alt="" title="2ndfloor" width="212" height="300" class="alignnone size-medium wp-image-219" /></a>
</p>
</div>
</div>
<div id="outline-container-3" class="outline-2">
<h2 id="sec-3">What exists now. </h2>
<div class="outline-text-2" id="text-3">
<p>
All infrastructure is in the office on the 2nd floor.
</p>
<p>
I have a 3TB nas that is plugged into the wired network and is available over wifi. My wifi is an ancient vanilla WRT54GL.  Signal reception is pretty good across the entire house. The laptops can play music off of the nfs share without any noticable problems.
</p>
<p>
I would like to upgrade the WRT54GL to 802.11n, but that thing is stable as hell and I am reluctant to touch it. </p>
<p>
I would also like to upgrade the wired network from 10/100Mbps to GigE, but that is for other reasons. (running vmware instances directly off the nas.)
</p>
<p>
The only thing out of the ordinary which might be notable is that we do not have a TV or audio system of any kind. The only electronics that we have are:
</p>
<ul>
<li>
5x laptops
</li>
<li>
3x rackmounted computers
</li>
<li>
1x iMac
</li>
<li>
1x 3TB rack mounted nas
</li>
<li>
1x n900,n810
</li>
<li>
2x standard lowend cell  phones</p>
</li>
</ul>
<p>All computers are running either gentoo or ubuntu with the singular exception of the iMac of course.
</p>
</div>
</div>
<div id="outline-container-4" class="outline-2">
<h2 id="sec-4">What I would like. </h2>
<div class="outline-text-2" id="text-4">
<p>
I would like to have a set of speakers in the following rooms:
</p>
<ul>
<li>
kitchen
</li>
<li>
dining room
</li>
<li>
living room</p>
</li>
</ul>
<p>If the system is cheap enough, I would like to add it to
</p>
<ul>
<li>
bath
</li>
<li>
bed rooms
</li>
<li>
office
</li>
</ul>
</div>
<div id="outline-container-4_1" class="outline-3">
<h3 id="sec-4_1">Hardware </h3>
<div class="outline-text-3" id="text-4_1">
<p>
Ideally, I would like a plug n play device. I can deal with a manual config system; ssh, http, config files on sd cards, whatever&hellip; As long as I don&#8217;t flip bits with toggle switches and patching kernel code, I am ok with it. (I should also add that I would prefer to not sift through gigs of forum posts to figure out how to get the device to work.)
</p>
<p>
To continue with my hardware minimilization things that it will need:
</p>
<ul>
<li>
power
</li>
<li>
audio out (preferable &#8216;standard&#8217;)
</li>
<li>
wifi (ethernet a plus)</p>
</li>
</ul>
<p>(the audio processing + cpu, etc&hellip; is implied).
</p>
<p>
As I have looked around I see a lot of these systems have &#8216;optical audio&#8217; yet I am unable to find speakers that have &#8216;optical&#8217; anything. I have come to the conclusion that you will then need some kind of receiver that will take the &#8216;optical&#8217; signals and transcode them into analog over the wire signal for speakers.  While it might be great, that is too much equipment to slap in 4-5 rooms.
</p>
<p>
So I want a small simple box I can plug speakers into.  Power + box + speakers.
</p>
</div>
</div>
<div id="outline-container-4_2" class="outline-3">
<h3 id="sec-4_2">Software </h3>
<div class="outline-text-3" id="text-4_2">
<p>
So this magical box has to <b>do</b> something. I don&#8217;t need it to store anything. And I don&#8217;t need it to organize anything. All I need this box to do is take audio data and make the speakers sound pretty.</p>
<p>
It could mount the shares via nfs,ftp,smb,etc&hellip; and keep some kind of continously updated catalog. This would mean some kind of control interface. I would prefer to avoid a broken and limited control interface.
</p>
<p>
It could also just listen on a stream and play whatever is shove down that, e.g. radio station lists per room/device.
</p>
<p>
Ideally the control interface would be 1) hackable 2) http based. (note: http != html)
</p>
</div>
</div>
</div>
<div id="outline-container-5" class="outline-2">
<h2 id="sec-5">Am I mud yet? </h2>
<div class="outline-text-2" id="text-5">
<p>
So yes, is that all clear as mud?  I want to avoid some proprietary crap device that will die in two years. Then I will be left with having to jailbreak it so it will work with the next codec. </p>
<p>
No, I do not want to deal with <a href="http://linuxmce.com/">http://linuxmce.com/</a>
</p>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blogs.openaether.org/?feed=rss2&#038;p=217</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
