<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>allskonar - All</title>
  <id>tag:baldur.snitchmedia.com,2010:mephisto/</id>
  <generator version="0.8.0" uri="http://mephistoblog.com">Mephisto Drax</generator>
  <link href="http://baldur.snitchmedia.com/feed/atom.xml" rel="self" type="application/atom+xml"/>
  <link href="http://baldur.snitchmedia.com/" rel="alternate" type="text/html"/>
  <updated>2010-05-06T02:51:51Z</updated>
  <entry xml:base="http://baldur.snitchmedia.com/">
    <author>
      <name>baldur</name>
    </author>
    <id>tag:baldur.snitchmedia.com,2010-05-05:703</id>
    <published>2010-05-05T22:28:00Z</published>
    <updated>2010-05-06T02:51:51Z</updated>
    <category term="note to self"/>
    <category term="Tips and Tricks"/>
    <category term="ruby"/>
    <category term="transcoding"/>
    <category term="video"/>
    <link href="http://baldur.snitchmedia.com/2010/5/5/zencoder-transcoding-in-style" rel="alternate" type="text/html"/>
    <title>zencoder ... transcoding in style</title>
<content type="html">
            &lt;p&gt;I am not saying it isn&#8217;t fun hacking together a combination of ffmpeg, mencoder and dealing with all the dependencies and throwing down one ninja trick after another, just to transcode your video so it will display properly on the web, iphone or what ever device you want them on.&lt;/p&gt;


	&lt;p&gt;Using &lt;a href=&quot;http://zencoder.com/&quot;&gt;zencoder&lt;/a&gt; makes processing videos really satisfying. Just tell them where the source video is and tell them where you want them to dump the output, and as any modern web application it has implemented a web hook so if you want to stay tuned about the process specify a url where the status updates will be posted to. It looks like they only send you status when it is completed. Here is a quick example of how to get this working with ruby code.&lt;/p&gt;


&lt;pre&gt;
&lt;code class=&quot;ruby&quot;&gt;
require 'rubygems'
require 'rest_client'
require 'json'

HOST  = &quot;https://app.zencoder.com/api/jobs&quot; 

opts = { 
  &quot;test&quot; =&amp;gt;  1,  
  &quot;input&quot; =&amp;gt; &quot;s3://bucketname/filename&quot;,
  &quot;output&quot; =&amp;gt; [
    {   
      &quot;label&quot; =&amp;gt; &quot;fromapi&quot;,
      &quot;base_url&quot; =&amp;gt; &quot;s3://bucketname/&quot;,
      &quot;filename&quot; =&amp;gt; &quot;newfilename&quot;,
      &quot;width&quot; =&amp;gt; 500,
      &quot;quality&quot; =&amp;gt; 3,
      &quot;speed&quot; =&amp;gt; 1,
      &quot;h264_profile&quot; =&amp;gt; &quot;high&quot;,
      &quot;audio_channels&quot; =&amp;gt; 2,
      &quot;notifications&quot; =&amp;gt; [
        &quot;http://example.com/status&quot;,
        &quot;you@example.com&quot; 
      ]
    }   
  ],  
  &quot;api_key&quot; =&amp;gt; &quot;youapikeyhere&quot; 
}

headers = {:content_type =&amp;gt; :json, :accept =&amp;gt; :json}
RestClient.post HOST, JSON.generate(opts), headers 

&lt;/code&gt;
&lt;/pre&gt;
&lt;br /&gt;

