<?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>the evolving ultrasaurus &#187; code</title>
	<atom:link href="http://www.ultrasaurus.com/sarahblog/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ultrasaurus.com</link>
	<description>Sarah Allen's reflections on internet software and other topics</description>
	<lastBuildDate>Wed, 22 May 2013 05:10:36 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>getting started with minecraft modding</title>
		<link>http://www.ultrasaurus.com/sarahblog/2013/03/getting-started-with-minecraft-modding/</link>
		<comments>http://www.ultrasaurus.com/sarahblog/2013/03/getting-started-with-minecraft-modding/#comments</comments>
		<pubDate>Mon, 01 Apr 2013 01:41:11 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://www.ultrasaurus.com/?p=3824</guid>
		<description><![CDATA[I started learning about creating a Minecraft mod today, using this excellent tutorial (thanks @0&#215;17h and @adudney).
Background: Minecraft is a very popular world-building game.  They announced last November that they will release an API, but they have a friendly attitude toward users who have reverse-engineered how to create &#8220;mods&#8221; (extensions to the game and [...]]]></description>
			<content:encoded><![CDATA[<p>I started learning about creating a Minecraft mod today, using this <a href="http://www.minecraftforge.net/wiki/Basic_Modding">excellent tutorial</a> (thanks <a href="https://twitter.com/0x17h">@0&#215;17h</a> and <a href="https://twitter.com/adudney">@adudney</a>).</p>
<p>Background: <a href="https://minecraft.net/">Minecraft</a> is a very popular world-building game.  They announced last November that they will release an API, but they have a friendly attitude toward users who have reverse-engineered how to create &#8220;mods&#8221; (extensions to the game and changes to the behavior of objects in the world).  <a href="http://www.minecraftforge.net/">Minecraft Forge</a> is the de-facto standard API toolkit for making mods.  </p>
<p>We found that the easiest way to run a server is to run it locally on an old MacBook, allowing external connections to connect to a <a href="http://www.noip.com/">noip</a> domain and tunnel into our home network. </p>
<p><strong>Prerequisites:</strong>We&#8217;re running Mac OSX SnowLeopard.  We need Java and the JDK, 1.6 or better.  </p>
<p>Check that java is installed</p>
<pre>
$ java -version
java version "1.6.0_37"
</pre>
<p>Check that the JDK is installed</p>
<pre>
$ javac -version
javac 1.6.0_37
</pre>
<p>We installed 64-bit version of Eclipse.  </p>
<p>Other than those platform-specific details that I had to look up, we had no problem following the <a href="http://www.minecraftforge.net/wiki/Basic_Modding">basic modding tutorial</a>.  The mod doesn&#8217;t do anything yet, but we can run minecraft and see it load:</p>
<p><img src="https://www.evernote.com/shard/s6/sh/53988b22-69d4-4697-8b20-30e7f972280c/ea226fa8a84f98a14dd5b31981c4e625/res/98cbe8d2-f482-4d89-9466-ad2c34e476cd/skitch.png?resizeSmall&#038;width=832"/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ultrasaurus.com/sarahblog/2013/03/getting-started-with-minecraft-modding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>d3.js experiments in the console</title>
		<link>http://www.ultrasaurus.com/sarahblog/2012/03/d3-js-experiments-in-the-console/</link>
		<comments>http://www.ultrasaurus.com/sarahblog/2012/03/d3-js-experiments-in-the-console/#comments</comments>
		<pubDate>Fri, 30 Mar 2012 20:39:44 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://www.ultrasaurus.com/?p=3573</guid>
		<description><![CDATA[d3 (aka Data-Driven Documents) is a great little JavaScript framework for data visualization.  It&#8217;s got a nice declarative syntax for DOM manipulation that&#8217;s quite readable, but takes a bit of effort to understand exactly what it&#8217;s doing.
Favorite links:

UPDATE: Dashing D3.js is an amazing series of tutorials with great conceptual grounding
d3 tutorials provide a great [...]]]></description>
			<content:encoded><![CDATA[<p>d3 (aka Data-Driven Documents) is a great little JavaScript framework for data visualization.  It&#8217;s got a nice declarative syntax for DOM manipulation that&#8217;s quite readable, but takes a bit of effort to understand exactly what it&#8217;s doing.</p>
<p>Favorite links:</p>
<ul>
<li>UPDATE: <a href="http://www.dashingd3js.com/">Dashing D3.js</a> is an amazing series of tutorials with great conceptual grounding</li>
<li><a href="http://mbostock.github.com/d3/api/">d3 tutorials</a> provide a great conceptual foundation</li>
<li><a href="http://bost.ocks.org/mike/join/">Thinking with Joins</a> by d3 creator, Mike Bostick, helps explain the syntax for chaining methods</li>
<li><a href="http://alignedleft.com/tutorials/d3/">Scott Murray&#8217;s d3 tutorial</a> offers a very nice step-by-step, covering a lot of the same ground as my little tutorial below with excellent discussions of the fundamentals.</li>
</ul>
<p>I like to understand stuff by playing with it interactively, so I created a skeleton index.html which just includes d3.js and a style a div where I&#8217;ll display some data.</p>
<p>UPDATE: blank file below posted <a href="http://ultrasaurus.github.com/d3js-examples/simple-div.html" window="_blank">here</a></p>
<pre>
&lt;html&gt;<br/>&nbsp;&nbsp;&lt;head&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;title&gt;d3&nbsp;experiment&lt;/title&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;script&nbsp;type=&quot;text/javascript&quot;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;src=&quot;https://raw.github.com/mbostock/d3/master/d3.js&quot;&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/script&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;style&nbsp;type=&quot;text/css&quot;&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.box&nbsp;{<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;background-color:&nbsp;skyblue;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;width:&nbsp;24px;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;height:&nbsp;18px;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;padding:&nbsp;4px;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;margin:&nbsp;1px;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/style&gt;<br/>&nbsp;&nbsp;&lt;/head&gt;<br/>&nbsp;&nbsp;&lt;body&gt;<br/>&nbsp;&nbsp;&lt;/body&gt;<br/>&lt;/html&gt;<br/><br/><br/><br/>
</pre>
<p>Then in the FireBug console, we can interact with d3, the top-level object that allows us to access all of d3&#8217;s goodness.</p>
<pre>
&gt;&gt;&gt; d3
Object { version="3.0.1", random={...}, ns={...}, more...}
&gt;&gt;&gt;  body = d3.select("body")
[[body]]
</pre>
<p>Like jQuery, d3 let&#8217;s us &#8220;select&#8221; one or more DOM elements to operate on them.  I only have one body tag, so I just get one element in an array &#8212; not yet sure why it needs a nested array.  Now I can manipulate the DOM:</p>
<pre>
&gt;&gt;&gt;  body.append('p').text('Hello d3!')
[[p]]
</pre>
<p>and &#8220;Hello d3!&#8221; appears at the top of my page.  Yay!  Of course that could have been written in a single line like:</p>
<pre>
d3.select("body").append('p').text('Hello d3!')
</pre>
<p>and if I want to change the text, I can use a regular old css selector to grab the paragraph element I just created:</p>
<pre>
d3.select("body p").text("Welcome to d3")
</pre>
<p>or, using the reference to the &#8216;body&#8217; variable I created above:</p>
<pre>
body.select("p").text("d3 is cool")
</pre>
<h2>Data-driven Boxes</h2>
<p>Ok, now that we understand the basics, let&#8217;s put some boxes on the page:</p>
<pre>
body.append('div').attr('class','box')
</pre>
<p>and let&#8217;s add a couple with text in them:</p>
<pre>
body.append('div').attr('class','box').text('hi')
body.append('div').attr('class','box').text('foo')
</pre>
<p>With my set of boxes, I can select one or all of them:</p>
<pre>
>>> d3.select('.box')
[[div.box]]
>>> d3.selectAll('.box')
[[div.box, div.box, div.box]]
</pre>
<p>Then I can specify data to <em>bind</em> to each box and display it.  I&#8217;ve read that d3 can deal with all sorts of data (like json, csv, etc.) but we&#8217;ll start with an array of numbers.</p>
<pre>
>>> my_data = [20, 7, 32]
[20, 7, 32]
>>> d3.selectAll('.box').data(my_data).text( function(d) { return d } )
[[div.box, div.box, div.box]]
</pre>
<p><img src="https://img.skitch.com/20120330-jb12cx9qa7p16diptgy6kqjq6c.png"/><br />
<img src="https://img.skitch.com/20120330-qhkt419gnaqh2d9f5s53xns6nh.png"/></p>
<p>We can see that our data is associated with the DOM element and we can get at it via JavaScript in the console.  (Of course, we should only do that for debugging. I would guess that __data__ is the private implementation of d3&#8217;s data binding.)</p>
<pre>
>>> d3.select('.box')[0][0].__data__
20
</pre>
<p>We can change the data like this:</p>
<pre>
>>> new_data = [10, 50, 25]
[10, 50, 25]
>>> d3.selectAll('.box').data(new_data)
</pre>
<p>You&#8217;ll see that the page doesn&#8217;t change visually, but in the console, you can see that the data does:<br />
<img src="https://img.skitch.com/20120330-kwnsfr1kiuaskauqeruib7in3d.png"/></p>
<p>We need to explicitly tell d3 to do something with the data like this:</p>
<pre>
d3.selectAll('.box').text( function(d) { return d } )
</pre>
<p>We can also use this handy shortcut:</p>
<pre>
d3.selectAll('.box').text( String )
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ultrasaurus.com/sarahblog/2012/03/d3-js-experiments-in-the-console/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>fixing brew install opencv on osx</title>
		<link>http://www.ultrasaurus.com/sarahblog/2012/03/fixing-brew-install-opencv/</link>
		<comments>http://www.ultrasaurus.com/sarahblog/2012/03/fixing-brew-install-opencv/#comments</comments>
		<pubDate>Fri, 30 Mar 2012 11:46:27 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://www.ultrasaurus.com/?p=3583</guid>
		<description><![CDATA[This is more about fixing my brew install, than about opencv.  As with many install issues the root cause was actually pretty simple, but finding it was challenging.  Along the way, I fixed a number of issues which took a bit of digging to find, so I&#8217;m leaving a little trail on the [...]]]></description>
			<content:encoded><![CDATA[<p>This is more about fixing my brew install, than about opencv.  As with many install issues the root cause was actually pretty simple, but finding it was challenging.  Along the way, I fixed a number of issues which took a bit of digging to find, so I&#8217;m leaving a little trail on the web in case other people run into the same things &#8212; or in case some inspired open source citizen has time to add better solution messages to brew.  The first step of any solution, is, of course, understanding the problem.</p>
<p>$ brew install opencv<br />
==> Installing opencv dependency: cmake<br />
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/cmake-2.8.7-bottle.tar.gz<br />
######################################################################## 100.0%<br />
Error: SHA1 mismatch<br />
Expected: f218ed64ce6e7a5d3670acdd6a18e5ed95421d1f<br />
Got: 3a57f6f44186e0dba34ef8b8fb4a9047e9e5d8a3</p>
<p>solution:<br />
$ brew update<br />
	:<br />
	:<br />
Error: Failed executing: make install (libtiff.rb:18)<br />
If `brew doctor&#8217; does not help diagnose the issue, please report the bug:<br />
    https://github.com/mxcl/homebrew/wiki/reporting-bugs</p>
<h2>tl;dr;<br/>install command-line tools from developer.apple.com</h2>
<p>before I figured that out I fixed all of the issues found with &#8216;brew doctor&#8217;</p>
<p>$ brew doctor</p>
<p>Warning: Some directories in /usr/local/share/man aren&#8217;t writable.<br />
This can happen if you &#8220;sudo make install&#8221; software that isn&#8217;t managed<br />
by Homebrew. If a brew tries to add locale information to one of these<br />
directories, then the install will fail during the link step.<br />
You should probably `chown` them:</p>
<p>    /usr/local/share/man/de<br />
    /usr/local/share/man/de/man1</p>
<p>solution:<br />
$ sudo chown sarah /usr/local/share/man/de/*<br />
$ sudo chown sarah /usr/local/share/man/*</p>
<p>Warning: &#8220;config&#8221; scripts exist outside your system or Homebrew directories.<br />
`./configure` scripts often look for *-config scripts to determine if<br />
software packages are installed, and what additional flags to use when<br />
compiling and linking.</p>
<p>Having additional scripts in your path can confuse software installed via<br />
Homebrew if the config script overrides a system or Homebrew provided<br />
script of the same name. We found the following &#8220;config&#8221; scripts:</p>
<p>    /Library/Frameworks/Python.framework/Versions/2.7/bin/python-config<br />
    /Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config</p>
<p>solution:<br />
Uninstalled python, which I don&#8217;t use much &#8212; I figure I can install later with brew<br />
$ sudo rm -rf /Library/Frameworks/Python.framework/Versions/2.7<br />
$ sudo rm -rf /Library/Frameworks/Python.framework/Versions/2.7<br />
$ sudo rm -rf &#8220;/Applications/Python 2.7&#8243;<br />
$ sudo rm /usr/local/bin/py*</p>
<p>Warning: You have unlinked kegs in your Cellar<br />
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on<br />
those kegs to fail to run properly once built.</p>
<p>    coreutils<br />
    geoip</p>
<p>solution:<br />
$ brew link coreutils<br />
Linking /usr/local/Cellar/coreutils/8.12&#8230; 0 symlinks created<br />
$ brew link geoip<br />
Linking /usr/local/Cellar/geoip/1.4.6&#8230; 2 symlinks created</p>
<p>Warning: You have uncommitted modifications to Homebrew&#8217;s core.<br />
Unless you know what you are doing, you should run:<br />
  cd /usr/local &#038;&#038; git reset &#8211;hard</p>
<p>tried this:<br />
$ cd /usr/local &#038;&#038; git reset &#8211;hard<br />
HEAD is now at ffb9aa5 Remove &#8220;__brew_ps1&#8243; function from completion<br />
&#8211;> didn&#8217;t work</p>
<p>solution:<br />
$ pushd /usr/local<br />
$ git status<br />
&#8211;> lots of untracked files, no idea how I got into that state<br />
$ git add .<br />
$ git reset HEAD &#8211;hard<br />
$ popd</p>
<p>Warning: Your Xcode is configured with an invalid path.<br />
You should change it to the correct path. Please note that there is no correct<br />
path at this time if you have *only* installed the Command Line Tools for Xcode.<br />
If your Xcode is pre-4.3 or you installed the whole of Xcode 4.3 then one of<br />
these is (probably) what you want:</p>
<p>    sudo xcode-select -switch /Developer<br />
    sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer</p>
<p>DO NOT SET / OR EVERYTHING BREAKS!</p>
<p>I don&#8217;t have anything at /Developer, so I did this:<br />
$  sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer</p>
<p>$ brew doctor<br />
Your system is raring to brew.</p>
<p>Of course, it wasn&#8217;t, the key clue for me was finding this in the long stream of installation output:<br />
tiffgt.c:35:11: fatal error: &#8216;OpenGL/gl.h&#8217; file not found</p>
<p>which convinced me that I was missing some fundamentals.  Searching on the text of the error led me to:<br />
<a href="https://github.com/mxcl/homebrew/issues/11088">https://github.com/mxcl/homebrew/issues/11088</a></p>
<p>Ideally &#8216;brew doctor&#8217; would have caught that I was missing the command-line tools that don&#8217;t get installed automatically with XCode 4.3.  I installed those and all was well.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ultrasaurus.com/sarahblog/2012/03/fixing-brew-install-opencv/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>cucumber and custom rspec matchers with rails 3.1</title>
		<link>http://www.ultrasaurus.com/sarahblog/2012/01/cucumber-and-custom-rspec-matchers-with-rails-3-1/</link>
		<comments>http://www.ultrasaurus.com/sarahblog/2012/01/cucumber-and-custom-rspec-matchers-with-rails-3-1/#comments</comments>
		<pubDate>Sun, 22 Jan 2012 16:40:52 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://www.ultrasaurus.com/?p=3548</guid>
		<description><![CDATA[I&#8217;m working my way through an epic Rails 3.1 upgrade and some of my cucumber features were failing because I was using a custom RSpec matcher and the method wasn&#8217;t found.
My custom matcher looks something like this:

module CustomMatchers

  class XmlSubsetMatcher
      :
  end

  def be_xml_subset_of(expected)
    [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m working my way through an epic Rails 3.1 upgrade and some of my cucumber features were failing because I was using a custom RSpec matcher and the method wasn&#8217;t found.</p>
<p>My custom matcher looks something like this:</p>
<pre>
module CustomMatchers

  class XmlSubsetMatcher
      :
  end

  def be_xml_subset_of(expected)
    XmlSubsetMatcher.new(expected)
  end
</pre>
<p>and when I ran my feature I was getting this failure:<br />
<code><br />
      undefined method `xml_subset_of?' for #<String:0x007f9839d30378> (NoMethodError)<br />
</code></p>
<p>As it turns out, in my zeal to make sure everything was using the latest and great new stuff, I had forgotten to move over this critical configuration line in cucumbers env.rb:</p>
<p><code><br />
World(CustomMatchers)<br />
</code></p>
<p>Now, my cucumber feature is happily failing cuz my code doesn&#8217;t work. Whew.  I couldn&#8217;t find this documented anywhere and I&#8217;m not even sure where this documentation would belong.  I found a hint on the <a href="https://github.com/cucumber/cucumber/wiki/RSpec-Expectations">cucumber wiki rspec expectations page</a>, but none of the code on that page is actually needed when using cucumber with Rails, so I decided not to touch it and just write this blog post.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ultrasaurus.com/sarahblog/2012/01/cucumber-and-custom-rspec-matchers-with-rails-3-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ffmpeg on osx lion</title>
		<link>http://www.ultrasaurus.com/sarahblog/2012/01/ffmpeg-on-osx-lion/</link>
		<comments>http://www.ultrasaurus.com/sarahblog/2012/01/ffmpeg-on-osx-lion/#comments</comments>
		<pubDate>Sun, 08 Jan 2012 05:40:37 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://www.ultrasaurus.com/?p=3537</guid>
		<description><![CDATA[I found that I needed to convert an m4a audio file (which is what QuickTime saves when I record audio) to a wav file, so I decided to use my favorite &#8220;can opener.&#8221; The versatile open source ffmpeg tool has always seemed to be able to convert anything to anything in audio-video formats.
I decided to [...]]]></description>
			<content:encoded><![CDATA[<p>I found that I needed to convert an m4a audio file (which is what QuickTime saves when I record audio) to a wav file, so I decided to use my favorite &#8220;can opener.&#8221; The versatile open source <a href="http://ffmpeg.org">ffmpeg</a> tool has always seemed to be able to convert anything to anything in audio-video formats.</p>
<p>I decided to pull the source from git:<br />
<code><br />
$ git clone git://source.ffmpeg.org/ffmpeg.git<br />
$ cd ffmpeg/<br />
</code></p>
<p>Stable versions are tagged (which I could see with &#8220;git tag -l&#8221;).  I don&#8217;t need to live on the edge right now, so I switched to the tag &#8220;n0.9.1&#8243; which I assume is for the latest stable build &#8220;harmony&#8221; 0.9.1 and made a local branch based on that.<br />
<code><br />
$ git co n0.9.1<br />
$ git checkout -b n0.9.1<br />
</code></p>
<p>Instructions for building ffmpeg are in the &#8220;INSTALL&#8221; file.  I discovered I needed yasm, which I could install with brew.  Here&#8217;s what I did:<br />
<code><br />
$  brew install yasm<br />
$  ./configure<br />
$ make<br />
CC	libavdevice/alldevices.o<br />
CC	libavdevice/avdevice.o<br />
CC	libavdevice/lavfi.o<br />
AR	libavdevice/libavdevice.a<br />
CC	libavfilter/af_aconvert.o<br />
libavfilter/af_aconvert.c:53: warning: function declaration isn’t a prototype<br />
libavfilter/af_aconvert.c:105: warning: function declaration isn’t a prototype<br />
CC	libavfilter/af_aformat.o<br />
CC	libavfilter/af_anull.o<br />
CC	libavfilter/af_aresample.o<br />
    :<br />
   :<br />
ffserver.c: In function ‘parse_ffconfig’:<br />
ffserver.c:4236: warning: ‘avcodec_get_context_defaults2’ is deprecated (declared at ./libavcodec/avcodec.h:3948)<br />
ffserver.c:4237: warning: ‘avcodec_get_context_defaults2’ is deprecated (declared at ./libavcodec/avcodec.h:3948)<br />
LD	ffserver_g<br />
CP	ffserver<br />
STRIP	ffserver<br />
</code><br />
I saw a lot of warnings, but they didn&#8217;t seem to negatively affect what I was trying to do.  I found a <a href="http://www.catswhocode.com/blog/19-ffmpeg-commands-for-all-needs">nice blog post from catswhocode</a> to remind me of the usage, and was able to use this simple command:</p>
<p><code><br />
$ ./ffmpeg -i frog.m4a frog.wav<br />
ffmpeg version 0.9.1, Copyright (c) 2000-2012 the FFmpeg developers<br />
  built on Jan  7 2012 21:19:08 with llvm_gcc 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)<br />
  configuration:<br />
  libavutil    51. 32. 0 / 51. 32. 0<br />
  libavcodec   53. 42. 4 / 53. 42. 4<br />
  libavformat  53. 24. 2 / 53. 24. 2<br />
  libavdevice  53.  4. 0 / 53.  4. 0<br />
  libavfilter   2. 53. 0 /  2. 53. 0<br />
  libswscale    2.  1. 0 /  2.  1. 0<br />
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'frog.m4a':<br />
  Metadata:<br />
    major_brand     : M4A<br />
    minor_version   : 0<br />
    compatible_brands: M4V M4A mp42isom<br />
    creation_time   : 2012-01-08 05:09:05<br />
  Duration: 00:00:07.22, start: 0.000000, bitrate: 206 kb/s<br />
    Stream #0:0(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, s16, 201 kb/s<br />
    Metadata:<br />
      creation_time   : 2012-01-08 05:09:05<br />
      handler_name    :<br />
Output #0, wav, to 'frog.wav':<br />
  Metadata:<br />
    major_brand     : M4A<br />
    minor_version   : 0<br />
    compatible_brands: M4V M4A mp42isom<br />
    creation_time   : 2012-01-08 05:09:05<br />
    encoder         : Lavf53.24.2<br />
    Stream #0:0(und): Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, stereo, s16, 1411 kb/s<br />
    Metadata:<br />
      creation_time   : 2012-01-08 05:09:05<br />
      handler_name    :<br />
Stream mapping:<br />
  Stream #0:0 -> #0:0 (aac -> pcm_s16le)<br />
Press [q] to stop, [?] for help<br />
size=    1244kB time=00:00:07.22 bitrate=1411.3kbits/s<br />
video:0kB audio:1244kB global headers:0kB muxing overhead 0.003611%</p>
<p>$ ls<br />
frog.m4a  frog.wav<br />
</code></p>
<p>Success!!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ultrasaurus.com/sarahblog/2012/01/ffmpeg-on-osx-lion/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>rails 3.0 and rake 0.9.2</title>
		<link>http://www.ultrasaurus.com/sarahblog/2011/09/rails-3-0-and-rake-0-9-2/</link>
		<comments>http://www.ultrasaurus.com/sarahblog/2011/09/rails-3-0-and-rake-0-9-2/#comments</comments>
		<pubDate>Sun, 11 Sep 2011 16:37:17 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://www.ultrasaurus.com/?p=3401</guid>
		<description><![CDATA[I really want to upgrade a Rails 3.0 project to Rails 3.1, but I&#8217;ve done a few spikes and it lacks test coverage, so I decided to pull in cucumber and write some features before moving forward.
I added cucumber-rails to my gemfile, and ran &#8220;bundle&#8221; and got this error:

/Users/sarah/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:289:in `load': uninitialized constant Psych::Syck (NameError)

What I [...]]]></description>
			<content:encoded><![CDATA[<p>I really want to upgrade a Rails 3.0 project to Rails 3.1, but I&#8217;ve done a few spikes and it lacks test coverage, so I decided to pull in cucumber and write some features before moving forward.</p>
<p>I added cucumber-rails to my gemfile, and ran &#8220;bundle&#8221; and got this error:</p>
<pre>
/Users/sarah/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:289:in `load': uninitialized constant Psych::Syck (NameError)
</pre>
<p>What I really needed was to <a href="http://blog.rubygems.org/2011/08/31/shaving-the-yaml-yacc.html">update my Ruby Gems</a> (bundle update &#8211;system) but before I discovered that I did &#8220;bundle update&#8221; which moved me forward to rake 0.9.2, so I started getting these warnings:</p>
<pre>
/Users/sarah/.rvm/gems/ruby-1.9.2-p290@pie-bakery/gems/psych-1.2.1/lib/psych.rb:93: warning: already initialized constant VERSION
/Users/sarah/.rvm/gems/ruby-1.9.2-p290@pie-bakery/gems/psych-1.2.1/lib/psych.rb:96: warning: already initialized constant LIBYAML_VERSION
WARNING: Global access to Rake DSL methods is deprecated.  Please include
...  Rake::DSL into classes and modules which use the Rake DSL methods.
WARNING: DSL method Bakery::Application#task called at /Users/sarah/.rvm/gems/ruby-1.9.2-p290@pie-bakery/gems/railties-3.0.0/lib/rails/application.rb:214:in `initialize_tasks'
</pre>
<p>So, I&#8217;ve learned from google, stackoverflow, various blogs and my twitter friend <a href="http://twitter.com/#!/excid3">@excid3</a> that I need to update my Rakefile to include:</p>
<pre>
require 'rake/dsl_definition'
require 'rake'
include Rake::DSL
</pre>
<p>That lets me use rake (yay!).  I still have the following two warnings:</p>
<pre>
/Users/sarah/.rvm/gems/ruby-1.9.2-p290@pie-bakery/gems/psych-1.2.1/lib/psych.rb:93: warning: already initialized constant VERSION
/Users/sarah/.rvm/gems/ruby-1.9.2-p290@pie-bakery/gems/psych-1.2.1/lib/psych.rb:96: warning: already initialized constant LIBYAML_VERSION
</pre>
<p>which I&#8217;m hoping will go away with the Rails 3.1 upgrade, but I thought I would write up the rest of it in case it helps other wayward souls on their journey.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ultrasaurus.com/sarahblog/2011/09/rails-3-0-and-rake-0-9-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>what exactly does rake spec do?</title>
		<link>http://www.ultrasaurus.com/sarahblog/2011/05/what-exactly-does-rake-spec-do/</link>
		<comments>http://www.ultrasaurus.com/sarahblog/2011/05/what-exactly-does-rake-spec-do/#comments</comments>
		<pubDate>Sun, 08 May 2011 21:41:35 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://www.ultrasaurus.com/?p=3164</guid>
		<description><![CDATA[$ rake spec
(in /Users/sarah/src/../my_app)
You have 1 pending migrations:
  20110416135407 CreateCourses
The rake spec command reminds us that we need to run our migration before running
our tests. In fact, it does a whole lot more than that. There are a whole bunch of best practices rolled in that one
command. To see exactly what is going on, [...]]]></description>
			<content:encoded><![CDATA[<p>$ rake spec<br />
(in /Users/sarah/src/../my_app)<br />
You have 1 pending migrations:<br />
  20110416135407 CreateCourses</p>
<p>The <commandname>rake spec</commandname> command reminds us that we need to run our migration before running<br />
our tests. In fact, it does a whole lot more than that. There are a whole bunch of best practices rolled in that one<br />
command. To see exactly what is going on, we can run <commandname>rake spec</commandname> with the <ic>&#8211;trace</ic><br />
option:</p>
<p><code language="session"><br />
$ rake spec --trace<br />
(in /Users/sarah/src/tfr/svn/Book/code/class_app_new_source)<br />
** Invoke spec (first_time)<br />
** Invoke db:test:prepare (first_time)<br />
** Invoke db:abort_if_pending_migrations (first_time)<br />
** Invoke environment (first_time)<br />
** Execute environment<br />
** Execute db:abort_if_pending_migrations<br />
** Execute db:test:prepare<br />
** Invoke db:test:load (first_time)<br />
** Invoke db:test:purge (first_time)<br />
** Invoke environment<br />
** Execute db:test:purge<br />
** Execute db:test:load<br />
** Invoke db:schema:load (first_time)<br />
** Invoke environment<br />
** Execute db:schema:load<br />
** Execute spec<br />
</code></p>
<p>When it says <ic>invoke</ic> it is calling a particular rake task, but then it will call its dependencies. To really see what is happening in what order, check out the <ic>execute</ic> commands.  The commands db:test:prepare and db:test:load don’t do much themselves, aside from setting up the environment and executing another task or two.  We can see from the output that rake is actually executing the following steps:</p>
<ol>
<li>
<p>
Don’t run the specs if there are pending migrations in the development database. (db:abort_if_pending_migrations)
</p>
</li>
<li>
<p>
Drop the test database (db:test:purge)
</p>
</li>
<li>
<p>
Load the schema into the test database (db:schema:load in environment “test”)
</p>
</li>
</ol>
<p>These steps make sure that we are always testing in a clean environment, so we know exactly what we’re testing when we run our specs.</p>
<p>The code that makes this happen in Rails 3, can now be found in <a href="https://github.com/rails/rails/blob/master/activerecord/lib/active_record/railties/databases.rake#L455">railties</a>.  (Thanks to <a href="http://twitter.com/pixeltrix">@pixeltrix</a> for pointing me to it.)/62206174505873408</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ultrasaurus.com/sarahblog/2011/05/what-exactly-does-rake-spec-do/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>repl rspec mocks</title>
		<link>http://www.ultrasaurus.com/sarahblog/2011/04/repl-rspec-mocks/</link>
		<comments>http://www.ultrasaurus.com/sarahblog/2011/04/repl-rspec-mocks/#comments</comments>
		<pubDate>Tue, 05 Apr 2011 01:59:19 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://www.ultrasaurus.com/?p=3127</guid>
		<description><![CDATA[REPL (Read-Eval-Print-Loop) is a great way to learn.  With Ruby, the experience is enabled with irb.  Sometimes, to do this we need to peek into the innards of things, which I find to be an extremely effective way to explain mocks and stubs.  It&#8217;s a regular part of my Ruby curriculum, even [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Read-eval-print_loop">REPL</a> (Read-Eval-Print-Loop) is a great way to learn.  With Ruby, the experience is enabled with irb.  Sometimes, to do this we need to peek into the innards of things, which I find to be an extremely effective way to explain mocks and stubs.  It&#8217;s a regular part of my Ruby curriculum, even though I have needed to figure out the syntax three times in the last couple of years.  (Many thanks to Jen-Mei Wu for the most recent iteration.)  I still think it is worth it, even though it seems to change with crazy frequency.  </p>
<p>Just in case anyone else ever wants to do this with current or previous versions of RSpec, I thought I would write it down before old versions become lost in the mists of time:</p>
<h2>RSpec 2.9</h2>
<p>[update for <a href="http://blog.blazingcloud.net/2012/04/14/repl-mocks-in-rspec-2-9/">repl mocks for RSpec 2.9 by Curtis Schofield</a>]</p>
<pre>
>> require 'rspec/mocks/standalone'
>>Time.stub(:now).and_return(10,20)
>>Time.now
10
>>Time.now
20
>>Time.now
20
 </pre>
<h2>RSpec 2.5</h2>
<pre>
>> require 'rspec/mocks'
>> include RSpec::Mocks::Methods
>>Time.stub(:now).and_return(10,20)
>>Time.now
10
>>Time.now
20
>>Time.now
20
</pre>
<h2>RSpec 2.0</h2>
<pre>
>> require 'rspec/mocks'
>> require 'rspec/mocks/extensions/object'
>>Time.stub(:now).and_return(10,20)
>>Time.now
10
>>Time.now
20
>>Time.now
20
</pre>
<h2>RSpec 1.3</h2>
<pre>
>> require 'spec'
>> require 'spec/mocks'
>>Time.stub(:now).and_return(10,20)
>>Time.now
10
>>Time.now
20
>>Time.now
20
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ultrasaurus.com/sarahblog/2011/04/repl-rspec-mocks/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>rails 3 vs. rails 2 validation errors</title>
		<link>http://www.ultrasaurus.com/sarahblog/2010/09/rails-3-vs-rails-2-validation-errors/</link>
		<comments>http://www.ultrasaurus.com/sarahblog/2010/09/rails-3-vs-rails-2-validation-errors/#comments</comments>
		<pubDate>Tue, 07 Sep 2010 10:14:06 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://www.ultrasaurus.com/?p=2795</guid>
		<description><![CDATA[Not sure if this is a bug or a feature.  I&#8217;d guess it is here for a reason, and maybe I&#8217;m late for noticing, but Rails 3 errors now provides an array for each attribute, whereas in Rails 2.3 it was just a string.  Here&#8217;s the output from two almost identical applications&#8230;
Loading development environment [...]]]></description>
			<content:encoded><![CDATA[<p>Not sure if this is a bug or a feature.  I&#8217;d guess it is here for a reason, and maybe I&#8217;m late for noticing, but Rails 3 errors now provides an array for each attribute, whereas in Rails 2.3 it was just a string.  Here&#8217;s the output from two almost identical applications&#8230;</p>
<p>Loading development environment (Rails 2.3.8)<br />
&gt;&gt; person = Person.new<br />
=&gt; #&lt;Person id: nil, first_name: nil, last_name: nil, present: nil&#8230;<br />
&gt;&gt; person.valid?<br />
=&gt; false<br />
&gt;&gt; person.errors<br />
=&gt; #&lt;ActiveRecord::Errors:0&#215;1034d8f10 @errors=#&lt;OrderedHash &#8230;<br />
&gt;&gt; person.errors[:first_name]<br />
=&gt; &#8220;can&#8217;t be blank&#8221;</p>
<p>Loading development environment (Rails 3.0.0)<br />
&gt;&gt; person = Person.new<br />
=&gt; #&lt;Person id: nil, first_name: nil, last_name: nil, present: nil&#8230;<br />
&gt;&gt; person.valid?<br />
=&gt; false<br />
&gt;&gt; person.errors<br />
=&gt; {:first_name=&gt;["can't be blank"]}<br />
&gt;&gt; person.errors.class<br />
=&gt; ActiveModel::Errors<br />
&gt;&gt; person.errors[:first_name]<br />
=&gt; ["can't be blank"]</p>
<p>I didn&#8217;t see that in the release notes, but it failed my tests for ActiveRecord class.  Someone else must have a list of these details, yes?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ultrasaurus.com/sarahblog/2010/09/rails-3-vs-rails-2-validation-errors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>rails security review checklist</title>
		<link>http://www.ultrasaurus.com/sarahblog/2010/01/rails-security-review-checklist/</link>
		<comments>http://www.ultrasaurus.com/sarahblog/2010/01/rails-security-review-checklist/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 08:00:12 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://www.ultrasaurus.com/?p=2378</guid>
		<description><![CDATA[I&#8217;m reviewing the security of a web app built with Ruby on Rails, so I put together a checklist for a security audit.  This isn&#8217;t a bank or high security situation, but there were a number of engineers and quite a bit of open source code, so I thought a few checks were in [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m reviewing the security of a web app built with Ruby on Rails, so I put together a checklist for a security audit.  This isn&#8217;t a bank or high security situation, but there were a number of engineers and quite a bit of open source code, so I thought a few checks were in order.</p>
<p>Here&#8217;s the list I came up with that I thought other folks might appreciate as a starting point (special thanks to the sfruby list, <a href="http://afreshcup.com/">Mike Gunderloy</a>, and Scott Bronson for feedback):</p>
<p>0) Make sure your Rails and gems are up to date for latest security patches (see <a href="http://groups.google.com/group/rubyonrails-security">rails security mailing list</a> for recent advisory notes)</p>
<p>1) Active Record audit:<br />
&nbsp;&nbsp;A) SQL injection:<br />
&nbsp;&nbsp;&nbsp;&nbsp;(i) whole word search for &#8220;find&#8221;, &#8220;first&#8221;, and &#8220;all&#8221; then visually inspect all instances of ActiveRecord find calls for potential SQL injection vulnerability (also search for &#8220;sql&#8221; not whole work search to find find_by_sql and &#8220;execute&#8221; to find cases where raw sql is executed.<br />
&nbsp;&nbsp;&nbsp;&nbsp;(ii) search your models for &#8220;named_scope&#8221; and check :conditions<br />
&nbsp;&nbsp;B) check for <a href="http://railspikes.com/2008/9/22/is-your-rails-application-safe-from-mass-assignment">mass assignment</a>  Either disable mass assignment as Eric suggests in his article, or audit its use.  If doing an audit, check every model to make sure it declares which attributes are settable with attr_accessible.  (While attr_protected may technically work, a white list approach is recommended by security experts and the <a href="http://groups.google.com/group/rubyonrails-security/browse_thread/thread/42c4d5d3b7354735">rails security advisory</a> on this topic)</p>
<p>2) Scripting attack: search all eRB files for &lt;%= and ensure that if dynamically generated text was originally entered by the user, it is HTML escaped. Consider <a href="http://github.com/nzkoz/rails_xss">rails_xss</a></p>
<p>3) Secure Access: If some of the site does not have public access, check controllers and ensure that public actions are specifically allowed and that protected access is the default</p>
<p>4) search for &#8220;eval&#8221; (whole word) and verify that  usages are safe (assume javascript eval is ok)</p>
<p>5) search for &#8220;forgery&#8221; (not whole word), make sure that<br />
config.action_controller.allow_forgery_protection    = false<br />
is only disabled in test config<br />
 protect_from_forgery should be in the ApplicationController, unless there is a good reason for it not to be</p>
<p>6) check user auth and review that controller actions are limited to expected use</p>
<p>7) passwords: not saved as clear-text in the db, not logged</p>
<p>8) check that private data is not stored in cookies </p>
]]></content:encoded>
			<wfw:commentRss>http://www.ultrasaurus.com/sarahblog/2010/01/rails-security-review-checklist/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
