<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><atom:link rel="hub" href="http://tumblr.superfeedr.com/" xmlns:atom="http://www.w3.org/2005/Atom"/><description></description><title>Reflective Pixel</title><generator>Tumblr (3.0; @kbrock)</generator><link>http://code.reflectivepixel.com/</link><item><title>Rails only accepts certain http verbs. It is simple enough to...</title><description>&lt;img src="http://29.media.tumblr.com/tumblr_lh0oo1if3B1qzc7cto1_100.jpg"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;Rails only accepts certain http verbs. It is simple enough to tell apache to limit access to passenger&lt;/p&gt;
&lt;p&gt;It can also live at the directory or server config level&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&lt;VirtualHost *:80&gt;
  ServerName plm.local
  DocumentRoot "/Users/kbrock/projects/plm-website/public"
  RailsEnv development
  &lt;Directory "/Users/kbrock/projects/plm-website/public"&gt;
    &lt;LimitExcept POST GET PUT DELETE OPTIONS&gt;
      Order deny,allow
      Deny from all
    &lt;/LimitExcept&gt;
  &lt;/Directory&gt;
&lt;/VirtualHost&gt;&lt;/code&gt;&lt;/pre&gt;</description><link>http://code.reflectivepixel.com/post/3443117286</link><guid>http://code.reflectivepixel.com/post/3443117286</guid><pubDate>Tue, 22 Feb 2011 05:45:00 -0500</pubDate></item><item><title>I want to speed up my local database. So I compromise data...</title><description>&lt;img src="http://28.media.tumblr.com/tumblr_lgoffvDXWi1qzc7cto1_250.png"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;I want to speed up my local database. So I compromise data integrity by not forcing the syncs. Loose a little bit of the ACID, but get some speed&lt;/p&gt;

&lt;p&gt;On homebres, I have this file installed in /usr/local/var/db/postgres/postgres.conf&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;fsync = off				# turns forced synchronization on or off
synchronous_commit = off		# immediate fsync at commit
&lt;/code&gt;&lt;/pre&gt;</description><link>http://code.reflectivepixel.com/post/3313765899</link><guid>http://code.reflectivepixel.com/post/3313765899</guid><pubDate>Tue, 15 Feb 2011 15:55:17 -0500</pubDate></item><item><title>I’d love to use a game controller like the IshockX to...</title><description>&lt;img src="http://29.media.tumblr.com/tumblr_ldhg402Tz81qzc7cto1_500.jpg"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;I’d love to use a game controller like the &lt;a href="http://www.macally.com/EN/Product/ArticleShow.asp?ArticleID=309"&gt;IshockX&lt;/a&gt; to write software.&lt;/p&gt;
&lt;p&gt;Wonder why the programming languages are so verbose, filled with nuances, and require so much typing&lt;/p&gt;</description><link>http://code.reflectivepixel.com/post/2326447756</link><guid>http://code.reflectivepixel.com/post/2326447756</guid><pubDate>Wed, 15 Dec 2010 13:45:36 -0500</pubDate></item><item><title>trying out redcar


# install redcar
rvm use ree
rvm gemset...</title><description>&lt;img src="http://26.media.tumblr.com/tumblr_ld70lxqjTg1qzc7cto1_500.jpg"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;trying out redcar&lt;/p&gt;

&lt;pre&gt;&lt;code class="sh"&gt;
# install redcar
rvm use ree
rvm gemset create redcar
rvm use @gemset
gem install redcar
redcar install

# create wrapper
rvm wrapper ree@redcar wrapped redcar

# alias wrapper to redcar
echo -e '\nalias redcar=wrapped_redcar' &gt;&gt; ~/.bashrc
. ~/.bashrc
&lt;/code&gt;
&lt;/pre&gt;
via &lt;a href="https://redcar.lighthouseapp.com/projects/25090/tickets/320-redcar-install-doesnt-play-nice-with-rvm"&gt;redcar lighthouse&lt;/a&gt;
&lt;br/&gt;&lt;a href="http://www.bradscollisioncenter.com/"&gt;image&lt;/a&gt;</description><link>http://code.reflectivepixel.com/post/2161556102</link><guid>http://code.reflectivepixel.com/post/2161556102</guid><pubDate>Thu, 09 Dec 2010 22:34:45 -0500</pubDate></item><item><title>If you do printf debugging, this adds pretty colors and only...</title><description>&lt;img src="http://29.media.tumblr.com/tumblr_l5t2yeF2P31qzc7cto1_250.png"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;If you do printf debugging, this adds pretty colors and only shows for the user requesting the logging&lt;/p&gt;
&lt;pre&gt;&lt;code class="ruby"&gt;# if you want to customize, redefine in initializers
# passenger does not define ENV['USER']
USER=ENV['HOME'].split('/').last