Then on the receiving end you get the status update
&lt;pre&gt;
&lt;code class=&quot;json&quot;&gt;
{
 &quot;output&quot;: {&quot;url&quot;:&quot;s3://bucketname/filename&quot;,
                &quot;state&quot;:&quot;finished&quot;,
                &quot;label&quot;:&quot;fromapi&quot;,
                &quot;id&quot;:38384},
 &quot;job&quot;:{&quot;test&quot;:true,
          &quot;state&quot;:&quot;finished&quot;,
          &quot;id&quot;:38328}
}
&lt;/code&gt;
&lt;/pre&gt;
&lt;br /&gt;

	&lt;p&gt;This is pretty much all you need to start up your &#8220;next going to conquer the world and become a web celeb&#8221; venture, well this and a lot of free time. &lt;a href=&quot;http://baldur.snitchmedia.com/2008/7/11/how-to-make-an-object-in-a-amazon-s3-bucket-public&quot;&gt;There are some acl settings you need to apply on your bucket something I have covered previously&lt;/a&gt; but using the &lt;a href=&quot;https://addons.mozilla.org/en-US/firefox/addon/3247&quot;&gt;firefox pluggin for S3 is good for that stuff as well&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;The things I really like about this approach is that it&#8217;s decoupled from the upload process. They will pick up your file so the only thing is that you have to either have it uploaded to S3 or simply have your somewhere accessibly to them. The benefits of having it all on S3 is that the access control is built in so you don&#8217;t have to expose your high quality videos to the public unless you want to.&lt;/p&gt;


	&lt;p&gt;The pricing seems reasonable, especially given that they charges for minutes of video transcoded instead of filesize, which is a really refreshing perspective. 6 cents a minute makes it $3.6 to transcode all of the stuff my flip mino HD can record.&lt;/p&gt;


	&lt;p&gt;&lt;a href=&quot;http://zencoder.com/&quot;&gt;Go check it out&lt;/a&gt; it&#8217;s really fun to play with and it was written up by &lt;a href=&quot;http://techcrunch.com/2010/05/05/yc-funded-zencoder-wants-to-be-the-amazon-web-services-of-video-encoding/&quot;&gt;techcrunch today&lt;/a&gt;&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://baldur.snitchmedia.com/">
    <author>
      <name>baldur</name>
    </author>
    <id>tag:baldur.snitchmedia.com,2009-11-24:679</id>
    <published>2009-11-24T21:53:00Z</published>
    <updated>2009-11-24T21:57:36Z</updated>
    <category term="Tips and Tricks"/>
    <category term="logging"/>
    <category term="ruby"/>
    <link href="http://baldur.snitchmedia.com/2009/11/24/pimping-ruby-logger-instance" rel="alternate" type="text/html"/>
    <title>Pimping ruby Logger instance</title>
<content type="html">
            &lt;pre&gt;
&lt;code class=&quot;ruby&quot;&gt;
# pimping loggin a bit 
LOG = Logger.new('logs/application.log')
%w(debug info warn error fatal).each do |level|
  eval &amp;lt;&amp;lt;-end_eval
    def LOG.#{level}(message=&quot;&quot;, &#38;blk)
      if message == &quot;&quot; and block_given?
        message = blk.call
      end 
      file,line_number,method_name = caller.first.split(&quot;:&quot;)
      method_name = &quot;&quot; unless method_name
      filename = File.basename(file)
      super(filename + &quot;:&quot; + line_number) { method_name + &quot; &quot; + message }
    end 
  end_eval
end
&lt;/code&gt;
&lt;/pre&gt;
&lt;br /&gt;

	&lt;p&gt;I had to brag, it&#8217;s rare that I dabble in magic code i.e. code that is too clever to be understood right away and impossible to troubleshoot unless you wrote it yourself (recently). I usually try to keep my code quite simple. Clever has a bad rap in coding and for good reason since even the cleverest person can easily forget the lightning of cleverness that struck when he or she wrote something just a few weeks earlier. Even though clever code is bad it&#8217;s extremely satisfying when you solve something cleverly.&lt;/p&gt;


	&lt;p&gt;I am writing an application that operates mostly in the background i.e. without user interacting with it directly which makes troubleshooting tricky since one  can&#8217;t easily throw in a debug statement and step through the code execution.  I ofcourse have decent test coverage helps but in production code seems determinate to make once life miserable. This is where good logging becomes vital in chasing down bugs or performance bottlenecks in production code.&lt;/p&gt;


	&lt;p&gt;Logger in the standard ruby library is extremely awesome I have found that  I just wanted a little more out of it namely I wanted by default a single log  file with the name script file name, line number and perhaps the method name  where a particular message was sent to the logger. There didn&#8217;t seem to be an automatic  way of doing this so I resulted to do a little overwriting (the magic). I accomplished this by defining a singleton method on my logger instance.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://baldur.snitchmedia.com/">
    <author>
      <name>baldur</name>
    </author>
    <id>tag:baldur.snitchmedia.com,2009-08-30:659</id>
    <published>2009-08-30T12:04:00Z</published>
    <updated>2009-08-30T12:08:46Z</updated>
    <category term=".bash_history"/>
    <category term="note to self"/>
    <category term="Ruby on Rails"/>
    <category term="Tips and Tricks"/>
    <category term="ruby"/>
    <link href="http://baldur.snitchmedia.com/2009/8/30/the-partition-methdod" rel="alternate" type="text/html"/>
    <title>Ruby Enumerable#partition methdod</title>
<content type="html">
            &lt;p&gt;I finally found an opportunity to use ruby partition method. It splits an array you have upon a criteria you supply in a block. Typically, in the old days, I would have done this by doing something like this:&lt;/p&gt;


&lt;pre&gt;
&lt;code class=&quot;ruby&quot;&gt;
big_array = Array.new(11) {|i| i}
number_lower_than_5 = []

