<?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>MoMolog</title>
	<atom:link href="http://momolog.info/feed/" rel="self" type="application/rss+xml" />
	<link>http://momolog.info</link>
	<description>MoMolog aus Berlin stellt sich vor. Projekte, Ideen, Referenzen.</description>
	<lastBuildDate>Sat, 07 Apr 2012 23:23:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Using throw and catch to tidy up our code</title>
		<link>http://momolog.info/2012/03/29/using-throw-and-catch-in-controllers/</link>
		<comments>http://momolog.info/2012/03/29/using-throw-and-catch-in-controllers/#comments</comments>
		<pubDate>Thu, 29 Mar 2012 10:17:25 +0000</pubDate>
		<dc:creator>aljoscha</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://momolog.info/?p=316</guid>
		<description><![CDATA[Let&#8217;s say we want a simple controller action that checks, if a given code is valid. It should return true and false and, if the code is invalid, give the reason (whether that is because it is unknown or because it has been used already). The action could look like this: Now this deep nesting [...]]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s say we want a simple controller action that checks, if a given code is valid.<br />
It should return true and false and, if the code is invalid, give the reason (whether that is because it is unknown or because it has been used already). The action could look like this:</p>
<p><div id="gist-2235608" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="k">def</span> <span class="nf">valid</span></div><div class='line' id='LC2'>&nbsp;&nbsp;<span class="k">if</span> <span class="n">code</span> <span class="o">=</span> <span class="no">Code</span><span class="o">.</span><span class="n">find_by_value</span><span class="p">(</span><span class="n">params</span><span class="o">[</span><span class="ss">:id</span><span class="o">]</span><span class="p">)</span></div><div class='line' id='LC3'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">unless</span> <span class="n">code</span><span class="o">.</span><span class="n">used?</span></div><div class='line' id='LC4'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">respond_with</span> <span class="ss">:valid</span> <span class="o">=&gt;</span> <span class="kp">true</span></div><div class='line' id='LC5'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">else</span></div><div class='line' id='LC6'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">respond_with</span> <span class="ss">:valid</span> <span class="o">=&gt;</span> <span class="kp">false</span><span class="p">,</span> <span class="ss">:reason</span> <span class="o">=&gt;</span> <span class="s1">&#39;used&#39;</span></div><div class='line' id='LC7'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">end</span> </div><div class='line' id='LC8'>&nbsp;&nbsp;<span class="k">else</span></div><div class='line' id='LC9'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">respond_with</span> <span class="ss">:valid</span> <span class="o">=&gt;</span> <span class="kp">false</span><span class="p">,</span> <span class="ss">:reason</span> <span class="o">=&gt;</span> <span class="s1">&#39;unknown&#39;</span></div><div class='line' id='LC10'>&nbsp;&nbsp;<span class="k">end</span> </div><div class='line' id='LC11'><span class="k">end</span> </div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/2235608/3eb1d48a47361bb1b7d1bd60716e0124f44bd284/nested.rb" style="float:right;">view raw</a>
            <a href="https://gist.github.com/2235608#file_nested.rb" style="float:right;margin-right:10px;color:#666">nested.rb</a>
            <a href="https://gist.github.com/2235608">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>
</p>
<p>Now this deep nesting effectively hides the underlying algorithm, a simple one in this case.<br />
Expressing this using <code>throw</code> and <code>catch</code> straightens the code a bit:</p>
<p><div id="gist-2235614" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="k">def</span> <span class="nf">valid</span></div><div class='line' id='LC2'>&nbsp;&nbsp;<span class="n">failure</span> <span class="o">=</span> <span class="kp">catch</span> <span class="ss">:fail</span> <span class="k">do</span></div><div class='line' id='LC3'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">code</span> <span class="o">=</span> <span class="no">Code</span><span class="o">.</span><span class="n">find_by_value</span><span class="p">(</span><span class="n">params</span><span class="o">[</span><span class="ss">:id</span><span class="o">]</span><span class="p">)</span> <span class="ow">or</span> <span class="kp">throw</span><span class="p">(</span><span class="ss">:fail</span><span class="p">,</span> <span class="s1">&#39;unknown&#39;</span><span class="p">)</span></div><div class='line' id='LC4'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">code</span><span class="o">.</span><span class="n">unused?</span>                           <span class="ow">or</span> <span class="kp">throw</span><span class="p">(</span><span class="ss">:fail</span><span class="p">,</span> <span class="s1">&#39;used&#39;</span><span class="p">)</span></div><div class='line' id='LC5'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="kp">nil</span></div><div class='line' id='LC6'>&nbsp;&nbsp;<span class="k">end</span></div><div class='line' id='LC7'>&nbsp;&nbsp;<span class="n">respond_with</span><span class="p">({</span><span class="ss">:valid</span> <span class="o">=&gt;</span> <span class="o">!</span><span class="n">failure</span><span class="p">}</span><span class="o">.</span><span class="n">merge</span><span class="p">(</span><span class="n">failure</span> <span class="p">?</span> <span class="p">{</span><span class="ss">:reason</span> <span class="o">=&gt;</span> <span class="n">failure</span><span class="p">}:</span> <span class="p">{}))</span></div><div class='line' id='LC8'><span class="k">end</span></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/2235614/a118ac15ff04ad1f189a73b1ff790f1c17e042b3/throw-catch.rb" style="float:right;">view raw</a>
            <a href="https://gist.github.com/2235614#file_throw_catch.rb" style="float:right;margin-right:10px;color:#666">throw-catch.rb</a>
            <a href="https://gist.github.com/2235614">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>
</p>
<p>We are down to one <code>respond_with</code> line but the has merging and the throws at the beginning of the line are not particularly pretty.</p>
<p>Let&#8217;s introduce a little Ruby mixin for the <code>Hash</code> class that provides it with a <code>compact</code> method that its friend <code>Array</code> has had all along:</p>
<p><div id="gist-2235631" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="k">module</span> <span class="nn">HashExtensions</span></div><div class='line' id='LC2'>&nbsp;&nbsp;<span class="k">def</span> <span class="nf">compact</span></div><div class='line' id='LC3'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nb">self</span><span class="o">.</span><span class="n">reject</span><span class="p">{</span><span class="o">|</span><span class="n">key</span><span class="p">,</span> <span class="n">value</span><span class="o">|</span> <span class="n">value</span><span class="o">.</span><span class="n">nil?</span> <span class="p">}</span></div><div class='line' id='LC4'>&nbsp;&nbsp;<span class="k">end</span></div><div class='line' id='LC5'><span class="k">end</span></div><div class='line' id='LC6'><br/></div><div class='line' id='LC7'><span class="k">class</span> <span class="nc">Hash</span></div><div class='line' id='LC8'>&nbsp;&nbsp;<span class="kp">include</span> <span class="no">HashExtensions</span></div><div class='line' id='LC9'><span class="k">end</span></div><div class='line' id='LC10'><br/></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/2235631/b319e64306d93d94bcb809954b344f59442c3ea2/hash-compact.rb" style="float:right;">view raw</a>
            <a href="https://gist.github.com/2235631#file_hash_compact.rb" style="float:right;margin-right:10px;color:#666">hash-compact.rb</a>
            <a href="https://gist.github.com/2235631">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>
</p>
<p>Now using this to clean up the response hash and moving the throw statements to the end so the steps of the algorithm are visible we have our final version of the action:</p>
<p><div id="gist-2235618" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="k">def</span> <span class="nf">valid</span></div><div class='line' id='LC2'>&nbsp;&nbsp;<span class="n">failure</span> <span class="o">=</span> <span class="kp">catch</span> <span class="ss">:fail</span> <span class="k">do</span></div><div class='line' id='LC3'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">code</span> <span class="o">=</span> <span class="no">Code</span><span class="o">.</span><span class="n">find_by_value</span><span class="p">(</span><span class="n">params</span><span class="o">[</span><span class="ss">:id</span><span class="o">]</span><span class="p">)</span> <span class="ow">or</span> <span class="kp">throw</span> <span class="ss">:fail</span><span class="p">,</span> <span class="s1">&#39;unknown&#39;</span></div><div class='line' id='LC4'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">code</span><span class="o">.</span><span class="n">unused?</span>                           <span class="ow">or</span> <span class="kp">throw</span> <span class="ss">:fail</span><span class="p">,</span> <span class="s1">&#39;used&#39;</span></div><div class='line' id='LC5'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="kp">nil</span> </div><div class='line' id='LC6'>&nbsp;&nbsp;<span class="k">end</span> </div><div class='line' id='LC7'>&nbsp;&nbsp;<span class="n">respond_with</span><span class="p">({</span><span class="ss">:valid</span> <span class="o">=&gt;</span> <span class="o">!</span><span class="n">failure</span><span class="p">,</span> <span class="ss">:reason</span> <span class="o">=&gt;</span> <span class="n">failure</span><span class="p">}</span><span class="o">.</span><span class="n">compact</span><span class="p">)</span></div><div class='line' id='LC8'><span class="k">end</span> </div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/2235618/23a91505eeedb8d84d0cbeda32daab673be27754/throw-catch-final.rb" style="float:right;">view raw</a>
            <a href="https://gist.github.com/2235618#file_throw_catch_final.rb" style="float:right;margin-right:10px;color:#666">throw-catch-final.rb</a>
            <a href="https://gist.github.com/2235618">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>
</p>
]]></content:encoded>
			<wfw:commentRss>http://momolog.info/2012/03/29/using-throw-and-catch-in-controllers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Saving local text files to S3 using paperclip</title>
		<link>http://momolog.info/2011/12/02/saving-local-text-files-to-s3-using-paperclip/</link>
		<comments>http://momolog.info/2011/12/02/saving-local-text-files-to-s3-using-paperclip/#comments</comments>
		<pubDate>Fri, 02 Dec 2011 10:49:36 +0000</pubDate>
		<dc:creator>aljoscha</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://momolog.info/?p=290</guid>
		<description><![CDATA[Sometimes you need to save a locally created file to S3 instead of an uploaded file, as is the standard. Here is how: has_attached_file :tagged_text_file, STORAGE_OPTIONS.merge({ :processors => [] }) def save_tagged_text_file file = File.open("#{RAILS_ROOT}/tmp/tagged_text_#{id}.txt", 'w+') file]]></description>
			<content:encoded><![CDATA[<p>Sometimes you need to save a locally created file to S3 instead of an uploaded file, as is the standard. Here is how:</p>
<pre>
  has_attached_file :tagged_text_file,  STORAGE_OPTIONS.merge({
    :processors   => []
  })
</pre>
<pre>
  def save_tagged_text_file
    file = File.open("#{RAILS_ROOT}/tmp/tagged_text_#{id}.txt", 'w+')
    file << tagged_text
    self.tagged_text_file = file
    save!
    file.close
  end
</pre>
]]></content:encoded>
			<wfw:commentRss>http://momolog.info/2011/12/02/saving-local-text-files-to-s3-using-paperclip/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Connecting to redis via SSH tunneling</title>
		<link>http://momolog.info/2011/12/02/connect-to-redis-via-ssh-tunneling/</link>
		<comments>http://momolog.info/2011/12/02/connect-to-redis-via-ssh-tunneling/#comments</comments>
		<pubDate>Fri, 02 Dec 2011 10:46:53 +0000</pubDate>
		<dc:creator>aljoscha</dc:creator>
				<category><![CDATA[Allgemein]]></category>

		<guid isPermaLink="false">http://momolog.info/?p=293</guid>
		<description><![CDATA[SSH tunneling is, of course, useful for a ton of services, but I happened to stumble upon it, when I wanted to connect to a remote redis server. If you have a redis server running on [remotehost], you can easily connect to it (given you have ssh access to it, of course) via: ssh -L [...]]]></description>
			<content:encoded><![CDATA[<p>SSH tunneling is, of course, useful for a ton of services, but I happened to stumble upon it, when I wanted to connect to a remote redis server.</p>
<p>If you have a redis server running on [remotehost], you can easily connect<br />
to it (given you have ssh access to it, of course) via:</p>
<p><code>ssh -L 9999:localhost:6379 [remoteuser]@[remotehost]</code></p>
<p>This will open a tunnel from the remote port 6379 (redis standard) to your local port 9999.</p>
<p>You can now use the redis on your local port 9999 like you would if it was running locally. Nice.</p>
]]></content:encoded>
			<wfw:commentRss>http://momolog.info/2011/12/02/connect-to-redis-via-ssh-tunneling/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Push local branch to specific heroku app</title>
		<link>http://momolog.info/2011/11/28/push-local-branch-to-specific-heroku-app/</link>
		<comments>http://momolog.info/2011/11/28/push-local-branch-to-specific-heroku-app/#comments</comments>
		<pubDate>Mon, 28 Nov 2011 17:33:24 +0000</pubDate>
		<dc:creator>aljoscha</dc:creator>
				<category><![CDATA[Note to self]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://momolog.info/?p=295</guid>
		<description><![CDATA[You use two heroku apps as staging and production for your project. You added both as git remotes, e.g. &#8220;production&#8221; and &#8220;staging&#8221;. Now you want to push your local branch &#8220;poster&#8221; to remote &#8220;staging&#8221;, use git push staging poster:master Note, that you can only push to &#8220;master&#8221; on herokus side. This is just git syntax, [...]]]></description>
			<content:encoded><![CDATA[<p>You use two heroku apps as staging and production for your project. You added both as git remotes, e.g. &#8220;production&#8221; and &#8220;staging&#8221;.</p>
<p>Now you want to push your local branch &#8220;poster&#8221; to remote &#8220;staging&#8221;, use<br />
<code>git push staging poster:master<br />
</code></p>
<p>Note, that you can only push to &#8220;master&#8221; on herokus side. This is just git syntax, but I keep forgetting it, so here it is for future reference.</p>
]]></content:encoded>
			<wfw:commentRss>http://momolog.info/2011/11/28/push-local-branch-to-specific-heroku-app/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby: map Array to Hash</title>
		<link>http://momolog.info/2010/10/07/ruby-map-array-to-hash/</link>
		<comments>http://momolog.info/2010/10/07/ruby-map-array-to-hash/#comments</comments>
		<pubDate>Thu, 07 Oct 2010 06:49:50 +0000</pubDate>
		<dc:creator>aljoscha</dc:creator>
				<category><![CDATA[Note to self]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://momolog.info/?p=277</guid>
		<description><![CDATA[Sometimes you may wish to map an Array to a Hash in Ruby, like say, you got the output of I18n.available_locales locales = [:en, :de, :fr] and want to transform that into a Hash to fill a select element, like so: [:en => 'EN', :de => 'DE', :fr => 'FR'] How do you do that [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes you may wish to map an Array to a Hash in Ruby, like say, you got the output of I18n.available_locales</p>
<p><code>locales = [:en, :de, :fr]</code></p>
<p>and want to transform that into a Hash to fill a select element, like so:</p>
<p><code>[:en => 'EN', :de => 'DE', :fr => 'FR']</code></p>
<p>How do you do that in the most concise way?<br />
First, there is always <code>inject</code>:</p>
<p><code>locales.inject({}) {|hsh, sym| hsh[sym] = sym.to_s.upcase; hsh}</code></p>
<p>But I like the following approach way better, mainly because it emphasizes my intention more clearly (and, btw. is faster too):</p>
<p><code>Hash[locales.map{|sym| [sym, sym.to_s.upcase]}]</code></p>
<p><em>Remember</em>: <code>Hash[:a,:b,:c,:d]</code> produces <code>{:a => :b, :c => :d}</code>.</p>
]]></content:encoded>
			<wfw:commentRss>http://momolog.info/2010/10/07/ruby-map-array-to-hash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Copying Files between S3 buckets</title>
		<link>http://momolog.info/2010/07/08/copying-files-between-s3-buckets/</link>
		<comments>http://momolog.info/2010/07/08/copying-files-between-s3-buckets/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 10:27:26 +0000</pubDate>
		<dc:creator>aljoscha</dc:creator>
				<category><![CDATA[AWS]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://momolog.info/?p=268</guid>
		<description><![CDATA[Building on this article here is a simple ruby script, that copies files between two buckets of the same S3 account, omitting files already present (by name). This variant adds a list of path prefixes, so you can selectively copy only certain directories of your buckets. Furthermore it copies the original buckets ACLs for each [...]]]></description>
			<content:encoded><![CDATA[<p>Building on <a href="http://www.lakedenman.com/2009/10/27/copying-files-between-s3-buckets.html">this article</a> here is a simple ruby script, that copies files between two buckets of the same S3 account, omitting files already present (by name).<br />
This variant adds a list of path prefixes, so you can selectively copy only certain directories of your buckets.<br />
Furthermore it copies the original buckets ACLs for each key.</p>
<pre>
require 'rubygems'
require 'right_aws'

aws_access_key_id     = 'YOUR AMAZON ACCESS KEY'
aws_secret_access_key = 'YOUR AMAZON SECRET ACCESS KEY'
source_bucket         = 'SOURCE BUCKET NAME'
target_bucket         = 'TARGET BUCKET NAME'
prefixes              = [PATH_PREFIX1, PATH_PREFIX2, ...]

s3 = RightAws::S3Interface.new(aws_access_key_id, aws_secret_access_key)

copied_keys = Array.new
(prefixes || ['']).each do |prefix|
  s3.incrementally_list_bucket(target_bucket, {:prefix => prefix}) do |key_set|
    copied_keys << key_set[:contents].map{|k| k[:key]}.flatten
  end
end
copied_keys.flatten!

(prefixes || ['']).each do |prefix|
  s3.incrementally_list_bucket(source_bucket, {:prefix => prefix}) do |key_set|
    key_set[:contents].each do |key|
      key = key[:key]
      if copied_keys.include?(key)
        puts "#{target_bucket} #{key} already exists. Skipping..."
      else

        puts "Copying #{source_bucket} #{key}, setting acl"

        retries=0
        begin
          s3.copy(source_bucket, key, target_bucket)
          acl = s3.get_acl(source_bucket, key)
          s3.put_acl(target_bucket, key, acl[:object])
        rescue Exception => e
          puts "cannot copy key, #{e.inspect}\nretrying #{retries} out of 10 times..."
          retries += 1
          retry if retries <= 10
        end
      end
    end
  end
end
</pre>
]]></content:encoded>
			<wfw:commentRss>http://momolog.info/2010/07/08/copying-files-between-s3-buckets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MomoFlow</title>
		<link>http://momolog.info/2009/11/28/momoflow/</link>
		<comments>http://momolog.info/2009/11/28/momoflow/#comments</comments>
		<pubDate>Sat, 28 Nov 2009 10:26:22 +0000</pubDate>
		<dc:creator>aljoscha</dc:creator>
				<category><![CDATA[Allgemein]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://momolog.info/?p=219</guid>
		<description><![CDATA[Coverflow has become a de facto visualization standard for the presentation of collections of images, be it covers or portraits. There are a number of implementations for usage on web pages (e.g. this one) but the usable ones require Adobes Flash and thus won&#8217;t run on the iPhone. When looking for HTML5 canvas based implementations [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Cover_Flow">Coverflow</a> has become a  de facto visualization standard for the presentation of collections of images, be it covers or portraits.<br />
There are a number of implementations for usage on web pages (e.g. <a href="http://www.flashloaded.com/flashcomponents/photoflow/example1.html">this one</a>) but the usable ones require Adobes Flash and thus won&#8217;t run on the iPhone.</p>
<p>When looking for HTML5 canvas based implementations I found <a href="http://elmasse.gaver.nl/projects/Coverflow0.1/test.html">this promising implementation</a> based on the YUI library.<br />
Though workig, it has three major drawbacks: It is rather overengineered and difficult to tweak, it uses YUI (whereas I prefer the more lightweight jQuery) and it performs poorly with image sizes bigger than thumbnails.</p>
<p>After trying to change the code for a while I decided to do a reimplementation in jQuery. The result can be seen on the <a href="http://flow.momolog.info">MomoFlow demo page</a>. Here are two screenshots:</p>
<p><div id="attachment_229" class="wp-caption aligncenter" style="width: 310px"><img class="size-medium wp-image-229" title="MomoFlow I" src="http://momolog.info/wp-content/uploads/2009/11/Bildschirmfoto-2009-11-22-um-09.01.33-300x240.png" alt="CoverFlow using canvas and jQuery" width="300" height="240" /><p class="wp-caption-text">CoverFlow using canvas and jQuery</p></div></p>
<p><div id="attachment_226" class="wp-caption aligncenter" style="width: 310px"><img class="size-medium wp-image-226" title="MomoFlow II" src="http://momolog.info/wp-content/uploads/2009/11/Bildschirmfoto-2009-11-22-um-09.01.20-300x240.png" alt="Quicklook mode" width="300" height="240" /><p class="wp-caption-text">Quicklook mode</p></div></p>
<p>The used 3D transformation is superbly described on the <a href="http://yuiblog.com/blog/2008/06/23/slicing/">YUI blog</a> .</p>
<p>My implementation caches the rendered canvases per rendering angle. Further speed increments are made possible by adjusting the mesh width used for the slicing transformation depending on the achieved framerate.</p>
<p>The result performs beautifully in recent Safari, Chrome and Opera, decently on Firefox. It also works flawlessly on the iPhone. Keyboard control is coming soon.</p>
<p>I do still need help on IE, maybe the image composition is too demanding for <a href="http://excanvas.sourceforge.net/">ExplorerCanvas</a>? <br />
The code is available on github: <a href="http://github.com/momolog/momoflow">http://github.com/momolog/momoflow</a>.<br />
Comments and improvements are very much welcome!</p>
]]></content:encoded>
			<wfw:commentRss>http://momolog.info/2009/11/28/momoflow/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>MySQL BEFORE INSERT trigger as check constraint</title>
		<link>http://momolog.info/2009/10/21/mysql-before-insert-trigger-as-check-constraint/</link>
		<comments>http://momolog.info/2009/10/21/mysql-before-insert-trigger-as-check-constraint/#comments</comments>
		<pubDate>Wed, 21 Oct 2009 09:03:55 +0000</pubDate>
		<dc:creator>aljoscha</dc:creator>
				<category><![CDATA[Allgemein]]></category>

		<guid isPermaLink="false">http://momolog.info/?p=212</guid>
		<description><![CDATA[Since MySQL does neither have real check constraints nor a way to raise an exception in a stored procedure, we found it not instantly obvious, how we could *reject* a certain row on insert, based on a certain condition. A nice way we found was to set the value in question to NULL, based on [...]]]></description>
			<content:encoded><![CDATA[<p>Since MySQL does neither have real check constraints nor a way to raise an exception in a stored procedure, we found it not instantly obvious, how we could *reject* a certain row on insert, based on a certain condition.</p>
<p>A nice way we found was to set the value in question to NULL, based on the condition and let the NOT NULL constraint do its work.</p>
<pre>
ALTER TABLE sessions MODIFY session_id varchar(255) NOT NULL;
DROP TRIGGER IF EXISTS check_sessionid;
DELIMITER $$
CREATE TRIGGER check_sessionid BEFORE INSERT ON sessions
FOR EACH ROW BEGIN
  IF NOT NEW.session_id REGEXP '^[[:xdigit:]]{32}$' THEN
    SET NEW.session_id = NULL;
  END IF;
END;
$$
DELIMITER ;
</pre>
<p>The trigger will let any 32 character string with only HEX characters for the column session_id pass and rejects the rest.</p>
<pre>
> INSERT INTO sessions (session_id) VALUES ('ffffffffffffffffffffffffffffffff');
Query OK, 1 row affected (0.01 sec)
</pre>
<pre>
> INSERT INTO sessions (session_id) VALUES ('fffffffffffffffffffffffffffffffg');
ERROR 1048 (23000): Column 'session_id' cannot be null
</pre>
<p>Happy triggering.</p>
]]></content:encoded>
			<wfw:commentRss>http://momolog.info/2009/10/21/mysql-before-insert-trigger-as-check-constraint/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Vor kurzem dazugelernt:</title>
		<link>http://momolog.info/2009/10/18/vor-kurzem-dazugelernt/</link>
		<comments>http://momolog.info/2009/10/18/vor-kurzem-dazugelernt/#comments</comments>
		<pubDate>Sun, 18 Oct 2009 15:46:19 +0000</pubDate>
		<dc:creator>aljoscha</dc:creator>
				<category><![CDATA[Allgemein]]></category>
		<category><![CDATA[MacOSX]]></category>
		<category><![CDATA[Note to self]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://momolog.info/?p=204</guid>
		<description><![CDATA[Suche nach Wort unter dem Cursor in vim: #. jssh ist eine JavaScript Shell, die den Firefox per Port 9997 fernsteuerbar macht. Download z.B. hier. y erzeugt einen YAML dump auf der Rails console, mehr dazu hier. =3D ist ein escaptes &#8220;=&#8221; in quoted_printable. sudo /usr/libexec/locate.updatedb aktualisiert unter MacOSX sofort die locate Datenbank. rake db:migrate:redo [...]]]></description>
			<content:encoded><![CDATA[<p>Suche nach Wort unter dem Cursor in vim: <code>#</code>.</p>
<p><code>jssh</code> ist eine JavaScript Shell, die den Firefox per Port 9997 fernsteuerbar macht.<br />
Download z.B. <a href="http://wiki.openqa.org/display/WTR/FireWatir+Installation">hier</a>.</p>
<p><code>y</code> erzeugt einen YAML dump auf der Rails console, mehr dazu <a href="http://blog.floehopper.org/articles/2006/12/22/rails-console-shortcuts">hier</a>.</p>
<p><code>=3D</code> ist ein escaptes &#8220;=&#8221; in <a href="http://de.wikipedia.org/wiki/Quoted-printable">quoted_printable</a>.</p>
<p><code>sudo /usr/libexec/locate.updatedb</code> aktualisiert unter MacOSX sofort die <code>locate</code> Datenbank.</p>
<p><code>rake db:migrate:redo</code> führt unter rails die letzte Migration rückwärts und sofort wieder vorwärts aus, so dass sich die Vorwärts-Action korrigieren läßt </p>
<p><code>ack -Q</code> bringt <a href="http://betterthangrep.com/">ack</a> dazu, <em>literal</em>, also ohne RegExp zu suchen.</p>
]]></content:encoded>
			<wfw:commentRss>http://momolog.info/2009/10/18/vor-kurzem-dazugelernt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MacOSX Boot-Tastenkombinationen: single user, verbose, safe</title>
		<link>http://momolog.info/2009/10/01/single-user-vs-verbose-vs-safe/</link>
		<comments>http://momolog.info/2009/10/01/single-user-vs-verbose-vs-safe/#comments</comments>
		<pubDate>Thu, 01 Oct 2009 09:24:26 +0000</pubDate>
		<dc:creator>aljoscha</dc:creator>
				<category><![CDATA[MacOSX]]></category>
		<category><![CDATA[Note to self]]></category>

		<guid isPermaLink="false">http://momolog.info/?p=187</guid>
		<description><![CDATA[In den single user mode (root shell) starten, beim Neustart: [CMS] s In den verbose mode (boot log) starten: [CMD] v In den safe mode (nur core kexts) starten: [SHIFT]]]></description>
			<content:encoded><![CDATA[<p>In den <a href="http://support.apple.com/kb/HT1492">single user mode (root shell)</a> starten, beim Neustart:<br />
<code>[CMS] s<br />
</code><br />
In den <a href="http://support.apple.com/kb/HT1492">verbose mode (boot log)</a> starten:<br />
<code>[CMD] v<br />
</code><br />
In den <a href="http://support.apple.com/kb/HT1564">safe mode (nur core kexts)</a> starten:<br />
<code>[SHIFT]<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://momolog.info/2009/10/01/single-user-vs-verbose-vs-safe/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