#usage:  my_log 'kbrock', 'UserController#logout', name
#only for me, will log 
def my_log(*args)
  who=args.shift #determine who wants to see this
  if who.nil? || who == USER
    theme=args.shift
    params = args.join ' ' || ''
    params += ' ' + yield if block_given?
    message="\e[1;34m#{theme}\e[0m #{params}"
    Rails.logger.debug(message)
    puts(message) unless Rails.env.test?
  end
end&lt;/code&gt;&lt;/pre&gt;</description><link>http://code.reflectivepixel.com/post/831933641</link><guid>http://code.reflectivepixel.com/post/831933641</guid><pubDate>Mon, 19 Jul 2010 09:03:50 -0400</pubDate></item><item><title>Private Browsing or cleared your cookies?

heh - go to flash...</title><description>&lt;img src="http://29.media.tumblr.com/tumblr_l4sj3p1TCQ1qzc7cto1_400.jpg"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;Private Browsing or cleared your cookies?&lt;/p&gt;

&lt;p&gt;heh - go to &lt;a href="http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager07.html"&gt;flash player preferences&lt;/a&gt; to see the stuff that you missed.&lt;/p&gt;</description><link>http://code.reflectivepixel.com/post/750652757</link><guid>http://code.reflectivepixel.com/post/750652757</guid><pubDate>Tue, 29 Jun 2010 15:21:25 -0400</pubDate></item><item><title>Tests rebuild database which takes a bit of time. I hacked...</title><description>&lt;img src="http://25.media.tumblr.com/tumblr_l4kxbqWSRL1qzc7cto1_100.png"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;Tests rebuild database which takes a bit of time. I hacked &lt;code&gt;Rakefile&lt;/code&gt; to not rebuild database every time.&lt;/p&gt;
&lt;pre&gt;&lt;code class="ruby"&gt;
Rake::Task['features'].clear_prerequisites   rescue nil # For some super weird reason this fails for some...
Rake::Task['default'].clear_prerequisites    rescue nil
Rake::Task['spec'].clear_prerequisites rescue nil

task :spec          =&gt; %w[db:abort_if_pending_migrations]
task :features      =&gt; %w[db:abort_if_pending_migrations]

desc "Run all tests and features"
task :default =&gt; %w(spec features)
&lt;/code&gt;&lt;/pre&gt;</description><link>http://code.reflectivepixel.com/post/746632083</link><guid>http://code.reflectivepixel.com/post/746632083</guid><pubDate>Mon, 28 Jun 2010 15:34:31 -0400</pubDate></item><item><title>Rake task to generate model diagrams in a rails...</title><description>&lt;img src="http://25.media.tumblr.com/tumblr_l4kwyujIMG1qzc7cto1_400.jpg"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;Rake task to generate model diagrams in a rails project&lt;/p&gt;
&lt;pre&gt;&lt;code class="ruby"&gt;
namespace :doc do
  desc "document db: (annotate, schema.rb, dot)"
  task :db=&gt;%w(annotate_models db:schema:dump doc:dot)

  desc "Use railroad to generate graphviz dot files"
  task :dot do
    #tack on stuff at the top of the page
    FORMAT=%q{sed 's/graph\\[/  graph[page="8.5,11",\
            size="7.5,10",center=1];\
    node[shape=Mrecord,width="1.2",fillcolor="#cccccc",\
            style="filled", penwidth="2"]\
    edge [ minlen="1.2", penwidth="2"]\
    graph[/'}
  
    now=`rake db:version`.chomp.split(' ')[-1]
    models="doc/models#{now}.dot"
    #hide magic hides created_at, updated_at
   puts `railroad -liM --hide-magic|#{FORMAT}&gt;#{models}`
  
    [models].each do |filename|
      filetype='pdf'
      outfile=filename.gsub('.dot',".#{filetype}")
      #create viewable file (graphviz must be installed)
      puts `dot -T#{filetype} #{filename} -o#{outfile}`

      #open the file using mac graphviz app
      puts `open #{filename} -a graphviz`
    end
  end