big_array.each do |number|
  if number &amp;lt; 5 
    number_lower_than_5 &amp;lt;&amp;lt; number
  end 
end

# &amp;gt;&amp;gt; number_lower_than_5
# =&amp;gt; [0,1,2,3,4]
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;or more recently I would use select&lt;/p&gt;


&lt;pre&gt;
&lt;code class=&quot;ruby&quot;&gt;
big_array = Array.new(11) {|i| i}
number_lower_than_5 = []

number_lower_than_5 = 
big_array.select do |number|
  number &amp;lt; 5 
end

# &amp;gt;&amp;gt; number_lower_than_5
# =&amp;gt; [0,1,2,3,4]
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;These are both fine methods but what happens if you need the other halve as well? The above approaches just collect you an array to work with and both lack the convenient array of the other stuff you sometimes care about. That&#8217;s where ruby&#8217;s partition comes in handy. It may not be that often that&#8217;s why I was so pumped up when I found an opportunity to use it.&lt;/p&gt;


&lt;pre&gt;
&lt;code class=&quot;ruby&quot;&gt;
big_array = Array.new(11) {|i| i}
number_lower_than_5, the_rest =
big_array.partition do |number|
  number &amp;lt; 5 
end

# &amp;gt;&amp;gt; number_lower_than_5
# =&amp;gt; [0,1,2,3,4]
# &amp;gt;&amp;gt; the_rest
# =&amp;gt; [5,6,7,8,9,10]
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;&lt;a href=&quot;http://www.ruby-doc.org/core/classes/Enumerable.html#M003130&quot;&gt;When needed the partition method can be very convenient&lt;/a&gt;&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://baldur.snitchmedia.com/">
    <author>
      <name>baldur</name>
    </author>
    <id>tag:baldur.snitchmedia.com,2009-04-16:648</id>
    <published>2009-04-16T18:03:00Z</published>
    <updated>2009-04-16T18:05:24Z</updated>
    <category term="joke"/>
    <link href="http://baldur.snitchmedia.com/2009/4/16/no-man" rel="alternate" type="text/html"/>
    <title>no man</title>
<content type="html">
            &lt;p&gt;on a recent ubuntu server instance I had to issue&lt;/p&gt;


&lt;pre&gt;
&lt;code class=&quot;bash&quot;&gt;
$ sudo apt-get install man
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;is this recession taking everything away from us?&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://baldur.snitchmedia.com/">
    <author>
      <name>baldur</name>
    </author>
    <id>tag:baldur.snitchmedia.com,2009-04-15:646</id>
    <published>2009-04-15T22:15:00Z</published>
    <updated>2009-04-16T02:25:48Z</updated>
    <category term="note to self"/>
    <category term="Tips and Tricks"/>
    <category term="apple"/>
    <category term="launchd"/>
    <category term="lingon"/>
    <category term="Linux"/>
    <category term="linux"/>
    <category term="plist"/>
    <link href="http://baldur.snitchmedia.com/2009/4/15/launchd-and-lingon" rel="alternate" type="text/html"/>
    <title>Different ways to moniter file system events</title>
<content type="html">
            &lt;h2&gt;The apple way&lt;/h2&gt;


	&lt;p&gt;In Leopard Apple introduced launchd which is their new system startup program. Launchd is a deamon which is a manager and scheduler. In addition to eliminating the need for crontab, which is traditionally how you would run scheduled jobs on unix systems, launchd offers you a whole slew of other events you can react to programatically. Events such as mounts, file creation and modifications. The example below demonstrates creating files in a watched folder. To do this you&#8217;ll need to create a property list file with a .plist suffix and place it in the Library/LaunchAgents/ folder for the user you can also have it work system wide for all users. Name the file com.foobar.watchmyfolder.plist re-login to your computer and you should be able to test this by placing a file in the folder $HOME/dropfolder and you should see that it in return touched a file did_it_work file in your home directory.&lt;/p&gt;


&lt;pre&gt;
&lt;code class=&quot;html&quot;&gt;

