<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>Astrails - Home</title>
  <id>tag:blog.astrails.com,2009:mephisto/</id>
  <generator uri="http://mephistoblog.com" version="0.8.0">Mephisto Drax</generator>
  <link href="http://blog.astrails.com/feed/atom.xml" rel="self" type="application/atom+xml"/>
  <link href="http://blog.astrails.com/" rel="alternate" type="text/html"/>
  <updated>2009-07-07T16:02:44Z</updated>
  <entry xml:base="http://blog.astrails.com/">
    <author>
      <name>vitaly</name>
    </author>
    <id>tag:blog.astrails.com,2009-07-07:162</id>
    <published>2009-07-07T16:01:00Z</published>
    <updated>2009-07-07T16:02:44Z</updated>
    <category term="IT"/>
    <category term="Ruby"/>
    <category term="amazon"/>
    <category term="backup"/>
    <category term="mysql"/>
    <category term="ruby"/>
    <category term="s3"/>
    <category term="tar"/>
    <link href="http://blog.astrails.com/2009/7/7/astrails-safe-0-2-2-sftp-timing-another-cleanup-bugfix" rel="alternate" type="text/html"/>
    <title>astrails-safe-0.2.2 - sftp, timing + another rotation bugfix</title>
<summary type="html">&lt;p&gt;There is a new 0.2.2 version of astrails-safe on &lt;a href=&quot;http://github.com/astrails/safe/&quot;&gt;github&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you don&#8217;t know it yet: astrails-safe is an easy to use backup solution for Unix like operating systems.
It supports filesystem, mysql, postgresql, and subversion backups to local filesytem, Amazon S3 and remote SFTP.&lt;/p&gt;</summary><content type="html">
            &lt;p&gt;There is a new 0.2.2 version of astrails-safe on &lt;a href=&quot;http://github.com/astrails/safe/&quot;&gt;github&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you don&#8217;t know it yet: astrails-safe is an easy to use backup solution for Unix like operating systems.