end
&lt;/code&gt;&lt;/pre&gt;</description><link>http://code.reflectivepixel.com/post/735018363</link><guid>http://code.reflectivepixel.com/post/735018363</guid><pubDate>Fri, 25 Jun 2010 12:40:06 -0400</pubDate></item><item><title>Easiest way I’ve fount to work with svn is to just use git...</title><description>&lt;img src="http://26.media.tumblr.com/tumblr_l1nyzoz3rL1qzc7cto1_250.jpg"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;Easiest way I’ve fount to work with svn is to just use git as the client.&lt;/p&gt;
&lt;p&gt;Most people explain how to converting svn to git. This lets me use git as a client for an svn server.&lt;/p&gt;
&lt;pre&gt;&lt;code class="bash"&gt;SVN_ROOT=ssh+svn://repo/opt/svn/repo/project1
git svn init -s $SVN_ROOT
git svn fetch
#git checkout -b svnrebase trunk
git rebase --onto trunk --root master
git svn dcommit&lt;/code&gt;&lt;/pre&gt;</description><link>http://code.reflectivepixel.com/post/559617408</link><guid>http://code.reflectivepixel.com/post/559617408</guid><pubDate>Thu, 29 Apr 2010 20:35:00 -0400</pubDate></item><item><title>Collect for a hash</title><description>&lt;pre&gt;&lt;code class="ruby"&gt;module Enumerable
  def hash_map
    hash = {}
    self.each {|o| hash.store(*yield(o))}
    hash
  end
end

my_hash = lines.hash_map {|l| l.split /:/}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Great suggestion on &lt;a href="http://www.reddit.com/r/ruby/comments/buytk/collectlike_method_for_populating_hashes/"&gt;redit&lt;/a&gt; for creating a hash from other objects.&lt;/p&gt;</description><link>http://code.reflectivepixel.com/post/543476720</link><guid>http://code.reflectivepixel.com/post/543476720</guid><pubDate>Fri, 23 Apr 2010 13:11:42 -0400</pubDate></item><item><title>test helper</title><description>&lt;p&gt;I added &lt;code class="ruby"&gt;assert_empty&lt;/code&gt; to check that an array is empty.&lt;/p&gt;
&lt;p&gt;But the line number from &lt;code&gt;test helper.rb&lt;/code&gt; was the first line of the test helper, not the line in the test.&lt;/p&gt;
&lt;p&gt;Instead, I wanted to see the actual failure as the first line. Welcome &lt;code class="ruby"&gt;remove_me_from_trace(exception)&lt;/code&gt;&lt;/p&gt;
 
&lt;pre&gt;&lt;code class="ruby"&gt;class Test::Unit::TestCase
  def assert_empty(*args)
    begin
      args.unshift []
      assert_equal *args
    rescue =&gt; e
      raise remove_me_from_trace(e)
    end
  end

  def remove_me_from_trace(e)
    x=e.backtrace.shift until (x =~ /test_helper.rb/ )
    e
  end
end
&lt;/code&gt;&lt;/pre&gt;</description><link>http://code.reflectivepixel.com/post/484537653</link><guid>http://code.reflectivepixel.com/post/484537653</guid><pubDate>Tue, 30 Mar 2010 13:04:00 -0400</pubDate></item><item><title>even better rake db:migrate</title><description>&lt;p&gt;I normally don’t like hacking rails files directly, but this is the only way I could extend &lt;code&gt;rake db:migrate&lt;/code&gt; to support a friendly &lt;code&gt;VERSION&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;railities/lib/tasks/database.rake&lt;/code&gt; on line 111.&lt;/p&gt;