&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;
&amp;lt;!DOCTYPE plist PUBLIC &quot;-//Apple//DTD PLIST 1.0//EN&quot; 
&quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&amp;gt;
&amp;lt;plist version=&quot;1.0&quot;&amp;gt;
&amp;lt;dict&amp;gt;
    &amp;lt;key&amp;gt;Label&amp;lt;/key&amp;gt;
    &amp;lt;string&amp;gt;com.foobar.watchmyfolder&amp;lt;/string&amp;gt;
    &amp;lt;key&amp;gt;ProgramArguments&amp;lt;/key&amp;gt;
    &amp;lt;array&amp;gt;
        &amp;lt;string&amp;gt;touch&amp;lt;/string&amp;gt;
        &amp;lt;string&amp;gt;/Users/username/did_it_work&amp;lt;/string&amp;gt;
    &amp;lt;/array&amp;gt;
    &amp;lt;key&amp;gt;QueueDirectories&amp;lt;/key&amp;gt;
    &amp;lt;array&amp;gt;
        &amp;lt;string&amp;gt;/Users/username/watchfolder&amp;lt;/string&amp;gt;
    &amp;lt;/array&amp;gt;
    &amp;lt;key&amp;gt;StartOnMount&amp;lt;/key&amp;gt;
    &amp;lt;false/&amp;gt;
    &amp;lt;key&amp;gt;WatchPaths&amp;lt;/key&amp;gt;
    &amp;lt;array/&amp;gt;
&amp;lt;/dict&amp;gt;
&amp;lt;/plist&amp;gt;

&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;Its kind of a bummer that the format for the .plist files is xml since other much nicer formats could have been used such as yaml or something lightweight format. But to get around that bump I installed lingon which has really open up the possibilities of launchd, it doesn&#8217;t include all the options it does include enough to get your imagination going.&lt;/p&gt;


&lt;strong&gt;More information&lt;/strong&gt;
	&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;http://developer.apple.com/MacOsX/launchd.html&quot;&gt;Getting Started with launchd&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;http://tuppis.com/lingon/&quot;&gt;Lingon&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;&lt;br /&gt;&lt;/p&gt;


	&lt;h2&gt;The linux way&lt;/h2&gt;


	&lt;p&gt;During my research on this one it seems like the inotify library is the best option which can be used directly with the inotify-tools and also through some apis (see a c example in a link below). I have scetched a bash example below which I don&#8217;t like so much since relies on a crazy while loop to do its thing which just doesn&#8217;t seem right to me &#8230; or rather I would much prefer someone hiding that mess from me. So my hope is that there is something useful out there that works with configuration files similar to the launchd on the Mac &lt;span class=&quot;caps&quot;&gt;OS X&lt;/span&gt;.&lt;/p&gt;


&lt;pre&gt;
&lt;code class=&quot;bash&quot;&gt;
#!/bin/sh

while inotifywait -e create ~/watchfolder
do
  touch ~/watchfolder.log
  `date` &amp;gt;&amp;gt; ~/watchfolder.log
done

&lt;/code&gt;
&lt;/pre&gt;

&lt;strong&gt;More information&lt;/strong&gt;
	&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;http://inotify-tools.sourceforge.net/&quot;&gt;inotify-tools&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;http://www.ibm.com/developerworks/linux/library/l-ubuntu-inotify/index.html&quot;&gt;Moniter file system activity with inotify&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;http://manpages.ubuntu.com/manpages/intrepid/man1/inotifywait.1.html&quot;&gt;Manpage for inotifywait&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;
          </content>  </entry>
  <entry xml:base="http://baldur.snitchmedia.com/">
    <author>
      <name>baldur</name>
    </author>
    <id>tag:baldur.snitchmedia.com,2009-04-11:645</id>
    <published>2009-04-11T01:18:00Z</published>
    <updated>2009-04-11T01:19:44Z</updated>
    <category term="&quot;rotten shark&quot;"/>
    <category term="tasting"/>
    <link href="http://baldur.snitchmedia.com/2009/4/11/rotten-shark-tasting-fest" rel="alternate" type="text/html"/>
    <title>Rotten Shark Tasting Fest</title>
<content type="html">
            &lt;p&gt;Ah these fellas thought they knew what disgusting meant &#8230; bad taste has now reached another level.&lt;/p&gt;


&amp;lt;object height=&quot;300&quot; width=&quot;400&quot;&gt;&amp;lt;param /&gt;&amp;lt;param /&gt;&amp;lt;param /&gt;&amp;lt;embed src=&quot;http://vimeo.com/moogaloop.swf?clip_id=4098148&amp;amp;amp;server=vimeo.com&amp;amp;amp;show_title=1&amp;amp;amp;show_byline=1&amp;amp;amp;show_portrait=0&amp;amp;amp;color=&amp;amp;amp;fullscreen=1&quot; height=&quot;300&quot; width=&quot;400&quot;&gt;&amp;lt;/embed&gt;&amp;lt;/object&gt;&lt;br /&gt;&lt;a href=&quot;http://vimeo.com/4098148&quot;&gt;Viz Rotten Shark&lt;/a&gt; from &lt;a href=&quot;http://vimeo.com/user1569239&quot;&gt;Baldur Gudbjornsson&lt;/a&gt; on &lt;a href=&quot;http://vimeo.com&quot;&gt;Vimeo&lt;/a&gt;.
          </content>  </entry>
  <entry xml:base="http://baldur.snitchmedia.com/">
    <author>
      <name>baldur</name>
    </author>
    <id>tag:baldur.snitchmedia.com,2009-03-11:631</id>
    <published>2009-03-11T00:56:00Z</published>
    <updated>2009-03-11T00:58:54Z</updated>
    <category term="About me"/>
    <category term="Nothing That Matters"/>
    <link href="http://baldur.snitchmedia.com/2009/3/11/working-with-swedes" rel="alternate" type="text/html"/>
    <title>Working With Swedes</title>
