<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	
	xmlns:georss="http://www.georss.org/georss"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
	>

<channel>
	<title>Ruby / Rails - Cognizant Transmutation</title>
	<atom:link href="https://www.ibd.com/category/ruby-rails/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.ibd.com</link>
	<description>Internet Bandwidth Development: Composting the Internet for over Two Decades</description>
	<lastBuildDate>Thu, 05 Aug 2021 06:18:12 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1</generator>

<image>
	<url>https://i0.wp.com/www.ibd.com/wp-content/uploads/2019/01/fullsizeoutput_7ae8.jpeg?fit=32%2C32&#038;ssl=1</url>
	<title>Ruby / Rails - Cognizant Transmutation</title>
	<link>https://www.ibd.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<atom:link rel="hub" href="https://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="https://pubsubhubbub.superfeedr.com"/><atom:link rel="hub" href="https://websubhub.com/hub"/><site xmlns="com-wordpress:feed-additions:1">156814061</site>	<item>
		<title>Avoiding a series of tests with Ruby Hashes of Hashes that might have nil before the leaf hash</title>
		<link>https://www.ibd.com/ruby-rails/avoiding-a-series-of-tests-with-hashes-of-hashes-that-might-have-nil-before-the-leaf-hash/</link>
		
		<dc:creator><![CDATA[Robert J Berger]]></dc:creator>
		<pubDate>Thu, 04 Aug 2011 05:41:11 +0000</pubDate>
				<category><![CDATA[Opscode Chef]]></category>
		<category><![CDATA[Ruby / Rails]]></category>
		<category><![CDATA[Sysadmin]]></category>
		<category><![CDATA[Chef]]></category>
		<category><![CDATA[Ruby]]></category>
		<guid isPermaLink="false">http://blog2.ibd.com/?p=805</guid>

					<description><![CDATA[<p>I&#8217;m mostly using Ruby to write Opscode Chef Cookbooks. There are a lot of hashes of hashes that contain attributes or Data Bags. Things that look like: If I wanted to test if this value is set I couldn&#8217;t safely just say: because in some cases or may be nil . If ether of those were nil and I execute&#8230;</p>
<p>The post <a href="https://www.ibd.com/ruby-rails/avoiding-a-series-of-tests-with-hashes-of-hashes-that-might-have-nil-before-the-leaf-hash/">Avoiding a series of tests with Ruby Hashes of Hashes that might have nil before the leaf hash</a> first appeared on <a href="https://www.ibd.com">Cognizant Transmutation</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>I&#8217;m mostly using Ruby to write <a href="http://www.opscode.com/" target="_blank">Opscode </a>Chef <a href="http://wiki.opscode.com/display/chef/Cookbooks" target="_blank">Cookbooks</a>. There are a lot of hashes of hashes that contain <a href="http://wiki.opscode.com/display/chef/Attributes" target="_blank">attributes</a> or <a href="http://wiki.opscode.com/display/chef/Data+Bags" target="_blank">Data Bags</a>. Things that look like:</p>
<pre class="brush: ruby; title: ; notranslate">app['rds_database'][environment]['rds_name']</pre>
<p>If I wanted to test if this value is set I couldn&#8217;t safely just say:</p>
<pre class="brush: ruby; title: ; notranslate">if app['rds_database'][environment]['rds_name']</pre>
<p>because in some cases</p>
<pre class="brush: ruby; title: ; notranslate">if app['rds_database']</pre>
<p>or</p>
<pre class="brush: ruby; title: ; notranslate">if app['rds_database'][environment]</pre>
<p>may be nil .</p>
<p>If ether of those were nil and I execute</p>
<pre class="brush: ruby; title: ; notranslate">if app['rds_database'][environment]['rds_name']</pre>
<p>I would get an exception like:</p>
<pre class="brush: plain; title: ; notranslate">NoMethodError: undefined method `[]' for nil:NilClass</pre>
<p>I have been doing something like:</p>
<pre class="brush: ruby; title: ; notranslate">if app['rds_database'] &amp;&amp; app['rds_database'][environment] &amp;&amp; app['rds_database'][environment]['rds_name']</pre>
<p>But that was starting to make me sick to my stomach. I like my Ruby fine and DRY</p>
<p>So I scoured the Internet (well googled a bit) and found a couple of good Stack Overflow posts like <a href="http://stackoverflow.com/questions/6334639/how-to-access-an-element-deep-in-an-array-of-arrays-without-getting-undefined-me" target="_blank">How to access an element deep in an array of arrays without getting &#8216;undefined method&#8217; error</a> and <a href="http://stackoverflow.com/questions/4371716/looking-for-a-good-way-to-avoid-hash-conditionals-in-ruby" target="_blank">Looking for a Good Way to Avoid Hash Conditionals in Ruby</a>.</p>
<p>But most of them were ways to Monkey Patch the Hash Object or use new operators that are loaded by Gems.</p>
<p>One of them was pretty simple and was pretty DRY. Though some commentors called it <em>an indiscriminate use of </em> <code>rescue</code> <em>and EEEEVVVVIIILLLLL.</em></p>
<p>But it seems to me to be a very discriminate use of rescue, as any case where the rescue happens, I want it to return nil:</p>
<pre class="brush: ruby; title: ; notranslate">if (app['rds_database'][environment]['rds_name'] rescue nil)</pre>
<p>The parenthesis aren&#8217;t needed, but I think it makes it clearer whats going on. Especially if you say something like:</p>
<pre class="brush: ruby; title: ; notranslate">return unless (app['rds_database'][environment]['rds_name'] rescue nil)</pre>
<p>So I&#8217;m going to give that a try for a while.</p><p>The post <a href="https://www.ibd.com/ruby-rails/avoiding-a-series-of-tests-with-hashes-of-hashes-that-might-have-nil-before-the-leaf-hash/">Avoiding a series of tests with Ruby Hashes of Hashes that might have nil before the leaf hash</a> first appeared on <a href="https://www.ibd.com">Cognizant Transmutation</a>.</p>]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">805</post-id>	</item>
		<item>
		<title>Using the Official Opscode 0.8.x Gems to build EC2 AMI Chef Client and Server</title>
		<link>https://www.ibd.com/howto/using-the-official-opscode-0-8-x-gems-to-build-ec2-ami-chef-client-and-server/</link>
		
		<dc:creator><![CDATA[Robert J Berger]]></dc:creator>
		<pubDate>Wed, 03 Mar 2010 06:50:57 +0000</pubDate>
				<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Opscode Chef]]></category>
		<category><![CDATA[Ruby / Rails]]></category>
		<category><![CDATA[Scalable Deployment]]></category>
		<category><![CDATA[Sysadmin]]></category>
		<category><![CDATA[AWS]]></category>
		<category><![CDATA[EC2]]></category>
		<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[ubuntu]]></category>
		<guid isPermaLink="false">http://blog2.ibd.com/?p=513</guid>

					<description><![CDATA[<p>Updates Mar 3, 2010 Added call to script ec2-set-defaults that is normally called on ec2 init that sets the locale and apt sources for EC availability Zone Introduction Opscode has officially released 0.8.x of Chef. It is now even more fabulous. I&#8217;ve been using the pre-release version for the last couple of months and it is rock steady and very&#8230;</p>
<p>The post <a href="https://www.ibd.com/howto/using-the-official-opscode-0-8-x-gems-to-build-ec2-ami-chef-client-and-server/">Using the Official Opscode 0.8.x Gems to build EC2 AMI Chef Client and Server</a> first appeared on <a href="https://www.ibd.com">Cognizant Transmutation</a>.</p>]]></description>
										<content:encoded><![CDATA[<h2>Updates</h2>
<ul>
<li><strong>Mar 3, 2010</strong> Added call to script <em>ec2-set-defaults </em>that is normally called on ec2 init that sets the locale and apt sources for EC availability Zone</li>
</ul>
<h2>Introduction</h2>
<p>Opscode has officially released 0.8.x of Chef. It is now even more fabulous. I&#8217;ve been using the pre-release version for the last couple of months and it is rock steady and very powerful. I&#8217;ll be having a post soon on how I used it to deploy a pretty complicated cloud stack with multiple Rails/Mysql/Nginx/Unicorn/Postfix apps for front-ends, and a back end made up of a mix of a Clojure/Swarmiji distributed processing swarm, HBase/Hadoop, Redis, RabbitMQ.</p>
<p>But first, I needed to upgrade my Amazon EC2 AMIs for the officially released Chef 0.8.x. I also wanted to try the EBS Boot image as a basis for the AMI.</p>
<p>This is an update to my earlier post, <a href="http://blog2.ibd.com/scalable-deployment/creating-an-amazon-ami-for-chef-0-8/" target="_blank">Creating an Amazon EC2 AMI for Opscode Chef 0.8</a>, but now using the official Opscode 0.8.x Gems instead of building your own Gems. A lot of the content is the same, but you can consider this mostly superceding the older one except where mentioned otherwise. This version will use the EBS Boot AMIs as per Eric Hammond&#8217;s Tutorial Building <a href="http://alestic.com/2010/01/ec2-ebs-boot-ubuntu" target="_blank">EBS Boot AMIs Using Canonical&#8217;s Downloadable EC2 Images</a>. Much of this is blog post is taken from Eric&#8217;s blog post but in the context of creating a Chef Client base AMI and a Chef Server. Note that <a href="http://thecloudmarket.com/owner/345069653647--opscode" target="_blank">Opscode now has their own AMIs,</a> including ones for Chef 0.8.4, but as of this writing, they do not have AMIs for Amazon us-west.</p>
<h2>Setup</h2>
<h3>Prerequisites</h3>
<p>On your host development machine (ie your laptop or whatever machine you are developing from) you should have already installed:</p>
<ul>
<li>ec2-api-tools and ec2-ami-tools (these assume you have a modern Java run time setup)</li>
<li>chef-0.8.4 or later chef client gem (which implies the entire ruby 1.8.x and rubygems toolchain)</li>
</ul>
<h3>Set some Shell variables on host machine</h3>
<p>Just to make using these instructions as a cookbook, we&#8217;ll have some shell variables that you can set once and then all the instructions will use the variables so you can just cut and paste the instructions into your shell.</p>
<pre>keypair=id_runa-staging-us-west
fullpath_keypair=~/.ssh/runa/id_runa-staging-us-west
availability_zone=us-west-1a
instance_type=m1.large
region=us-west-1

# Pick one of these two AMIs (Note that it will be different for different Amazon Regions)
# 32bit AMI
origin_ami=ami-fd5100b8
#64bit AMI
origin_ami=ami-ff5100ba</pre>
<h3>Start up an instance and capture the instanceid</h3>
<pre>instanceid=$(ec2-run-instances \
  --key $keypair \
  --availability-zone $availability_zone \
  --instance-type $instance_type \
  $origin_ami \
  --region $region  |
  egrep ^INSTANCE | cut -f2)
echo "instanceid=$instanceid"</pre>
<h3>Wait for the instance to move to the “running” state</h3>
<pre>while host=$(ec2-describe-instances --region $region "$instanceid" |
  egrep ^INSTANCE | cut -f4) &amp;&amp; test -z $host; do echo -n .; sleep 1; done
echo host=$host</pre>
<p>This should loop till you see something like:</p>
<pre>$ echo host=$host
host=ec2-184-72-2-93.us-west-1.compute.amazonaws.com</pre>
<h3>Upload your certs</h3>
<p>This assumes that your Amazon certs are in ~/.ec2</p>
<pre>rsync                            \
 --rsh="ssh -i $fullpath_keypair" \
 --rsync-path="sudo rsync"      \
 ~/.ec2/{cert,pk}-*.pem         \
 ubuntu@$host:/mnt/</pre>
<h3>Connect to the instance</h3>
<pre>ssh -i $fullpath_keypair ubuntu@$host</pre>
<h3>Update the Amazon ec2 tools on the instance</h3>
<pre>export DEBIAN_FRONTEND=noninteractive
echo "deb http://ppa.launchpad.net/ubuntu-on-ec2/ec2-tools/ubuntu karmic main" |
  sudo tee /etc/apt/sources.list.d/ubuntu-on-ec2-ec2-tools.list &amp;&amp;
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 9EE6D873 &amp;&amp;
sudo apt-get update &amp;&amp;
sudo -E apt-get dist-upgrade -y &amp;&amp;
sudo -E apt-get install -y ec2-api-tools</pre>
<h3>Set some parameters on instance shell environment</h3>
<p>Again this makes it easier to cut and paste the instructions.</p>
<pre>codename=karmic
release=9.10
tag=server
region=us-west-1
availability_zone=us-west-1a
if [ $(uname -m) = 'x86_64' ]; then
  arch=x86_64
  arch2=amd64
  # You will need to set the aki and ari values base on the actual base AMI you used
  # It will be different for different regions.  These are set for us-west-1
  ebsopts="--kernel=aki-7f3c6d3a --ramdisk=ari-cf2e7f8a"
  ebsopts="$ebsopts --block-device-mapping /dev/sdb=ephemeral0"
else
  arch=i386
  arch2=i386
  # You will need to set the aki and ari values base on the actual base AMI you used
  # It will be different for different regions. These are set for us-west-1
  ebsopts="--kernel=aki-773c6d32 --ramdisk=ari-c12e7f84"
  ebsopts="$ebsopts --block-device-mapping /dev/sda2=ephemeral0"
fi</pre>
<h3>Download and unpack the latest released Ubuntu server image file</h3>
<p>This contains the output of vmbuilder as run by Canonical.</p>
<pre>imagesource=http://uec-images.ubuntu.com/releases/$codename/release/unpacked/ubuntu-$release-$tag-uec-$arch2.img.tar.gz
image=/mnt/$codename-$tag-uec-$arch2.img
imagedir=/mnt/$codename-$tag-uec-$arch2
wget -O- $imagesource |
  sudo tar xzf - -C /mnt
sudo mkdir -p $imagedir
sudo mount -o loop $image $imagedir</pre>
<h3>Bring the packages on the instance up to date</h3>
<pre># Allow network access from chroot environment
sudo cp /etc/resolv.conf $imagedir/etc/

# Fix what I consider to be a bug in vmbuilder
sudo rm -f $imagedir/etc/hostname

# Add multiverse
sudo perl -pi -e 's%(universe)$%$1 multiverse%' \
$imagedir/etc/ec2-init/templates/sources.list.tmpl

# Add Alestic PPA for runurl package (handy in user-data scripts)
echo "deb http://ppa.launchpad.net/alestic/ppa/ubuntu karmic main" |
sudo tee $imagedir/etc/apt/sources.list.d/alestic-ppa.list
sudo chroot $imagedir \
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys BE09C571

# Add ubuntu-on-ec2/ec2-tools PPA for updated ec2-ami-tools
echo "deb http://ppa.launchpad.net/ubuntu-on-ec2/ec2-tools/ubuntu karmic main" |
sudo tee $imagedir/etc/apt/sources.list.d/ubuntu-on-ec2-ec2-tools.list
sudo chroot $imagedir \
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 9EE6D873

# Upgrade the system and install packages
sudo chroot $imagedir mount -t proc none /proc
sudo chroot $imagedir mount -t devpts none /dev/pts

cat &lt;&lt;EOF &gt; /tmp/policy-rc.d
#!/bin/sh
exit 101
EOF
sudo mv /tmp/policy-rc.d $imagedir/usr/sbin/policy-rc.d

chmod 755 $imagedir/usr/sbin/policy-rc.d
DEBIAN_FRONTEND=noninteractive

# It seems this has to be done to set up the Locale &amp; apt sources
sudo -E chroot $imagedir /usr/bin/ec2-set-defaults

# Update the apt sources and packages
sudo chroot $imagedir apt-get update &amp;&amp;
sudo -E chroot $imagedir apt-get dist-upgrade -y &amp;&amp;
sudo -E chroot $imagedir apt-get install -y runurl ec2-ami-tools</pre>
<h2>Install Chef Client and other customizations</h2>
<h3>Install Ruby and needed packages</h3>
<pre><code>sudo -E chroot $imagedir apt-get -y install ruby ruby1.8-dev libopenssl-ruby1.8 rdoc ri irb \
build-essential wget ssl-cert git-core rake librspec-ruby libxml-ruby \
thin couchdb zlib1g-dev libxml2-dev emacs23-nox</code></pre>
<h4>Install Rubygems</h4>
<p>Rubygems will be installed from source since debian/ubuntu try to control rubygems upgrades. If you don&#8217;t care you can install it via apt-get install rubygems</p>
<pre><code>cd $imagedir/tmp
wget http://rubyforge.org/frs/download.php/69365/rubygems-1.3.6.tgz
tar zxf rubygems-1.3.6.tgz
cd rubygems-1.3.6
sudo -E chroot $imagedir ruby /tmp/rubygems-1.3.6/setup.rb
cd ..
sudo rm -rf rubygems-1.3.6
sudo -E chroot $imagedir ln -sfv /usr/bin/gem1.8 /usr/bin/gem
sudo -E chroot $imagedir gem sources -a http://gems.opscode.com
sudo -E chroot $imagedir gem sources -a http://gemcutter.org
sudo -E chroot $imagedir gem install chef
</code></pre>
<h3>Use Opscode Chef Solo Bootstrap to configure the Chef Client</h3>
<p>The following will set up all the default paths and directories as well as install and configure runit to start and monitor the chef-client. Originally I shied away from runit, but this time I&#8217;m going as Opscode Vanilla as possible and they like runit.</p>
<h4>Create the solo.rb file</h4>
<p>All of the following files should be done in $imagedir as we are going to have to run this as chroot to $imagedir</p>
<p>Create $imagedir/solo.rb with an editor and put in the following:</p>
<pre>file_cache_path "/tmp/chef-solo"
cookbook_path "/tmp/chef-solo/cookbooks"
recipe_url "http://s3.amazonaws.com/chef-solo/bootstrap-latest.tar.gz"</pre>
<h4>Create the chef.json file</h4>
<p>Create $imagedir/chef.json with the following. (set the server_fqdn to the chef server you are using):</p>
<pre>{
  "bootstrap": {
    "chef": {
      "url_type": "http",
      "init_style": "runit",
      "path": "/srv/chef",
      "serve_path": "/srv/chef",
      "server_fqdn": "chef-server-staging.runa.com"
    }
  },
  "run_list": [ "recipe[bootstrap::client]" ]
}</pre>
<h4>Run the chef-solo command</h4>
<pre>sudo -E chroot $imagedir chef-solo -c solo.rb -j chef.json \
  -r http://s3.amazonaws.com/chef-solo/bootstrap-latest.tar.gz</pre>
<p>I had to run it 3 times before it completed with no errors.<br />
After it does work, clean up the chef-solo stuff:</p>
<pre>sudo rm $imagedir/{solo.rb,chef.json}</pre>
<h3>Update the client config file</h3>
<p>The Chef Solo Client bootstrap process creates an /etc/chef/client.rb that is not ideal for Amazon EC2. The following will replace that:</p>
<pre><code>mkdir -p /etc/chef
chown root:root /etc/chef
chmod 755 /etc/chef
</code></pre>
<p>Put the following in /etc/chef/client.rb:</p>
<pre><code>
# Chef Client Config File
# Automatically grabs configuration from ohai ec2 metadata.

require 'ohai'
require 'json'

o = Ohai::System.new
o.all_plugins
chef_config = JSON.parse(o[:ec2][:userdata])
if chef_config.kind_of?(Array)
  chef_config = chef_config[o[:ec2][:ami_launch_index]]
end

log_level        :info
log_location     STDOUT
node_name        o[:ec2][:instance_id]
chef_server_url  chef_config["chef_server"]

unless File.exists?("/etc/chef/client.pem")
  File.open("/etc/chef/validation.pem", "w", 0600) do |f|
    f.print(chef_config["validation_key"])
  end
end

if chef_config.has_key?("attributes")
  File.open("/etc/chef/client-config.json", "w") do |f|
    f.print(JSON.pretty_generate(chef_config["attributes"]))
  end
  json_attribs "/etc/chef/client-config.json"
end

validation_key "/etc/chef/validation.pem"
validation_client_name chef_config["validation_client_name"]

Mixlib::Log::Formatter.show_time = true
</code></pre>
<h2>Finish creating the new image</h2>
<h3>Clean up from the building of the image</h3>
<pre>sudo chroot $imagedir umount /proc
sudo chroot $imagedir umount /dev/pts
sudo rm -f $imagedir/usr/sbin/policy-rc.d</pre>
<h3>Copy the image files to a new EBS volume, snapshot and register the snapshot</h3>
<pre>size=15 # root disk in GB
now=$(date +%Y%m%d-%H%M)
prefix=runa-chef-0.8.4-ubuntu-$release-$codename-$tag-$arch-$now
description="Runa Chef 0.8.4 Ubuntu $release $codename $tag $arch $now"
export EC2_CERT=$(echo /mnt/cert-*.pem)
export EC2_PRIVATE_KEY=$(echo /mnt/pk-*.pem)

volumeid=$(ec2-create-volume --region $region --size $size \
  --availability-zone $availability_zone | cut -f2)

instanceid=$(wget -qO- http://instance-data/latest/meta-data/instance-id)

ec2-attach-volume --region $region --device /dev/sdi --instance "$instanceid" "$volumeid"

while [ ! -e /dev/sdi ]; do echo -n .; sleep 1; done

sudo mkfs.ext3 -F /dev/sdi
ebsimage=$imagedir-ebs
sudo mkdir $ebsimage
sudo mount /dev/sdi $ebsimage

sudo tar -cSf - -C $imagedir . | sudo tar xvf - -C $ebsimage
sudo umount $ebsimage

ec2-detach-volume --region $region "$volumeid"
snapshotid=$(ec2-create-snapshot --region $region "$volumeid" | cut -f2)

ec2-delete-volume --region $region "$volumeid"

# This takes a while
while ec2-describe-snapshots --region $region "$snapshotid" | grep -q pending
  do echo -n .; sleep 1; done

ec2-register \
  --region $region \
  --architecture $arch \
  --name "$prefix" \
  --description "$description" \
  $ebsopts \
  --snapshot "$snapshotid"</pre>
<h2>Afterward</h2>
<p>That will get you an AMI that you can now use as a chef-client. You can use the directions from the section <em>Creating a Chef Server from your new Image</em> in the previous article: <a href="http://blog2.ibd.com/scalable-deployment/creating-an-amazon-ami-for-chef-0-8/" target="_blank">Creating an Amazon EC2 AMI for Opscode Chef 0.8</a>.</p><p>The post <a href="https://www.ibd.com/howto/using-the-official-opscode-0-8-x-gems-to-build-ec2-ami-chef-client-and-server/">Using the Official Opscode 0.8.x Gems to build EC2 AMI Chef Client and Server</a> first appeared on <a href="https://www.ibd.com">Cognizant Transmutation</a>.</p>]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">513</post-id>	</item>
		<item>
		<title>Installing Ruby Mysql Gem on Snow Leopard Server</title>
		<link>https://www.ibd.com/macintosh/installing-ruby-mysql-gem-on-snow-leopard-server/</link>
		
		<dc:creator><![CDATA[Robert J Berger]]></dc:creator>
		<pubDate>Fri, 02 Oct 2009 23:30:47 +0000</pubDate>
				<category><![CDATA[Macintosh]]></category>
		<category><![CDATA[Ruby / Rails]]></category>
		<category><![CDATA[Scalable Deployment]]></category>
		<category><![CDATA[Sysadmin]]></category>
		<guid isPermaLink="false">http://blog2.ibd.com/?p=304</guid>

					<description><![CDATA[<p>Snow Leopard  Server (and at least Leopard Server) both have MySQL installed already. But its not a complete enough install to build the Ruby Mysql Gem. It seems that the Snow Leopard Server Mysql does not include all the client stuff that is needed by the mysql gem. The Apple Support article: Mac OS X Server 10.5.6 or later: MySQL libraries&#8230;</p>
<p>The post <a href="https://www.ibd.com/macintosh/installing-ruby-mysql-gem-on-snow-leopard-server/">Installing Ruby Mysql Gem on Snow Leopard Server</a> first appeared on <a href="https://www.ibd.com">Cognizant Transmutation</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Snow Leopard  <span style="text-decoration: underline;"><em>Server</em></span> (and at least Leopard <span style="text-decoration: underline;"><em>Server</em></span>) both have MySQL installed already. But its not a complete enough install to build the Ruby Mysql Gem. It seems that the Snow Leopard Server Mysql does not include all the client stuff that is needed by the mysql gem.</p>
<p>The Apple Support article: <a href="http://support.apple.com/kb/HT3370" target="_blank">Mac OS X Server 10.5.6 or later: MySQL libraries available for download</a> is the main tip, but you&#8217;ll need to get the actual latest version, not necessarily the version specified in the article. I downloaded <a href="http://www.opensource.apple.com/other/MySQL-49.binaries.tar.gz">MySQL-49 Binary</a> which is actually mysql  Ver 14.12 Distrib 5.0.82, for apple-darwin10.0.</p>
<p>This is a bit scary as the installation process is to untar the binary right on top of the actual /usr filesystem. I don&#8217;t know for sure if its totally right&#8230; and 64 bit and there&#8217;s no going back.</p>
<p>The prcoess is after you download the binary run the following command as root/sudo (and remember the -C / says to untar it starting at the root of the filesystem, so its going to overwrite things in /usr):</p>
<p>tar -xzvf MySQL-49.binaries.tar.gz -C /</p><p>The post <a href="https://www.ibd.com/macintosh/installing-ruby-mysql-gem-on-snow-leopard-server/">Installing Ruby Mysql Gem on Snow Leopard Server</a> first appeared on <a href="https://www.ibd.com">Cognizant Transmutation</a>.</p>]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">304</post-id>	</item>
		<item>
		<title>Want to work at a Startup with Cool Tech? (HBase, Clojure, Chef, Swarms, Javascript, Ruby &#038; Rails)</title>
		<link>https://www.ibd.com/macintosh/want-to-work-at-a-startup-with-cool-tech-hbase-clojure-chef-swarms-javascript-ruby-rails/</link>
		
		<dc:creator><![CDATA[Robert J Berger]]></dc:creator>
		<pubDate>Fri, 28 Aug 2009 18:15:01 +0000</pubDate>
				<category><![CDATA[Macintosh]]></category>
		<category><![CDATA[Opscode Chef]]></category>
		<category><![CDATA[Ruby / Rails]]></category>
		<category><![CDATA[Runa]]></category>
		<category><![CDATA[Scalable Deployment]]></category>
		<category><![CDATA[AWS]]></category>
		<category><![CDATA[Git]]></category>
		<category><![CDATA[Hadoop]]></category>
		<category><![CDATA[HBase]]></category>
		<category><![CDATA[rabbitmq]]></category>
		<category><![CDATA[tweekts]]></category>
		<category><![CDATA[ubuntu]]></category>
		<guid isPermaLink="false">http://blog2.ibd.com/?p=253</guid>

					<description><![CDATA[<p>Opportunity Knocks Runa.com, the startup where I am CTO, is looking for great developers to join our small agile team. We&#8217;re an early stage, pre-series-A startup (presently funded with strategic investments from two large corporations). Runa offers a SaaS to on-line merchant that allows them to offer dynamic product and consumer specific promotions embeded in their website. This will be&#8230;</p>
<p>The post <a href="https://www.ibd.com/macintosh/want-to-work-at-a-startup-with-cool-tech-hbase-clojure-chef-swarms-javascript-ruby-rails/">Want to work at a Startup with Cool Tech? (HBase, Clojure, Chef, Swarms, Javascript, Ruby & Rails)</a> first appeared on <a href="https://www.ibd.com">Cognizant Transmutation</a>.</p>]]></description>
										<content:encoded><![CDATA[<h1 style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana;"><strong>Opportunity Knocks</strong></h1>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana;">Runa.com, the startup where I am CTO, is looking for great developers to join our small agile team. We&#8217;re an early stage, pre-series-A startup (presently funded with strategic investments from two large corporations). Runa offers a SaaS to on-line merchant that allows them to offer dynamic product and consumer specific promotions embeded in their website. This will be a very large positive disruption to the online retailing world.</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana; min-height: 15.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana;"><span style="text-decoration: underline;">Techie keywords:</span> <strong>clojure, hadoop, hbase, rabbitmq, erlang, chef, swarm computing, ruby, rails, javascript, amazon EC2, emacs, Macintosh, Linux, selenium, test/behavior driven development, agile, lean, XP, scalability</strong></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana;">If you&#8217;re interested, email  <a href="mailto:jobs@runa.com">jobs@runa.com</a></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana; min-height: 15.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana;">If you want to know more, read on!</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana; min-height: 15.0px;">
<h1 style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana;"><strong>What do we do</strong></h1>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana; min-height: 15.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana;">Runa aims to provide the top of the long tail thru the middle of the top 500 online retailers with tools/services that companies like amazon.com use/provide. These smaller guys can&#8217;t afford or don&#8217;t have the resources to do anything on that scale, but by using our SaaS services, they can make more money while providing customers with greater value.</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana; min-height: 15.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana;">The first service we&#8217;re building is what we call Dynamic Sale Price.</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana; min-height: 15.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana;">It&#8217;s a simple concept &#8211; it allows the online-retailer to offer a sale price for each product on his site, personalized to the individual consumer who is browsing it. By using this service, merchants are able to &#8211;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana; min-height: 15.0px;">
<ul>
<li>Increase conversion (get them to buy!) and</li>
<li>Offer consumers a special price which maximizes the merchant&#8217;s profit</li>
</ul>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana; min-height: 15.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana;">This is different from &#8220;dumb-discounting&#8221; where something is marked-down, and everyone sees the same price. This service is more like airline or hotel pricing which varies from day to day, but much more dynamic and real-time. Further, it is based on broad statistical factors AND individual consumer behavior. After all, if you lower prices enough, consumers will buy. Instead, we dynamically lower prices to a point where statistically, that consumer is most likely to buy.</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana; min-height: 15.0px;">
<h1 style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana;"><strong>How we do it</strong></h1>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana; min-height: 15.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana;">Runa does this by performing statistical analysis and pattern recognition of what consumers are doing on the merchant sites. This includes browsing products on various pages, adding and removing items from carts, and purchasing or abandoning the carts. We track consumers as they browse, and collect vast quantities of this click-stream data. By mining this data and applying algorithms to determine a price point per consumer based on their behavior, we&#8217;re able to  maximize both conversion (getting the consumer to buy) AND merchant profit.</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana; min-height: 15.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana;">We also offer the merchant comprehensive reports based on analysis of the mountains of data we collect. Since the data tracks consumer activity down to the individual product SKU level (for each individual consumer), we can provide very rich analytics.  This is a tool that merchants need today, but don&#8217;t have the resources to build for themselves.</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana; min-height: 15.0px;">
<h1 style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana;"><strong>The business model</strong></h1>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana; min-height: 15.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana;">For reference, it is useful to understand the affiliate marketing space. Small-to-medium merchants (our target audience) pay affiliates up to 40% of a sale price. Yes, 40%. The average is in the 20% range.</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana; min-height: 15.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana;">We charge our merchants around 10% of sales the Runa delivers. Our merchants are happy to pay it, because it is a performance-based pay, lower than what they pay affiliates, and there is zero up-front cost to the service. In fact, the above mentioned analytics reports are free.</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana; min-height: 15.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana;">We&#8217;re targeting e-commerce PLATFORMS (as opposed to individual merchants); in this way, we&#8217;re able to scale up merchant-acquisition. We have 10 early-customer merchants right now, with about 100 more planned to go live in the next 2-3 months. By the end of next year, we&#8217;re targeting about 1,000 merchants and 10,000 merchants the following year. Our channel deployment model makes these goals achievable.</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana; min-height: 15.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana;">At something like a 5 to 10% service charge, and a typical merchant having between 500K to 1M in sales per year, this is a VERY profitable business model. That is, of course, if we&#8217;re successful&#8230; but we&#8217;re seeing very positive signs so far.</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana; min-height: 15.0px;">
<h1 style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana;"><strong>Technology</strong></h1>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana; min-height: 15.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana;">Most of our front-end stuff (like the merchant-dashboard, reports, campaign management) is built with Ruby on Rails. Our merchant integration requires browser-side Javascript magic. All our analytics (batch-processing) and real-time pricing services are written in Clojure. We use RabbitMQ for all our messaging needs. We store data in HBase. We&#8217;re deployed on Amazon&#8217;s EC2.</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana; min-height: 15.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana;">Here are a few blog postings about what we&#8217;ve been up to &#8211;</p>
<p><a href="http://s-expressions.com/2009/05/02/startup-logbook-distributed-clojure-system-in-production-v02/" target="_blank">Distributed Clojure system in production</a><br />
<a href="http://s-expressions.com/2009/04/12/using-messaging-for-scalability/" target="_blank">Using messaging for scalability</a><br />
<a href="http://s-expressions.com/2009/03/31/capjure-a-simple-hbase-persistence-layer/" target="_blank">Capjure: a simple HBase persistence layer</a><br />
<a href="http://s-expressions.com/2009/01/28/startup-logbook-clojure-in-production-release-v01/" target="_blank">Clojure in production<br />
</a><span style="color: #0000ee; "><span style="text-decoration: underline;"><a href="http://blog2.ibd.com/scalable-deployment/experience-installing-hbase-0-20-0-cluster-on-ubuntu-9-04-and-ec2/" target="_blank">Experience installing Hbase 0.20.0 Cluster on Ubuntu 9.04 and EC2</a></span></span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana;">We&#8217;ve also open-sourced a few of our projects &#8211;</p>
<p><a href="http://github.com/amitrathore/swarmiji/tree/master" target="_blank">swarmiji</a> &#8211; A distributed computing system to write and run Clojure code in parallel, across CPUs<br />
<a href="http://github.com/amitrathore/capjure/tree/master" target="_blank">capjure</a> &#8211; Clojure persistence for HBase</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana; min-height: 15.0px;">
<h1 style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana;"><strong>Culture at Runa</strong></h1>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana; min-height: 15.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana;">We&#8217;re a small team, very passionate about what we do. We&#8217;re focused on delivering a ground-breaking, disruptive service that will allow merchants to really change the way they sell online. We work start-up hours, but we&#8217;re flexible and laid-back about it. We know that a healthy personal life is important for a good professional life. We work with each other to support it.</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana; min-height: 15.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana;">We use an agile process with a lot of influences from the &#8220;Lean&#8221;:http://en.wikipedia.org/wiki/Lean_software_development and &#8220;Kanban&#8221;:http://leansoftwareengineering.com/2007/08/29/kanban-systems-for-software-development/ world. We use &#8220;Mingle&#8221;:http://studios.thoughtworks.com/mingle-agile-project-management to run our development process. Everything, OK mostly everything <img src="https://s.w.org/images/core/emoji/14.0.0/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /> is covered by automated tests, so we can change things as needed.</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana; min-height: 15.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana;">We&#8217;re all Apple in the office &#8211; developers get a MacPro with a nice 30&#8243; screen, and a nice 17&#8243; MacBook Pro.  We deploy on Ubuntu servers.  Aeron chairs are cliché, yes; but, very comfy.</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana; min-height: 15.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana;">The environment is chilled out&#8230; you can wear shorts and sandals to work&#8230;  Very flat organization, very non-bureaucratic&#8230; nice open spaces (no cubes!). Lunch is brought in on most days! Beer and snacks are always in the fridge.</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana; min-height: 15.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana;">We&#8217;re walking distance to the San Antonio Caltrain station (biking distance from the Mountain View Caltrain/VTA lightrail station).</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana; min-height: 15.0px;">
<h1 style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana;"><strong>What&#8217;s in it for you</strong></h1>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana; min-height: 15.0px;">
<ul>
<li>Competitive salaries, and lots of stock-options</li>
<li>Cutting edge technology stack</li>
<li>Fantastic business opportunity, and early-stage (= great time to join!)</li>
<li>Developer #5 &#8211; means plenty of influence on foundational architecture and design</li>
<li>Smart, full bandwidth, fun people to work with</li>
<li>Very comfortable, nice office environment</li>
<li>We have a &#8220;No Assholes&#8221; policy</li>
</ul>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana; min-height: 15.0px;">
<h1 style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana;"><strong>OK!</strong></h1>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana; min-height: 15.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana;">So, if you&#8217;re interested, email us at <a href="mailto:jobs@runa.com">jobs@runa.com</a></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana;">No recruiters please!</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Verdana;">We would prefer folks who are already in the Bay Area (but if you not local and are really great let&#8217;s talk!)</p>
<div><span style="font-family: verdana, arial, helvetica, clean, sans-serif; font-size: small;"><span style="line-height: 14px; white-space: pre-wrap; "><br />
</span></span></div><p>The post <a href="https://www.ibd.com/macintosh/want-to-work-at-a-startup-with-cool-tech-hbase-clojure-chef-swarms-javascript-ruby-rails/">Want to work at a Startup with Cool Tech? (HBase, Clojure, Chef, Swarms, Javascript, Ruby & Rails)</a> first appeared on <a href="https://www.ibd.com">Cognizant Transmutation</a>.</p>]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">253</post-id>	</item>
		<item>
		<title>Cross Domain RESTful AJAX with jQuery and Rails 2.2.2</title>
		<link>https://www.ibd.com/howto/cross-domain-restful-ajax-with-jquery-and-rails-222/</link>
					<comments>https://www.ibd.com/howto/cross-domain-restful-ajax-with-jquery-and-rails-222/#comments</comments>
		
		<dc:creator><![CDATA[Robert J Berger]]></dc:creator>
		<pubDate>Fri, 16 Jan 2009 07:32:10 +0000</pubDate>
				<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Ruby / Rails]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[monkey patch]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[ubuntu]]></category>
		<guid isPermaLink="false">http://blog2.ibd.com/?p=156</guid>

					<description><![CDATA[<p>Flinn Mueller aka actsasflinn wrote an blog post Cross domain RESTful JSON-P with Rails back in July. There he showed how to monkeypatch Rails to allow json-p to do all the REST verbs even when going across domains. He also showed how to make the json-p calls with jquery. A very nice solution that we take advantage of in one&#8230;</p>
<p>The post <a href="https://www.ibd.com/howto/cross-domain-restful-ajax-with-jquery-and-rails-222/">Cross Domain RESTful AJAX with jQuery and Rails 2.2.2</a> first appeared on <a href="https://www.ibd.com">Cognizant Transmutation</a>.</p>]]></description>
										<content:encoded><![CDATA[<p><a href="http://www.actsasflinn.com" target="_blank">Flinn Mueller aka actsasflinn</a> wrote an blog post <a href="http://www.actsasflinn.com/2008/06/13/cross-domain-restful-json-p-with-rails" target="_blank">Cross domain RESTful JSON-P with Rails</a> back in July. There he showed how to monkeypatch Rails to allow json-p to do all the REST verbs even when going across domains. He also showed how to make the json-p calls with jquery. A very nice solution that we take advantage of in one of our apps. The only problem we had was that it stopped working when we upgraded to Rails 2.2.2.</p>
<p>There are other issues using this technique. To quote Flinn:</p>
<blockquote><p>Achtung! Monkey patching with the above will expose your create method without using an actual post. Imho no big deal, others might be more cautious (<a href="http://actsasflinn.com/articles/2008/04/27/captcha-sucks">CAPTCHA</a>is always an option), ymmv.</p></blockquote>
<p>See his original article for details on how to use it generally. </p>
<p>The problem with the monkeypatch that he wrote up is that Rails 2.2.2 changed the function that was monkeypatched so the patch stopped working. Below is code that will work on both pre and post 2.2.2 Rails:</p>
<pre>
<pre>
<span>module</span> ActionController
<span>  class</span> AbstractRequest

<span>    </span><span>def</span> request_method

<span>      if</span> Rails::VERSION::STRING &lt;<span> "2.2.2"</span>

<span>        <span>@request_method</span><span> ||=</span><span> begin</span></span>

<span>          method = (parameters[<span>:_method</span>].blank? ?<span> </span><span>@env</span>[<span>'REQUEST_METHOD'</span>] : parameters[<span>:_method</span>].to_s).<span>downcase</span></span>

<span><span>          if</span> ACCEPTED_HTTP_METHODS.include?(method)</span>

            method.to_sym

          else

            raise UnknownHttpMethod,<span> "#{</span>method<span>}, accepted HTTP methods are #{</span>ACCEPTED_HTTP_METHODS.to_a.to_sentence<span>}"</span>

<span>          end</span>

        end

      else

        method =<span> </span><span>@env</span>[<span>'REQUEST_METHOD'</span>]

        method = parameters[<span>:_method</span>]<span> unless</span> parameters[<span>:_method</span>].blank?

        HTTP_METHOD_LOOKUP[method] || raise(UnknownHttpMethod,<span> "#{</span>method<span>}, accepted HTTP methods are #{</span>HTTP_METHODS.to_sentence<span>}"</span>)
      end

    end

  end
end</pre><p>The post <a href="https://www.ibd.com/howto/cross-domain-restful-ajax-with-jquery-and-rails-222/">Cross Domain RESTful AJAX with jQuery and Rails 2.2.2</a> first appeared on <a href="https://www.ibd.com">Cognizant Transmutation</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://www.ibd.com/howto/cross-domain-restful-ajax-with-jquery-and-rails-222/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">156</post-id>	</item>
		<item>
		<title>QuarkRuby: Consume non rails-style REST APIs</title>
		<link>https://www.ibd.com/ruby-rails/quarkruby-consume-non-rails-style-rest-apis/</link>
		
		<dc:creator><![CDATA[Robert J Berger]]></dc:creator>
		<pubDate>Wed, 31 Dec 2008 01:09:41 +0000</pubDate>
				<category><![CDATA[Ruby / Rails]]></category>
		<category><![CDATA[APIs]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[Ruby]]></category>
		<guid isPermaLink="false">http://blog2.ibd.com/?p=87</guid>

					<description><![CDATA[<p>It seems that most &#8220;RESTful&#8221; APIs in the wild are well, pretty wild. They don&#8217;t meet the strict requirements of the pure CRUD/REST of ActiveResource. The article in QuarkRuby:  Consume non rails-style REST APIs shows how to create a nice ruby wrapper around ActiveResource so you can adapt to any arbitrary REST / http interface on the Internet.</p>
<p>The post <a href="https://www.ibd.com/ruby-rails/quarkruby-consume-non-rails-style-rest-apis/">QuarkRuby: Consume non rails-style REST APIs</a> first appeared on <a href="https://www.ibd.com">Cognizant Transmutation</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>It seems that most &#8220;RESTful&#8221; APIs in the wild are well, pretty wild. They don&#8217;t meet the strict requirements of the pure CRUD/REST of ActiveResource.</p>
<p>The article in <a href="http://www.quarkruby.com">QuarkRuby</a>:  <a href="http://www.quarkruby.com/2008/3/11/consume-non-rails-style-rest-apis">Consume non rails-style REST APIs</a> shows how to create a nice ruby wrapper around ActiveResource so you can adapt to any arbitrary REST / http interface on the Internet.</p><p>The post <a href="https://www.ibd.com/ruby-rails/quarkruby-consume-non-rails-style-rest-apis/">QuarkRuby: Consume non rails-style REST APIs</a> first appeared on <a href="https://www.ibd.com">Cognizant Transmutation</a>.</p>]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">87</post-id>	</item>
		<item>
		<title>Installing a git client on a shared host with no compiler</title>
		<link>https://www.ibd.com/how-the-world-works/installing-a-git-client-on-a-shared-host-with-no-compiler/</link>
					<comments>https://www.ibd.com/how-the-world-works/installing-a-git-client-on-a-shared-host-with-no-compiler/#comments</comments>
		
		<dc:creator><![CDATA[Robert J Berger]]></dc:creator>
		<pubDate>Sat, 29 Nov 2008 05:51:22 +0000</pubDate>
				<category><![CDATA[How the World Works]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Macintosh]]></category>
		<category><![CDATA[Ruby / Rails]]></category>
		<category><![CDATA[Scalable Deployment]]></category>
		<category><![CDATA[Sysadmin]]></category>
		<category><![CDATA[EC2]]></category>
		<category><![CDATA[Git]]></category>
		<guid isPermaLink="false">http://blog2.ibd.com/?p=50</guid>

					<description><![CDATA[<p>We are using Git to manage our deployments, but have some clients that use shared hosting services that don&#8217;t have git installed (in particular Hostgator.com). Most of these shared hosting services do allow ssh shell access but don&#8217;t have compilers available on the shared hosting account. So I couldn&#8217;t just build git on the shared hosting account. Many hosting services&#8230;</p>
<p>The post <a href="https://www.ibd.com/how-the-world-works/installing-a-git-client-on-a-shared-host-with-no-compiler/">Installing a git client on a shared host with no compiler</a> first appeared on <a href="https://www.ibd.com">Cognizant Transmutation</a>.</p>]]></description>
										<content:encoded><![CDATA[<p><a href="http://git.or.cz/"><img decoding="async" loading="lazy" class="alignleft size-full wp-image-47" src="https://i0.wp.com/www.ibd.com/wp-content/uploads/2008/11/e0648a1a-c59e-4e4d-8bcd-36aae2058f07.jpg?resize=97%2C188" alt="Git Logo" width="97" height="188" data-recalc-dims="1" /><br />
</a>We are using <a href="http://git.or.cz/"> Git</a> to manage our deployments, but have some clients that use shared hosting services that don&#8217;t have git installed (in particular <a href="http://hostgator.com">Hostgator.com</a>).<br />
<a href="http://www.hostgator.com/"><img decoding="async" loading="lazy" src="https://i0.wp.com/blog2.ibd.com/wp-content/uploads/2008/11/eb811b4e-4f15-4076-a664-9af913505b8e.jpg?resize=100%2C85" alt="Hostgator Logo" width="100" height="85" align="right" border="0" data-recalc-dims="1" /></a><br />
Most of these shared hosting services do allow ssh shell access but don&#8217;t have compilers available on the shared hosting account. So I couldn&#8217;t just build git on the shared hosting account.</p>
<p>Many hosting services do offer webdav access to the account&#8217;s filesystem. I tried <a href="http://www.kernel.org/pub/software/scm/git/docs/howto/setup-git-server-over-http.txt">pushing git trees to the target filesystem over https/webdev</a>, but couldn&#8217;t get it to work even if I first copied a bare git directory to the target.</p>
<p>This left me with the thought that maybe I could build git on another host that I controled that had the same type of Linux environment that was running the target shared host environment. Once I built it in the environment I controled, I could then copy it to the shared hosting account and use it via ssh shell access.</p>
<p><a href="http://www.centos.org/"><img decoding="async" loading="lazy" src="https://i0.wp.com/blog2.ibd.com/wp-content/uploads/2008/11/572ee076-af40-4225-a4d7-0366c3220d4e.jpg?resize=63%2C60" alt="CentOS Logo" width="63" height="60" align="right" border="0" data-recalc-dims="1" /></a><br />
In the particular case of Hostgator, they were running <a href="http://www.centos.org/">CentOS 5.2</a>.Thus I needed a CentOS 5.2 machine to build Git on. I didn&#8217;t have one lying around, but I do have an Amazon EC2 account!<br />
(You should be able to modify this to work with other Linux versions pretty easily.)</p>
<h2>Create a CentOS 5.2 instance on Amazon EC2</h2>
<p>Used the Amazon Machine Image ami-0459bc6d described in <a href="http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1536">CentOS 5 i386 Base AMI posting</a> which includes instructions on how to instantiate and update to CentOS 5.2.<img decoding="async" loading="lazy" class="alignleft size-full wp-image-49" src="https://i0.wp.com/www.ibd.com/wp-content/uploads/2008/11/5c0fe721-5842-4f70-ad2a-5a4421eb5b38.jpg?resize=164%2C60" alt="Amazon Web Services Logo" width="164" height="60" data-recalc-dims="1" /></p>
<p>I used the fabulous <a href="http://developer.amazonwebservices.com/connect/entry.jspa?externalID=609&amp;categoryID=88"> ElasticFox</a> extension to Firefox to instantiate and run the base image.</p>
<p>Documentation on using ElasticFox can be found at <a href="http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1797">Elasticfox Getting Started Guide</a>. Documentation on using Amazon EC2 can be found at <a href="http://docs.amazonwebservices.com/AWSEC2/2008-05-05/GettingStartedGuide/">Amazon EC2 Getting Started Guide</a>.</p>
<p>I won&#8217;t repeat those instructions here, you&#8217;ll have to get the Amazon EC2 basics from those docs.</p>
<p>One you have the base ami-0459bc6d instance running, there are a few things you must do to to the stock CentOS 5.1 image to get it ready to build git:</p>
<h3>Update the CentOS image from 5.1 to 5.2</h3>
<pre><code>yum -y upgrade
reboot</code></pre>
<h3>Install gcc</h3>
<p><code>yum install gcc</code></p>
<h3>Install zlib-devel package</h3>
<p>Noticed that zlib-devel was needed by the git install process when I first tried to run configure on the git distribution.</p>
<p><code>yum install zlib-devel</code></p>
<h3>Install curl-devel</h3>
<p>Needed if you want to use http/https/webdav access to git repositories.</p>
<p><code>yum install curl-devel</code></p>
<h2>Build Git from Source</h2>
<p>Once you have got your CentOS 5.2 system running, you can build git from the source tree.</p>
<h3>Download git</h3>
<p><code>wget http://kernel.org/pub/software/scm/git/git-1.6.0.4.tar.gz</code></p>
<h3>Unpack the Git source tree</h3>
<p><code>tar xvzf git-1.6.0.4.tar.gz</code></p>
<h3>Create a build target path</h3>
<p>You will need to have a build target directory path on your build machine that is the same as the path to your home directory on your target virtual host account. In this example we&#8217;re calling it<br />
<code>/home/clientname</code>.</p>
<p>Replace clientname with the name of your home directory on hostgatore which is usually the same as your domainname.</p>
<p>This is where the build/install process will end up &#8220;installing&#8221; the compiled and other run time files:</p>
<p><code>mkdir /home/clientname</code></p>
<h3>Run Configure on source tree</h3>
<p>Change directory on the build machine to the top of the git source tree. (Where you unpacked the tar file <code>git-1.6.0.4.tar.gz</code> it does not have to be in /home/clientname)</p>
<p><code>cd git-1.6.0.4</code></p>
<p>Configure and set the prefix to the home directory that is your home directory on the target virtual host.</p>
<p><code>./configure --prefix=/home/clientname/git_root</code></p>
<p>Build the code and have it be installed in the directory that you defined in the &#8211;prefix line above<br />
<code>make<br />
make install</code><br />
Assuming all goes well, it will build the code in the directory</p>
<p>git-1.6.0.4</p>
<p>and install everything in the directory</p>
<pre><code>/home/clientname/git_root</code></pre>
<p>It will automatically create the git_root directory but you have to have created /home/clientname</p>
<h2>Tar it up and scp it to target</h2>
<pre><code>cd /home/clientname
tar cvzf git_root.tgz git_root
scp git_root.tgz userid@clienturl:
</code></pre>
<h2>Unpack it on target</h2>
<pre><code>ssh userid@clienturl
tar xvzf git_root.tgz
</code></pre>
<h2>Set up environment to use the newly installed git</h2>
<p>Add the path to the newly created bin to your path:</p>
<p>Edit your startup file such as ~/.bash_profile and add:</p>
<p><code>PATH=/home/clientname/git_root/bin:$PATH</code></p>
<p>You have to log out and log back in or source .bash_profile to update the path. You can also type that line into your current session at the prompt and have it immediately active.</p>
<h2>Use Git as normal!</h2>
<p>I found that I can now use Git as normal except that with Hostgator they seemed to be blocking the git protocol or something. I could not say:</p>
<p><code>git clone git://github.com/rberger/project.git</code></p>
<p>But I could say:</p>
<p><code>git clone git@github.com:rberger/project.git</code></p>
<p>(assuming I had my ssh keys setup to access github as git)</p>
<p>or</p>
<p><code>git clone http://github.com/rberger/project.git</code></p>
<p>Note that you do not say ./git. We are assuming that you added git to your path and you can just say git and it will find the executables via the $PATH</p>
<p>If you didn&#8217;t want to change $PATH, you could  give a full path like:</p>
<p><code>/home/clientname/git_root/bin/</code><code>git clone git@github.com:rberger/project.git</code></p>
<h2>Save your CentOS 5.2 Amazon Image</h2>
<p>If you want to, you can save the CentOS 5.2 customized image you created on Amazon EC2.</p>
<p>Ssh into the root account on your running CentOS amazon instance, copy your Amazon EC2 certificate and private key to the home directory of root on the running CentOS instance and run the following commands:</p>
<h3>Build the new AMI</h3>
<p>Replace cert-your_cert_sig.pem, your-private-key-sig and your-amazon-userid with the appropriate values for your EC2 certificate.</p>
<p><code>ec2-bundle-vol -d /mnt --cert cert-your_cert_sig.pem --privatekey pk-your-private-key-sig.pem -u your-amazon-userid -s 3096<br />
</code></p>
<p>The -s 3096 tells it to create an image that is 3GB big. You may have to make it bigger if the command fails. You can check that this is the problem by adding the &#8211;debug flag to the above command.</p>
<h3>Stash the image into your S3 account</h3>
<p>Use your own ws-access-key-id and aws-secret-access-key</p>
<p><code>ec2-upload-bundle -b centos-5.2-git -m /mnt/image.manifest.xml -a aws-access-key-id -s aws-secret-access-key</code></p>
<h2>Git to your hearts content!</h2>
<p>Here is the gzipped tar file of git built to run on hostgator. I don&#8217;t know if it will work in any other directory than the one it was built for though.</p>
<p><a href="http://blog2.ibd.com/wp-content/uploads/2009/04/git_root.tgz">git_root.tgz</a></p><p>The post <a href="https://www.ibd.com/how-the-world-works/installing-a-git-client-on-a-shared-host-with-no-compiler/">Installing a git client on a shared host with no compiler</a> first appeared on <a href="https://www.ibd.com">Cognizant Transmutation</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://www.ibd.com/how-the-world-works/installing-a-git-client-on-a-shared-host-with-no-compiler/feed/</wfw:commentRss>
			<slash:comments>15</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">50</post-id>	</item>
	</channel>
</rss>