It supports filesystem, mysql, postgresql, and subversion backups to local filesytem, Amazon S3 and remote SFTP.&lt;/p&gt;
&lt;p&gt;The biggest change in this version is the support for SFTP as a storage option (contributed by &lt;a href=&quot;http://github.com/adam12&quot;&gt;Adam&lt;/a&gt;).
It can be used instead of or in addition to S3. Note that is is still somewhat experimental and was not tested much in production. Please report any problems in the &lt;a href=&quot;http://github.com/astrails/safe/issues&quot;&gt;issues tracker&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&#8216;local&#8217; storage option is still mandatory since S3 requires knowing the file size &lt;b&gt;before&lt;/b&gt; the upload and keeping all in memory is not a good option :).&lt;/p&gt;

&lt;p&gt;Does anyone &lt;b&gt;really&lt;/b&gt; need an option of using SFTP w/o the local storage? If so please comment and I will look into possibility of implementing it.&lt;/p&gt;

&lt;p&gt;Another change is that astrails-safe will now print timing statistics when running in a verbose mode (-v)
(contributed by &lt;a href=&quot;http://github.com/neerfri&quot;&gt;Neer&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;Also another bug with rotation code was fixed (contributed by &lt;a href=&quot;http://github.com/layton&quot;&gt;Layton&lt;/a&gt;). Rotation code would mistakenly match any file starting with the name of the current backup. e.g. cleanup for &#8216;foo&#8217; would cleanup &#8216;foobar&#8217; as well. I also added a test that should have caught this bug :)&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.astrails.com/">
    <author>
      <name>michael</name>
    </author>
    <id>tag:blog.astrails.com,2009-06-03:160</id>
    <published>2009-06-03T14:43:00Z</published>
    <updated>2009-06-04T12:59:50Z</updated>
    <category term="Rails"/>
    <link href="http://blog.astrails.com/2009/6/3/clicktale-rails-better-usability" rel="alternate" type="text/html"/>
    <title>Clicktale + Rails = Better Usability</title>
<summary type="html">&lt;p&gt;&lt;a href=&quot;http://clicktale.com&quot;&gt;Clicktale&lt;/a&gt; is a service that allows you to record and later playback behavior of your users while they are using your site. And Rails is &lt;a href=&quot;http://rubyonrails.org&quot;&gt;Rails&lt;/a&gt;, you know. And those two are getting along just fine, until the user logs in. After that clicktale service is cut out of the html pages this user gets and can&#8217;t record the session. But it just started to get interesting&#8230;&lt;/p&gt;

&lt;p&gt;This &lt;a href=&quot;http://github.com/astrails/clicktale/tree/master&quot;&gt;plugin&lt;/a&gt; brings back the connection between Clicktale and Rails even for those closed pages. You&#8217;re going to get your better usability after all.&lt;/p&gt;</summary><content type="html">
            &lt;p&gt;&lt;a href=&quot;http://clicktale.com&quot;&gt;Clicktale&lt;/a&gt; is a service that allows you to record and later playback behavior of your users while they are using your site. And Rails is &lt;a href=&quot;http://rubyonrails.org&quot;&gt;Rails&lt;/a&gt;, you know. And those two are getting along just fine, until the user logs in. After that clicktale service is cut out of the html pages this user gets and can&#8217;t record the session. But it just started to get interesting&#8230;&lt;/p&gt;

&lt;p&gt;This &lt;a href=&quot;http://github.com/astrails/clicktale/tree/master&quot;&gt;plugin&lt;/a&gt; brings back the connection between Clicktale and Rails even for those closed pages. You&#8217;re going to get your better usability after all.&lt;/p&gt;
&lt;h3&gt;Clicktale&lt;/h3&gt;

&lt;p&gt;Clicktale is nice. I suggest you to head over to &lt;a href=&quot;http://clicktale.com&quot;&gt;their site&lt;/a&gt; and check out the short(1:15) promotional video they have to get a feeling of what they do.&lt;/p&gt;

&lt;p&gt;It records user sessions, allows form optimization by showing how much users drop out on any form field, does landing page optimization and other goodness.&lt;/p&gt;

&lt;p&gt;Anyways, i find it very useful. It should be installed from the very first users new service is starting to get. It is an easy way to approximate field usability testing. It doesn&#8217;t replace the actual usability testing, but it is as close as you get without dragging yourself from the comfort of your &lt;a href=&quot;http://en.wikipedia.org/wiki/Aeron_chair&quot;&gt;Aeron chair&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Bottom line is that can help you make lives of your users a bit easier.&lt;/p&gt;

&lt;p&gt;They are on pricey side of the internet with cheapest plan at $99/month, but they have a free plan. Very limited, but enough to see what it is about.&lt;/p&gt;

&lt;h3&gt;Rails Integration&lt;/h3&gt;

&lt;p&gt;I was really disappointed to find out that in our rails projects i could record user sessions only on outer parts of the site.&lt;/p&gt;

&lt;p&gt;You see, clicktale works by combining two sides:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A small javascript snippet inserted into your rendered page to record user behavior&lt;/li&gt;
&lt;li&gt;A copy of rendered HTML that clicktale stores on it&#8217;s servers to allow playback of recorded user actions on top of it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, the first part in not a problem. The second part is. When a user hides behind a login, clicktale is no longer able to get the HTML. So it still knows where user clicks and where the mouse was moved, but this information is useless without the actual page your user sees at this moment.&lt;/p&gt;

&lt;p&gt;To continue to enjoy the &#8220;big brother&#8221; feeling even after users log in, we need to supply this HTML to clicktale. Fortunately clicktailers allowed this by adding an option to their javascript to provide a URL to this HTML file that is different from the current page&#8217;s URL.&lt;/p&gt;

&lt;p&gt;To close this circle, i use rails caching mechanism to store rendered page on the disk, and handle a path to the resulted file to clicktale.&lt;/p&gt;

&lt;h3&gt;Ok, nice, now how do i&#8230;&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Install the plugin&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;./script/plugin install git://github.com/astrails/clicktale.git&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Head to &lt;a href=&quot;http://clicktale.com&quot;&gt;http://clicktale.com&lt;/a&gt; and signup for a free account. Or not free. Your choice.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Get a tracking code from clicktale. It should look something like this:&lt;pre class=&quot;ruby&quot;&gt;&lt;code class=&quot;ruby&quot;&gt;&lt;small&gt;&amp;lt;!-- ClickTale Bottom part --&amp;gt;
&amp;lt;div id=&amp;quot;ClickTaleDiv&amp;quot; style=&amp;quot;display: none;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;script src=&amp;quot;http://s.clicktale.net/WRb.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;
  if(typeof ClickTale==&amp;#x27;function&amp;#x27;) ClickTale(&amp;lt;u&gt;&lt;strong&gt;&amp;lt;project_id&amp;gt;&lt;/strong&gt;,&lt;strong&gt;&amp;lt;ratio&amp;gt;&lt;/strong&gt;,&lt;strong&gt;&amp;lt;param&amp;gt;&lt;/strong&gt;&amp;lt;/u&gt;);
&amp;lt;/script&amp;gt;
&amp;lt;!-- ClickTale end of Bottom part --&amp;gt;
&lt;/small&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Replace &lt;code&gt;project_id&lt;/code&gt;, &lt;code&gt;ratio&lt;/code&gt; and &lt;code&gt;param&lt;/code&gt; in the autogenerated config/clicktale.yml with values from clicktale tracking code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add clicktale partials into layout inside the ‘body’ tag:&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;&amp;lt;body&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;lt;%= clicktale_top %&amp;gt;
&amp;nbsp;&amp;nbsp;...
&amp;nbsp;&amp;nbsp;&amp;lt;%= yield %&amp;gt;
&amp;nbsp;&amp;nbsp;...
&amp;nbsp;&amp;nbsp;&amp;lt;%= clicktale_bottom %&amp;gt;
&amp;lt;/body&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add a cron job(crontab -e, right?) that will take care of the old cached files&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;*/30 * * * * find /path/to/your/application/public/clicktale/ -type f -mmin +30 -exec rm {} \;
&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; The plugin works by leveraging rails caching mechanism, which is by default only enabled in production environment. To enable the plugin in the development environment do the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;set enabled=true in config/clicktale.yml (development section)&lt;/li&gt;
&lt;li&gt;set config.action_controller.perform_caching=true in config/environments/development.rb&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Another Note:&lt;/strong&gt; As of this writing, clicktale service ignores existance of Safari browser. I hope it will someday.&lt;/p&gt;

&lt;h3&gt;Options&lt;/h3&gt;

&lt;p&gt;Not much for now. But you can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add clicktale method on class level in your controller to change the clicktale project for specific controller&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;class UsersController &amp;lt; ApplicationController
&amp;nbsp;&amp;nbsp;clicktale :project_id =&amp;gt; ANOTHER_PROJECT_ID
&amp;nbsp;&amp;nbsp;...
end
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;Call the same method to tag this controller&#8217;s actions in clicktale records&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;class UsersController &amp;lt; ApplicationController
&amp;nbsp;&amp;nbsp;clicktale :project_id =&amp;gt; ANOTHER_PROJECT_ID, :tag =&amp;gt; :specific_tag
&amp;nbsp;&amp;nbsp;...
end
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;You can call the same method with same parameters on the action level to control project id and tag for this specific action&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Where&#8217;s everything&lt;/h3&gt;

&lt;p&gt;The code is on &lt;a href=&quot;http://github.com/astrails/clicktale/tree/master&quot;&gt;github&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Please submit issues also to &lt;a href=&quot;http://github.com/astrails/clicktale/issues&quot;&gt;github&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;As always, suggestions are welcome, code contributions are even more welcome.&lt;/p&gt;

&lt;p&gt;Now, go see what your users are doing.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.astrails.com/">
    <author>
      <name>vitaly</name>
    </author>
    <id>tag:blog.astrails.com,2009-05-22:161</id>
    <published>2009-05-22T11:40:00Z</published>
    <updated>2009-05-22T11:40:43Z</updated>
    <category term="Ruby"/>
    <category term="backup"/>
    <category term="bug"/>
    <category term="s3"/>
    <link href="http://blog.astrails.com/2009/5/22/astrails-safe-0-1-9-bugfix-release" rel="alternate" type="text/html"/>
    <title>Astrails-safe: 0.1.9 - BUGFIX release</title>
<content type="html">
            &lt;p&gt;I just pushed new version 0.1.9 of &lt;a href=&quot;http://github.com/astrails/safe&quot;&gt;astrails-safe&lt;/a&gt; to github.&lt;/p&gt;

&lt;p&gt;The main difference is a fix to an embarrassing bug in the S3 backup rotation code.
Thanks to Thuvarakan Tharmalingam for reporting.&lt;/p&gt;

&lt;p&gt;Again, the reason it escaped was the fact that we don't yet have full test coverage.
We are getting there though....&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.astrails.com/">
    <author>
      <name>vitaly</name>
    </author>
    <id>tag:blog.astrails.com,2009-05-21:159</id>
    <published>2009-05-21T01:47:00Z</published>
    <updated>2009-05-21T02:23:32Z</updated>
    <category term="IT"/>
    <category term="Ruby"/>
    <category term="amazon"/>
    <category term="astrails"/>
    <category term="backup"/>
    <category term="encryption"/>
    <category term="s3"/>
    <category term="safe"/>
    <link href="http://blog.astrails.com/2009/5/21/postgress-and-svndump-support-for-astrails-safe-s3-backup" rel="alternate" type="text/html"/>
    <title>PostgreSQL and Subversion support for astrails-safe s3 backup</title>
<summary type="html">&lt;p&gt;It looks like our astrails-safe gem is quite popular :). People started to contribute new features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://github.com/markmansour&quot;&gt;Mark Mansour&lt;/a&gt; contributed PostgreSQL backup support&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://github.com/tangofoxtrot&quot;&gt;Richard Luther&lt;/a&gt; contributed Subversion repository dump support&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I just released new version 0.1.8 on the &lt;a href=&quot;http://github.com/astrails/safe/tree/master&quot;&gt;github&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In addition to postgre/svn support this release also includes a long overdue test suite.&lt;/p&gt;</summary><content type="html">
            &lt;p&gt;It looks like our astrails-safe gem is quite popular :). People started to contribute new features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://github.com/markmansour&quot;&gt;Mark Mansour&lt;/a&gt; contributed PostgreSQL backup support&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://github.com/tangofoxtrot&quot;&gt;Richard Luther&lt;/a&gt; contributed Subversion repository dump support&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I just released new version 0.1.8 on the &lt;a href=&quot;http://github.com/astrails/safe/tree/master&quot;&gt;github&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In addition to postgre/svn support this release also includes a long overdue test suite.&lt;/p&gt;
&lt;p&gt;Note: I personally don&#8217;t use Subversion or PostgreSQL so I can&#8217;t actually test it. 
If you use it you can now easily backup it to local filesystem or Amazon S3 and if you find any problem
please report &lt;a href=&quot;http://github.com/astrails/safe/issues&quot;&gt;here&lt;/a&gt; ;-)&lt;/p&gt;

&lt;p&gt;If you don&#8217;t know what is astrails-safe, you can read the original &lt;a href=&quot;blog.astrails.com/2009/4/6/simple-backups-can-be-simple&quot;&gt;announcement&lt;/a&gt;. In a nutshell its a simple backup script that supports file backups (with tar),
MySQL backup (with mysqldump), PostgreSQL backup (with pg_dump) and Subversion backup (with &#8220;svnadmin dump&#8221;),
all that with GPG encryption and backup rotation and Amazon S3 support.&lt;/p&gt;

&lt;p&gt;See &lt;a href=&quot;http://github.com/astrails/safe/blob/master/README.markdown&quot;&gt;README&lt;/a&gt; for installation instructions.&lt;/p&gt;

&lt;p&gt;The backup can be configured in minutes, so now you don&#8217;t have the excuse not to do it ;-).&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.astrails.com/">
    <author>
      <name>vitaly</name>
    </author>
    <id>tag:blog.astrails.com,2009-05-20:158</id>
    <published>2009-05-20T23:06:00Z</published>
    <updated>2009-05-20T23:13:28Z</updated>
    <category term="Ruby"/>
    <category term="blog"/>
    <category term="comment"/>
    <category term="comments"/>
    <category term="database"/>
    <category term="disqus"/>
    <category term="export"/>
    <category term="import"/>
    <category term="mephisto"/>
    <link href="http://blog.astrails.com/2009/5/20/importing-mephisto-comments-into-disqus" rel="alternate" type="text/html"/>
    <title>Importing Mephisto comments into Disqus</title>
<summary type="html">&lt;p&gt;&lt;a href=&quot;http://mephistoblog.com/&quot;&gt;Mephisto&lt;/a&gt; commenting system is&#8230; how do i put it &#8230; outdated :)&lt;/p&gt;

&lt;p&gt;And we wanted something more engaging for our blog. Looking around the web
we found that &lt;a href=&quot;http://disqus.com&quot;&gt;Disqus&lt;/a&gt; was used all over the place, so
we decided to integrate it into our blog instead of the native comments system.&lt;/p&gt;</summary><content type="html">
            &lt;p&gt;&lt;a href=&quot;http://mephistoblog.com/&quot;&gt;Mephisto&lt;/a&gt; commenting system is&#8230; how do i put it &#8230; outdated :)&lt;/p&gt;

&lt;p&gt;And we wanted something more engaging for our blog. Looking around the web
we found that &lt;a href=&quot;http://disqus.com&quot;&gt;Disqus&lt;/a&gt; was used all over the place, so
we decided to integrate it into our blog instead of the native comments system.&lt;/p&gt;
&lt;p&gt;The integration itself was fairly painless, they provide simple html/js snippets that we had to insert into Mephisto liquid templates for our blog.&lt;/p&gt;

&lt;p&gt;The problem is that we wanted to completely remove the old commenting system but we didn&#8217;t want to loose existing comments on the blog.&lt;/p&gt;

&lt;p&gt;So we needed a way to import existing comments to Disqus.&lt;/p&gt;

&lt;p&gt;Google to the resque&#8230;&lt;/p&gt;

&lt;p&gt;And we found &lt;a href=&quot;http://www.locomotivation.com/blog/2008/12/01/disqus-sinatra-importer.html&quot;&gt;this&lt;/a&gt;. Jim Mulholland wrote a small &lt;a href=&quot;http://www.sinatrarb.com/&quot;&gt;sinatra&lt;/a&gt; app that accepts blog comments RSS feed and imports the comments to Disqus. Which we didn&#8217;t have.&lt;/p&gt;

&lt;p&gt;So we decided to write a direct export script instead, after all we don&#8217;t need RSS, we have mephisto db right here.&lt;/p&gt;

&lt;p&gt;Below is the script. You just need to edit a couple of constants at the beginning and run it from your mepthisto directory like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;./script/runner path/to/the/importer/script/disqus_import
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If you use something other than Mephisto, you can still find it usefull, but it&#8217;s up to you to replace the code that retrieves comments from your blog engine.&lt;/p&gt;

&lt;p&gt;Enjoy&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.astrails.com/">
    <author>
      <name>vitaly</name>
    </author>
    <id>tag:blog.astrails.com,2009-05-12:120</id>
    <published>2009-05-12T15:24:00Z</published>
    <updated>2009-05-12T20:12:46Z</updated>
    <category term="Ruby"/>
    <category term="gem"/>
    <category term="http"/>
    <category term="network"/>
    <category term="require"/>
    <category term="ruby"/>
    <link href="http://blog.astrails.com/2009/5/12/ruby-http-require" rel="alternate" type="text/html"/>
    <title>Yes We Can. &quot;require&quot; over HTTP, That Is.</title>
<content type="html">
            &lt;p&gt;Wouldn&#8217;t it be cool if you could just require &#8220;http://my-host/my-lib.rb&#8221; in ruby?&lt;/p&gt;

&lt;p&gt;Now You Can! Using our &#8220;http_require&#8221; gem! :-)&lt;/p&gt;

&lt;p&gt;test.rb:&lt;/p&gt;

&lt;pre class=&quot;ruby&quot;&gt;&lt;code class=&quot;ruby&quot;&gt;require &quot;http_require&quot;
# this will download bar.rb and eval it
require &quot;http://example.com/foo/bar.rb&quot;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If a remote file (or one of its local dependencies) requires something that
can&#8217;t be found locally, it will try to find it remotely from the same location
as the parent.&lt;/p&gt;

&lt;h3&gt;Example&lt;/h3&gt;

&lt;p&gt;http://example.com/test/foo.rb:&lt;/p&gt;

&lt;pre class=&quot;ruby&quot;&gt;&lt;code class=&quot;ruby&quot;&gt;# this will load &quot;http://example.com/test/foo/bar.rb&quot;
# if &quot;foo/bar&quot; is not available locally
require &quot;foo/bar&quot;
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;Stacktrace&lt;/h3&gt;

&lt;p&gt;http_require properly sets filename on eval so that the file&#8217;s URI appears in the stacktrace:&lt;/p&gt;

&lt;p&gt;http://example.com/foo/foo.rb:&lt;/p&gt;

&lt;pre class=&quot;ruby&quot;&gt;&lt;code class=&quot;ruby&quot;&gt;puts :foo
require 'bar'
def foo
  bar
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;http://example.com/foo/bar.rb&lt;/p&gt;

&lt;pre class=&quot;ruby&quot;&gt;&lt;code class=&quot;ruby&quot;&gt;puts :bar
def bar
  raise
end
&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code&gt;$ irb
&amp;gt;&amp;gt; require 'http_require'
=&amp;gt; true
&amp;gt;&amp;gt; require 'http://example.com/foo/bar.rb'
foo
bar
=&amp;gt; nil
&amp;gt;&amp;gt; foo
RuntimeError:
    from http://localhost:2000/bar.rb:3:in `bar'
    from http://localhost:2000/foo.rb:5:in `foo'
    from (irb):3
&amp;gt;&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;Installation&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;sudo gem install astrails-http_require --source http://gems.github.com/
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;Sources&lt;/h3&gt;

&lt;p&gt;You can find sources on &lt;a href=&quot;http://github.com/astrails/http_require&quot;&gt;github&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;UPDATE:&lt;/h3&gt;

&lt;p&gt;There seems to be lots of similar comments that I&#8217;d like to answer here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Q: This is a HUGE security hole&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A: No it isn&#8217;t. running it directly from the web is no less secure then downloading it and then running locally.
   you can use same security protections, for example SSH tunnel, or SSL like you would for any other kind of &#8216;code delivery&#8217; e.g. rsync, scp etc.
   If you control the source and the &#8216;tunnel&#8217; then this is no less secure, and if you don&#8217;t, then no other method is secure unless you start encrypting/signing files.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Q: Why on earth would you do something crazy like this?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;A: It is kind of cool :) Seriously though I do have a real usage in mind for this (more on that later), meanwhile consider rails app templates (rails -m app_template.rb) which do support running templates form the web, and no one seems to be crying out laud about a huge security hole :) Unfortunately though rails templates do not support (not out of the box) breaking down such remote templates into subfiles. you will need to do manual path mangeling (see &lt;a href=&quot;http://github.com/lackac/app_lego/blob/128ea59e87992cbc5762ab19565f19f30dfbf891/app_lego.rb#L57&quot;&gt;app_lego&lt;/a&gt; for example). I guess http_require can be used to do it cleaner.&lt;/li&gt;
&lt;/ul&gt;
          </content>  </entry>
  <entry xml:base="http://blog.astrails.com/">
    <author>
      <name>vitaly</name>
    </author>
    <id>tag:blog.astrails.com,2009-04-06:76</id>
    <published>2009-04-06T17:09:00Z</published>
    <updated>2009-05-22T09:35:50Z</updated>
    <category term="Astrails"/>
    <category term="IT"/>
    <category term="amazon"/>
    <category term="backup"/>
    <category term="dsl"/>
    <category term="mysql"/>
    <category term="ruby"/>
    <category term="s3"/>
    <category term="tar"/>
    <link href="http://blog.astrails.com/2009/4/6/simple-backups-can-be-simple" rel="alternate" type="text/html"/>
    <title>Simple backups can be simple!</title>
<summary type="html">&lt;p&gt;Everyone needs a backup, right?
Unfortunately almost no one does though. Why?!&lt;/p&gt;


	&lt;p&gt;We needed something for ourselves and our customers. Something simple, free, configure-and-forget.
Most of the time there is no need for something fancy, a simple tar + mysqldump can do the job for many small/medium sites.&lt;/p&gt;</summary><content type="html">
            &lt;p&gt;Everyone needs a backup, right?
Unfortunately almost no one does though. Why?!&lt;/p&gt;


	&lt;p&gt;We needed something for ourselves and our customers. Something simple, free, configure-and-forget.
Most of the time there is no need for something fancy, a simple tar + mysqldump can do the job for many small/medium sites.&lt;/p&gt;
We did some reasearch but every solution we found had one of the following problems:
	&lt;ul&gt;
	&lt;li&gt;too complicated to use/configure&lt;/li&gt;
		&lt;li&gt;not open source&lt;/li&gt;
		&lt;li&gt;does only filesystem or only mysql backup but not both&lt;/li&gt;
		&lt;li&gt;no Amazon S3 support&lt;/li&gt;
		&lt;li&gt;no backup rotation support&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;So we wrote &lt;a href=&quot;http://github.com/astrails/safe&quot;&gt;our own&lt;/a&gt;. Basically we cleaned up and refactored some custom backup scripts that we had for ages on our own servers.&lt;/p&gt;


	&lt;p&gt;We had the following requirements in mind when we wrote it:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;opensource :)&lt;/li&gt;
		&lt;li&gt;simple to install and configure&lt;/li&gt;
		&lt;li&gt;support for simple &#8216;tar&#8217; backups of directories (with includes/excludes)&lt;/li&gt;
		&lt;li&gt;support for simple mysqldump of mysql databases&lt;/li&gt;
		&lt;li&gt;support for symmetric or public key encryption (&lt;a href=&quot;http://github.com/astrails/safe/tree/master&quot;&gt;see &lt;span class=&quot;caps&quot;&gt;README&lt;/span&gt; for instructions&lt;/a&gt;)&lt;/li&gt;
		&lt;li&gt;support for local filesystem and Amazon S3 for storage&lt;/li&gt;
		&lt;li&gt;support for backup rotation. we don&#8217;t want backups filling all the
  diskspace or cost a fortune on S3&lt;/li&gt;
	&lt;/ul&gt;


So lets dive right in:
&lt;pre class=&quot;ruby&quot;&gt;&lt;code class=&quot;ruby&quot;&gt;
# gem install astrails-safe --source http://gems.github.com/
Successfully installed astrails-safe-0.1.4
1 gem installed
Installing ri documentation for astrails-safe-0.1.4...
Installing RDoc documentation for astrails-safe-0.1.4...

# astrails-safe my-backup.conf
ERROR: Created default /root/my-backup.conf. Please edit and run again.
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;For configuration file format we use Ruby &lt;span class=&quot;caps&quot;&gt;DSL&lt;/span&gt; (yeah, we probably got too excited writing it and went a little overboard with the implementation, a simple hash
probably would suffice here :), but we actually like the result.&lt;/p&gt;


	&lt;p&gt;Check it out (you can see more configuration options in the generated template config file):&lt;/p&gt;


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

safe do
  local :path =&amp;gt; &quot;/backup/:kind/:id&quot; 

  s3 do
    key &quot;....................&quot; 
    secret &quot;........................................&quot; 
    bucket &quot;backup.astrails.com&quot; 
    path &quot;servers/alpha/:kind/:id&quot; 
  end

  gpg do
    # symmetric encryption key
    # password &quot;qwe&quot; 

    # public GPG key (must be known to GPG, i.e. be on the keyring)
    key &quot;backup@astrails.com&quot; 
  end

  keep do
    local 2
    s3 30
  end

  mysqldump do
    options &quot;-ceKq --single-transaction --create-options&quot; 

    user &quot;root&quot; 
    password &quot;............&quot; 
    socket &quot;/var/run/mysqld/mysqld.sock&quot; 

    database :blog
    database :servershape
    database :astrails_com
    database :secret_project_com

  end

  tar do
    archive &quot;git-repositories&quot;, :files =&amp;gt; &quot;/home/git/repositories&quot; 
    archive &quot;dot-configs&quot;,      :files =&amp;gt; &quot;/home/*/.[^.]*&quot; 
    archive &quot;etc&quot;,              :files =&amp;gt; &quot;/etc&quot;, :exclude =&amp;gt; &quot;/etc/puppet/other&quot; 

    archive &quot;blog-astrails-com&quot; do
      files &quot;/var/www/blog.astrails.com/&quot; 
      exclude [&quot;/var/www/blog.astrails.com/log&quot;, &quot;/var/www/blog.astrails.com/tmp&quot;]
    end

    archive &quot;astrails-com&quot; do
      files &quot;/var/www/astrails.com/&quot; 
      exclude [&quot;/var/www/astrails.com/log&quot;, &quot;/var/www/astrails.com/tmp&quot;]
    end
  end
end

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

	&lt;p&gt;&lt;span class=&quot;caps&quot;&gt;UPDATE&lt;/span&gt;: There is new &lt;a href=&quot;http://blog.astrails.com/2009/5/21/postgress-and-svndump-support-for-astrails-safe-s3-backup&quot;&gt;updated version&lt;/a&gt; with PostgreSQL and svn support.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.astrails.com/">
    <author>
      <name>boris</name>
    </author>
    <id>tag:blog.astrails.com,2009-04-01:74</id>
    <published>2009-04-01T14:46:00Z</published>
    <updated>2009-04-01T14:48:05Z</updated>
    <category term="Ruby"/>
    <link href="http://blog.astrails.com/2009/4/1/rrdtool-on-osx-leopard" rel="alternate" type="text/html"/>
    <title>RRDtool and Ruby bindings on OSX Leopard</title>
<summary type="html">&lt;p&gt;&lt;a href=&quot;http://oss.oetiker.ch/rrdtool/index.en.html&quot;&gt;RRDtool&lt;/a&gt; is the OpenSource industry standard, high performance data logging and graphing system for time series data. Use it to write your custom monitoring shell scripts or create whole applications using its Perl, Python, Ruby, &lt;span class=&quot;caps&quot;&gt;TCL&lt;/span&gt; or &lt;span class=&quot;caps&quot;&gt;PHP&lt;/span&gt; bindings.&lt;/p&gt;


	&lt;p&gt;Let&#8217;s run it with Ruby on Leopard.&lt;/p&gt;</summary><content type="html">
            &lt;p&gt;&lt;a href=&quot;http://oss.oetiker.ch/rrdtool/index.en.html&quot;&gt;RRDtool&lt;/a&gt; is the OpenSource industry standard, high performance data logging and graphing system for time series data. Use it to write your custom monitoring shell scripts or create whole applications using its Perl, Python, Ruby, &lt;span class=&quot;caps&quot;&gt;TCL&lt;/span&gt; or &lt;span class=&quot;caps&quot;&gt;PHP&lt;/span&gt; bindings.&lt;/p&gt;


	&lt;p&gt;Let&#8217;s run it with Ruby on Leopard.&lt;/p&gt;
&lt;pre class=&quot;ruby&quot;&gt;&lt;code class=&quot;shell&quot;&gt;
sudo port install rrdtool
&lt;/code&gt;&lt;/pre&gt;

Default ports installation comes without ruby bindings.
Get full installation from here:
&lt;pre class=&quot;ruby&quot;&gt;&lt;code class=&quot;shell&quot;&gt;
cd ~/tmp
wget &quot;http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.3.6.tar.gz&quot; 
&lt;/code&gt;&lt;/pre&gt;
It&#8217;s likely to download the same version that has been installed with ports :-)

&lt;pre class=&quot;ruby&quot;&gt;&lt;code class=&quot;shell&quot;&gt;
open &quot;rrdtool-1.3.6.tar.gz&quot; 
&lt;/code&gt;&lt;/pre&gt;
&#8220;open&#8221; not &#8220;tar&#8221; &#8211; we&#8217;re on macs after all :-)

&lt;pre class=&quot;ruby&quot;&gt;&lt;code class=&quot;shell&quot;&gt;
cd rrdtool-1.3.6/bindings/ruby
ARCHFLAGS=&quot;-arch i386&quot; ruby extconf.rb --with-rrd-dir=/opt/local
make
sudo make install
&lt;/code&gt;&lt;/pre&gt;

Enjoy:
&lt;pre class=&quot;ruby&quot;&gt;
&lt;code class=&quot;shell&quot;&gt;
irb
&amp;gt;&amp;gt; require &quot;RRD&quot; 
=&amp;gt; true
&amp;gt;&amp;gt; RRD
=&amp;gt; RRD
&lt;/code&gt;
&lt;/pre&gt;
          </content>  </entry>
  <entry xml:base="http://blog.astrails.com/">
    <author>
      <name>boris</name>
    </author>
    <id>tag:blog.astrails.com,2009-03-19:63</id>
    <published>2009-03-19T12:29:00Z</published>
    <updated>2009-03-19T12:30:31Z</updated>
    <category term="IT"/>
    <category term="Rails"/>
    <category term="Ruby"/>
    <link href="http://blog.astrails.com/2009/3/19/jruby-on-rails-on-glassfish-with-mysql" rel="alternate" type="text/html"/>
    <title>JRuby on Rails on Glassfish with Mysql</title>
<content type="html">
            &lt;p&gt;Thanks a lot to &lt;a href=&quot;http://blogs.sun.com/amith/&quot;&gt;Amit Hurvitz&lt;/a&gt; for providing a file of Virtual Disk Image (VDI) of &lt;a href=&quot;http://www.virtualbox.org/&quot;&gt;VirtualBox&lt;/a&gt;, containing an up and running JRuby on Rails on Glassfish with Mysql. Image also contains some examples (actually solutions to the code camp exercises), all running on top of an &lt;a href=&quot;http://opensolaris.org/&quot;&gt;OpenSolaris&lt;/a&gt; guest OS (can be run on many host systems).&lt;/p&gt;


	&lt;p&gt;&lt;a href=&quot;http://assets.astrails.com.s3.amazonaws.com/rails-glassfish/OpenSolaris11-ror.vdi.bz2&quot;&gt;Grab the image&lt;/a&gt; ~1.5GB archive.&lt;/p&gt;


	&lt;p&gt;&lt;a href=&quot;http://assets.astrails.com.s3.amazonaws.com/rails-glassfish/exercises.zip&quot;&gt;Grab the exercises&lt;/a&gt; ~9.7MB archive.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.astrails.com/">
    <author>
      <name>vitaly</name>
    </author>
    <id>tag:blog.astrails.com,2009-03-03:43</id>
    <published>2009-03-03T16:43:00Z</published>
    <updated>2009-03-03T16:43:43Z</updated>
    <category term="IT"/>
    <category term="cache"/>
    <category term="dns"/>
    <category term="it"/>
    <category term="leopard"/>
    <category term="osx"/>
    <link href="http://blog.astrails.com/2009/3/3/flushing-os-x-dns-cache" rel="alternate" type="text/html"/>
    <title>flushing OS X DNS cache</title>
<content type="html">
            &lt;p&gt;We recently moved our &lt;span class=&quot;caps&quot;&gt;DNS&lt;/span&gt; to dnsmadeeasy.com from godaddy.com name servers.&lt;/p&gt;


	&lt;p&gt;After the transfer some internal &lt;span class=&quot;caps&quot;&gt;CNAME&lt;/span&gt; records had a problem. So after fixing the problem and checking in the terminal that the changes propagated to the &lt;span class=&quot;caps&quot;&gt;DNS&lt;/span&gt; server (host xxx.astrails.com) I tried to type the address in the browser, but it kept giving me the  &#8220;can&#8217;t find host&#8221; error.&lt;/p&gt;


	&lt;p&gt;The solution was to flush &lt;span class=&quot;caps&quot;&gt;OSX&lt;/span&gt; built in &lt;span class=&quot;caps&quot;&gt;DNS&lt;/span&gt; cache (apparently the &#8216;host&#8217; utility bypasses it, and browsers do not).&lt;/p&gt;


	&lt;p&gt;Fortunately it is very easy to do:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;On Leopard: dscacheutil -flushcache&lt;/li&gt;
		&lt;li&gt;On Tiger (didn&#8217;t check it, no tigers here :): lookupd -flushcache&lt;/li&gt;
	&lt;/ul&gt;
          </content>  </entry>
  <entry xml:base="http://blog.astrails.com/">
    <author>
      <name>vitaly</name>
    </author>
    <id>tag:blog.astrails.com,2009-02-27:40</id>
    <published>2009-02-27T09:53:00Z</published>
    <updated>2009-02-27T20:17:50Z</updated>
    <category term="IT"/>
    <category term="it"/>
    <link href="http://blog.astrails.com/2009/2/27/non-relational-mysql" rel="alternate" type="text/html"/>
    <title>Non relational MySQL</title>
<content type="html">
            &lt;p&gt;Nice idea and implementation of a &lt;a href=&quot;http://bret.appspot.com/entry/how-friendfeed-uses-mysql&quot;&gt;schema-less data store on top of MySQL&lt;/a&gt; .&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.astrails.com/">
    <author>
      <name>boris</name>
    </author>
    <id>tag:blog.astrails.com,2009-02-26:39</id>
    <published>2009-02-26T11:48:00Z</published>
    <updated>2009-02-26T11:52:09Z</updated>
    <category term="Astrails"/>
    <category term="Rails"/>
    <category term="Ruby"/>
    <link href="http://blog.astrails.com/2009/2/26/jruby-on-rails-with-glassfish-code-camp" rel="alternate" type="text/html"/>
    <title>JRuby on Rails with GlassFish Code Camp</title>
<content type="html">
            &lt;p&gt;We participated in JRuby on Rails with GlassFish Code Camp hosted by Sun Microsystems Inc. I was speaking about the framework in general trying to infect Java developers with Ruby On Rails. &lt;a href=&quot;http://blog.astrails.com/assets/2009/2/22/ror-sun-presentation.pdf&quot;&gt;Slides are available&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;&lt;a href=&quot;http://blogs.sun.com/amith/&quot;&gt;Amit Hurvitz&lt;/a&gt; gave exciting presentation about &lt;a href=&quot;https://glassfish.dev.java.net/&quot;&gt;GlassFish&lt;/a&gt; and short introduction into &lt;a href=&quot;http://wikis.sun.com/display/DTrace/Documentation&quot;&gt;DTrace&lt;/a&gt;. &lt;a href=&quot;http://blogs.sun.com/amith/entry/jruby_on_rails_on_glassfish&quot;&gt;Find out&lt;/a&gt; more details about the Code Camp.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.astrails.com/">
    <author>
      <name>boris</name>
    </author>
    <id>tag:blog.astrails.com,2009-02-11:36</id>
    <published>2009-02-11T15:24:00Z</published>
    <updated>2009-02-11T16:55:51Z</updated>
    <category term="Rails"/>
    <category term="Ruby"/>
    <link href="http://blog.astrails.com/2009/2/11/rediscovering-haml" rel="alternate" type="text/html"/>
    <title>Rediscovering HAML</title>
<summary type="html">&lt;p&gt;I was the last person in our company working with &lt;span class=&quot;caps&quot;&gt;ERB&lt;/span&gt; to render templates. While all the rest switched to &lt;a href=&quot;http://haml.hamptoncatlin.com/&quot;&gt;&lt;span class=&quot;caps&quot;&gt;HAML&lt;/span&gt;&lt;/a&gt;. At the beginning it was quite hard for me to read &lt;span class=&quot;caps&quot;&gt;HAML&lt;/span&gt; comparing to &lt;span class=&quot;caps&quot;&gt;ERB&lt;/span&gt;. HAML looked for me like some completely alien thing with weird percent marks all over the place and the significant whitespace never did it for me. On the other hand &lt;span class=&quot;caps&quot;&gt;ERB&lt;/span&gt; felt like warm home after years we spent together.&lt;/p&gt;


	&lt;p&gt;Until I did the switch.&lt;/p&gt;</summary><content type="html">
            &lt;p&gt;I was the last person in our company working with &lt;span class=&quot;caps&quot;&gt;ERB&lt;/span&gt; to render templates. While all the rest switched to &lt;a href=&quot;http://haml.hamptoncatlin.com/&quot;&gt;&lt;span class=&quot;caps&quot;&gt;HAML&lt;/span&gt;&lt;/a&gt;. At the beginning it was quite hard for me to read &lt;span class=&quot;caps&quot;&gt;HAML&lt;/span&gt; comparing to &lt;span class=&quot;caps&quot;&gt;ERB&lt;/span&gt;. HAML looked for me like some completely alien thing with weird percent marks all over the place and the significant whitespace never did it for me. On the other hand &lt;span class=&quot;caps&quot;&gt;ERB&lt;/span&gt; felt like warm home after years we spent together.&lt;/p&gt;


	&lt;p&gt;Until I did the switch.&lt;/p&gt;
&lt;p&gt;Now I would compare &lt;span class=&quot;caps&quot;&gt;HAML&lt;/span&gt; with Mac. Once you&#8217;ve switched you never get back. Guys from &lt;span class=&quot;caps&quot;&gt;HAML&lt;/span&gt; say that &#8220;HAML is based on one primary principle. Markup should be beautiful.&#8221;, they even go as far as call it markup &lt;a href=&quot;http://en.wikipedia.org/wiki/Haiku&quot;&gt;haiku&lt;/a&gt;. Which is true. Together with &#8220;beautiful&#8221; you get less code that is more readable and secure.&lt;/p&gt;


	&lt;p&gt;Now, writing rails views that are readable, maintainable and concise was never an easy job. If you let them to get out of hand you quickly find yourself with 400 lines of&#8230; not code, no&#8230; let&#8217;s call it a mess. We actually seen it happens to less careful colleagues, and cleaning this mess was not a fun and easy thing to do.&lt;/p&gt;


	&lt;p&gt;&lt;span class=&quot;caps&quot;&gt;HAML&lt;/span&gt; is here to help you with that.&lt;/p&gt;


	&lt;p&gt;You obviously can get to the same mess level with &lt;span class=&quot;caps&quot;&gt;HAML&lt;/span&gt;, but if you on a task to avoid it, &lt;span class=&quot;caps&quot;&gt;HAML&lt;/span&gt; is there to support you.&lt;/p&gt;


	&lt;p&gt;Simply put, If you write something that doesn&#8217;t look beautiful you know that you&#8217;re doing something wrong and it is a time to stop for a minute and think about refactoring.&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;long views with deep nesting &#8211; you can check 2 things here
	&lt;ul&gt;
	&lt;li&gt;whether you need to create some partials for duplicating parts &lt;/li&gt;
		&lt;li&gt;or you can check your &lt;span class=&quot;caps&quot;&gt;HTML&lt;/span&gt; markup (table layout will look really really bad in &lt;span class=&quot;caps&quot;&gt;HAML&lt;/span&gt;)&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
		&lt;li&gt;if your lines are too long &#8211; create helpers and get your ruby code out of views&lt;/li&gt;
		&lt;li&gt;inline javascript doesn&#8217;t really looks fit &#8211; check out the &lt;a href=&quot;http://en.wikipedia.org/wiki/Unobtrusive_JavaScript&quot;&gt;unobtrusive javascript&lt;/a&gt;, which will bring along another nicetohaves.&lt;/li&gt;
	&lt;/ul&gt;


Another big bounty you get is that &lt;span class=&quot;caps&quot;&gt;HTML&lt;/span&gt; escaping is opt out vs. the opt in in &lt;span class=&quot;caps&quot;&gt;ERB&lt;/span&gt; after the following magic. Put this in in config/environment.rb (after Rails::Initializer.run):
&lt;pre class=&quot;ruby&quot;&gt;&lt;code class=&quot;ruby&quot;&gt;Haml::Template.options[:escape_html] = true
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;So you have to make an informed decision that you want this piece of code unescaped which hopefully will make your code more secure out of the box with next to nothing additional work on your hands. So long, nasty &lt;a href=&quot;http://en.wikipedia.org/wiki/Cross-site_scripting&quot;&gt;&lt;span class=&quot;caps&quot;&gt;XSS&lt;/span&gt;&lt;/a&gt;.&lt;/p&gt;


This line should not get your &lt;span class=&quot;caps&quot;&gt;XSS&lt;/span&gt; alarm go off
&lt;pre class=&quot;ruby&quot;&gt;&lt;code class=&quot;ruby&quot;&gt;%h2= @product.title
&lt;/code&gt;&lt;/pre&gt;

This one should, but i&#8217;m sure you know it, cause you went to an extra step of putting &#8221;!&#8221; there
&lt;pre class=&quot;ruby&quot;&gt;&lt;code class=&quot;ruby&quot;&gt;#products
  != render(:partial =&amp;gt; @products)
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Generally, i can&#8217;t find a good reason for leaving all your strings unescaped by default (wink-wink &lt;span class=&quot;caps&quot;&gt;ERB&lt;/span&gt;). Do I miss something?&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.astrails.com/">
    <author>
      <name>boris</name>
    </author>
    <id>tag:blog.astrails.com,2009-02-04:31</id>
    <published>2009-02-04T21:43:00Z</published>
    <updated>2009-02-11T14:34:57Z</updated>
    <category term="Astrails"/>
    <link href="http://blog.astrails.com/2009/2/4/another-year-in-consulting" rel="alternate" type="text/html"/>
    <title>Another year in consulting</title>
<summary type="html">&lt;p&gt;2008 was the year when we finally switched to full time consulting. And like all consulters we faced the problem of correct pricing. There are two well-known ways to charge a customer: per-hour rate and fixed bid quote, and several combinations of them.&lt;/p&gt;</summary><content type="html">
            &lt;p&gt;2008 was the year when we finally switched to full time consulting. And like all consulters we faced the problem of correct pricing. There are two well-known ways to charge a customer: per-hour rate and fixed bid quote, and several combinations of them.&lt;/p&gt;
&lt;h3&gt;Per-hour rate.&lt;/h3&gt;


	&lt;p&gt;Everything is quite clear here. You just charge per hour rate no matter what. Your customer wears all risks. Per-hour rate is good for short-term consulting projects, like &lt;a href=&quot;http://blog.astrails.com/2008/12/17/deployment-process-requirements&quot;&gt;deployments&lt;/a&gt;, &lt;a href=&quot;http://astrails.com/launch_review.html&quot;&gt;launch reviews&lt;/a&gt;, etc. If you&#8217;re going to work on a project that takes more then 10-15 hours, you will need to estimate the required hours to accomplish the tasks. And, obviously, meet this estimation.&lt;/p&gt;


	&lt;p&gt;So, you calculate estimations. Actually, you always do an estimation, it may be time, it may be money. But you always estimate. Because every customer needs to be sure that she has a budget to hire you.&lt;/p&gt;


	&lt;h3&gt;Fixed bid.&lt;/h3&gt;


	&lt;p&gt;The Dark Art of Realistic Time Estimation is something that anyone can learn. The only question is how much time and money are wasted until you learn it. Because you wear risks in such a case. With fixed bid you can get more money then working on per-hour basis. But also you can loose money, or actually time, working for free because of wrong estimation. Give an expensive quote and customer goes to other developers, give underestimated quote and work for free. Sounds like a dangerous and loose-loose situation.&lt;/p&gt;


	&lt;p&gt;Sometimes, preparing a realistic fixed bid quote requires several hours or even days of research and planning. At the beginning we did a time consuming planing for free, just to give some number to a potential customer. Sometimes customers just ask for a quote and don&#8217;t mean to work with you, they&#8217;re just curious about your quote.&lt;/p&gt;


	&lt;h3&gt;Save your time.&lt;/h3&gt;


	&lt;p&gt;We&#8217;ve found a way to save our time and filter such customers. We make very very rough estimation that sometimes just a price range, which takes 2-4 hours maximum. If the price range matches customer expectations we proceed with exact quote. This is the first-level filter. Obviously, to issue an exact quote we make general software designs and discuss implementation of complex parts. If a quote preparing takes more then 5-7 hours we charge our customer for working on it. Customers that don&#8217;t agree to pay for issuing fixed bid quote don&#8217;t pass second-level filter.&lt;/p&gt;


	&lt;p&gt;In such a way we get only serious customers that really want to hire us and have their projects done. And we always want to work with them. Often, we can reduce a final price by reconsidering our approaches, changing some requirements, reworking flows, etc. We always find out a way to work with these customers, and they always find out a way to work with us. These are high quality customers, and we enjoy every minute of working with them.&lt;/p&gt;


	&lt;h3&gt;Experimental approach.&lt;/h3&gt;


	&lt;p&gt;There is another approach that sounds quite fair. Risks are shared between customer and consulter. Let&#8217;s say the original estimation is 10 days, and you charge say $800 per day. The total price of $8000 is split into 2 parts: per day part, say $3500 ($350 per day), and final part $4500. Final part is paid at the end of the job. If something bad is happened and you work 12 days instead of 10 days &#8211; customer pays you extra of 2x$350, final part remains unchanged. If you complete the project in 8 days instead of 10 days &#8211; customer pays you 2x$350 less, and final part also remains unchanged. So if things got complicated, or you underestimate the tasks you get lower average per-hour rate and customer pays a bit more. If you work faster &#8211; you get higher average per-hour rate and customer pays less and gets the project early.&lt;/p&gt;


	&lt;h3&gt;Slow and expensive.&lt;/h3&gt;


	&lt;p&gt;We heard a lot that large companies charge 5 times more then we do, work 3 times slower, and produce ugly unmaintainable code. And they still get customers. So what&#8217;s the secret here? I can think about only one reason: they&#8217;re big. Sometimes customers think that if you&#8217;re small you will disappear in a nearest future, and no one will be able to take care of the project. This is ridiculous when you&#8217;re talking about Ruby On Rails.&lt;/p&gt;


	&lt;p&gt;Are there other reasons?&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.astrails.com/">
    <author>
      <name>vitaly</name>
    </author>
    <id>tag:blog.astrails.com,2009-01-22:32</id>
    <published>2009-01-22T10:12:00Z</published>
    <updated>2009-02-11T16:54:08Z</updated>
    <category term="IT"/>
    <category term="Rails"/>
    <category term="Ruby"/>
    <category term="amazon"/>
    <category term="ami"/>
    <category term="debian"/>
    <category term="ec2"/>
    <category term="panda"/>
    <category term="s3"/>
    <category term="sdb"/>
    <category term="security"/>
    <link href="http://blog.astrails.com/2009/1/22/securing-panda-ami-instance-for-produciton" rel="alternate" type="text/html"/>
    <title>Securing Panda AMI instance for production</title>
<summary type="html">&lt;p&gt;Recently we looked for video transcoding/hosting solution to use in one of our client&#8217;s projects.&lt;/p&gt;


	&lt;p&gt;The best thing we&#8217;ve found is &lt;a href=&quot;http://pandastream.com/&quot;&gt;Panda&lt;/a&gt;. It runs on Amazon stack of services including &lt;a href=&quot;http://amazon.com/ec2&quot;&gt;ec2&lt;/a&gt;, &lt;a href=&quot;http://amazon.com/s3&quot;&gt;s3&lt;/a&gt;, and &lt;a href=&quot;http://amazon.com/sdb&quot;&gt;simpledb&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;Using amazon has many advantages. no contracts, pay as you go, easy and fast scaling in case your site explodes :)&lt;/p&gt;


	&lt;p&gt;Unfortunately the image that is refered in the &lt;a href=&quot;http://pandastream.com/docs/getting_started&quot;&gt;Getting Started&lt;/a&gt; (ami-05d7336c) is not safe for production &#8211; it has openssh version with a serious &lt;a href=&quot;http://www.debian.org/security/2008/dsa-1571&quot;&gt;security bug&lt;/a&gt;, but don&#8217;t worry, we will explain how to fix it.&lt;/p&gt;</summary><content type="html">
            &lt;p&gt;Recently we looked for video transcoding/hosting solution to use in one of our client&#8217;s projects.&lt;/p&gt;


	&lt;p&gt;The best thing we&#8217;ve found is &lt;a href=&quot;http://pandastream.com/&quot;&gt;Panda&lt;/a&gt;. It runs on Amazon stack of services including &lt;a href=&quot;http://amazon.com/ec2&quot;&gt;ec2&lt;/a&gt;, &lt;a href=&quot;http://amazon.com/s3&quot;&gt;s3&lt;/a&gt;, and &lt;a href=&quot;http://amazon.com/sdb&quot;&gt;simpledb&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;Using amazon has many advantages. no contracts, pay as you go, easy and fast scaling in case your site explodes :)&lt;/p&gt;


	&lt;p&gt;Unfortunately the image that is refered in the &lt;a href=&quot;http://pandastream.com/docs/getting_started&quot;&gt;Getting Started&lt;/a&gt; (ami-05d7336c) is not safe for production &#8211; it has openssh version with a serious &lt;a href=&quot;http://www.debian.org/security/2008/dsa-1571&quot;&gt;security bug&lt;/a&gt;, but don&#8217;t worry, we will explain how to fix it.&lt;/p&gt;
&lt;p&gt;Actually, you should always apply latest security patches and change ssh keys  when using public &lt;span class=&quot;caps&quot;&gt;AMI&lt;/span&gt; images in production. Or even better, bundle your own &lt;span class=&quot;caps&quot;&gt;AMI&lt;/span&gt; image with all your changes and never use public ones in production.&lt;/p&gt;


	&lt;p&gt;OK, now lets get to work.&lt;/p&gt;


	&lt;h3&gt;start ami instance&lt;/h3&gt;


&lt;pre class=&quot;ruby&quot;&gt;&lt;code class=&quot;shell small&quot;&gt;
$ ec2-run-instances ami-05d7336c -k EC2_PUBLIC_KEY_NAME
RESERVATION    r-xxxxxxxx    xxxxxxxxxxxx    default
INSTANCE    i-xxxxxxx    ami-05d7336c            pending    your_key    0        m1.small    2009-01-22T08:44:12+0000    us-east-1c        
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;&lt;span class=&quot;caps&quot;&gt;EC2&lt;/span&gt;_PUBLIC_KEY_NAME is the name of the keypair that you generated using ec2-add-keypair command. (see 
&lt;a href=&quot;http://docs.amazonwebservices.com/AWSEC2/2008-05-05/GettingStartedGuide/&quot;&gt;Amazon &lt;span class=&quot;caps&quot;&gt;EC2&lt;/span&gt; Getting Started Guide&lt;/a&gt; for details)&lt;/p&gt;


	&lt;h3&gt;wait until it starts&lt;/h3&gt;


&lt;pre class=&quot;ruby&quot;&gt;&lt;code class=&quot;shell small&quot;&gt;
$ ec2-describe-instances
RESERVATION    r-xxxxxx    xxxxxxxxxxxxxx    default
INSTANCE    i-xxxxxxx    ami-05d7336c    xxxxxxx.compute-1.amazonaws.com    ip-xxxxxxxxx.ec2.internal    running    your_key    0        m1.small    2009-01-22T08:44:12+0000    us-east-1c        
&lt;/code&gt;&lt;/pre&gt;

	&lt;h3&gt;login into the instance&lt;/h3&gt;


&lt;pre class=&quot;ruby&quot;&gt;&lt;code class=&quot;shell small&quot;&gt;
$ ssh -i key-c2a root@xxxxx.compute-1.amazonaws.com
The authenticity of host 'xxxx.compute-1.amazonaws.com (xxxxx)' can't be established.
RSA key fingerprint is c4:e0:8e:cc:6a:b6:6f:63:8c:c2:5d:13:7e:77:36:a2.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'xxxx.compute-1.amazonaws.com,xxxxx' (RSA) to the list of known hosts.
Last login: Wed Sep 24 10:43:28 2008 from zzzz
Linux xxxxx.compute-1.amazonaws.com 2.6.16-xenU #1 SMP Mon May 28 03:41:49 SAST 2007 i686

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
panda:~# 

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

	&lt;h3&gt;update apt&lt;/h3&gt;


The current source list
&lt;pre class=&quot;ruby&quot;&gt;&lt;code class=&quot;shell small&quot;&gt;
panda:~# apt-get update
...
Reading package lists... Done
panda:~# 

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

	&lt;h3&gt;upgrade packages&lt;/h3&gt;


	&lt;p&gt;Those are bug security fixes:&lt;/p&gt;


&lt;pre class=&quot;ruby&quot;&gt;&lt;code class=&quot;shell small&quot;&gt;
panda:~# apt-get upgrade -u
Reading package lists... Done
Building dependency tree... Done
The following packages have been kept back:
  openssh-client openssh-server
The following packages will be upgraded:
  bsdutils cpio debconf debconf-i18n dpkg dpkg-dev dselect e2fslibs e2fsprogs file findutils git-core initscripts irb1.8 libblkid1 libc6 libc6-amd64 libc6-dev libc6-dev-amd64
  libc6-xen libcairo2 libcomerr2 libdbi-perl libfreetype6 libgnutls13 libkrb53 liblcms1 libmagic1 libmysqlclient15off libopenssl-ruby1.8 libpam-modules libpam-runtime libpam0g
  libpcre3 libpcre3-dev libpcrecpp0 libpq4 libpulse0 libqt3-mt libreadline-ruby1.8 libruby1.8 libruby1.9 libspeex1 libss2 libssl-dev libssl0.9.8 libtiff4 libuuid1 libvorbis-dev
  libvorbis0a libvorbisenc2 libvorbisfile3 libxine1 libxml2 locales login mount mplayer mysql-client-5.0 mysql-common openssl passwd perl perl-base perl-modules postfix python2.4
  python2.4-minimal rdoc1.8 rsync ruby1.8 ruby1.8-dev ruby1.9 sysv-rc sysvinit sysvinit-utils tar tzdata unzip util-linux
80 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
Need to get 77.1MB of archives.
After unpacking 1220kB disk space will be freed.
Do you want to continue [Y/n]? y
Get:1 http://security.debian.org etch/updates/main login 1:4.0.18.1-7+etch1 [797kB]
Get:2 http://ftp.debian.org etch/main bsdutils 1:2.12r-19etch1 [68.5kB]
Get:3 http://ftp.debian.org etch/main dpkg 1.13.26 [2034kB]
Get:4 http://security.debian.org etch/updates/main perl-modules 5.8.8-7etch6 [2328kB]
Get:5 http://ftp.debian.org etch/main libc6-dev 2.3.6.ds1-13etch8 [2718kB]
Get:6 http://security.debian.org etch/updates/main perl 5.8.8-7etch6 [3599kB]                                                                                                       
Get:7 http://ftp.debian.org etch/main libc6-dev-amd64 2.3.6.ds1-13etch8 [2015kB]                                                                                                    
Get:8 http://security.debian.org etch/updates/main perl-base 5.8.8-7etch6 [763kB]                                                                                                   
Get:9 http://ftp.debian.org etch/main libc6-amd64 2.3.6.ds1-13etch8 [3327kB]                                                                                                        
Get:10 http://security.debian.org etch/updates/main libssl-dev 0.9.8c-4etch4 [2094kB]                                                                                               
Get:11 http://security.debian.org etch/updates/main libssl0.9.8 0.9.8c-4etch4 [2721kB]            
...
Get:79 http://ftp.debian.org etch/main unzip 5.52-9etch1 [152kB]                                                                                                                    
Get:80 http://ftp.debian.org etch/main postfix 2.3.8-2+etch1 [1090kB]                                                                                                               
Fetched 77.1MB in 2m36s (494kB/s)                                                                                                                                                   
Extracting templates from packages: 100%
Preconfiguring packages ...
...
Unpacking replacement tzdata ...
Setting up tzdata (2008e-1etch3) ...
Running 'tzconfig' to set this system's timezone.
Your current time zone is set to Unknown
Do you want to change that? [n]: y

Please enter the number of the geographic area in which you live:

    1) Africa            7) Australia

    2) America            8) Europe

    3) US time zones        9) Indian Ocean

    4) Canada time zones        10) Pacific Ocean

    5) Asia                11) Use System V style time zones

    6) Atlantic Ocean        12) None of the above

Then you will be shown a list of cities which represent the time zone
in which they are located. You should choose a city in your time zone.

Number: 12

GMT GMT+0 GMT+1 GMT+10 GMT+11 GMT+12 GMT+2 GMT+3 GMT+4 GMT+5 GMT+6 GMT+7
GMT+8 GMT+9 GMT-0 GMT-1 GMT-10 GMT-11 GMT-12 GMT-13 GMT-14 GMT-2 GMT-3
GMT-4 GMT-5 GMT-6 GMT-7 GMT-8 GMT-9 GMT0 Greenwich UCT UTC Universal Zulu

Please enter the name of one of these cities or zones
You just need to type enough letters to resolve ambiguities
Press Enter to view all of them again
Name: [] UTC
Your default time zone is set to 'Etc/UTC'.
Local time is now:      Thu Jan 22 09:03:14 UTC 2009.
Universal Time is now:  Thu Jan 22 09:03:14 UTC 2009.

...
Setting up perl (5.8.8-7etch6) ...

Setting up dpkg-dev (1.13.26) ...
Setting up mysql-client-5.0 (5.0.32-7etch8) ...
panda:~# 

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

	&lt;p&gt;Notice 2 packages that were not upgraded: openssh-client and openssh-server&lt;/p&gt;


	&lt;h3&gt;upgrade openssh&lt;/h3&gt;


&lt;pre class=&quot;ruby&quot;&gt;&lt;code class=&quot;shell small&quot;&gt;
panda:~# apt-get install openssh-server 
Reading package lists... Done
Building dependency tree... Done
The following extra packages will be installed:
  openssh-blacklist openssh-client
Suggested packages:
  ssh-askpass xbase-clients rssh molly-guard
The following NEW packages will be installed:
  openssh-blacklist
The following packages will be upgraded:
  openssh-client openssh-server
2 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 3006kB of archives.
After unpacking 4096kB of additional disk space will be used.
Do you want to continue [Y/n]? y
...
Setting up openssh-server (4.3p2-9etch3) ...
Creating SSH2 RSA key; this may take some time ...
Creating SSH2 DSA key; this may take some time ...
Restarting OpenBSD Secure Shell server: sshd.

panda:~# 

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

	&lt;p&gt;During the installation it created new sshd server keys.&lt;/p&gt;


	&lt;h3&gt;check for vulnerable ssh keys&lt;/h3&gt;


&lt;pre class=&quot;ruby&quot;&gt;&lt;code class=&quot;shell small&quot;&gt;
panda:~# ssh-vulnkey  -a
Not blacklisted: 2048 25:7b:b5:cf:ae:44:87:00:9d:b6:62:39:f9:4e:10:7d /etc/ssh/ssh_host_rsa_key.pub
Not blacklisted: 1024 e2:26:98:52:ad:9f:2c:43:77:45:71:e9:87:17:7c:08 /etc/ssh/ssh_host_dsa_key.pub
Not blacklisted: 2048 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx your-key
panda:~# 
&lt;/code&gt;&lt;/pre&gt;

	&lt;h3&gt;update known_hosts file&lt;/h3&gt;


	&lt;p&gt;you just changed server&#8217;s ssh key, so next time you try to login ssh will complain:&lt;/p&gt;


&lt;pre class=&quot;ruby&quot;&gt;&lt;code class=&quot;shell small&quot;&gt;
$ ssh -i your-key root@xxxxxxxxxxxxxxxxxxx.compute-1.amazonaws.com
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Please contact your system administrator.
Add correct host key in /Users/vitaly/.ssh/known_hosts to get rid of this message.
Offending key in /Users/vitaly/.ssh/known_hosts:68
RSA host key for xxxxxxxxxxxxxxxxxx.compute-1.amazonaws.com has changed and you have requested strict checking.
Host key verification failed.
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Remove line with the old host key (filename and line number is given by ssh) and you will be able to login again&lt;/p&gt;


	&lt;h3&gt;install panda&lt;/h3&gt;


	&lt;p&gt;Just follow &lt;a href=&quot;http://pandastream.com/docs/getting_started&quot;&gt;Panda Getting Started Guide&lt;/a&gt; starting with &#8220;Grab Panda&#8221;&lt;/p&gt;


	&lt;h3&gt;bundle new &lt;span class=&quot;caps&quot;&gt;AMI&lt;/span&gt;&lt;/h3&gt;


	&lt;p&gt;Now you can create a new Amazon &lt;span class=&quot;caps&quot;&gt;AMI&lt;/span&gt; image from your current instance. Refer to &lt;a href=&quot;http://docs.amazonwebservices.com/AWSEC2/2008-05-05/GettingStartedGuide/&quot;&gt;Amazon &lt;span class=&quot;caps&quot;&gt;EC2&lt;/span&gt; Getting Started Guide&lt;/a&gt; (section &#8220;Creating an Image&#8221;)&lt;/p&gt;
          </content>  </entry>
</feed>