<content type="html">
            &lt;p&gt;For the last few weeks in new job I hear a lot of Swedish. And all I can contribute is &lt;span class=&quot;caps&quot;&gt;BORK BORK BORK&lt;/span&gt;!&lt;/p&gt;


&amp;lt;object height=&quot;344&quot; width=&quot;425&quot;&gt;&amp;lt;param&gt;&amp;lt;/param&gt;&amp;lt;param&gt;&amp;lt;/param&gt;&amp;lt;param&gt;&amp;lt;/param&gt;&amp;lt;embed src=&quot;http://www.youtube.com/v/JJjh2DJ_r00&amp;amp;#38;hl=en&amp;amp;#38;fs=1&quot; height=&quot;344&quot; width=&quot;425&quot;&gt;&amp;lt;/embed&gt;&amp;lt;/object&gt;
          </content>  </entry>
  <entry xml:base="http://baldur.snitchmedia.com/">
    <author>
      <name>baldur</name>
    </author>
    <id>tag:baldur.snitchmedia.com,2009-02-15:587</id>
    <published>2009-02-15T18:55:00Z</published>
    <updated>2009-02-16T16:01:57Z</updated>
    <category term=".bash_history"/>
    <category term="Tips and Tricks"/>
    <category term="Bash"/>
    <category term="bash"/>
    <link href="http://baldur.snitchmedia.com/2009/2/15/serializing-a-bunch-of-files" rel="alternate" type="text/html"/>
    <title>Serializing a Bunch of Files</title>
<content type="html">
            &lt;p&gt;One thing I do love is to spend 15 minutes to solve a problem that would have taken me 20 minutes to do manually &#8230; heck that&#8217;s how I got into this programming thing. Bash scripting is becoming one of my favorite tools as it&#8217;s so simple once you wrap your head around it&#8217;s weirdness &#8230; which I am hoping to do early 2010 :)&lt;/p&gt;


	&lt;p&gt;So the problem I had was that I had a bunch of photos with some stupid names which were automatically generated by my stupid scanner software, sc30rr.jpg not joking it was total rubbish so after spending roughly 30 minutes scanning photographs I had this folder filled with files with that stupid name and I just wanted to make it name_of_event_001 and have the last bit be a serialized number.&lt;/p&gt;


&lt;pre&gt;
&lt;code class=&quot;bash&quot;&gt;
for filename in *.jpg ; \
  do n=$(( $n+1 )); \
  mv $filename name_of_event_`printf &quot;%03d&quot; $n`.jpg; \
done
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;My hope is next time I need to do this I will not have to fudge around for 15 minutes and just either remember how I did it this time or alternatively look it up on my blog :)&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://baldur.snitchmedia.com/">
    <author>
      <name>baldur</name>
    </author>
    <id>tag:baldur.snitchmedia.com,2009-02-14:586</id>
    <published>2009-02-14T03:26:00Z</published>
    <updated>2009-02-14T03:39:56Z</updated>
    <category term="Nothing That Matters"/>
    <category term="Linux"/>
    <category term="linux"/>
    <category term="mac"/>
    <category term="windows"/>
    <link href="http://baldur.snitchmedia.com/2009/2/14/love-hate-os-statistics" rel="alternate" type="text/html"/>
    <title>love/hate OS statistics</title>
<content type="html">
            &lt;p&gt;Lets define Friday night boredom :)&lt;/p&gt;


	&lt;p&gt;&lt;a href=&quot;http://www.google.com/search?hl=en&amp;amp;#38;q=%22i+love+windows%22&amp;amp;#38;btnG=Google+Search&amp;amp;#38;aq=f&amp;amp;#38;oq&quot;&gt;i love windows&lt;/a&gt;= 45k
