<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>MyUtil&#8482; - Home</title>
  <id>tag:myutil.com,2012:mephisto/</id>
  <generator uri="http://mephistoblog.com" version="0.8.0">Mephisto Drax</generator>
  <link href="http://myutil.com/feed/atom.xml" type="application/atom+xml" rel="self"/>
  <link href="http://myutil.com/" type="text/html" rel="alternate"/>
  <updated>2012-05-11T02:22:44Z</updated>
  <entry xml:base="http://myutil.com/">
    <author>
      <name>face</name>
    </author>
    <id>tag:myutil.com,2012-05-03:5561</id>
    <published>2012-05-03T00:56:00Z</published>
    <updated>2012-05-11T02:22:44Z</updated>
    <category term="openssl"/>
    <category term="Ruby"/>
    <category term="ruby"/>
    <link href="http://myutil.com/2012/5/3/openssl-1-0-1b_0-breaks-ruby-in-macports" type="text/html" rel="alternate"/>
    <title>openssl @1.0.1b_0 breaks Ruby in macports</title>
<content type="html">
            <p>Aloha,</p>


	<p>When updating to the latest macports, openssl 1.0.1 is installed.     Then whenever Ruby tries to connect to facebook, you get errors like:</p>


	<p>Errno::ECONNRESET (Connection reset by peer &#8211; <span class="caps">SSL</span>_connect)</p>


The solution&#8230;downgrade openssl.    You can see what you versions you have installed:
<pre><code>
port installed | grep  openssl
  openssl @1.0.0h_0
  openssl @1.0.1_2
  openssl @1.0.1b_0 (active)
</pre></code>
<p><br />

Ok Great, we have the old version:
</p>
<pre><code>
sudo port activate openssl @1.0.0h_0
</pre></code>
<p><br />

	<p>Oh, but what if you don&#8217;t have the correct version already installed?  Thats a little trickier:
<br />
</p>
<pre><code>
svn co -r  90715 https://trac.macports.org/browser/trunk/dports/devel/openssl
cd openssl
sudo port install
</pre></code>
<p><br /></p>


	<p><span>Update: </span>Installing Openssl 1.0.1c and rebuilding ruby also fixes the problem
<pre><code>
sudo port selfupdate
sudo port update outdated
sudo port uninstall ruby19
sudo port install ruby19 +doc+nosuffix
</pre></code>
<p><br />
And now I have ruby 1.9 and openssl 1.0.1c talking to facebook without peer resets.</p>


	<p><br />
References:</p>


<a href="http://reinout.vanrees.org/weblog/2008/09/19/macports-downgrading-subversion.html">http://reinout.vanrees.org/weblog/2008/09/19/macports-downgrading-subversion.html</a>
<a href="https://trac.macports.org/wiki/howto/InstallingOlderPort">https://trac.macports.org/wiki/howto/InstallingOlderPort</a>
<a href="https://trac.macports.org/log/trunk/dports/devel/openssl/Portfile">https://trac.macports.org/log/trunk/dports/devel/openssl/Portfile</a>
</p>

	<p>A hui hou!</p>
          </content>  </entry>
  <entry xml:base="http://myutil.com/">
    <author>
      <name>face</name>
    </author>
    <id>tag:myutil.com,2009-09-27:5328</id>
    <published>2009-09-27T04:18:00Z</published>
    <updated>2009-09-27T04:19:05Z</updated>
    <category term="hawaii"/>
    <category term="Rails"/>
    <category term="rails"/>
    <category term="Ruby"/>
    <category term="ruby"/>
    <link href="http://myutil.com/2009/9/27/ruby-is-paradise-and-rails-in-paradise" type="text/html" rel="alternate"/>
    <title>Ruby is Paradise and Rails in Paradise</title>
<content type="html">
            <div><a href="http://alohaonrails.com/"><img width="154" alt="I Am Attending Aloha On Rails, The Hawaii Ruby on Rails Conference" height="218" class="alignnone size-full wp-image-130" title="I Am Attending Aloha On Rails, The Hawaii Ruby on Rails Conference" src="http://www.alohaonrails.com/wp-content/uploads/2009/05/aor_attd.jpg" /></a></div><p><br /><br />
I&#8217;ve been meaning to attend a rails conference and after moving to Oahu I figured it would be a while.  But now the Rails conference is coming to me!   So I couldn&#8217;t pass and will be at Aloha on Rails. </p><p> I hope to see you there!</p><br /><br /><br /><br /><br />
          </content>  </entry>
  <entry xml:base="http://myutil.com/">
    <author>
      <name>face</name>
    </author>
    <id>tag:myutil.com,2009-06-15:4411</id>
    <published>2009-06-15T22:43:00Z</published>
    <updated>2009-06-16T00:03:46Z</updated>
    <category term="iPhone Development"/>
    <category term="iphone"/>
    <category term="objective-c"/>
    <link href="http://myutil.com/2009/6/15/simple-way-to-embed-a-http-server-into-your-iphone-app" type="text/html" rel="alternate"/>
    <title>Simple way to embed a http server into your iPhone app</title>
<content type="html">
            <p>Announcing <a href="http://github.com/face/MongooseDaemon/tree/master">MongooseDaemon</a>, an objective-c wrapper for the wonderful mongoose http server.</p>


	<p>It can be indispensable to be able to explore your iPhone apps directory structure when developing and debugging iPhone applications.   You may also want to serve up content from your iPhone application via http.</p>


	<p>Erica Sadun&#8217;s cookbook has an example of a hand rolled http server.   However, it is only an example and is incomplete.   I recently needed a http server in an iPhone app and after playing with Erica&#8217;s example I quickly realized I didn&#8217;t want to be in the business of creating a complete http server.</p>


	<p>So I started looking for an existing http server I could embed in my app.    I quickly found <a href="http://code.google.com/p/mongoose/">moongoose.</a></p>


	<p>With just a few minutes of coding, I was able to get mongoose working in my iPhone application.     To make it even easier for the next developer, I extracted my wrapper into the MongooseDaemon class and am offering it under a <span class="caps">BSD</span> license.</p>


	<p>Here is some example code taken directly from one of my apps I am debugging:</p>


Add the following to one of your projects classes .h  (MyAppDelegate.h for this example):
<table class="CodeRay"><tr>
  <td class="line_numbers" title="click to toggle"><pre>1<tt>
</tt>2<tt>
</tt>3<tt>
</tt>4<tt>
</tt><strong>5</strong><tt>
</tt>6<tt>
</tt>7<tt>
</tt>8<tt>
</tt>9<tt>
</tt></pre></td>
  <td class="code"><pre>  <span class="pp">#import</span> <span class="s"><span class="dl">&quot;</span><span class="k">MongooseDaemon.h</span><span class="dl">&quot;</span></span><tt>
</tt>  ....<tt>
</tt>  <span class="er">@</span>class MongooseDaemon<tt>
</tt><tt>
</tt>  <span class="er">@</span>interface MyAppDelegate : NSObject &lt;UIApplicationDelegate, UITabBarControllerDelegate&gt; {<tt>
</tt>    ...<tt>
</tt>    MongooseDaemon    *mongooseDaemon;<tt>
</tt>    ...<tt>
</tt>  }</pre></td>
</tr></table>


And add the following to the class ( MyAppDelegate.m for this example):
<table class="CodeRay"><tr>
  <td class="line_numbers" title="click to toggle"><pre>1<tt>
</tt>2<tt>
</tt>3<tt>
</tt>4<tt>
</tt><strong>5</strong><tt>
</tt>6<tt>
</tt>7<tt>
</tt>8<tt>
</tt>9<tt>
</tt><strong>10</strong><tt>
</tt>11<tt>
</tt>12<tt>
</tt>13<tt>
</tt>14<tt>
</tt></pre></td>
  <td class="code"><pre>  ...<tt>
</tt>  <span class="er">@</span>implementation LightyAppDelegate<tt>
</tt>  ...<tt>
</tt>  - (<span class="pt">void</span>)<span class="la">applicationDidFinishLaunching:</span>(UIApplication *)application {<tt>
</tt>  mongooseDaemon = [[MongooseDaemon alloc] init];<tt>
</tt>  [mongooseDaemon <span class="la">startMongooseDaemon:</span><span class="er">@</span><span class="s"><span class="dl">&quot;</span><span class="k">8080</span><span class="dl">&quot;</span></span>];<tt>
</tt><tt>
</tt>  ...<tt>
</tt>  - (<span class="pt">void</span>)dealloc {<tt>
</tt>  ...<tt>
</tt>    [mongooseDaemon stopMongooseDaemon];<tt>
</tt>    [mongooseDaemon release];<tt>
</tt>  ...<tt>
</tt>  }</pre></td>
</tr></table>


	<p>Now you can surf to your application.  For example, if your iPhones IP on
wifi is 192.168.1.100 (sorry a helper method for determining your iPhones
IP will be coming soon), then you could surf to http://192.168.1.100:8080/</p>


	<p>Serve files in good health!</p>
          </content>  </entry>
  <entry xml:base="http://myutil.com/">
    <author>
      <name>face</name>
    </author>
    <id>tag:myutil.com,2009-02-06:3809</id>
    <published>2009-02-06T22:02:00Z</published>
    <updated>2009-02-06T22:09:59Z</updated>
    <category term="iPhone Development"/>
    <category term="atos"/>
    <category term="cocoa"/>
    <category term="iphone"/>
    <category term="ratos"/>
    <category term="Ruby"/>
    <category term="ruby"/>
    <link href="http://myutil.com/2009/2/6/announcing-ratos-a-shell-to-decode-iphone-stack-traces" type="text/html" rel="alternate"/>
    <title>Announcing ratos: A shell to Decode iPhone Stack Traces</title>
<content type="html">
            I&#8217;m pleased to give you <a href="http://github.com/face/ratos/tree/master">ratos</a>, a shell to speed iPhone development by decoding an entire stack trace at once using atos.   Of course as it relies on atos, so it only works on a Mac with Xcode installed.</p>
<div>
<pre><code>
 [301] tako:~&gt;  ratos

App Name:TheSnapper
App Path:/Users/face/proj/TheSnapper

Paste xcode stack trace to stdin, then type 'sim' or 'arm' on a line by itself.
  Type 'exit' or '^D' to quit and 'app' to print the current app.

ratos&gt;2009-02-05 10:21:31.107 TheSnapper[751:20b] Stack: (
    808221155,
    806100816,
    808224973,
    807957033,
    807851552,
    25785,
    22599,
    22855,
    807923363,

arm

-[BackViewController doubleSnapAction:] (in TheSnapper) (BackViewController.m:192)
-[BackViewController resetAllSiders] (in TheSnapper) (BackViewController.m:126)
-[BackViewController resetSnap:] (in TheSnapper) (BackViewController.m:138)

</pre></code>
</div><p><br />
When I first learned iPhone development it took me a while to find atos.      Exception handling comes natural but Xcode spits out addresses in their stack traces.     After much googling I finally found atos.     I then immediately found Apple&#8217;s docs to integrate atos into an exception handler.   Cool&#8230;.<b><span class="caps">NOT</span>!</b>

	<p>Turns out Apple&#8217;s Xcode integration relies on /usr/bin/atos at runtime&#8230;.not possible on my iPhone.</p>


	<p>So, I immediately wrote a quick and dirty shell in Ruby that takes a stack trace in from xcode, and prints out any lines that have symbols.    Gobbledygook in, nice human readable stack trace out!</p>


	<p>After enjoying ratos for the past few months I finally had a chance today to clean it up a little and <a href="http://github.com/face/ratos/tree/master">publish it on github</a>.</p>


To use it, first install it on your path.:
<code><pre>
git clone git://github.com/face/ratos.git
sudo cp ratos/bin/ratos /usr/local/bin/.
</pre></code>
There are a couple environment variables that can be used to configure ratos.     Also, if ratos happens to be installed in a project under the directory bin it will self configure.   If your application name and directory name are the same and ratos is installed in a shared location like /usr/local/bin, you only need to set <code>RATOS_APP_PATH</code>:
<code><pre>
# csh
setenv RATOS_APP_PATH ~/proj/TheSnapper

# or bash
export RATOS_APP_PATH=~/proj/TheSnapper
</pre></code>
If your application name is different than the directory name, you can also set <code>RATOS_APP_NAME</code>.

Here are some real world examples of how I start up the ratos shell:
<code><pre>
 [303] tako:~&gt;  echo $RATOS_APP_PATH
/Users/face/proj/TheSnapper
 [304] tako:~&gt;  ratos

App Name:TheSnapper
App Path:/Users/face/proj/TheSnapper

Paste xcode stack trace to stdin, then type 'sim' or 'arm' on a line by itself.
  Type 'exit' or '^D' to quit and 'app' to print the current app.

ratos&gt;exit
</pre></code>
<code><pre>
 [305] tako:~&gt;  env RATOS_APP_PATH=~/proj/IttyBooks ratos

App Name:TheSnapper
App Path:~/proj/IttyBooks

Paste xcode stack trace to stdin, then type 'sim' or 'arm' on a line by itself.
  Type 'exit' or '^D' to quit and 'app' to print the current app.

ratos&gt;exit
</pre></code>
<code><pre>
 [306] tako:~&gt;  env RATOS_APP_PATH=~/proj/IttyBooksFree RATOS_APP_NAME=IttyBooks ratos

App Name:IttyBooks
App Path:~/proj/IttyBooksFree

Paste xcode stack trace to stdin, then type 'sim' or 'arm' on a line by itself.
  Type 'exit' or '^D' to quit and 'app' to print the current app.

ratos&gt;exit
</pre></code>
And finally, here is an example interaction:
<code><pre>
 [307] tako:~&gt;  ratos

App Name:TheSnapper
App Path:/Users/face/proj/TheSnapper

Paste xcode stack trace to stdin, then type 'sim' or 'arm' on a line by itself.
  Type 'exit' or '^D' to quit and 'app' to print the current app.

ratos&gt;2009-02-05 10:21:31.107 TheSnapper[751:20b] Stack: (
    808221155,
    806100816,
    808224973,
    807957033,
    807851552,
    25785,
    22599,
    22855,
    807923363,
    816119156,
    816119004,
    816157144,
    8381,
    8244
)
terminate called after throwing an instance of 'NSException'

arm

-[BackViewController doubleSnapAction:] (in TheSnapper) (BackViewController.m:192)
-[BackViewController resetAllSiders] (in TheSnapper) (BackViewController.m:126)
-[BackViewController resetSnap:] (in TheSnapper) (BackViewController.m:138)
main (in TheSnapper) (main.m:14)
start (in TheSnapper) + 52

ratos&gt;exit
</pre></code>

	<p>Enjoy!</p>
          </content>  </entry>
  <entry xml:base="http://myutil.com/">
    <author>
      <name>face</name>
    </author>
    <id>tag:myutil.com,2009-02-06:3807</id>
    <published>2009-02-06T19:39:00Z</published>
    <updated>2009-02-06T19:40:54Z</updated>
    <category term="iPhone Development"/>
    <category term="activerecord"/>
    <category term="cocoa"/>
    <category term="iphone"/>
    <category term="objective-c"/>
    <category term="sqlite"/>
    <link href="http://myutil.com/2009/2/6/i-ve-pushed-some-enhancements-to-objective-c-activerecord" type="text/html" rel="alternate"/>
    <title>I've pushed some enhancements to objective-c activerecord</title>
<content type="html">
            <div><a href="http://openid.net/"><img alt="OpenID logo" src="/assets/2009/2/6/Picture_20.png"></a></div> 
<p><br />
I used <a href="http://github.com/aptiva/activerecord/tree/master">objective-c activerecord</a> in <a href="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=300995849&amp;mt=8">IttyBooks</a> as my <span class="caps">ORM</span> layer.

	<p>I fixed some bugs and made some <span class="caps">API</span> changes.   Most of the <span class="caps">API</span> changes where for performance or memory reasons.     While activerecord is not as feature complete as its Ruby cousin, it was nice to contribute.   Sure beats mixing <span class="caps">SQL</span> in objective-c as well.</p>


	<p>Anyway, you can view all of my changes on <a href="http://github.com/face/activerecord/tree/master">my fork at github.</a>   And they should end up merged back in aptiva&#8217;s master tree as well.</p>


	<p>Gota love github!
<br />
<br /></p>
          </content>  </entry>
  <entry xml:base="http://myutil.com/">
    <author>
      <name>face</name>
    </author>
    <id>tag:myutil.com,2009-02-06:3806</id>
    <published>2009-02-06T19:10:00Z</published>
    <updated>2009-02-06T19:15:58Z</updated>
    <category term="iPhone Development"/>
    <category term="cocoa"/>
    <category term="iphone"/>
    <link href="http://myutil.com/2009/2/6/some-iphone-apps-i-have-written" type="text/html" rel="alternate"/>
    <title>Some iPhone apps I have written</title>
<content type="html">
            Been busy writing iPhone apps full time these days.    Here are a couple of the apps I&#8217;ve recently written.

<a href="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=301994602&amp;mt=8"><img src="http://memeinc.com/images/TheSnapper.png"></a>
<a href="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=300995849&amp;mt=8"><img src="http://memeinc.com/images/ittybooks.png"></a>
<a href="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=303504098&amp;mt=8"><img src="http://memeinc.com/images/ittybooksfree.png"></a>


	<p>Please check them out!</p>
          </content>  </entry>
  <entry xml:base="http://myutil.com/">
    <author>
      <name>face</name>
    </author>
    <id>tag:myutil.com,2008-09-23:2828</id>
    <published>2008-09-23T19:49:00Z</published>
    <updated>2008-09-23T19:56:55Z</updated>
    <category term="activity streams"/>
    <category term="Rails"/>
    <category term="rails"/>
    <category term="Ruby"/>
    <category term="ruby"/>
    <link href="http://myutil.com/2008/9/23/activity-streams-extracted-from-legal-torrents-released" type="text/html" rel="alternate"/>
    <title>ActivityStreams has been extracted from LegalTorrents and Released</title>
<content type="html">
            <div><a href="http://beta.legaltorrents.com/torrents/208-star-wreck-legacy"><img alt="Screen shot of activity streams on Legaltorrents.com" src="http://myutil.com/assets/2008/9/23/activities.png"></a></div><p>

	<p>We have extracted <a href="http://matsonsystems.com/activity-streams/">ActivityStreams</a> from <a href="http://beta.legaltorrents.com">Legaltorrents.com</a> and released it under the <span class="caps">BSD</span> license.</p>


<blockquote>This is a new plugin for the Rails Community that provides a
customizable framework for cataloging and publishing user activity and
social objects.  We currently aim to provide support for microformats
in <span class="caps">HTML</span>, Atom feeds, and compatibility with the open source <span class="caps">DISO</span>
social networking implementation for activity discovery and
consumption.</blockquote>

	<p>Here is a quickie for Rails 2.1:</p>


	<pre><code>./script/plugin install git://github.com/face/activity_streams.git</code></pre>


	<p>It may work on earlier versions of Rails as well.   Don&#8217;t have git:</p>


	<pre><code>./script/plugin install svn://rubyforge.org/var/svn/activitystreams/trunk</code></pre>


	<p><br />
For further documentation <a href="http://matsonsystems.com/activity-streams/rdoc/">here is the rdoc</a> and the <a href="http://matsonsystems.com/activity-streams/">AcitivityStreams Home Page</a>, or <a href="http://github.com/face/activity_streams/tree/master">just show me the code.</a></p>
          </content>  </entry>
  <entry xml:base="http://myutil.com/">
    <author>
      <name>face</name>
    </author>
    <id>tag:myutil.com,2008-08-31:2533</id>
    <published>2008-08-31T22:09:00Z</published>
    <updated>2009-02-06T19:01:45Z</updated>
    <category term="Rails"/>
    <category term="rails"/>
    <category term="Ruby"/>
    <category term="ruby"/>
    <link href="http://myutil.com/2008/8/31/rake-task-transfer-rails-database-mysql-to-postgres" type="text/html" rel="alternate"/>
    <title>Rake task to transfer a Rails database, say from MySQL to Postgres and back again</title>
<content type="html">
            <div>
<pre><code>
development:
  adapter: mysql
  database: legaltorrents_development
  username: fred
  password: password
  socket: /tmp/mysql.sock

production:
  adapter: postgresql
  database: legaltorrents_production
  username: fred
  password: password
  host: localhost
</pre></code>
</div><p><br />
Thanks to Ruby on Rails, <a href="http://github.com/face/rails_db_convert_using_adapters/tree/master">transferring and converting database from one database platform to another only takes a few lines of code.</a>    There are rake tasks for dumping to <span class="caps">YAML</span> and back.  However the existing  <span class="caps">YAML</span> scripts I found had issues with some of our data and then failed for blobs.    This script will only work with a &#8220;rails style&#8221; database.   By &#8220;rails style&#8221; I mean any database where every table has a unique key named &#8220;id&#8221;.</p>
<h2>A special thanks to <a href="http://www.matsonsystems.com">Matson Systems, Inc.</a> for having me write this script for <a href="http://beta.legaltorrents.com/">LegalTorrents</a> and then contribute it to all under a <span class="caps">BSD</span> license.</h2>
<br />
Be sure to read the warnings in script.    Here is a complete example converting a production postgresql database into a development mysql database.   Let&#8217;s start with <code>config/database.yml</code> found to the left.

Now both schemas must be identical.  For this example let&#8217;s ensure both schemas are at the same migration:
<table class="CodeRay"><tr>
  <td class="line_numbers" title="click to toggle"><pre>1<tt>
</tt>2<tt>
</tt></pre></td>
  <td class="code"><pre>rake db<span class="sy">:migrate</span><tt>
</tt>env <span class="co">RAILS_ENV</span>=production rake db<span class="sy">:migrate</span></pre></td>
</tr></table>

Ok, let&#8217;s get the rake task and run it.   Running the rake task may take a long time.
<table class="CodeRay"><tr>
  <td class="line_numbers" title="click to toggle"><pre>1<tt>
</tt>2<tt>
</tt>3<tt>
</tt>4<tt>
</tt><strong>5</strong><tt>
</tt></pre></td>
  <td class="code"><pre>cd lib/tasks<tt>
</tt>wget <span class="s"><span class="dl">'</span><span class="k">http://github.com/face/rails_db_convert_using_adapters/tree/master%2Fconvert.rake?raw=true</span><span class="dl">'</span></span> -<span class="co">O</span> convert.rake<tt>
</tt><tt>
</tt><span class="c"># and run it</span><tt>
</tt>rake db<span class="sy">:convert</span><span class="sy">:prod2dev</span></pre></td>
</tr></table>

You should now have a copy of the production data in the development database.  
</p><p><br />
Update Oct 1, 2008:Fixed a bug today for Rails 2.1.1.   Also got rid of the hash of data that was a relic from an early version of the script that used a single model object.
</p><p>
Here is the full code to convert.rake:
</p>
<table class="CodeRay"><tr>
  <td class="line_numbers" title="click to toggle"><pre>1<tt>
</tt>2<tt>
</tt>3<tt>
</tt>4<tt>
</tt><strong>5</strong><tt>
</tt>6<tt>
</tt>7<tt>
</tt>8<tt>
</tt>9<tt>
</tt><strong>10</strong><tt>
</tt>11<tt>
</tt>12<tt>
</tt>13<tt>
</tt>14<tt>
</tt><strong>15</strong><tt>
</tt>16<tt>
</tt>17<tt>
</tt>18<tt>
</tt>19<tt>
</tt><strong>20</strong><tt>
</tt>21<tt>
</tt>22<tt>
</tt>23<tt>
</tt>24<tt>
</tt><strong>25</strong><tt>
</tt>26<tt>
</tt>27<tt>
</tt>28<tt>
</tt>29<tt>
</tt><strong>30</strong><tt>
</tt>31<tt>
</tt>32<tt>
</tt>33<tt>
</tt>34<tt>
</tt><strong>35</strong><tt>
</tt>36<tt>
</tt>37<tt>
</tt>38<tt>
</tt>39<tt>
</tt><strong>40</strong><tt>
</tt>41<tt>
</tt>42<tt>
</tt>43<tt>
</tt>44<tt>
</tt><strong>45</strong><tt>
</tt>46<tt>
</tt>47<tt>
</tt>48<tt>
</tt>49<tt>
</tt><strong>50</strong><tt>
</tt>51<tt>
</tt>52<tt>
</tt>53<tt>
</tt>54<tt>
</tt><strong>55</strong><tt>
</tt>56<tt>
</tt>57<tt>
</tt>58<tt>
</tt>59<tt>
</tt><strong>60</strong><tt>
</tt>61<tt>
</tt>62<tt>
</tt>63<tt>
</tt>64<tt>
</tt><strong>65</strong><tt>
</tt>66<tt>
</tt>67<tt>
</tt>68<tt>
</tt>69<tt>
</tt><strong>70</strong><tt>
</tt>71<tt>
</tt>72<tt>
</tt>73<tt>
</tt>74<tt>
</tt><strong>75</strong><tt>
</tt>76<tt>
</tt>77<tt>
</tt>78<tt>
</tt>79<tt>
</tt><strong>80</strong><tt>
</tt>81<tt>
</tt>82<tt>
</tt>83<tt>
</tt>84<tt>
</tt><strong>85</strong><tt>
</tt>86<tt>
</tt>87<tt>
</tt>88<tt>
</tt>89<tt>
</tt><strong>90</strong><tt>
</tt>91<tt>
</tt>92<tt>
</tt>93<tt>
</tt>94<tt>
</tt><strong>95</strong><tt>
</tt>96<tt>
</tt>97<tt>
</tt>98<tt>
</tt>99<tt>
</tt><strong>100</strong><tt>
</tt>101<tt>
</tt>102<tt>
</tt>103<tt>
</tt>104<tt>
</tt><strong>105</strong><tt>
</tt>106<tt>
</tt>107<tt>
</tt>108<tt>
</tt>109<tt>
</tt><strong>110</strong><tt>
</tt>111<tt>
</tt>112<tt>
</tt>113<tt>
</tt>114<tt>
</tt></pre></td>
  <td class="code"><pre><span class="c">#</span><tt>
</tt><span class="c"># Convert/transfer data from production =&gt; development.    This facilitates</span><tt>
</tt><span class="c"># a conversion one database adapter type to another (say postgres -&gt; mysql )</span><tt>
</tt><span class="c">#</span><tt>
</tt><span class="c"># WARNING 1: this script deletes all development data and replaces it with</span><tt>
</tt><span class="c">#                     production data</span><tt>
</tt><span class="c">#</span><tt>
</tt><span class="c"># WARNING 2: This script assumes it is the only user updating either database.</span><tt>
</tt><span class="c">#                     Database integrity could be corrupted if other users where </span><tt>
</tt><span class="c">#                     writing to the databases.</span><tt>
</tt><span class="c">#</span><tt>
</tt><span class="c"># Usage:  rake db:convert:prod2dev</span><tt>
</tt><span class="c">#</span><tt>
</tt><span class="c"># It assumes the development database has a schema identical to the production </span><tt>
</tt><span class="c"># database, but will delete any data before importing the production data</span><tt>
</tt><span class="c">#</span><tt>
</tt><span class="c"># A couple of the outer loops evolved from </span><tt>
</tt><span class="c">#    http://snippets.dzone.com/posts/show/3393</span><tt>
</tt><span class="c">#</span><tt>
</tt><span class="c"># For further instructions see </span><tt>
</tt><span class="c">#    http://myutil.com/2008/8/31/rake-task-transfer-rails-database-mysql-to-postgres</span><tt>
</tt><span class="c">#</span><tt>
</tt><span class="c"># The master repository for this script is at github:</span><tt>
</tt><span class="c">#    http://github.com/face/rails_db_convert_using_adapters/tree/master</span><tt>
</tt><span class="c">#</span><tt>
</tt><span class="c">#</span><tt>
</tt><span class="c"># Author: Rama McIntosh</span><tt>
</tt><span class="c">#         Matson Systems, Inc.</span><tt>
</tt><span class="c">#         http://www.matsonsystems.com</span><tt>
</tt><span class="c">#</span><tt>
</tt><span class="c"># This rake task is released under this BSD license:</span><tt>
</tt><span class="c">#</span><tt>
</tt><span class="c"># Copyright (c) 2008, Matson Systems, Inc. All rights reserved.</span><tt>
</tt><span class="c"># </span><tt>
</tt><span class="c"># Redistribution and use in source and binary forms, with or without</span><tt>
</tt><span class="c"># modification, are permitted provided that the following conditions</span><tt>
</tt><span class="c"># are met:</span><tt>
</tt><span class="c"># </span><tt>
</tt><span class="c"># * Redistributions of source code must retain the above copyright</span><tt>
</tt><span class="c">#   notice, this list of conditions and the following disclaimer.</span><tt>
</tt><span class="c"># * Redistributions in binary form must reproduce the above copyright</span><tt>
</tt><span class="c">#   notice, this list of conditions and the following disclaimer in the</span><tt>
</tt><span class="c">#   documentation and/or other materials provided with the distribution.</span><tt>
</tt><span class="c"># * Neither the name of Matson Systems, Inc. nor the names of its</span><tt>
</tt><span class="c">#   contributors may be used to endorse or promote products derived</span><tt>
</tt><span class="c">#   from this software without specific prior written permission.</span><tt>
</tt><span class="c">#</span><tt>
</tt><span class="c"># THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS</span><tt>
</tt><span class="c"># &quot;AS IS&quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT</span><tt>
</tt><span class="c"># LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS</span><tt>
</tt><span class="c"># FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE</span><tt>
</tt><span class="c"># COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,</span><tt>
</tt><span class="c"># INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,</span><tt>
</tt><span class="c"># BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;</span><tt>
</tt><span class="c"># LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER</span><tt>
</tt><span class="c"># CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT</span><tt>
</tt><span class="c"># LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN</span><tt>
</tt><span class="c"># ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE</span><tt>
</tt><span class="c"># POSSIBILITY OF SUCH DAMAGE.</span><tt>
</tt><tt>
</tt><span class="c"># PAGE_SIZE is the number of rows updated in a single transaction.</span><tt>
</tt><span class="c"># This facilitates tables where the number of rows exceeds the systems</span><tt>
</tt><span class="c"># memory</span><tt>
</tt><span class="co">PAGE_SIZE</span>=<span class="i">10000</span><tt>
</tt><tt>
</tt>namespace <span class="sy">:db</span> <span class="r">do</span><tt>
</tt>  namespace <span class="sy">:convert</span> <span class="r">do</span>    <tt>
</tt>    desc <span class="s"><span class="dl">'</span><span class="k">Convert/import production data to development.   DANGER Deletes all data in the development database.   Assumes both schemas are already migrated.</span><span class="dl">'</span></span><tt>
</tt>    task <span class="sy">:prod2dev</span> =&gt; <span class="sy">:environment</span> <span class="r">do</span><tt>
</tt><tt>
</tt>      <span class="c"># We need unique classes so ActiveRecord can hash different connections</span><tt>
</tt>      <span class="c"># We do not want to use the real Model classes because any business</span><tt>
</tt>      <span class="c"># rules will likely get in the way of a database transfer</span><tt>
</tt>      <span class="r">class</span> <span class="cl">ProductionModelClass</span> &lt; <span class="co">ActiveRecord</span>::<span class="co">Base</span><tt>
</tt>      <span class="r">end</span><tt>
</tt>      <span class="r">class</span> <span class="cl">DevelopmentModelClass</span> &lt; <span class="co">ActiveRecord</span>::<span class="co">Base</span><tt>
</tt>      <span class="r">end</span><tt>
</tt><tt>
</tt>      skip_tables = [<span class="s"><span class="dl">&quot;</span><span class="k">schema_info</span><span class="dl">&quot;</span></span>, <span class="s"><span class="dl">&quot;</span><span class="k">schema_migrations</span><span class="dl">&quot;</span></span>]<tt>
</tt>      <span class="co">ActiveRecord</span>::<span class="co">Base</span>.establish_connection(<span class="sy">:production</span>)<tt>
</tt>      (<span class="co">ActiveRecord</span>::<span class="co">Base</span>.connection.tables - skip_tables).each <span class="r">do</span> |table_name|<tt>
</tt><tt>
</tt>        <span class="co">ProductionModelClass</span>.set_table_name(table_name)<tt>
</tt>        <span class="co">DevelopmentModelClass</span>.set_table_name(table_name)<tt>
</tt>        <span class="co">DevelopmentModelClass</span>.establish_connection(<span class="sy">:development</span>)<tt>
</tt>        <span class="co">DevelopmentModelClass</span>.reset_column_information<tt>
</tt>        <span class="co">ProductionModelClass</span>.reset_column_information<tt>
</tt>        <span class="co">DevelopmentModelClass</span>.record_timestamps = <span class="pc">false</span><tt>
</tt><tt>
</tt>        <span class="c"># Page through the data in case the table is too large to fit in RAM</span><tt>
</tt>        offset = count = <span class="i">0</span>;<tt>
</tt>        print <span class="s"><span class="dl">&quot;</span><span class="k">Converting </span><span class="il"><span class="idl">#{</span>table_name<span class="idl">}</span></span><span class="k">...</span><span class="dl">&quot;</span></span>; <span class="co">STDOUT</span>.flush<tt>
</tt>        <span class="c"># First, delete any old dev data</span><tt>
</tt>        <span class="co">DevelopmentModelClass</span>.delete_all<tt>
</tt>        <span class="r">while</span> ((models = <span class="co">ProductionModelClass</span>.find(<span class="sy">:all</span>, <tt>
</tt>            <span class="sy">:offset</span>=&gt;offset, <span class="sy">:limit</span>=&gt;<span class="co">PAGE_SIZE</span>)).size &gt; <span class="i">0</span>)<tt>
</tt><tt>
</tt>          count += models.size<tt>
</tt>          offset += <span class="co">PAGE_SIZE</span><tt>
</tt><tt>
</tt>          <span class="c"># Now, write out the prod data to the dev db</span><tt>
</tt>          <span class="co">DevelopmentModelClass</span>.transaction <span class="r">do</span><tt>
</tt>            models.each <span class="r">do</span> |model|<tt>
</tt>              new_model = <span class="co">DevelopmentModelClass</span>.new(model.attributes)<tt>
</tt>              new_model.id = model.id<tt>
</tt>              new_model.save(<span class="pc">false</span>)<tt>
</tt>            <span class="r">end</span><tt>
</tt>          <span class="r">end</span><tt>
</tt>        <span class="r">end</span><tt>
</tt>        print <span class="s"><span class="dl">&quot;</span><span class="il"><span class="idl">#{</span>count<span class="idl">}</span></span><span class="k"> records converted</span><span class="ch">\n</span><span class="dl">&quot;</span></span><tt>
</tt>      <span class="r">end</span><tt>
</tt>    <span class="r">end</span><tt>
</tt>  <span class="r">end</span><tt>
</tt><span class="r">end</span></pre></td>
</tr></table>
          </content>  </entry>
  <entry xml:base="http://myutil.com/">
    <author>
      <name>face</name>
    </author>
    <id>tag:myutil.com,2008-08-31:2526</id>
    <published>2008-08-31T07:00:00Z</published>
    <updated>2008-09-23T19:37:53Z</updated>
    <category term="Web Design"/>
    <category term="Rails"/>
    <category term="rails"/>
    <category term="Ruby"/>
    <category term="ruby"/>
    <link href="http://myutil.com/2008/8/31/conditionally-caching-actions-when-logged-in-for-rails-2-1-and-2-0" type="text/html" rel="alternate"/>
    <title>Conditionally caching actions when logged in for Rails 2.1 and 2.0</title>
<content type="html">
            <div><a href="http://beta.legaltorrents.com/"><img alt="Screen shot of Legaltorrents.com" src="http://myutil.com/assets/2008/8/29/lt.png"></a></div><p>

As some of you know I&#8217;ve been working full time for <a href="http://matsonsystems.com/">Matson Systems, Inc.</a> building out <a href="http://beta.legaltorrents.com/">LegalTorrents</a>.   I must apologize I have been neglecting parts of my blog.    Fortunately, I&#8217;ve been swamped building out cool features for <a href="http://beta.legaltorrents.com/">LegalTorrents</a> and Matson wants to contribute back.   After this caching article look for a rake task to convert a Rails app from one database platform to another, then a plugin for generating Activity Streams. </p>
<p>
<h3>As a new community, we have to support tens of thousands of registered users.  Yet on any given news day we need to support hundreds of thousands of non registered users.</h3> 
<br />
 This can be done using action caching and very modest hardware requirements.   Given huge hardware resources, using memcached would solve the issue.
<i>However, meeting initial demands can be done using action caching with
very modest hardware requirements.</i>  We use the built-in rails action
caching to disk with a <span class="caps">TTL</span> hack from cron.  We don&#8217;t want our
logged-in users subjected to a <span class="caps">TTL</span>, as their changes should be
instantaneous.  We simply don&#8217;t cache actions for users who are logged
in, and provide cached pages for everyone else.  As the number of
registered users grows&#8230; then we&#8217;ll use memcached.
</p>
<p>
<br />
Let&#8217;s begin with conditional caching in Rails 2.1 (if 2.0, see below).    Conditional action caching is a new feature of the Rails 2.1 <span class="caps">API</span>.    First off, pre Rails 2.1 the default was disk.   In rails 2.1, the default is <span class="caps">RAM</span>.   Not going to work on limited resources:
<table class="CodeRay"><tr>
  <td class="line_numbers" title="click to toggle"><pre>1<tt>
</tt>2<tt>
</tt>3<tt>
</tt></pre></td>
  <td class="code"><pre><tt>
</tt><span class="c"># Put this in RAILS_ROOT/config/initializers/something.rb</span><tt>
</tt><span class="co">ActionController</span>::<span class="co">Base</span>.cache_store = <span class="sy">:file_store</span>, <span class="s"><span class="dl">&quot;</span><span class="il"><span class="dl">#{</span><span class="co">RAILS_ROOT</span><span class="dl">}</span></span><span class="k">/tmp/cache</span><span class="dl">&quot;</span></span><tt>
</tt></pre></td>
</tr></table>

Ok, the application controller is a great place to decide if we want to cache:
<table class="CodeRay"><tr>
  <td class="line_numbers" title="click to toggle"><pre>1<tt>
</tt>2<tt>
</tt>3<tt>
</tt>4<tt>
</tt><strong>5</strong><tt>
</tt>6<tt>
</tt>7<tt>
</tt>8<tt>
</tt></pre></td>
  <td class="code"><pre><tt>
</tt><span class="r">class</span> <span class="cl">ApplicationController</span> &lt; <span class="co">ActionController</span>::<span class="co">Base</span><tt>
</tt>  <span class="c"># ...</span><tt>
</tt>  protected<tt>
</tt>  <span class="c"># of course logged_in? needs to be defined...restful_authentication is what I recommend.</span><tt>
</tt>  <span class="r">def</span> <span class="fu">do_caching?</span><tt>
</tt>    !logged_in? &amp;&amp; flash.empty?<tt>
</tt>  <span class="r">end</span><tt>
</tt></pre></td>
</tr></table>

Now we can use the new Rails 2.1 :if feature to conditionally cache actions:
<table class="CodeRay"><tr>
  <td class="line_numbers" title="click to toggle"><pre>1<tt>
</tt>2<tt>
</tt>3<tt>
</tt>4<tt>
</tt><strong>5</strong><tt>
</tt>6<tt>
</tt></pre></td>
  <td class="code"><pre><tt>
</tt><span class="r">class</span> <span class="cl">TorrentsController</span> &lt; <span class="co">ApplicationController</span><tt>
</tt>  <span class="c"># ...</span><tt>
</tt>  caches_action <span class="sy">:show</span> , <span class="sy">:if</span> =&gt; <span class="co">Proc</span>.new { |controller|<tt>
</tt>                          controller.send(<span class="sy">:do_caching?</span>) }<tt>
</tt><tt>
</tt></pre></td>
</tr></table>

The final piece of the puzzle is a <span class="caps">TTL</span>.   We use find to remove files older than 10 minutes, giving us a 10 minute <span class="caps">TTL</span>:
<table class="CodeRay"><tr>
  <td class="line_numbers" title="click to toggle"><pre>1<tt>
</tt>2<tt>
</tt>3<tt>
</tt></pre></td>
  <td class="code"><pre><tt>
</tt><span class="c"># This cron entry that runs every 10 minutes and removes any files older than 10 minutes named '*.cache'</span><tt>
</tt><span class="i">3</span>,<span class="i">13</span>,<span class="i">23</span>,<span class="i">33</span>,<span class="i">43</span>,<span class="i">53</span> * * * * find <span class="rx"><span class="dl">/</span><span class="k">home</span><span class="dl">/</span></span>ltdeploy/legaltorrents/tmp/cache -mmin <span class="i">+10</span> -name <span class="s"><span class="dl">'</span><span class="k">*.cache</span><span class="dl">'</span></span> -exec rm -f {} <span class="er">\</span>;<tt>
</tt></pre></td>
</tr></table>

And that is it.   For those of you not familiar with caches action here is a more complex example for a page that integrates the will_paginate plugin using :cache_path:
<table class="CodeRay"><tr>
  <td class="line_numbers" title="click to toggle"><pre>1<tt>
</tt>2<tt>
</tt>3<tt>
</tt>4<tt>
</tt><strong>5</strong><tt>
</tt>6<tt>
</tt>7<tt>
</tt>8<tt>
</tt>9<tt>
</tt><strong>10</strong><tt>
</tt></pre></td>
  <td class="code"><pre><tt>
</tt><span class="r">class</span> <span class="cl">CategoriesController</span> &lt; <span class="co">ApplicationController</span><tt>
</tt><tt>
</tt>  caches_action <span class="sy">:show</span>, <tt>
</tt>    <span class="sy">:if</span> =&gt; <span class="co">Proc</span>.new { |controller| controller.send(<span class="sy">:do_caching?</span>) }, <tt>
</tt>    <span class="sy">:cache_path</span> =&gt; <span class="co">Proc</span>.new { |c|<tt>
</tt>      c.params[<span class="sy">:page</span>] ?<tt>
</tt>      <span class="s"><span class="dl">&quot;</span><span class="il"><span class="dl">#{</span>c.request.host<span class="dl">}</span></span><span class="k">.</span><span class="il"><span class="dl">#{</span>c.request.port<span class="dl">}</span></span><span class="k">/</span><span class="il"><span class="dl">#{</span>c.send(<span class="sy">:category_path</span>,c.params[<span class="sy">:id</span>])<span class="dl">}</span></span><span class="k">/page/</span><span class="il"><span class="dl">#{</span>c.params[<span class="sy">:page</span>]<span class="dl">}</span></span><span class="dl">&quot;</span></span> :<tt>
</tt>      <span class="s"><span class="dl">&quot;</span><span class="il"><span class="dl">#{</span>c.request.host<span class="dl">}</span></span><span class="k">.</span><span class="il"><span class="dl">#{</span>c.request.port<span class="dl">}</span></span><span class="k">/</span><span class="il"><span class="dl">#{</span>c.send(<span class="sy">:category_path</span>,c.params[<span class="sy">:id</span>])<span class="dl">}</span></span><span class="k">/page/1</span><span class="dl">&quot;</span></span><tt>
</tt>    }<tt>
</tt></pre></td>
</tr></table>


</p>
<p>End of Story for Rails 2.1</p>
<hr />
<p>
<br />
Now, Rails 2.0 doesn&#8217;t have :if in caches_action.   To work around this we used a simple monkey patch:
<table class="CodeRay"><tr>
  <td class="line_numbers" title="click to toggle"><pre>1<tt>
</tt>2<tt>
</tt>3<tt>
</tt>4<tt>
</tt><strong>5</strong><tt>
</tt>6<tt>
</tt>7<tt>
</tt>8<tt>
</tt></pre></td>
  <td class="code"><pre><tt>
</tt><span class="r">class</span> <span class="cl">ApplicationController</span> &lt; <span class="co">ActionController</span>::<span class="co">Base</span><tt>
</tt>  <span class="c"># ...</span><tt>
</tt>  protected<tt>
</tt>  <span class="c"># Overrides Rails core to do action_cache when not logged in...Only works in Rails 2.0 and maybe earlier</span><tt>
</tt>  <span class="r">def</span> <span class="fu">perform_caching</span><tt>
</tt>    <span class="cv">@@perform_caching</span> &amp;&amp; !logged_in? &amp;&amp; flash.empty?<tt>
</tt>   <span class="r">end</span><tt>
</tt></pre></td>
</tr></table>

Then we cache as normal:
<table class="CodeRay"><tr>
  <td class="line_numbers" title="click to toggle"><pre>1<tt>
</tt>2<tt>
</tt>3<tt>
</tt>4<tt>
</tt></pre></td>
  <td class="code"><pre><tt>
</tt><span class="r">class</span> <span class="cl">TorrentsController</span> &lt; <span class="co">ApplicationController</span><tt>
</tt>  <span class="c"># ...</span><tt>
</tt>  caches_action <span class="sy">:show</span><tt>
</tt></pre></td>
</tr></table>

</p>
          </content>  </entry>
  <entry xml:base="http://myutil.com/">
    <author>
      <name>face</name>
    </author>
    <id>tag:myutil.com,2008-08-01:2307</id>
    <published>2008-08-01T22:36:00Z</published>
    <updated>2008-08-22T20:01:02Z</updated>
    <category term="iphone"/>
    <category term="tether"/>
    <link href="http://myutil.com/2008/8/1/finally-got-netshare-to-work-on-my-iphone-3g" type="text/html" rel="alternate"/>
    <title>Finally got NetShare to work on my iphone 3G</title>
<content type="html">
            <div><a href="http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=286541579&amp;mt=8"><img alt="Screen shot of NetShare" src="http://myutil.com/assets/2008/8/1/netapp.png"># Of course the ProxyCommand can go in your ~/.ssh/config</span><tt>
</tt></pre></td>
</tr></table>

</p>
<p>Have iPhone, Have Laptop, will travel!</p>
          </content>  </entry>
  <entry xml:base="http://myutil.com/">
    <author>
      <name>face</name>
    </author>
    <id>tag:myutil.com,2008-06-02:1929</id>
    <published>2008-06-02T19:46:00Z</published>
    <updated>2008-06-02T20:44:03Z</updated>
    <category term="Systems"/>
    <category term="osx"/>
    <link href="http://myutil.com/2008/6/2/toolbar-boomark-icons-in-firefox-on-osx-leopard" type="text/html" rel="alternate"/>
    <title>Toolbar bookmark icons in Firefox 3 on OSX Leopard</title>
<content type="html">
            <div><a href="http://getfirefox.com/"><img alt="Screen shot of bookmarks" src="/assets/2008/6/2/bookmark.png">/</span></span><tt>
</tt>  toolbarbutton.bookmark-item[container] &gt; .toolbarbutton-icon {<tt>
</tt>  display: none !important;<tt>
</tt>} <tt>
</tt></pre></td>
</tr></table>
          </content>  </entry>
  <entry xml:base="http://myutil.com/">
    <author>
      <name>face</name>
    </author>
    <id>tag:myutil.com,2008-03-06:320</id>
    <published>2008-03-06T01:06:00Z</published>
    <updated>2008-03-06T01:17:35Z</updated>
    <category term="Web Design"/>
    <category term="OpenID"/>
    <category term="openid"/>
    <category term="Rails"/>
    <category term="rails"/>
    <category term="Ruby"/>
    <category term="ruby"/>
    <link href="http://myutil.com/2008/3/6/yahoo-openid-has-extra-security-constaints" type="text/html" rel="alternate"/>
    <title>Yahoo OpenID has extra security constaints</title>
<content type="html">
            <div><a href="http://openid.net/"><img alt="OpenID logo" src="/assets/2007/12/29/openid-logo.gif"></a></div> 
<p>
I have a feeling this will help some of y&#8217;all if you are getting the following error:

<pre>Sorry! Something is not quite right with the request we received from the website you are trying to use. Please try again in a few minutes. If this error persists, please contact the site administrator for the website you are trying to use. If you are the site administrator, click here to contact us.</pre>

	<p>I get this error if I try to login on my development environment because localhost:3000 just won&#8217;t cut it for Yahoo&#8217;s OpenID security policy.    If I run from a production <span class="caps">URL</span> on port 80, say http://myutil.com/ then signin works (though I haven&#8217;t gotten Simple Registration Attribute Exchange working with Yahoo).</p>


From the <a href="http://developer.yahoo.com/openid/faq.html">Yahoo OpenID Developers <span class="caps">FAQ</span>:</a>
<blockquote>
Yahoo! Security Policies

Yahoo! will only support Relying Parties running on webservers with real hostnames (IP addresses are not supported) running on standard ports (Port 80 for <span class="caps">HTTP</span> and Port 443 for <span class="caps">HTTPS</span>).
</blockquote>

	<p>Hope this saves ya some time!</p>
          </content>  </entry>
  <entry xml:base="http://myutil.com/">
    <author>
      <name>face</name>
    </author>
    <id>tag:myutil.com,2008-02-28:208</id>
    <published>2008-02-28T09:16:00Z</published>
    <updated>2008-07-16T22:29:09Z</updated>
    <category term="Systems"/>
    <category term="OpenBSD"/>
    <category term="openbsd"/>
    <category term="Ruby"/>
    <category term="ruby"/>
    <link href="http://myutil.com/2008/2/28/openbsd-port-of-sphinx" type="text/html" rel="alternate"/>
    <title>OpenBSD port of Sphinx</title>
<content type="html">
            <div><a href="http://www.sphinxsearch.com/"><img alt="Sphinx Free open-source SQL full-text search engine" src="/assets/2008/2/28/sphinx.jpg"></a></div><p>Update July 16th, 2008:  Sphinx sphinx-0.9.8 has been released and this port has been updated.</p>
<p><a href="http://myutil.com/ports/4.4/sphinx.tgz">Here</a> is a OpenBSD port of <a href="http://www.sphinxsearch.com/">Sphinx</a>, Free open-source <span class="caps">SQL</span> full-text search engine.   Sphinx is a wonderfully fast and memory efficient deep text search engine.   I have found integrates nicely with Ruby and Ruby-On-Rails.

	<p>I hope at some point to get this port committed to the OpenBSD <span class="caps">CVS</span> repository.  In the meantime this will be the ports home.    Till it hits the OpenBSDs repository, it will live in <a href="http://svn.myutil.com/projects/ports/textproc/sphinx/">my <span class="caps">SVN</span> repository here.</a></p>


	<p>You can download a snapshot of the source code for the port here: <a href="/ports/4.4/sphinx.tgz">sphinx.tgz.</a>   So far this port has been tested with MySQL and Postgresql on OpenBSD 4.2 and OpenBSD 4.3-betaOpenBSD-4.4-beta on the i386 platform with the Ultrasphinx Ruby-On-Rails plugin.</p>


<hr />

<h1>Instructions to build the port</h1>

	<p>If your ports tree is not already prepped, please begin by <a href="http://myutil.com/2007/11/5/prepping-ports-for-openbsd">prepping your ports tree</a>.</p>


The port will build much faster if you install the prerequisites via binaries:
<table class="CodeRay"><tr>
  <td class="line_numbers" title="click to toggle"><pre>1<tt>
</tt>2<tt>
</tt>3<tt>
</tt>4<tt>
</tt><strong>5</strong><tt>
</tt>6<tt>
</tt></pre></td>
  <td class="code"><pre><tt>
</tt>sudo su<tt>
</tt>export <span class="co">PKG_PATH</span>=<span class="s"><span class="dl">&quot;</span><span class="k">ftp://ftp2.usa.openbsd.org/pub/OpenBSD/4.3/packages/i386</span><span class="dl">&quot;</span></span><tt>
</tt><span class="c"># or, setenv PKG_PATH &quot;ftp://ftp2.usa.openbsd.org/pub/OpenBSD/4.3/packages/i386&quot;</span><tt>
</tt>pkg_add libiconv mysql-server mysql-client<tt>
</tt>exit<tt>
</tt></pre></td>
</tr></table>


	<p>Now we are ready to build the sphinx port:</p>


<table class="CodeRay"><tr>
  <td class="line_numbers" title="click to toggle"><pre>1<tt>
</tt>2<tt>
</tt>3<tt>
</tt>4<tt>
</tt><strong>5</strong><tt>
</tt>6<tt>
</tt></pre></td>
  <td class="code"><pre><tt>
</tt>cd <span class="rx"><span class="dl">/</span><span class="k">usr</span><span class="dl">/</span></span>ports/textproc<tt>
</tt>lynx --source <span class="s"><span class="dl">&quot;</span><span class="k">http://myutil.com/ports/4.4/sphinx.tgz</span><span class="dl">&quot;</span></span> &gt; sphinx.tgz<tt>
</tt>tar xvfz sphinx.tgz <tt>
</tt>cd sphinx<tt>
</tt>make install  <span class="c"># or make package</span><tt>
</tt></pre></td>
</tr></table>


There is also a Postgresql flavor.  Follow the instructions above, installing Postgresql instead of MySQL and then instead of <code>make install</code> do:
<table class="CodeRay"><tr>
  <td class="line_numbers" title="click to toggle"><pre>1<tt>
</tt>2<tt>
</tt></pre></td>
  <td class="code"><pre><tt>
</tt>env <span class="co">FLAVOR</span>=pgsql make install<tt>
</tt></pre></td>
</tr></table>


	<p>Thanks, and feedback is always welcome!</p>
          </content>  </entry>
  <entry xml:base="http://myutil.com/">
    <author>
      <name>face</name>
    </author>
    <id>tag:myutil.com,2008-02-26:171</id>
    <published>2008-02-26T20:58:00Z</published>
    <updated>2008-02-27T10:07:26Z</updated>
    <category term="Systems"/>
    <category term="OpenBSD"/>
    <category term="openbsd"/>
    <category term="Ruby"/>
    <category term="ruby"/>
    <link href="http://myutil.com/2008/2/26/raspell-shared-library-problems-on-openbsd" type="text/html" rel="alternate"/>
    <title>raspell shared library problems on OpenBSD</title>
<content type="html">
            <div>
<table class="CodeRay"><tr>
  <td class="line_numbers" title="click to toggle"><pre>1<tt>
</tt>2<tt>
</tt>3<tt>
</tt>4<tt>
</tt><strong>5</strong><tt>
</tt>6<tt>
</tt>7<tt>
</tt>8<tt>
</tt>9<tt>
</tt><strong>10</strong><tt>
</tt>11<tt>
</tt></pre></td>
  <td class="code"><pre><tt>
</tt>--- extconf.rb.orig     <span class="co">Tue</span> <span class="co">Feb</span> <span class="i">26</span> <span class="i">12</span>:<span class="i">03</span>:<span class="i">53</span> <span class="i">2008</span><tt>
</tt>+++ extconf.rb  <span class="co">Tue</span> <span class="co">Feb</span> <span class="i">26</span> <span class="i">11</span>:<span class="i">52</span>:<span class="i">16</span> <span class="i">2008</span><tt>
</tt><span class="er">@</span><span class="er">@</span> <span class="i">-1</span>,<span class="i">5</span> <span class="i">+1</span>,<span class="i">7</span> <span class="er">@</span><span class="er">@</span><tt>
</tt> require <span class="s"><span class="dl">&quot;</span><span class="k">mkmf</span><span class="dl">&quot;</span></span><tt>
</tt> <tt>
</tt>+<span class="gv">$LIBS</span> += <span class="s"><span class="dl">&quot;</span><span class="k"> -lstdc++ -laspell</span><span class="dl">&quot;</span></span><tt>
</tt>+<tt>
</tt> have_header(<span class="s"><span class="dl">&quot;</span><span class="k">ruby.h</span><span class="dl">&quot;</span></span>)<tt>
</tt> have_header(<span class="s"><span class="dl">&quot;</span><span class="k">aspell.h</span><span class="dl">&quot;</span></span>)<tt>
</tt> have_library(<span class="s"><span class="dl">&quot;</span><span class="k">aspell</span><span class="dl">&quot;</span></span>)<tt>
</tt></pre></td>
</tr></table>

</div>
<p><br /><br />
I recently installed the raspell gem on my development box as part of an evaluation of ultrasphinx.

	<p>Unfortunately, the native extension to raspell doesn&#8217;t link in the dynamic libraries it uses.   A fix is provided below.</p>


	<p>Note, using the raspell with ultrasphinx also caused a ruby core dump, this time in an assertion from the configuration for aspell.      OpenBSD uses aspell-0.50.5 and after upgrading aspell to 0.60.5, raspell started working fine.</p>


Here is the output from the dynamic library problem:
</p>
<br class="clear" />
<p>
<pre><code>
** Starting Rails with development environment...
ruby:/usr/local/lib/ruby/gems/1.8/gems/raspell-1.1/lib/raspell.so: undefined symbol 'new_aspell_config'
lazy binding failed!
/home/face/urevz/vendor/plugins/ultrasphinx/lib/ultrasphinx/spell.rb:33: [BUG] Segmentation fault
ruby 1.8.6 (2007-09-24) [i386-openbsd4.2]
</pre></code>
</p>

	<p>A little poking around and I noticed the native library, raspell.so, doesn&#8217;t link in libaspell!</p>


	<p>A quick fix is to add the libs to extconf.rb and rebuild the library:</p>


	<ol>
	<li>cd /usr/local/lib/ruby/gems/1.8/gems/raspell-1.1/ext</li>
		<li>edit extconf.rb and add the line $LIBS <ins>= &#8221; -lstdc</ins>+ -laspell&#8221; </li>
		<li>sudo make clean </li>
		<li>sudo make</li>
		<li>sudo cp raspell.so ../lib/.</li>
	</ol>
          </content>  </entry>
  <entry xml:base="http://myutil.com/">
    <author>
      <name>face</name>
    </author>
    <id>tag:myutil.com,2008-02-13:111</id>
    <published>2008-02-13T07:30:00Z</published>
    <updated>2008-02-21T02:35:42Z</updated>
    <category term="Systems"/>
    <category term="OpenBSD"/>
    <category term="openbsd"/>
    <category term="Ruby"/>
    <category term="ruby"/>
    <link href="http://myutil.com/2008/2/13/current-ruby-and-ruby-gem-binaries-for-current-openbsd" type="text/html" rel="alternate"/>
    <title>Current Ruby and Ruby-Gem binaries for the current release of OpenBSD</title>
<content type="html">
            <a href="http://rubyforge.org/projects/openbsd-dist/"><img alt="Ruby-Forge Header" src="/assets/2008/2/13/rubyforge.png"></a>
<br />
<p>
Here is how to install i386 binaries (please choose an OpenBSD mirror near you&#8230;and please buy a <a href="http://www.openbsd.org/tshirts.html">t-shirt</a>):
<table class="CodeRay"><tr>
  <td class="line_numbers" title="click to toggle"><pre>1<tt>
</tt>2<tt>
</tt>3<tt>
</tt>4<tt>
</tt><strong>5</strong><tt>
</tt>6<tt>
</tt>7<tt>
</tt>8<tt>
</tt>9<tt>
</tt><strong>10</strong><tt>
</tt>11<tt>
</tt>12<tt>
</tt>13<tt>
</tt>14<tt>
</tt><strong>15</strong><tt>
</tt>16<tt>
</tt>17<tt>
</tt></pre></td>
  <td class="code"><pre><tt>
</tt>sudo su<tt>
</tt><tt>
</tt><span class="c">#for ksh/bash</span><tt>
</tt>export <span class="co">PKG_PATH</span>=<span class="s"><span class="dl">&quot;</span><span class="k">ftp://ftp3.usa.openbsd.org/pub/OpenBSD/4.2/packages/i386</span><span class="dl">&quot;</span></span><tt>
</tt><tt>
</tt><span class="c">#or, for tcsh: setenv PKG_PATH=ftp://ftp3.usa.openbsd.org/pub/OpenBSD/4.2/packages/i386</span><tt>
</tt><tt>
</tt><span class="c"># Now for Ruby</span><tt>
</tt>pkg_add <span class="s"><span class="dl">&quot;</span><span class="k">http://rubyforge.org/frs/download.php/32289/ruby-1.8.6.111.tgz</span><span class="dl">&quot;</span></span><tt>
</tt><tt>
</tt><span class="c"># Optional, but Recommend for Rails</span><tt>
</tt>pkg_add <span class="s"><span class="dl">&quot;</span><span class="k">http://rubyforge.org/frs/download.php/32290/ruby-gems-1.0.1.tgz</span><span class="dl">&quot;</span></span><tt>
</tt>pkg_add <span class="s"><span class="dl">&quot;</span><span class="k">http://rubyforge.org/frs/download.php/32291/ruby-iconv-1.8.6.111.tgz</span><span class="dl">&quot;</span></span><tt>
</tt><tt>
</tt><span class="c"># Now you could install rails if you wanted:</span><tt>
</tt>gem install rails<tt>
</tt></pre></td>
</tr></table>


	<p>Rubyforge doesn&#8217;t allow you to have the same filename, even if it is in a different sub-package and release.  Therefore, amd64 and sparc64 binaries are distributed directly from MyUtil.com.</p>


For <span class="caps">AMD64</span> (which runs in <span class="caps">IA64</span> of course):
<table class="CodeRay"><tr>
  <td class="line_numbers" title="click to toggle"><pre>1<tt>
</tt>2<tt>
</tt>3<tt>
</tt>4<tt>
</tt><strong>5</strong><tt>
</tt>6<tt>
</tt>7<tt>
</tt>8<tt>
</tt>9<tt>
</tt><strong>10</strong><tt>
</tt></pre></td>
  <td class="code"><pre><tt>
</tt>sudo su<tt>
</tt>export <span class="co">PKG_PATH</span>=<span class="s"><span class="dl">&quot;</span><span class="k">http://myutil.com/ports/4.2/amd64/:ftp://ftp3.usa.openbsd.org/pub/OpenBSD/4.2/packages/amd64/</span><span class="dl">&quot;</span></span><tt>
</tt><tt>
</tt><span class="c"># or, setenv PKG_PATH &quot;http://myutil.com/ports/4.2/amd64/:ftp://ftp3.usa.openbsd.org/pub/OpenBSD/4.2/packages/amd64/&quot;</span><tt>
</tt><tt>
</tt>pkg_add ruby<span class="fl">-1.8</span>.<span class="fl">6.111</span> ruby-iconv<span class="fl">-1.8</span>.<span class="fl">6.111</span> ruby-gems<span class="fl">-1.0</span>.<span class="i">1</span><tt>
</tt><tt>
</tt><span class="c"># Perhaps Ruby-On-Rails:</span><tt>
</tt>gem install rails<tt>
</tt></pre></td>
</tr></table>


For sparc64:
<table class="CodeRay"><tr>
  <td class="line_numbers" title="click to toggle"><pre>1<tt>
</tt>2<tt>
</tt>3<tt>
</tt>4<tt>
</tt><strong>5</strong><tt>
</tt>6<tt>
</tt>7<tt>
</tt>8<tt>
</tt>9<tt>
</tt><strong>10</strong><tt>
</tt></pre></td>
  <td class="code"><pre><tt>
</tt>sudo su<tt>
</tt>export <span class="co">PKG_PATH</span>=<span class="s"><span class="dl">&quot;</span><span class="k">http://myutil.com/ports/4.2/sparc64/:ftp://ftp3.usa.openbsd.org/pub/OpenBSD/4.2/packages/sparc64/</span><span class="dl">&quot;</span></span><tt>
</tt><tt>
</tt><span class="c"># or, setenv PKG_PATH &quot;http://myutil.com/ports/4.2/sparc64/:ftp://ftp3.usa.openbsd.org/pub/OpenBSD/4.2/packages/sparc64/&quot;</span><tt>
</tt><tt>
</tt>pkg_add ruby<span class="fl">-1.8</span>.<span class="fl">6.111</span> ruby-iconv<span class="fl">-1.8</span>.<span class="fl">6.111</span> ruby-gems<span class="fl">-1.0</span>.<span class="i">1</span><tt>
</tt><tt>
</tt><span class="c"># Maybe Rails?</span><tt>
</tt>gem install rails<tt>
</tt></pre></td>
</tr></table>


	<p>Thanks, I find these useful and I hope you do too.   I now do all my development from a OpenBSD (patched) Desktop and have made these binaries as secure as possible.   All binaries are produced behind pf firewalls.</p>


	<p>I have a old Mac Mini I can install macppc and produce binaries&#8230;if there is a demand.</p>


</p>


<a href="http://www.openbsd.org/"><img alt="Puffy swimming" src="/assets/2008/2/13/openbsd.gif"></a>
          </content>  </entry>
</feed>

