<?xml version="1.0" encoding="UTF-8"?>
<rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>gnuu.org</title>
	<atom:link href="http://gnuu.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://gnuu.org</link>
	<description>my word against yours, fight.</description>
	<lastBuildDate>Sat, 07 Nov 2009 04:14:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>Get Ruby 1.9, Rails, MySQL and UTF-8 to Work Together</title>
		<link>http://feedproxy.google.com/~r/connectnothing/~3/RL5bkqVJqVs/</link>
		<comments>http://gnuu.org/2009/11/06/ruby19-rails-mysql-utf8/#comments</comments>
		<pubDate>Sat, 07 Nov 2009 02:01:33 +0000</pubDate>
		<dc:creator>Loren Segal</dc:creator>
				<category><![CDATA[post]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby 1.9]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[unicode]]></category>
		<category><![CDATA[utf-8]]></category>

		<guid isPermaLink="false">http://gnuu.org/2009/11/06/get-ruby-1-9-rails-mysql-and-utf-8-to-work-together/</guid>
		<description><![CDATA[Here&#8217;s a quick little hack to get MySQL 2.8.1 using UTF-8 in Rails 2.3.4 and Ruby 1.9.1.
Filename: lib/mysql_utf8.rb


Put that snippet in your Rails project (I used lib/mysql_utf8.rb) and load it in your environment.
That's all. Now your queries should use Unicode:
$ ./script/console
Loading development environment (Rails 2.3.4)
&#62;&#62; u = User.find(1)
=&#62; #&#60;User id: 1, name: &#34;Test&#34;, ...&#62;
&#62;&#62; u.name.encoding
=&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a quick little hack to get MySQL 2.8.1 using UTF-8 in Rails 2.3.4 and Ruby 1.9.1.</p>
<p class="note">Filename: lib/mysql_utf8.rb</p>
<p><script src="http://gist.github.com/228455.js"></script></p>
<p><!--
<pre class="sh_ruby">class Mysql::Result
  def encode(value, encoding = &#8220;utf-8&#8243;)
    String === value ? value.force_encoding(encoding) : value
  end

  def each_utf8(&#038;block)
    each_orig do |row|
      yield row.map {|col| encode(col) }
    end
  end
  alias each_orig each
  alias each each_utf8

  def each_hash_utf8(&#038;block)
    each_hash_orig do |row|
      row.each {|k, v| row[k] = encode(v) }
      yield(row)
    end
  end
  alias each_hash_orig each_hash
  alias each_hash each_hash_utf8
end</pre>
<p>--></p>
<p>Put that snippet in your Rails project (I used <tt>lib/mysql_utf8.rb</tt>) and load it in your environment.</p>
<p>That's all. Now your queries should use Unicode:</p>
<pre class="sh_ruby">$ ./script/console
Loading development environment (Rails 2.3.4)
&gt;&gt; u = User.find(1)
=&gt; #&lt;User id: 1, name: &quot;Test&quot;, ...&gt;
&gt;&gt; u.name.encoding
=&gt; #&lt;Encoding:ASCII-8BIT&gt;
&gt;&gt; require 'lib/mysql_utf8'
=&gt; []
&gt;&gt; u = User.find(1)
=&gt; #&lt;User id: 1, name: &quot;Test&quot;, ...&gt;
&gt;&gt; u.name.encoding
=&gt; #&lt;Encoding:UTF-8&gt;</pre>
<p>Note that if you have BLOB types in MySQL you’ll need to force_encoding back to another type. You could do this in your model.</p>
<p><strong>Update:</strong> You can also try out my <a href="http://github.com/lsegal/mysql-ruby">fork of mysql-ruby</a> that is properly encoding aware. It doesn't just convert everything to UTF-8, but rather to your default encoding, so make sure to <a href="http://gnuu.org/2009/11/02/ruby-1-9-encoding-issues-again/">set your LANG</a>!</p><img src="http://feeds.feedburner.com/~r/connectnothing/~4/RL5bkqVJqVs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://gnuu.org/2009/11/06/ruby19-rails-mysql-utf8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://gnuu.org/2009/11/06/ruby19-rails-mysql-utf8/</feedburner:origLink></item>
		<item>
		<title>Ruby 1.9 Encoding Issues, Again.</title>
		<link>http://feedproxy.google.com/~r/connectnothing/~3/4rdL4sChKUA/</link>
		<comments>http://gnuu.org/2009/11/02/ruby-1-9-encoding-issues-again/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 04:45:39 +0000</pubDate>
		<dc:creator>Loren Segal</dc:creator>
				<category><![CDATA[post]]></category>
		<category><![CDATA[encoding]]></category>
		<category><![CDATA[problems]]></category>
		<category><![CDATA[ruby 1.9]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[unicode]]></category>

		<guid isPermaLink="false">http://gnuu.org/2009/11/02/ruby-1-9-encoding-issues-again/</guid>
		<description><![CDATA[I covered Ruby 1.9 encodings a while back on my blog, but apparently I left out a few other major issues. I noticed these just recently, when running 1.9 on a new environment. It turns out, tweaking your environment is all it takes to fix most of the issues, and I had already done this [...]]]></description>
			<content:encoded><![CDATA[<p>I covered Ruby 1.9 encodings <a href="http://gnuu.org/2009/02/02/ruby-19-common-problems-pt-1-encoding/">a while back</a> on my blog, but apparently I left out a few other major issues. I noticed these just recently, when running 1.9 on a new environment. It turns out, tweaking your environment is all it takes to fix most of the issues, and I had already done this on my main machine.</p>
<p>So here we go, the issue:</p>
<h3>You’re using Rails, and you see this:</h3>
<blockquote><p>invalid byte sequence in US-ASCII</p>
</blockquote>
<p>You might also see:</p>
<blockquote><p>incompatible character encodings: ASCII-8BIT and UTF-8</p>
</blockquote>
<p>That happens <em>all the time</em> when trying to get <a href="http://yard.soen.ca">YARD</a> to parse Rails source. It also happens when your ERB templates and your DB data have mismatched encodings.</p>
<h3>The Problem</h3>
<p> Ruby has multiple default encoding values: internal (the default encoding for new String objects), external (the default encoding for file data), and script (the default encoding of the content of Ruby scripts). When dealing with IO, you need to make sure both your internal and external encodings match up, especially since Ruby defaults to ASCII-7BIT and not UTF-8. The “script” encoding problems were covered in my <a href="http://gnuu.org/2009/02/02/ruby-19-common-problems-pt-1-encoding/">last blog post</a> on the subject.&#160;<br />
<h3>The Fix</h3>
<p>All you need to do is tweak your environment variables (your region / language may differ):</p>
<pre>$ export LANG=en_US.UTF-8</pre>
<p>Now Ruby will use UTF-8 for your external encodings: </p>
<pre>$ LANG=en_US.ASCII-7BIT irb19
&gt;&gt; __ENCODING__
=&gt; #&lt;Encoding:US-ASCII&gt;
$ LANG=en_US.UTF-8 irb19
&gt;&gt; __ENCODING__
=&gt; #&lt;Encoding:UTF-8&gt;</pre>
<p>Note, this doesn’t cover your default_internal, but usually this will be handled for you. And if you can’t set your ENV, you can set this stuff right in Ruby:</p>
<pre class="sh_ruby">Encoding.default_internal, Encoding.default_external = ['utf-8'] * 2</pre>
<p>This sets both your default internal and external encodings. </p>
<p>Now when Rails (well, ERB) tries to read files on disk, it will default to UTF-8 rather than ASCII, and your UTF-8 data from the DB will work just fine.</p>
<p>If you have this problem the other way around (your DB is ASCII), just reverse everything I said.</p><img src="http://feeds.feedburner.com/~r/connectnothing/~4/4rdL4sChKUA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://gnuu.org/2009/11/02/ruby-1-9-encoding-issues-again/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://gnuu.org/2009/11/02/ruby-1-9-encoding-issues-again/</feedburner:origLink></item>
		<item>
		<title>Who “Owns” Documentation?</title>
		<link>http://feedproxy.google.com/~r/connectnothing/~3/NLWbZ2UwVPY/</link>
		<comments>http://gnuu.org/2009/10/20/who-owns-documentation/#comments</comments>
		<pubDate>Wed, 21 Oct 2009 01:46:52 +0000</pubDate>
		<dc:creator>Loren Segal</dc:creator>
				<category><![CDATA[post]]></category>

		<guid isPermaLink="false">http://gnuu.org/2009/10/20/who-owns-documentation/</guid>
		<description><![CDATA[When you manage a software project, how do you delegate the task of documentation? This is something I’ve been thinking about for a while. Many projects deal with documentation at an ad-hoc basis. The implementation developer is usually the one told to document what they’ve done. But generally this is the worst person to call [...]]]></description>
			<content:encoded><![CDATA[<p>When you manage a software project, how do you delegate the task of documentation? This is something I’ve been thinking about for a while. Many projects deal with documentation at an ad-hoc basis. The implementation developer is usually the one told to document what they’ve done. But generally this is the worst person to call on for the task, for many reasons. The real “owner” of documentation work should be the API architect, but maintaining documentation can easily become a near-full-time job for large projects, and some technical writing skills are required that not all API architects have. In an ideal project, I would propose having a dedicated architect who is also a technical writer. They would handle the maintenance of the documentation but also be kept in the loop on architecture decisions (though they should not be the lead architect).</p>
<h2>Why is the implementation developer a bad choice?</h2>
<p>I mentioned there are a number of reasons. Let’s go through some of them:</p>
<ol>
<li><strong>The developer knows exactly what the code does</strong> — This makes him a bad choice to author documentation, because his perspective is heavily biased. It is easy for this person to miss points of confusion that someone who is less familiar with the codebase may have upon reading the API documentation. </li>
<li><strong>Developers are often not skilled technical writers</strong> — Technical writing, or writing in general, is a separate skill that not all programmers have. To get quality documentation you should have someone with the right skill set. </li>
<li><strong>The developer doesn’t see the big picture </strong>— Usually your API’s implementation will bleed into other APIs or depend on domain knowledge from other parts of your architecture (your foo method takes a Bar widget from some external service). The architect is usually the one who knows when this information is new to the reader or if this has already been covered in another document.</li>
</ol>
<p>In addition to those points, there’s also a small matter of writing style. Documentation can become hard to follow if multiple writing styles are interchanged arbitrarily through documents. Having multiple developers can lead to style inconsistencies, especially if the developers aren’t that skilled at technical writing. Only a small group of people should be managing and maintaining the documentation, to ensure the phrasing is consistent throughout the API.</p>
<h2>Why should it be an API architect?</h2>
<p>The architects are the ones who have the least bias when it comes to the functionality of the system. A dedicated technical writer may be proficient at writing but may not have an understanding of the entire system and would suffer from some of the drawbacks that developers do (no “big picture”). Also, since an architect’s main responsibility is to define the API, they’re already done half the work of documentation anyway. They might as well go the extra mile and write it down.</p><img src="http://feeds.feedburner.com/~r/connectnothing/~4/NLWbZ2UwVPY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://gnuu.org/2009/10/20/who-owns-documentation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://gnuu.org/2009/10/20/who-owns-documentation/</feedburner:origLink></item>
		<item>
		<title>The Joy of Solving Problems, All of Them</title>
		<link>http://feedproxy.google.com/~r/connectnothing/~3/26RcN4-jG9k/</link>
		<comments>http://gnuu.org/2009/10/01/the-joy-of-solving-problems-all-of-them/#comments</comments>
		<pubDate>Thu, 01 Oct 2009 22:28:29 +0000</pubDate>
		<dc:creator>Loren Segal</dc:creator>
				<category><![CDATA[post]]></category>
		<category><![CDATA[contract work]]></category>
		<category><![CDATA[essay]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[technology]]></category>

		<guid isPermaLink="false">http://gnuu.org/2009/10/01/the-joy-of-solving-problems-all-of-them/</guid>
		<description><![CDATA[I get a lot of joy out of finding solutions to my own problems. This is not that surprising, as most people do. Of course some people don’t like to admit it out of fear of being labeled selfish or self-centered. Other people don’t have the means, but would love the idea of having such [...]]]></description>
			<content:encoded><![CDATA[<p>I get a lot of joy out of finding solutions to my own problems. This is not that surprising, as most people do. Of course some people don’t like to admit it out of fear of being labeled selfish or self-centered. Other people don’t have the means, but would love the idea of having such control. This makes me lucky, since I have both the means and don’t care much about being called selfish. I’ve been happily invested in many personal projects for a long time now. I’ve also been fortunate enough (as a recently graduated student with savings) to be able to focus exclusively on… myself. </p>
<p>Granted, all of my personal projects benefit others, whether it’s my <a href="http://yard.soen.ca">documentation tool</a>, my <a href="http://github.com/lsegal/barracuda">OpenCL Ruby bindings</a> or my apparently well received <a href="http://gnuu.org/2009/09/18/writing-your-own-toy-compiler/">compiler design tutorial</a> I’ve recently written. The dirty little secret is: <em>I do it for myself</em>. I wrote the compiler tutorial because <em>I</em> wanted to learn compiler design. I wrote OpenCL bindings because <em>I</em> wanted to learn OpenCL. I suppose I could even say that my willingness to help others to has a slightly selfish motivation; the joy <em>I</em> get out of being the one to help somebody else is certainly a factor in what motivates me to do the things I do.</p>
<p>Lately, however, I’ve been losing steam on a lot of these projects. I’ve been realizing that my lack of recent motivation is due in part to this <em>looking inwardness</em> that I’ve been guilty of for a while now. Rather than take somebody else’s problem and help them for the sake of their problem, I take my problems and apply them to others. This is hardly a sustainable way to live life. The problem lies in focusing too much on either end of the spectrum. I came to my own problems after being bombarded with contract work and clients looking for solutions to their own problems. That life was equally unsustainable, and likely drove me to the need to focus on myself. The conclusion? It’s just as bad to focus exclusively on my problems as it is to focus exclusively on somebody else’s. </p>
<p>The good thing is I’ve also been remembering another dirty little secret: <em>I like to solve other people’s problems too</em>. In fact, I’ve realized I get just as much joy out of solving someone else’s problem as my own. I write this in part as a confession, but also in hopes of being a footnote to somebody else. Solving your own problems is great, and anyone who has that opportunity should apply it often. But a skill like that should be shared with others as often as it is applied to oneself. The important part is balance. If you’re focusing exclusively on your client or boss’s problems, you need to change that and start writing some code for you. Something perhaps completely selfish. Just don’t quit your day job while doing it; variety is what keeps us fresh and motivated to solve problems, all problems.</p><img src="http://feeds.feedburner.com/~r/connectnothing/~4/26RcN4-jG9k" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://gnuu.org/2009/10/01/the-joy-of-solving-problems-all-of-them/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://gnuu.org/2009/10/01/the-joy-of-solving-problems-all-of-them/</feedburner:origLink></item>
		<item>
		<title>Writing Your Own Toy Compiler Using Flex, Bison and LLVM</title>
		<link>http://feedproxy.google.com/~r/connectnothing/~3/Ry5Q5AtsNlU/</link>
		<comments>http://gnuu.org/2009/09/18/writing-your-own-toy-compiler/#comments</comments>
		<pubDate>Fri, 18 Sep 2009 18:08:50 +0000</pubDate>
		<dc:creator>Loren Segal</dc:creator>
				<category><![CDATA[post]]></category>
		<category><![CDATA[bison]]></category>
		<category><![CDATA[compiler]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[grammar]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[llvm]]></category>
		<category><![CDATA[programming languages]]></category>

		<guid isPermaLink="false">http://gnuu.org/?p=266</guid>
		<description><![CDATA[
I’ve always been interested in compilers and languages, but interest only gets you so far. A lot of the concepts of compiler design can easily go way over most programmers’ heads, even the intelligent ones. Needless to say, I’ve tried, without much success, to write a small toy language/compiler before. I’d usually get caught up [...]]]></description>
			<content:encoded><![CDATA[<p><!--pagetitle:Introduction--></p>
<p>I’ve always been interested in compilers and languages, but interest only gets you so far. A lot of the concepts of compiler design can easily go way over most programmers’ heads, even the intelligent ones. Needless to say, I’ve tried, without much success, to write a small toy language/compiler before. I’d usually get caught up at the semantic parsing stage. And again, needless to say, this post is mostly inspired by my latest attempt, though this one has been much more successful (so far).</p>
<p>Fortunately over the last few years I’ve been involved in <a href="http://yard.soen.ca">some</a> <a href="http://www.eecs.ucf.edu/~leavens/JML//index.shtml">projects</a> that helped give me perspective and experience on what’s really involved in building a compiler. The other thing I’ve been lucky to have in my corner this time is the help of <a href="http://llvm.org">LLVM</a>, a tool which I’m hardly qualified to talk too much about, but it’s been quite handy in implementing most of the business end (read: complex aspects) of my toy compiler.</p>
<p> <!-- more --><br />
<h2>So Why Are You Reading This? </h2>
<p>Maybe you want to see what I’ve been doing with my time. It’s more likely, however, that you’re probably interested in compilers and languages as I am, and have probably been hitting similar roadblocks. You’ve probably wanted to try this but never found the resources, or did but couldn’t quite follow. The goal of this article is to provide such a resource and explain in a relatively step by step manner how to create the most basic-but-functional compiler from start to “finish”. </p>
<p>I won’t be covering much theory, so if you haven’t brushed up on your <a href="http://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form">BNF grammars</a>, <a href="http://en.wikipedia.org/wiki/Abstract_syntax_tree">AST data structures</a> and the basic <a href="http://en.wikipedia.org/wiki/Compiler">compiler pipeline</a>, I suggest you do so. That said, I plan on keeping this as simple as possible. The goal, of course, is to make this an easy-to-understand introductory resource for people interested but not experienced with compilers. </p>
<h2></h2>
<h2>What You Will End Up With</h2>
<p>If you follow this article, you should end up with a language that can define functions, call functions, define variables, assign data to variables and perform basic math operations. It will support two basic types, doubles and integers. Some of the functionality is unimplemented, so you can have the satisfaction of actually implementing some of this stuff yourself and get the hang of writing a compiler with a little help.</p>
<h2>Let’s Get Some Questions Out of the Way</h2>
<h3>1. What languages do I need to know?</h3>
<p>The tools we’ll be using are C/C++ based. LLVM is specifically C++ and our toy language will follow suit since there are some niceties of OOP and the STL (C++’s stdlib) that make for fewer lines of code. In addition to C, both Lex and Bison have their own syntax which may seem daunting at first, but I’ll try to explain as much as possible. The grammar we’re dealing with is actually very tiny (~100 LOC), so it should be feasible.</p>
<h3>2. Is this really complicated? </h3>
<p>Yes and no. There is plenty of stuff going on here and it might seem scary at first, but honestly, this is about as simple as it gets. We will also use a lot of tools to abstract the layers of complexity and make it manageable.</p>
<h3>3. How long will it take?</h3>
<p>What we will be building took me about 3 days of toying with, but I have a few failed attempts under my belt and those do have impact on my comprehension. Of course, this will be a “follow me” kind of deal, so it should be much shorter for you. To understand completely everything might take a little longer, but you should be able to run through all of this stuff (and hopefully understand a good amount of it) in an afternoon.</p>
<p>So, if you’re ready, let’s get started.</p><img src="http://feeds.feedburner.com/~r/connectnothing/~4/Ry5Q5AtsNlU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://gnuu.org/2009/09/18/writing-your-own-toy-compiler/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		<feedburner:origLink>http://gnuu.org/2009/09/18/writing-your-own-toy-compiler/</feedburner:origLink></item>
		<item>
		<title>The Angel</title>
		<link>http://feedproxy.google.com/~r/connectnothing/~3/kmxQu4sbynU/</link>
		<comments>http://gnuu.org/2009/09/17/the-angel/#comments</comments>
		<pubDate>Thu, 17 Sep 2009 08:42:45 +0000</pubDate>
		<dc:creator>Loren Segal</dc:creator>
				<category><![CDATA[post]]></category>
		<category><![CDATA[art]]></category>
		<category><![CDATA[d90]]></category>
		<category><![CDATA[photography]]></category>
		<category><![CDATA[silhouette]]></category>

		<guid isPermaLink="false">http://gnuu.org/2009/09/17/the-angel/</guid>
		<description><![CDATA[A small set of silhouettes I captured last week on my Nikon D90. The model is Emilie Olson.
Angel I

Angel II

Angel III

Angel IV

You can find more of my photos on Flickr.]]></description>
			<content:encoded><![CDATA[<p>A small set of silhouettes I captured last week on my Nikon D90. The model is <a href="http://emilieolson.com">Emilie Olson</a>.</p>
<h3>Angel I</h3>
<p><img alt="Angel I" src="http://gnuu.org/wp-content/uploads/2009/09/angeli.jpg" width="640" height="425" style="margin:0;padding:0" /></p>
<h3>Angel II</h3>
<p><img  style="margin:0;padding:0" alt="Angel II" src="http://gnuu.org/wp-content/uploads/2009/09/angelii.jpg" width="640" height="425" /></p>
<h3>Angel III</h3>
<p><img  style="margin:0;padding:0" alt="Angel III" src="http://gnuu.org/wp-content/uploads/2009/09/angeliii_thumb.jpg" width="398" height="600" /></p>
<h3>Angel IV</h3>
<p><img  style="margin:0;padding:0" alt="Angel IV" src="http://gnuu.org/wp-content/uploads/2009/09/angeliv.jpg" width="640" height="425" /></p>
<p>You can find more of my photos on <a href="http://flickr.com/photos/lsegal">Flickr</a>.</p><img src="http://feeds.feedburner.com/~r/connectnothing/~4/kmxQu4sbynU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://gnuu.org/2009/09/17/the-angel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://gnuu.org/2009/09/17/the-angel/</feedburner:origLink></item>
		<item>
		<title>Barracuda: An OpenCL Library for Ruby</title>
		<link>http://feedproxy.google.com/~r/connectnothing/~3/QYZQ40RExZs/</link>
		<comments>http://gnuu.org/2009/08/30/barracuda-an-opencl-library-for-ruby/#comments</comments>
		<pubDate>Mon, 31 Aug 2009 00:18:39 +0000</pubDate>
		<dc:creator>Loren Segal</dc:creator>
				<category><![CDATA[post]]></category>
		<category><![CDATA[barracuda]]></category>
		<category><![CDATA[cuda]]></category>
		<category><![CDATA[gpgpu]]></category>
		<category><![CDATA[gpu]]></category>
		<category><![CDATA[opencl]]></category>
		<category><![CDATA[parallel computing]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://gnuu.org/2009/08/30/barracuda-an-opencl-library-for-ruby/</guid>
		<description><![CDATA[
Barracuda is my latest experiment. I wanted to toy around with the new features of Snow Leopard, and as far as I’ve seen, there are no CUDA or OpenCL wrapper libraries out there for Ruby.
OpenCL, if you don’t know, is an “open” version of CUDA, which is NVIDIA’s proprietary architecture for GPGPU programming. Okay, acronyms [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://gnuu.org/wp-content/uploads/2009/08/D846PlymouthBarracudaCatchaCudaPosters.jpg" rel="lightbox"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="D846~Plymouth-Barracuda-Catch-a-Cuda-Posters" border="0" alt="D846~Plymouth-Barracuda-Catch-a-Cuda-Posters" align="right" src="http://gnuu.org/wp-content/uploads/2009/08/D846PlymouthBarracudaCatchaCudaPosters_thumb.jpg" width="260" height="206" /></a>
<p><a href="http://github.com/lsegal/barracuda">Barracuda</a> is my latest experiment. I wanted to toy around with the new features of Snow Leopard, and <a href="http://www.ruby-forum.com/topic/165155">as far as I’ve seen</a>, there are no CUDA or OpenCL wrapper libraries out there for Ruby.</p>
<p><a href="http://www.khronos.org/opencl/">OpenCL</a>, if you don’t know, is an “<a href="http://en.wikipedia.org/wiki/Open_standards">open</a>” version of <a href="http://en.wikipedia.org/wiki/CUDA">CUDA</a>, which is NVIDIA’s proprietary architecture for <a href="http://en.wikipedia.org/wiki/GPGPU">GPGPU</a> programming. Okay, acronyms out of the way, this means that OpenCL is a way to run small but heavy computations in parallel on your GPU’s hundred or so cores. There’s a great demo of why this is cool at <a href="http://www.macresearch.org/opencl_episode1">MacResearch</a> (skip to the end of the video).</p>
<p>I should point out that while the library is called Barra<em>cuda</em> (did you get it?), there&#8217;s currently no CUDA support. I want to add support for CUDA down the road after I figure out what&#8217;s involved, though.</p>
<h3>Show and Tell Time</h3>
<p>Anyway, long story short, I wrote a <em>very basic</em> wrapper for OpenCL which currently only supports signed integers and floats, but will hopefully add some more functionality soon. I know you’re all dying for a demo, so, here’s a benchmark of some integer to float related computation in Ruby, versus the same computation using Barracuda:</p>
<pre class="sh_ruby">require 'barracuda'
require 'benchmark'

include Barracuda

prog = Program.new &lt;&lt;-eof
  __kernel sum(__global float *out, __global int *in, int total) {
    int i = get_global_id(0);
    if (i &lt; total) out[i] = ((float)in[i] + 0.5) / 3.8 + 2.0;
  }
eof

arr = (1..3333333).to_a
input = Buffer.new(arr)
output = OutputBuffer.new(:float, arr.size)

Benchmark.bmbm do |x|
  x.report(&quot;cpu&quot;) { arr.map {|x| (x.to_f + 0.5) / 3.8 + 2.0 } }
  x.report(&quot;gpu&quot;) { prog.sum(output, input, arr.size) }
end</pre>
<p>The way OpenCL works is you compile a C-like program on the GPU, then run it on the GPU with your data input and get some output; it’s a standard <a href="http://en.wikipedia.org/wiki/Pipeline_%28software%29">Pipes and Filters</a> architecture. The compilation of the program happens through LLVM, meaning it doesn’t require GCC, so this is not like running <a href="http://www.zenspider.com/ZSS/Products/RubyInline/">RubyInline</a>. Also we’re running these programs on like 200 cores, so there’s that part too. Anyway, “<em>where are the benchmark results?”</em> you must be yelling right now, so here:</p>
<pre>Rehearsal ---------------------------------------
cpu   5.510000   0.250000   5.760000 (  5.767632)
gpu   0.630000   0.260000   0.890000 (  0.930966)
------------------------------ total: 6.650000sec

          user     system      total        real
cpu   3.860000   0.020000   3.880000 (  3.931644)
gpu   0.310000   0.040000   0.350000 (  0.366625)</pre>
<p>Okay, it’s only about a <big><strong>10x</strong></big> speed increase. That’s not <em>too</em> impressive. Keep in mind though, <tt>(x + 0.5) / 3.8 + 2.0</tt> is a freaking <em>simple</em> computation. I dare someone to hook this up to some Hadoop map-reduce and see some real world results, because they’d probably be much more impressive.</p>
<h3>Wanna Try It?</h3>
<p><strong>The catch</strong>: you can install Barracuda if you&#8217;re on OSX 10.6 (Snow Leopard) or have a way to get OpenCL on your machine and hack up the Makefiles. I&#8217;d like to add support for other environments but I <em>just</em> finished this build.</p>
<p>If you have the right stuff you can grab it right from rubyforge:</p>
<pre>sudo gem install barracuda</pre>
<p>Or visit the git repo:</p>
<pre><a href="http://github.com/lsegal/barracuda">http://github.com/lsegal/barracuda</a></pre><img src="http://feeds.feedburner.com/~r/connectnothing/~4/QYZQ40RExZs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://gnuu.org/2009/08/30/barracuda-an-opencl-library-for-ruby/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://gnuu.org/2009/08/30/barracuda-an-opencl-library-for-ruby/</feedburner:origLink></item>
		<item>
		<title>Brainz and Neural Networks</title>
		<link>http://feedproxy.google.com/~r/connectnothing/~3/hKwEA5xVXIQ/</link>
		<comments>http://gnuu.org/2009/08/23/brainz-and-neural-networks/#comments</comments>
		<pubDate>Mon, 24 Aug 2009 01:53:41 +0000</pubDate>
		<dc:creator>Loren Segal</dc:creator>
				<category><![CDATA[post]]></category>

		<guid isPermaLink="false">http://gnuu.org/2009/08/23/brainz-and-neural-networks/</guid>
		<description><![CDATA[Last night I toyed around with an implementation of a very simple Artificial Neural Network that could calculate the result of simple bitwise operations (AND, OR, XOR) written in C#. Today I ported that code to Ruby and released a library called Brainz. It’s extremely simplistic, undertested and probably really inefficient, but it was really [...]]]></description>
			<content:encoded><![CDATA[<p>Last night I toyed around with an implementation of a very simple <a href="http://en.wikipedia.org/wiki/Artificial_Neural_Network">Artificial Neural Network</a> that could calculate the result of simple bitwise operations (AND, OR, XOR) written in C#. Today I ported that code to Ruby and released a library called <a href="http://github.com/lsegal/brainz">Brainz</a>. It’s extremely simplistic, undertested and probably really inefficient, but it was really fun. If you don’t know much about neural networks, this is from the readme:</p>
<blockquote><p>Brainz is a Artificial Neural Network (ANN) library written by Loren Segal. Neural networks are generally used in pattern recognition, signal processing and other data intensive processing problems. ANN&#8217;s benefit by not having to explicitly define the procedural steps involved in the problem, but rather by <em>training</em> the neural network to return the correct output for the respective inputs. This means that the same neural network can be applied to many different problem sets without much (sometimes any) modification, and therefore make a good general solution to a large set of problem domains. The drawback, however, is that these neural networks require large sets of data to be trained and this training process can be processor intensive.</p>
</blockquote>
<h2></h2>
<h2>AND, OR, BUT…</h2>
<p>Want to see some code? This is also from the readme:</p>
<pre class="sh_ruby"># Define a 2-2-1 neural network
net = Brainz::Network.new(2, 2, 1) 

# We must train the system first
1000.times do
  net.train([0, 0], [0])
  net.train([0, 1], [0])
  net.train([1, 0], [0])
  net.train([1, 1], [1])
end

# Now some tests:
p net.run([0, 1]).map(&amp;:round) # =&gt; [0]
p net.run([1, 1]).map(&amp;:round) # =&gt; [1]</pre>
<p>With a small modification to the training data, you can reprogram that network to calculate any other bit operation with no actual modifications to the algorithm. ScAIry.</p><img src="http://feeds.feedburner.com/~r/connectnothing/~4/hKwEA5xVXIQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://gnuu.org/2009/08/23/brainz-and-neural-networks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://gnuu.org/2009/08/23/brainz-and-neural-networks/</feedburner:origLink></item>
		<item>
		<title>YARD in Ottawa Next Tuesday</title>
		<link>http://feedproxy.google.com/~r/connectnothing/~3/N3N2iBG7d_Y/</link>
		<comments>http://gnuu.org/2009/08/22/yard-in-ottawa-next-tuesday/#comments</comments>
		<pubDate>Sat, 22 Aug 2009 05:06:15 +0000</pubDate>
		<dc:creator>Loren Segal</dc:creator>
				<category><![CDATA[post]]></category>

		<guid isPermaLink="false">http://gnuu.org/2009/08/22/yard-in-ottawa-next-tuesday/</guid>
		<description><![CDATA[Just a quick note to let everyone know I’ll be giving a talk on YARD at the OGRE (Ruby) meetup in Ottawa next week. It&#8217;s Tuesday, August 25th at 6:00PM at The Code Factory (and this time I double checked the date). If you’re nearby you should stop by. It won’t be anything special, but [...]]]></description>
			<content:encoded><![CDATA[<p>Just a quick note to let everyone know I’ll be giving a talk on YARD at the <a href="http://ottawaruby.ca/">OGRE (Ruby) meetup</a> in Ottawa next week. It&#8217;s Tuesday, August 25th at 6:00PM at <a href="http://thecodefactory.ca">The Code Factory</a> (and this time I double checked the date). If you’re nearby you should stop by. It won’t be anything special, but if you haven’t yet checked out <a href="http://yard.soen.ca">YARD</a>, this will probably make a good intro session.</p><img src="http://feeds.feedburner.com/~r/connectnothing/~4/N3N2iBG7d_Y" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://gnuu.org/2009/08/22/yard-in-ottawa-next-tuesday/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://gnuu.org/2009/08/22/yard-in-ottawa-next-tuesday/</feedburner:origLink></item>
		<item>
		<title>I’m a Developer and I’m Looking for Work</title>
		<link>http://feedproxy.google.com/~r/connectnothing/~3/5I-0ImlFGks/</link>
		<comments>http://gnuu.org/2009/08/11/im-a-developer-and-im-looking-for-work/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 16:34:35 +0000</pubDate>
		<dc:creator>Loren Segal</dc:creator>
				<category><![CDATA[post]]></category>
		<category><![CDATA[developer]]></category>
		<category><![CDATA[freelance]]></category>
		<category><![CDATA[job hunting]]></category>
		<category><![CDATA[startups]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://gnuu.org/?p=228</guid>
		<description><![CDATA[As my work with YARD winds down over the summer after my last year at Concordia, I’m starting to face the reality of a graduating university student: the time to start looking for a job. I’ve been looking at a few prospects so far, but I want to see if there are any other interesting [...]]]></description>
			<content:encoded><![CDATA[<p>As my work with <a href="http://yard.soen.ca">YARD</a> winds down over the summer after my last year at Concordia, I’m starting to face the reality of a graduating university student: the time to start looking for a job. I’ve been looking at a few prospects so far, but I want to see if there are any other interesting projects out there before making a decision. I’d like to start in September but I’m in no <em>rush</em> to rush the process. I’d rather spend the extra time to find a really good match. </p>
<p>Before I get into it, I realize the rest of this post will likely sound a little more full of myself than I’m generally comfortable with being, and I apologize.</p>
<h2>What I’m Looking For</h2>
<p>I’m ideally looking for a senior / lead position on a team where I’d be managing a small group of people. Something where my responsibility is less to do with writing code. I say this not because I think I deserve the title “senior” (I don’t), but I’ve found that over the years I’m much better at management, high-level design and logistics than I am at being the algorithm or SQL guy. This is a position I’d like to grow into and gain experience at, although I’m quite confident that I’m already prepared for such a job. That said, I’m always able to get down in the trenches and code (sometimes I <em>need</em> to), and I’m pretty good at it too (see my skills below).</p>
<p>I’d rather work for something not entirely web-related, though I realize how pervasive the web is, so I can accept/understand that there will be some crossover. I’ve done the whole JavaScript, Rails, web app thing before, though, and I want to try something new. I’d be seriously interested in iPhone, Android, or desktop application development. You can look at it like this: the more web related it is, the more I’d want to be in a management/lead role where coding was not my main responsibility. The less web related it is, the more I’d want to deal with the coding aspect.</p>
<p>Language? Most people who read my blog know me as a Rubyist. I’m, however, by no means married to Ruby. I’m more turned on by interesting projects than evangelistic languages.</p>
<h2>What I’m <em>Not</em> Looking For</h2>
<p>A “hip new social networking site”. <em>Please god no</em>. Also, as I said above, I’d prefer something that is less related to the web as a general rule. If your web-related project has a large non-web-related component, that’s something I can tolerate. To be blunt, I’m kind of sick of HTML.</p>
<h2>My Experience &amp; Skills</h2>
<p>It’s hard to enumerate managerial and leadership skills because they mostly sound like complete bullshit on paper, so I’ll stick to something I <em>can</em> quantify my knowledge of, and that’s technology. Here are some buzzwords for you:</p>
<p>I know a multitude of languages including (from best to worst, only including practical experience): Ruby, Java, PHP<strong>*</strong>, Python, JavaScript, Objective-C, C/C++, and C# (and more). The last language I learned was Lua, which was earlier this year. I generally learn a new language at least once a year.</p>
<p>I’ve used the following major frameworks: Rails, Sinatra, Cocoa, Prototype, MooTools, jQuery, wxWidgets, .NET (WPF, WinForms), Swing.</p>
<p>If you want to see how I code, you can go to <a href="http://github.com/lsegal">http://github.com/lsegal</a> </p>
<p>I am extremely interested in compilers, languages, HCI, and DSP, though I don&#8217;t expect anyone to hire me for that. I am great with developer/workflow/testing tools as well as API design and even documentation (I <em>do</em> author a <a href="http://yard.soen.ca">documentation developer tool</a>). Through school I&#8217;ve ended up with a lot of experience in many Software Engineering best practices (Quality Assurance, Process Management, Requirements Gathering, Metrics, Software Architecture, System Design).</p>
<p>Professionally, my experience has mostly been with freelance consulting in various web technologies. I&#8217;ve also done a pretty awesome internship at Apple in 2007 working for Apple.com during the big website redesign (and original iPhone launch).</p>
<p><strong>*</strong> It’s unlikely I’d take a job in PHP since PHP usually equals web (see above).</p>
<h2>Location?</h2>
<p>I’m not too concerned with where I end up. I really want to stay in Montreal, but from what I’ve seen so far, salaries in the “software developer” field in this area aren’t all that competitive. I’m currently considering NYC, Seattle and the bay area as potential US candidate cities, though there are probably some other great places to live down there (know one? suggest it!). What about Canadian cities? Well, besides Montreal, I’d consider a few places in B.C., but I’ll be honest, I don’t think I could ever work anywhere in Ontario.</p>
<p>Finally, I’m not <em>too</em> interested in telecommuting. I’d prefer working in person with a team, but if it was really worth it, who knows.</p>
<h2>Hire Me</h2>
<p>If you know of anyone that might be interest<em>ed</em> in someone with my skill set and has a project that I might find interest<em>ing</em>, send them my way. Alternatively, if you’re capable of employing me and you’re interested, I can forward you my resume. My email is lsegal at soen.ca</p><img src="http://feeds.feedburner.com/~r/connectnothing/~4/5I-0ImlFGks" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://gnuu.org/2009/08/11/im-a-developer-and-im-looking-for-work/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://gnuu.org/2009/08/11/im-a-developer-and-im-looking-for-work/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 0.270 seconds. --><!-- Cached page generated by WP-Super-Cache on 2009-11-06 23:14:45 --><!-- Compression = gzip -->