&lt;a href=&quot;http://www.google.com/search?hl=en&amp;amp;#38;q=%22i+hate+windows%22&amp;amp;#38;btnG=Google+Search&amp;amp;#38;aq=f&amp;amp;#38;oq&quot;&gt;i hate windows&lt;/a&gt;= 79k
factor: 45/79 = 0.57&lt;/p&gt;


	&lt;p&gt;&lt;a href=&quot;http://www.google.com/search?hl=en&amp;amp;#38;q=%22i+love+mac%22&amp;amp;#38;btnG=Google+Search&amp;amp;#38;aq=f&amp;amp;#38;oq&quot;&gt;i love mac&lt;/a&gt;= 228k
&lt;a href=&quot;http://www.google.com/search?hl=en&amp;amp;#38;q=%22i+hate+mac%22&amp;amp;#38;btnG=Google+Search&amp;amp;#38;aq=f&amp;amp;#38;oq&quot;&gt;i hate mac&lt;/a&gt;= 10k
factor: 228/10 = 22.8&lt;/p&gt;


	&lt;p&gt;&lt;a href=&quot;http://www.google.com/search?hl=en&amp;amp;#38;q=%22i+love+linux%22&amp;amp;#38;btnG=Google+Search&amp;amp;#38;aq=f&amp;amp;#38;oq&quot;&gt;i love linux&lt;/a&gt;= 73k
&lt;a href=&quot;http://www.google.com/search?hl=en&amp;amp;#38;q=%22i+hate+linux%22&amp;amp;#38;btnG=Google+Search&amp;amp;#38;aq=f&amp;amp;#38;oq&quot;&gt;i hate linux&lt;/a&gt;= 7k
factor: 73/7 = 10.4&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://baldur.snitchmedia.com/">
    <author>
      <name>baldur</name>
    </author>
    <id>tag:baldur.snitchmedia.com,2009-02-13:585</id>
    <published>2009-02-13T11:46:00Z</published>
    <updated>2009-02-13T12:37:13Z</updated>
    <category term=".bash_history"/>
    <category term="Tips and Tricks"/>
    <category term="Bash"/>
    <category term="bash"/>
    <link href="http://baldur.snitchmedia.com/2009/2/13/a-kewl-bash-trick" rel="alternate" type="text/html"/>
    <title>A kewl bash Trick</title>
<content type="html">
            &lt;p&gt;when ever I get an opportunity to swings this trick out I get very excited. Say you have a task you wanna do and it&#8217;s should be applied to a number of files with a common name or are all with the same extension, basically any situation where you would be doing something that seems too repetitive for you taste.&lt;/p&gt;


	&lt;p&gt;Too create our example we can actually use the same trick. Lets say you have a number of files with the same name but have different number at the back of it: test_1.txt, test_2.txt, test_3.txt. So instead of doing touch file.txt n number of times you can instead do the following.&lt;/p&gt;


&lt;pre&gt;
&lt;code class=&quot;bash&quot;&gt;
$ touch test_{1,2,3}.txt 
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;Now when I was trying to figure out where I learned this from I found &lt;a href=&quot;http://www.linuxjournal.com/article/7385&quot;&gt;the website where it came from&lt;/a&gt; so go there for more kewl tricks.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://baldur.snitchmedia.com/">
    <author>
      <name>baldur</name>
    </author>
    <id>tag:baldur.snitchmedia.com,2009-02-10:584</id>
    <published>2009-02-10T02:17:00Z</published>
    <updated>2009-02-10T02:31:59Z</updated>
    <category term="note to self"/>
    <category term="Tips and Tricks"/>
    <category term="Bash"/>
    <category term="bash"/>
    <link href="http://baldur.snitchmedia.com/2009/2/10/deleting-everything-but" rel="alternate" type="text/html"/>
    <title>deleting everything but ...</title>
<content type="html">
            &lt;p&gt;Now if you have a problem where you wanna delete a couple of folders in a directory it&#8217;s easy to do that in a one liner&lt;/p&gt;


&lt;pre&gt;
&lt;code class=&quot;bash&quot;&gt;
$ rm -rf folder_1 folder_2 
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;but what if you want to delete all but those specific directories? Today my college showed me this amazing trick for finding everything but that&lt;/p&gt;


&lt;pre&gt;
&lt;code class=&quot;bash&quot;&gt;
$ find . -maxdepth 1 ! -name folder_1 ! -name folder_2 
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;which lists all the other folders in that particular directory and then that can easily be piped to rm.&lt;/p&gt;


&lt;pre&gt;
&lt;code class=&quot;bash&quot;&gt;
$ find . -maxdepth 1 ! -name folder_1 ! -name folder_2 | xargs rm -rf
&lt;/code&gt;
&lt;/pre&gt;
          </content>  </entry>
  <entry xml:base="http://baldur.snitchmedia.com/">
    <author>
      <name>baldur</name>
    </author>
    <id>tag:baldur.snitchmedia.com,2009-01-16:568</id>
    <published>2009-01-16T03:01:00Z</published>
    <updated>2009-01-16T03:44:40Z</updated>
    <category term="Javascript"/>
    <category term="Tips and Tricks"/>
    <category term="actionscript"/>
    <link href="http://baldur.snitchmedia.com/2009/1/16/my-recent-last-fm-tracks" rel="alternate" type="text/html"/>
    <title>My Recent last.fm Tracks</title>