&lt;pre&gt;&lt;code class="ruby"&gt;  # was ENV["VERSION"] ? ENV["VERSION"].to_i : nil
  # looks up version based upon migration files
  def version_num
    version=ENV["VERSION"]
    if version.to_i==0 &amp;&amp; version.present?
      matches=Dir["db/migrate/*#{ENV["VERSION"]}*"]
      if matches.length &gt; 0
        #prune off directory name
        matches=matches.collect{|n| n.gsub(/^.*\//,'')}

        unless matches.length == 1
          raise "VERSION #{version} matches "+
            "#{matches.join(', ')}"
        end

        #prune off version num
        version=matches.first.gsub(/([^_]*)_.*$/) {$1}
        puts "VERSION=#{version}"
      end
    end
    version ? version.to_i : nil
  end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;In 3 places (migrate, up, down), the version code is changed from&lt;/p&gt;
&lt;pre&gt;&lt;code class="ruby"&gt;ENV["VERSION"] ? ENV["VERSION"].to_i : nil&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;to&lt;/p&gt;
&lt;pre&gt;&lt;code class="ruby"&gt;version_num&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now &lt;code&gt;rake db:migrate:down VERSION=create_photo&lt;/code&gt; works like a charm.&lt;/p&gt;</description><link>http://code.reflectivepixel.com/post/470437618</link><guid>http://code.reflectivepixel.com/post/470437618</guid><pubDate>Wed, 24 Mar 2010 12:11:00 -0400</pubDate></item><item><title>better rake db:migrate</title><description>&lt;p&gt;I have been using a schell script so I don’t need to remember the long version number associated with ruby migrations.

&lt;pre&gt;&lt;code class="bash"&gt;#given a migration task, return the version
#e.g.: rake db:migrate:redo VERSION=$(mver create_photo)
function mver() {
  scr=${1:?Please specify migration action}
  ls db/migrate/*${scr}* | sed 's=^[^0-9]*\([0-9][^_]*\)_.*$=\1='
}&lt;/code&gt;&lt;/pre&gt;

which will run migration 20100302214328_create_photos_and_folders.rb&lt;/p&gt;</description><link>http://code.reflectivepixel.com/post/468544390</link><guid>http://code.reflectivepixel.com/post/468544390</guid><pubDate>Tue, 23 Mar 2010 16:27:00 -0400</pubDate></item><item><title>Had an error about removing Object::ClassMethods.
I added the...</title><description>&lt;img src="http://24.media.tumblr.com/tumblr_kycvonr5MD1qzc7cto1_r1_250.png"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;Had an error about removing &lt;code class="ruby"&gt;Object::ClassMethods&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;I added the following to &lt;code&gt;environment.rb&lt;/code&gt; to help me home in on the conflict.&lt;/p&gt;
&lt;pre&gt;&lt;code class="ruby"&gt;RAILS_DEFAULT_LOGGER = Logger.new(STDOUT)
ActiveSupport::Dependencies::log_activity = true&lt;/code&gt;&lt;/pre&gt;</description><link>http://code.reflectivepixel.com/post/409318961</link><guid>http://code.reflectivepixel.com/post/409318961</guid><pubDate>Wed, 24 Feb 2010 12:09:00 -0500</pubDate></item><item><title>New Hope: I’ve failed a few times ripping my DVDs to the...</title><description>&lt;img src="http://30.media.tumblr.com/tumblr_ky4bdnZiKH1qzc7cto1_400.jpg"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;New Hope: I’ve failed a few times ripping my DVDs to the network so I can watch on my TV/&lt;a href="http://www.wdtvlive.com/"&gt;WDTV Live&lt;/a&gt;. But this time it looks promising&lt;/p&gt;
&lt;p&gt;&lt;a href="http://thelittleappfactory.com/ripit/"&gt;Ripping&lt;/a&gt; is easy, but my &lt;a href="http://www.makemkv.com/"&gt;mkv&lt;/a&gt; files have been horrible. Am backing up to an iso so I can re compress these videos once I figure out my best options.&lt;/p&gt;
&lt;pre&gt;#mov_dir is the directory that contains the the VIDEO_TS directory.
hdiutil makehybrid -o "${mov_dir}.iso" "${mov_dir}"&lt;/pre&gt;
&lt;a href="http://www.avforums.com/forums/streamers-network-media-players/1142466-does-wdtv-live-play-isos.html"&gt;thanks&lt;/a&gt;</description><link>http://code.reflectivepixel.com/post/399607710</link><guid>http://code.reflectivepixel.com/post/399607710</guid><pubDate>Fri, 19 Feb 2010 21:10:00 -0500</pubDate></item><item><title>Question: Is it possible to calculate the Pythagorean Formula...</title><description>&lt;img src="http://25.media.tumblr.com/tumblr_krabcpXw4W1qzc7cto1_400.png"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;h3&gt;Question: Is it possible to calculate the Pythagorean Formula without the use of a square root function? &lt;small&gt;&lt;a href="http://github.com/kbrock/geokit-rails/"&gt;source&lt;/a&gt;&lt;/small&gt;&lt;/h3&gt;
&lt;p&gt;In order to support Geokit in sqlite3, I need a way to calculate distances that does not require cosine or square root. In my problem space, the points are relatively close to each other.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;C1=A+B&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The error was very similar to the size of the lowest number. So subtracted a fraction of the lowest number.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;C2=A+B-min(A,B)*0.6&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Restated the formula with min and max, and tweaked the ratios.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;C3=max(A,B)*0.945 + min(A,B)*0.415&lt;/code&gt;&lt;/pre&gt;

&lt;table border="1" cellspacing="0" cellpadding="4"&gt;&lt;caption&gt;calculation references&lt;/caption&gt;
&lt;tr&gt;&lt;td&gt;A&lt;/td&gt;&lt;td&gt;B&lt;/td&gt;&lt;td&gt;C&lt;/td&gt;&lt;td&gt;&lt;b&gt;c1&lt;/b&gt;&lt;/td&gt;&lt;td&gt;error&lt;/td&gt;&lt;td&gt;&lt;b&gt;c2&lt;/b&gt;&lt;/td&gt;&lt;td&gt;error&lt;/td&gt;&lt;td&gt;&lt;b&gt;c3&lt;/b&gt;&lt;/td&gt;&lt;td&gt;error&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;1000&lt;/td&gt;&lt;td&gt;1000&lt;/td&gt;&lt;td&gt;1414&lt;/td&gt;&lt;td&gt;&lt;b&gt;2000&lt;/b&gt;&lt;/td&gt;&lt;td&gt;586&lt;/td&gt;&lt;td&gt;&lt;b&gt;1400&lt;/b&gt;&lt;/td&gt;&lt;td&gt;-14&lt;/td&gt;&lt;td&gt;&lt;b&gt;1360&lt;/b&gt;&lt;/td&gt;&lt;td&gt;54&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;1000&lt;/td&gt;&lt;td&gt;750&lt;/td&gt;&lt;td&gt;1250&lt;/td&gt; &lt;td&gt;&lt;b&gt;1750&lt;/b&gt;&lt;/td&gt;&lt;td&gt;500&lt;/td&gt;&lt;td&gt;&lt;b&gt;1300&lt;/b&gt;&lt;/td&gt;&lt;td&gt;50&lt;/td&gt;&lt;td&gt;&lt;b&gt;1256&lt;/b&gt;&lt;/td&gt;&lt;td&gt;-6&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;1000&lt;/td&gt;&lt;td&gt;500&lt;/td&gt;&lt;td&gt;1118&lt;/td&gt; &lt;td&gt;&lt;b&gt;1500&lt;/b&gt;&lt;/td&gt;&lt;td&gt;382&lt;/td&gt;&lt;td&gt;&lt;b&gt;1200&lt;/b&gt;&lt;/td&gt;&lt;td&gt;82&lt;/td&gt;&lt;td&gt;&lt;b&gt;1153&lt;/b&gt;&lt;/td&gt;&lt;td&gt;-34&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;1000&lt;/td&gt;&lt;td&gt;250&lt;/td&gt;&lt;td&gt;1031&lt;/td&gt; &lt;td&gt;&lt;b&gt;1250&lt;/b&gt;&lt;/td&gt;&lt;td&gt;219&lt;/td&gt;&lt;td&gt;&lt;b&gt;1100&lt;/b&gt;&lt;/td&gt;&lt;td&gt;69&lt;/td&gt;&lt;td&gt;&lt;b&gt;1049&lt;/b&gt;&lt;/td&gt;&lt;td&gt;-18&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;1000&lt;/td&gt;&lt;td&gt;0&lt;/td&gt;&lt;td&gt;1000&lt;/td&gt;   &lt;td&gt;&lt;b&gt;1000&lt;/b&gt;&lt;/td&gt;  &lt;td&gt;0&lt;/td&gt;&lt;td&gt;&lt;b&gt;1000&lt;/b&gt;&lt;/td&gt; &lt;td&gt;0&lt;/td&gt;&lt;td&gt;&lt;b&gt;945&lt;/b&gt;&lt;/td&gt;&lt;td&gt;55&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;Please share if you can help me come up with a better approximation or if you see an error.&lt;/p&gt;
thanks &lt;a href="http://www.meridianworlddata.com/Distance-Calculation.asp"&gt;Meridian&lt;/a&gt;.</description><link>http://code.reflectivepixel.com/post/209051155</link><guid>http://code.reflectivepixel.com/post/209051155</guid><pubDate>Sat, 10 Oct 2009 02:00:00 -0400</pubDate></item><item><title>require 'hotcocoa'
class Application
  include HotCocoa
 ...</title><description>&lt;img src="http://27.media.tumblr.com/bcLuVNklypoqw200HVeYiis3o1_400.png"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;&lt;pre&gt;&lt;code class="ruby"&gt;require 'hotcocoa'
class Application
  include HotCocoa
  FULL={:expand =&gt; [:width,:height]}
  SHOW=[0,0,0,100]
  def start
    application :name =&gt; "MyTableView" do |app|
      app.delegate = self
      window(:title =&gt; "MyTableView",
        :frame =&gt; [10, 620, 330, 230]) do |win|
        win &lt;&lt; split_view(:horizontal =&gt; true,
          :layout =&gt; FULL,:frame=&gt;SHOW) do |sp|
          sp &lt;&lt; sc=scroll_view(:frame =&gt; SHOW)
          sc &lt;&lt; @tv=table_view(:data=&gt;[],:columns=&gt;[])
          sp &lt;&lt; @pr=text_field(:text =&gt; 'type here',
            :font =&gt; font(:name=&gt;'Monaco', :size =&gt; 16),
            :on_action =&gt; Proc.new {|t| type(t.to_s)})
        end #sp
        win.contentView.margin = 5
        win.makeFirstResponder @pr
        win.will_close { exit }
      end #window (win)
    end #application
  end
  def type(t)
    values={}
    t.split.each_with_index do |v,i|
      values["c#{i}"]=v
      if i &gt;= @tv.tableColumns.size
        @tv.tableColumns &lt;&lt; column(:id=&gt;"c#{i}",
          :title=&gt;"Word #{i+1}")
      end
    end
    @tv.dataSource.data &lt;&lt; values
    @tv.reloadData
  end
end
Application.new.start
&lt;/code&gt;&lt;/pre&gt;
#thanks again to &lt;a href="http://everburning.com/news/heating-up-with-hotcocoa-part-ii/"&gt;everburning.com&lt;/a&gt;&lt;/p&gt;</description><link>http://code.reflectivepixel.com/post/139104045</link><guid>http://code.reflectivepixel.com/post/139104045</guid><pubDate>Fri, 10 Jul 2009 12:00:00 -0400</pubDate></item><item><title>require 'hotcocoa'
include HotCocoa
require...</title><description>&lt;img src="http://28.media.tumblr.com/bcLuVNklypoioovkargD2pOXo1_r1_500.png"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;&lt;pre&gt;&lt;code class="ruby"&gt;require 'hotcocoa'
include HotCocoa
require "lib/bezel.rb";
framework 'ScriptingBridge'

class Application
  def start
    application :name =&gt; "Ask Google" do |app|
      app.delegate = self
      @main_window = bezel_window(
        :frame =&gt; [450,300,128,128],
        :buttons =&gt; [
          ["Google it",lambda { |s| doit }],
          ["Quit",lambda { |s| exit }]])
    end
  end
  def open_url(url)
    @safari.documents.first.URL=url
    sleep(1) #wait for safari to load url
    @safari.windows.first.currentTab
  end
  def fill_form(tab,form,values={})
    values.each_pair do |n,v|
      safari_do tab,"document.#{form}.#{n}.value='#{v}'"
    end
    safari_do tab,"document.#{form}.submit()"
  end
  def safari_do(tab,cmd)
    @safari.doJavaScript(cmd, :'in'=&gt;tab)
  end
  def doit
    @safari = SBApplication.
      applicationWithBundleIdentifier('com.apple.Safari')
    @safari.activate #bring to front
    tab=open_url('http://www.google.com/')
    fill_form tab,:f, :q=&gt;"macruby"
  end
end
Application.new.start
&lt;/code&gt;&lt;/pre&gt;
thanks &lt;a href="http://griddlenoise.blogspot.com/2007/11/applescripting-across-universe.html"&gt;python people&lt;/a&gt; and @&lt;a href="http://twitter.com/lrz"&gt;lrz&lt;/a&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;</description><link>http://code.reflectivepixel.com/post/138164790</link><guid>http://code.reflectivepixel.com/post/138164790</guid><pubDate>Thu, 09 Jul 2009 00:22:00 -0400</pubDate></item><item><title>require 'hotcocoa'
class Application
  include HotCocoa
 ...</title><description>&lt;img src="http://28.media.tumblr.com/bcLuVNklyp54m9eiCadfkw7Zo1_400.png"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;&lt;pre&gt;&lt;code class="ruby"&gt;require 'hotcocoa'
class Application
  include HotCocoa
  FULL={:expand =&gt; [:width,:height]}
  SHOW=[0,0,0,100]
  def start
    application :name =&gt; "MyTableView" do |app|
      app.delegate = self
      window(:title =&gt; "MyTableView",
        :frame =&gt; [10, 620, 330, 230]) do |win|
        win &lt;&lt; split_view(:horizontal =&gt; true,
          :layout =&gt; FULL) do |sp|
          sp &lt;&lt; scroll_view(:frame =&gt; SHOW) do |sv|
            sv &lt;&lt; @table=table_view(
              :data =&gt; [], :columns =&gt; [
                column(:id =&gt; :c1, :title =&gt; "Word 1"),
                column(:id =&gt; :c2, :title =&gt; "Word 2"),
                column(:id =&gt; :c3, :title =&gt; "...")])
          end #sv
          sp &lt;&lt; @prompt = text_field(:text =&gt; 'type here',
            :font =&gt; font(:name=&gt;'Monaco', :size =&gt; 16),
            :on_action =&gt; Proc.new {|t| type(t)})
        end #sp
        win.contentView.margin = 5
        win.makeFirstResponder @prompt
        win.will_close { exit }
      end #window (win)
    end #application
  end
  def type(t)
    c1,c2,*c3=t.to_s.split ; c3=c3.join ' '
    @table.dataSource.data &lt;&lt; {:c1=&gt;c1,:c2=&gt;c2,:c3=&gt;c3}
    @table.reloadData
  end
end
a=Application.new.start&lt;/code&gt;&lt;/pre&gt;
thanks &lt;a href="http://everburning.com/news/heating-up-with-hotcocoa-part-ii/"&gt;everburning&lt;/a&gt;&lt;/p&gt;</description><link>http://code.reflectivepixel.com/post/130008775</link><guid>http://code.reflectivepixel.com/post/130008775</guid><pubDate>Thu, 25 Jun 2009 10:40:45 -0400</pubDate></item><item><title>redirect app</title><description>&lt;p&gt;I currently work on port 80, but coworkers work on port 3000. So the urls they send often do not work. I created an app that bounces all local 3000 requests to port 80.

&lt;pre&gt;&lt;code class="shell"&gt;mkdir -p bounce/public bounce/tmp
cd bounce
&lt;/code&gt;&lt;/pre&gt;
created &lt;code&gt;config.ru&lt;/code&gt;:
&lt;pre&gt;&lt;code class="ruby"&gt;app = proc do |env|
    url="http://#{env['SERVER_NAME']}#{env['REQUEST_URI']}"
    return [302, { "Content-Type" =&gt; "text/html", "Location" =&gt; url }, "try &lt;a href=\"#{url}\"&gt;#{url}&lt;/a&gt;" ]
end
run app&lt;/code&gt;&lt;/pre&gt;
enabled port 3000 in &lt;code&gt;/private/etc/apache2/httpd.conf&lt;/code&gt;:
&lt;pre&gt;&lt;code&gt;Listen 3000&lt;/code&gt;&lt;/pre&gt;
added entry to passenger pref pane. But it didn’t create the proper vhosts entry. I changed port 80 to 3000
&lt;pre&gt;&lt;code&gt;&lt;VirtualHost *:&lt;b&gt;3000&lt;/b&gt;&gt;
  ServerName site1.local:3000
  ServerAlias test.local:3000
  DocumentRoot "/Users/kbrock/projects/bounce/public"
  RackEnv development
  &lt;directory "/Users/kbrock/projects/bounce/public"&gt;
    Order allow,deny
    Allow from all
  &lt;/directory&gt;
&lt;/VirtualHost&gt;&lt;/code&gt;&lt;/pre&gt;
All is working.&lt;/p&gt;</description><link>http://code.reflectivepixel.com/post/125827646</link><guid>http://code.reflectivepixel.com/post/125827646</guid><pubDate>Thu, 18 Jun 2009 09:39:00 -0400</pubDate><category>mac rack</category></item></channel></rss>