<content type="html">
            &lt;p&gt;The art of loving music is learning to never be ashamed of your taste, learn to embrace and defend it to death. No matter how lame or kewl the stuff you have in your ear buds you have to pretend that you don&#8217;t care what others think of you &#8230; yes even while you get caught listening to &lt;a href=&quot;http://www.supertramp.com/home.html&quot;&gt;Supertramp&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;Now you can follow my latest tracks on the sidebar here to the right =&amp;gt;&lt;/p&gt;


	&lt;p&gt;Right underneath my adorable daughter Freyja which has been keeping my away from coding for the most part :) recently. Can&#8217;t wait to teach her to code!&lt;/p&gt;


	&lt;p&gt;So to back up my claim on not being ashamed of my music taste and attempt at getting familiar with actionscript I wrote a little package that will grap your rss feed from last.fm and dump it on your blog. This is the the kewl thing about actionscript it can snag stuff hosted else where and publish it on your website provided that you allow it in your &lt;a href=&quot;/crossdomain.xml&quot;&gt;crossdomain.xml&lt;/a&gt; file.&lt;/p&gt;


	&lt;p&gt;So here are some things I thought about actionscript until my college &lt;a href=&quot;http://totalfail.com/&quot;&gt;Adam&lt;/a&gt; showed me otherwise.&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;You don&#8217;t have to have the Flash application to author actionscript.&lt;/li&gt;
		&lt;li&gt;You don&#8217;t need flex in order to not use the Flash App.&lt;/li&gt;
		&lt;li&gt;And compiling it is easy using the straight up mxmlc from the Flex &lt;span class=&quot;caps&quot;&gt;SDK&lt;/span&gt; just do&lt;/li&gt;
	&lt;/ul&gt;


&lt;pre&gt;
&lt;code class=&quot;bash&quot;&gt;
 $ mxmlc MyAwesomeScript.as
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;and that will spit out the MyAwesomeScript.swf.&lt;/p&gt;


	&lt;p&gt;Now let&#8217;s take a look at my snippet&lt;/p&gt;


&lt;pre&gt;
&lt;code class=&quot;actionscript&quot;&gt;
package {
    import flash.display.Sprite;
    import flash.events.*;
    import flash.net.*;
    import flash.external.ExternalInterface;

    public class RecentTracks extends Sprite {
        private var recentlyPlayed:XML;
        private var rssUrl:String = &quot;http://ws.audioscrobbler.com/2.0/user/bakdyr/recenttracks.rss&quot;;

        public function RecentTracks() {
            var loader:URLLoader = new URLLoader();
                loader.addEventListener(Event.COMPLETE, completeHandler);
            var request:URLRequest = new URLRequest(rssUrl);
                loader.load(request);
        }

        private function completeHandler(event:Event):void {
            var outHtml:String;
            var loader:URLLoader = URLLoader(event.target);
            recentlyPlayed = new XML(loader.data);
            outHtml = &quot;&amp;lt;ul&amp;gt;\n&quot;;                           
            for each (var title:XML in recentlyPlayed..item..title) {
               var artist:String = title.toString().split(&quot; – &quot;)[0];
               var song:String = title.toString().split(&quot; – &quot;)[1];
               outHtml += &quot;&amp;lt;li&amp;gt;&quot; + song + &quot;&amp;lt;br /&amp;gt;&amp;lt;em&amp;gt;&quot; + artist + &quot;&amp;lt;/em&amp;gt;&amp;lt;/li&amp;gt;\n&quot;;                           
            }                                          
            outHtml += &quot;&amp;lt;/ul&amp;gt;\n&quot;;                           
            ExternalInterface.call('Snitchmedia.recentTracks', outHtml);
        }
    }
}

&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;Very simple little script that dials up the rss feed to last.fm and once it&#8217;s done it will call a javascript function that will handle outputting it on the page. Now this is very basic but I think an elegant solution to handle this sort of thing as I did not need to do any heroic mephisto, wordpress (or what ever the blog engine flavor of the month is) hacking and still able to add functionality to my blog. Obviously there is a lot of polishing to be done and I think I might make this a bit generic so it can be used to call in all sorts of third party fun stuff.&lt;/p&gt;


	&lt;p&gt;Now for completeness here is the javascript bit using jQuery.&lt;/p&gt;


&lt;pre&gt;
&lt;code class=&quot;javascript&quot;&gt;
var Snitchmedia = {};
Snitchmedia.recentTracks = function(playlist) {
  $('#recent_tracks').html(playlist);
};
&lt;/code&gt;
&lt;/pre&gt;
          </content>  </entry>
  <entry xml:base="http://baldur.snitchmedia.com/">
    <author>
      <name>baldur</name>
    </author>
    <id>tag:baldur.snitchmedia.com,2008-12-29:566</id>
    <published>2008-12-29T02:40:00Z</published>
    <updated>2008-12-29T02:46:57Z</updated>
    <category term="Travels"/>
    <category term="dogs"/>
    <link href="http://baldur.snitchmedia.com/2008/12/29/happy-holiday-s" rel="alternate" type="text/html"/>
    <title>Happy Holidays</title>
<content type="html">
            &lt;p&gt;Seriously never seen a happier dog than Scout!&lt;/p&gt;


	&lt;p&gt;&lt;a href=&quot;http://www.flickr.com/photos/askurandembla/3142483323/&quot; title=&quot;Poor Scout by Askur and Embla, on Flickr&quot;&gt;&lt;img src=&quot;http://farm4.static.flickr.com/3233/3142483323_9818a694ba.jpg&quot; height=&quot;333&quot; alt=&quot;Poor Scout&quot; width=&quot;500&quot; /&gt;&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;&lt;a href=&quot;http://www.flickr.com/photos/askurandembla/3142490265/&quot; title=&quot;Scout excited by Askur and Embla, on Flickr&quot;&gt;&lt;img src=&quot;http://farm4.static.flickr.com/3236/3142490265_aa73131f6f.jpg&quot; height=&quot;333&quot; alt=&quot;Scout excited&quot; width=&quot;500&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://baldur.snitchmedia.com/">
    <author>
      <name>baldur</name>
    </author>
    <id>tag:baldur.snitchmedia.com,2008-12-18:564</id>
    <published>2008-12-18T14:24:00Z</published>
    <updated>2008-12-18T14:27:41Z</updated>
    <category term="note to self"/>
    <category term="grubsnitch"/>
    <link href="http://baldur.snitchmedia.com/2008/12/18/why-grubsnitch-is-closed" rel="alternate" type="text/html"/>
    <title>Why Grubsnitch is closed</title>
<content type="html">
            &lt;p&gt;So I like everyone else have been scrambling to save some $$$ and one expense that was hard to justify was to keep an Amazon &lt;span class=&quot;caps&quot;&gt;EC2&lt;/span&gt; image running for My blog, and other pet projects that didn&#8217;t get any traffic to speak one of which was Grubsnitch.com. But now that I have settled on just using my age old Dreamhost account to store these things until that becomes unreasonable. I finally managed to get this mephisto instance running on there thanks to &lt;a href=&quot;http://www.expressionlab.com/2008/9/17/installing-mephisto-0-8-on-rails-2-1&quot;&gt;this page&lt;/a&gt; and my next projecdt will be to get grubsnitch.com running there as well.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://baldur.snitchmedia.com/">
    <author>
      <name>baldur</name>
    </author>
    <id>tag:baldur.snitchmedia.com,2008-12-18:563</id>
    <published>2008-12-18T14:12:00Z</published>
    <updated>2008-12-31T14:28:33Z</updated>
    <category term="note to self"/>
    <category term="Tips and Tricks"/>
    <category term="Bash"/>
    <category term="bash"/>
    <category term="curl"/>
    <link href="http://baldur.snitchmedia.com/2008/12/18/obsession-with-curl" rel="alternate" type="text/html"/>
    <title>Obsession with curl</title>
<content type="html">
            &lt;p&gt;Ok, this is hardly worth putting down but it will work for me as a reminder. I have been loving the curl utility allot lately. I had a situation where I needed a to hit a page rather frequently and I really wanted to just stick it in a bash loop and just have it run. The problem is that the page was behind user/password credentials. But as it turns out curl can have it&#8217;s own cookie jar so it can sustain a session between requests. Here is how.&lt;/p&gt;


&lt;pre&gt;
&lt;code class=&quot;bash&quot;&gt;
  curl -d &quot;user[login]=username&#38;user[password]=password&quot; \\
  -c domain.cookie http://example.com/user/login
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;Also another trick I have been addicted to is curling a domain and only getting the response headers&lt;/p&gt;


&lt;pre&gt;
&lt;code class=&quot;bash&quot;&gt;
curl -I http://domain.example.com
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;Who said I don&#8217;t like browsers?&lt;/p&gt;
          </content>  </entry>
</feed>
