tag:blogger.com,1999:blog-32079852009-07-19T09:01:44.157-04:00CodeBits - Tested Complex Code!<a href="http://www.codebits.com">Home</a> -
<a href="http://www.linkedin.com/in/affyadvice">LinkedIn Profile</a> -
<a href="mailto:david.medinets@gmail.com">Email</a>David Medinetshttp://www.blogger.com/profile/16707286767120221163noreply@blogger.comBlogger197125tag:blogger.com,1999:blog-3207985.post-80644173211638578742009-04-02T21:39:00.001-04:002009-04-02T21:42:49.049-04:00Installing Ruby and RubyGems On Ubuntu 8.10<pre>
# ruby
cd ~/rn
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p0.tar.gz
tar -xzvf ruby-1.9.1-p0.tar.gz
cd ~/rn/ruby-1.9.1-p0
./configure
make
make test
sudo make install
# zlib
cd ~/rn/ruby-1.9.1-p0/ext/zlib
sudo apt-get install zlib1g-dev
ruby extconf.rb --with-zlib-include=/usr/include --with-zlib-lib=/usr/lib
make
sudo make install
# gem
cd ~/rn
wget http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz
tar -xzvf rubygems-1.3.1.tgz
cd rubygems-1.3.1
sudo ruby setup.rb
# fix ruby executable
cd ~/rn/ruby-1.9.1-p0
sudo make install
</pre><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3207985-8064417321163857874?l=affy.blogspot.com'/></div>David Medinetshttp://www.blogger.com/profile/16707286767120221163noreply@blogger.com1tag:blogger.com,1999:blog-3207985.post-1492522645189211412009-03-14T23:29:00.004-04:002009-03-15T00:07:11.032-04:00Using Rails Gem to Generate a New Project on Ubuntu<p>Using the rails installed by apt-get was a bit confusing because the rails project being generated was not the rails version that I expected. I had installed the rails gem v2.2.2 but the config/environment.rb file showed rails v2.1.</p>
<p>I fixed this issue by removing the default rails.</p>
<pre>sudo apt-get remove rails</pre>
<p>And then using an alias:</p>
<pre>export GEMDIR=`gem environment gemdir`
export RAILS_VERSION=`gem list rails | grep "rails " | cut -b8- | awk '{sub(/\)/, "");print}'`
alias rails='ruby $GEMDIR/gems/rails-$RAILS_VERSION/bin/rails'</pre>
<p>Now when I do</p>
<pre>rails dool</pre>
<p>The project uses the right version of rails!</p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3207985-149252264518921141?l=affy.blogspot.com'/></div>David Medinetshttp://www.blogger.com/profile/16707286767120221163noreply@blogger.com0tag:blogger.com,1999:blog-3207985.post-15183111009432495192009-01-05T00:37:00.003-05:002009-01-05T00:51:41.232-05:00The --include-activation and --aasm parameters of the Restful Authentication Rails Plugin are mutually exclusive<p>I was following the installation instructions for the Restful Authentication Rails plugin. So I executed:</p>
<pre>script/generate authenticated user sessions --include-activation -—aasm --rspec</pre>
<p>This resulted in:</p>
<blockquote>premature end of regular expression: /\A</blockquote>
<p>After digging into the source code, I found that the <code>parse!</code> method in
/usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/rails_generator/options.rb swallowed exceptions. Here is the original code.</p>
<pre>def parse!(args, runtime_options = {})
self.options = {}
@option_parser = OptionParser.new do |opt|
opt.banner = banner
add_options!(opt)
add_general_options!(opt)
opt.parse!(args)
end
return args
ensure
self.options = full_options(runtime_options)
end</pre>
<p>The <code>OptionParser</code> initialization may cause exceptions which are not properly handled. I don't know what should be down but added the following code immediately before the <code>ensure</code> line at least will show the exception.</p>
<pre> rescue => e
puts("I caught a #{e.class.to_s} with message #{e.to_s}")</pre>
<p>Now that the exception is displayed, I saw one of my underlying problems:</p>
<pre>I caught a OptionParser::InvalidOption with message invalid option: --include-activation</pre>
<p>So I learned that when the <code>--aasm</code> parameter is used, then the <code>--include-activation</code> must not be specified.</p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3207985-1518311100943249519?l=affy.blogspot.com'/></div>David Medinetshttp://www.blogger.com/profile/16707286767120221163noreply@blogger.com0tag:blogger.com,1999:blog-3207985.post-87609226484940017082009-01-04T13:34:00.001-05:002009-01-04T13:36:13.651-05:00Using the Visualize Models pluginThis is a good plugin. It works with GraphViz to generate diagrams of your object model. After installation, I ran into a problem that Visualize::Inflector was not found. This was easily resolved by using ActiveSupport::Inflector in visualize_models.rb.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3207985-8760922648494001708?l=affy.blogspot.com'/></div>David Medinetshttp://www.blogger.com/profile/16707286767120221163noreply@blogger.com0tag:blogger.com,1999:blog-3207985.post-48911664836461046922009-01-04T12:04:00.003-05:002009-01-04T12:30:37.350-05:00The Myth of the Hero Programmer<p>Fortunately, I have met few self-appointed heroic programmers over the years. However, late last year I was saddened to met another. People on truly agile teams might never have met this dying breed of programmer so let me present the archetype by borrowing from the Highlights magazine:</p>
<blockquote>Goofus: Writes complex hard-to-understand code to prove superiority.<br/>
Gallant: Writes clear easy-to-understand code to enhance team dynamics.</blockquote>
<blockquote>Goofus: Writes code with side-effects to show his mastery of arcana.<br/>
Gallant: Writes simple code that is easy to maintain and debug.</blockquote>
<blockquote>Goofus: Disdains and deletes comments.<br/>
Gallant: Describes code context to aid maintenance and provide road
maps for new team members.</blockquote>
<blockquote>Goofus: Speaks in imperative words and derisive tones.<br/>
Gallant: Speaks with humility and guides people to solutions.</blockquote>
<p>The Ruby community should guard against any tendency towards heroic
programmers to avoid some of the complaints made against the Perl
community. Too many 'perlers' loved complexity for its own sake which
lead to unmaintainable code and a bad reputation for the language in
general.</p>
<p>Let's focus on the agile concepts of teamwork, shared code ownership,
and collaboration. They are much healthier for the community.</p>
<p>What Goofus/Gallant experiences have you had?</p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3207985-4891166483646104692?l=affy.blogspot.com'/></div>David Medinetshttp://www.blogger.com/profile/16707286767120221163noreply@blogger.com1tag:blogger.com,1999:blog-3207985.post-16359840807641066522009-01-01T01:34:00.004-05:002009-01-01T01:42:12.541-05:00Avoiding the undefined method `use_transactional_fixtures=' error.After adding <span style="font-weight:bold;">rspec</span> to my project and generating a model with <span style="font-weight:bold;">rspec_model</span>, I tried to run the generated spec test:
<pre>
$ <span style="font-weight:bold;">spec -cfprofile spec/</span>
.../toshi/spec/spec_helper.rb:12: undefined method `use_transactional_fixtures=' for #<Spec::Example::Configuration:0xb7914b98> (NoMethodError)
from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner.rb:184:in `configure'
from /home/medined/Workspaces/toshi/spec/spec_helper.rb:8
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /home/medined/Workspaces/toshi/spec/models/book_spec.rb:1
</pre>
After a fruitless internet search, I tried using a rake task:
<pre>
$ <span style="font-weight:bold;">rake spec</span>
.
Finished in 0.061996 seconds
1 example, 0 failures
</pre><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3207985-1635984080764106652?l=affy.blogspot.com'/></div>David Medinetshttp://www.blogger.com/profile/16707286767120221163noreply@blogger.com1tag:blogger.com,1999:blog-3207985.post-42329721076065128692009-01-01T00:11:00.005-05:002009-01-01T01:41:49.994-05:00Adding RSPEC to a Rails Project<pre>
$ <span style="font-weight:bold;">rails toshi</span>
$ <span style="font-weight:bold;">script/generate rspec</span>
Couldn't find 'rspec' generator
$ <span style="font-weight:bold;">cd toshi/vendor/plugins</span>
$ <span style="font-weight:bold;">git clone git://github.com/dchelimsky/rspec.git</span>
$ <span style="font-weight:bold;">git clone git://github.com/dchelimsky/rspec-rails.git</span>
$ <span style="font-weight:bold;">cd ../../</span>
$ <span style="font-weight:bold;">script/generate rspec</span>
create lib/tasks/rspec.rake
create script/autospec
create script/spec
create script/spec_server
create spec
create spec/rcov.opts
create spec/spec.opts
create spec/spec_helper.rb
</pre><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3207985-4232972107606512869?l=affy.blogspot.com'/></div>David Medinetshttp://www.blogger.com/profile/16707286767120221163noreply@blogger.com0tag:blogger.com,1999:blog-3207985.post-32506571250484588812008-10-16T10:08:00.003-04:002008-10-16T10:11:10.134-04:00How is a Use Case Different From a User Story?http://alistair.cockburn.us/Elephant+carpaccio - Alistair provides a way to think about Use Cases and User Stories. In essence, he says that Use Cases provide the overall shape of the application while User Stories provide the details.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3207985-3250657125048458881?l=affy.blogspot.com'/></div>David Medinetshttp://www.blogger.com/profile/16707286767120221163noreply@blogger.com0tag:blogger.com,1999:blog-3207985.post-60711946629850613182008-10-08T10:05:00.002-04:002008-10-08T10:09:32.241-04:00How do I restore and change gedit key assignments?<p>Use the <code>vi</code> editor to modify the <code>.gnome2/accelsgedit</code>. Editing the file with <code>gedit</code> does not work; the changes are not saved. I had reassigned my <code>^s</code> key away from File>Save. I order to get the key assignment back, I re-commented the following line:
<pre>(gtk_accel_path "<Actions>/GeditWindowActions/FileSave" "<Control>s")</pre></p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3207985-6071194662985061318?l=affy.blogspot.com'/></div>David Medinetshttp://www.blogger.com/profile/16707286767120221163noreply@blogger.com0tag:blogger.com,1999:blog-3207985.post-53968567310783632392008-10-05T16:11:00.003-04:002008-10-05T16:18:37.233-04:00RCOV - Covering unit, integration, and functional testing in one analysis.<p>Add the following code into a file called <code>lib/tasks/rcov.rake</code>. Notice that I used the <code>find</code> to gather the relevant tests then the <code>xargs</code> to form them into a nice line which can be added to the <code>rcov</code> command.</p>
<pre>
namespace :test do
desc 'Tracks test coverage with rcov'
task :coverage => :environment do
rm_f "coverage"
rm_f "coverage.data"
rcov = "rcov --sort coverage --rails --aggregate coverage.data --text-summary -Ilib -Itest -T -x gem/*,rcov*"
files = `find . -name *_test.rb | xargs`
rcov = "#{rcov} " + files
puts rcov
system rcov
system("firefox coverage/index.html")
end
end
</pre>
<p>The new rake command can be executed using <code>rake test:coverage</code></p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3207985-5396856731078363239?l=affy.blogspot.com'/></div>David Medinetshttp://www.blogger.com/profile/16707286767120221163noreply@blogger.com0tag:blogger.com,1999:blog-3207985.post-74034580785849310232008-09-29T20:23:00.002-04:002008-09-29T20:28:49.215-04:00Advanced Rails Recipes - Chapter Two - The missing copy method.<p>I am reading through the <a href="http://pragprog.com/titles/fr_arr/advanced-rails-recipes">Advanced Rails Recipes</a> book. In chapter two, it refers to an <code>Event.copy</code> method which is not shown in the book. Shown below is the missing method from <code>app/models/event.rb</code>.</p>
<pre>
class Event < ActiveRecord::Base
def self.copy(other)
self.new(other.attributes.merge(:name => "Copy of #{other.name}"))
end
end
</pre>
<p align="center"><img src="http://www.pragprog.com/images/covers/190x228/fr_arr.jpg"></p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3207985-7403458078584931023?l=affy.blogspot.com'/></div>David Medinetshttp://www.blogger.com/profile/16707286767120221163noreply@blogger.com0tag:blogger.com,1999:blog-3207985.post-41161800103402320362008-07-20T21:05:00.003-04:002008-07-20T21:49:42.517-04:00JBoss Drools CLASSPATH Error; The Eclipse JDT Core jar is not in the classpath<p>JBoss Rules v4.0.7 is compatible with Eclipse v3.3 or higher. However there is a simple workaround. Run the following commands:</p>
<pre>export ECLIPSE_PLUGINS=/home/medined/Desktop/eclipse-3.4/plugins
ln -s
$ECLIPSE_PLUGINS/org.eclipse.jdt.core_3.4.0.v_874.jar
$ECLIPSE_PLUGINS/org.drools.eclipse_4.0.7/lib</pre><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3207985-4116180010340232036?l=affy.blogspot.com'/></div>David Medinetshttp://www.blogger.com/profile/16707286767120221163noreply@blogger.com1tag:blogger.com,1999:blog-3207985.post-68396472069219071282008-07-13T22:10:00.002-04:002008-07-13T22:41:41.630-04:00Getting "Client.InvalidKeyPair.NotFound" Error With Selenium Grid<p>When running the <code>cap grid:boot</code> command, I received the following error:</p>
<pre>Client.InvalidKeyPair.NotFound: The key pair '/home/medined/.ec2/affy.pem' does not exist</pre>
It turned out that the EC2_KEYPAIR_NAME system variable was set incorrectly. You can find the correct value using the <code>ec2-describe-keypairs</code> command. Here is an example of its use:</p>
<pre>$ <b>ec2-describe-keypairs</b>
KEYPAIR affy c3:e7:5f:09:50:66:f5:2b:3d:2b:ac:1d:09:52:9d:34:29:85:1b:76
</pre>
<p>So the correct value for me is <code>affy</code>, <i>not</i> the filename.</p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3207985-6839647206921907128?l=affy.blogspot.com'/></div>David Medinetshttp://www.blogger.com/profile/16707286767120221163noreply@blogger.com0tag:blogger.com,1999:blog-3207985.post-74085509487740747382008-07-12T11:29:00.002-04:002008-07-12T11:34:49.736-04:00Using Capistrano to Bundle Amazon EC2 Images<p>I've found the following bit of Capistrano script to be useful when tinkering with EC2 images. I can make a change and then bundle the image with just one command: <code>cap admin:bundle</code></p>
<p>The most difficult part of this script was finding out how to upload files to the remote instance using <code>scp</code>. The rest is fairly straightforward. I am only posting this script because I haven't seen this functionality posted anywhere else.</p><p>
</p><pre># capfile for <a href="http://en.wikipedia.org/wiki/Amazon_Elastic_Compute_Cloud" title="Amazon Elastic Compute Cloud" rel="wikipedia" class="zem_slink">Amazon EC2</a> Bundling. Normally, a yaml file would be
# hold configuration parameters. I am using environment
# variables because they are also used by the EC2
# programs - why have the information in two places?
# This script assumes that you are only bundling one
# instance at a time.
# EC2 Instance Hostname to be bundled.
ec2_hostname = ENV['BUNDLE_EC2_HOSTNAME']
# S3 Bucket Name (where the bundle is uploaded)
s3_bucket_name = ENV['BUNDLE_S3_BUCKET_NAME']
# If you are using ElasticFox (and if not, why not?) that
# you created in the KeyPairs tab. Specify the full
# path to the file.
ssh_keypair_file = ENV['BUNDLE_SSH_PRIVATE_KEY_FILESPEC']
# <a href="http://en.wikipedia.org/wiki/Amazon_Web_Services" title="Amazon Web Services" rel="wikipedia" class="zem_slink">Amazon Web Services</a> Info
amazon_account_id = ENV['AMAZON_ACCOUNT_ID']
amazon_access_key_id = ENV['AMAZON_ACCESS_KEY_ID']
amazon_secret_access_key = ENV['AMAZON_SECRET_ACCESS_KEY']
# Amazon EC2 Info
cert_filespec = ENV['EC2_CERT']
private_key_filespec = ENV['EC2_PRIVATE_KEY']
# We are only dealing with one EC2 instance.
role :libs, "#{ec2_hostname}"
# I like working with ElasticFox which seems to only
# support using the root user.
set :user, "root"
ssh_options[:keys] = ssh_keypair_file
namespace :admin do
task :bundle do
# Copy the certificate and private key to the remote computer.
upload("#{private_key_filespec}", "/mnt", :via => :scp)
upload("#{cert_filespec}", "/mnt", :via => :scp)
# Extract just the filename from the filespec.
private_key_filename_start = private_key_filespec.rindex('/') + 1
private_key_filename_end = private_key_filespec.length
private_key_filename = private_key_filespec[private_key_filename_start, private_key_filename_end]
# Extract just the filename from the filespec.
cert_filename_start = cert_filespec.rindex('/') + 1
cert_filename_end = cert_filespec.length
cert_filename = cert_filespec[cert_filename_start, cert_filename_end]
# Remove any old image.
run "rm --force /mnt/image /mnt/image.*"
# Create the EC2 Bundle
#run "ec2-bundle-vol -d /mnt -c /mnt/#{cert_filename} -k /mnt/#{private_key_filename} -u #{amazon_account_id} -r i386"
# Upload the EC2 Bundle to S3
run "ec2-upload-bundle -b #{s3_bucket_name} -m /mnt/image.manifest.xml -a #{amazon_access_key_id} -s #{amazon_secret_access_key}"
exec "ec2-register #{s3_bucket_name}/image.manifest.xml"
end
task :update do
run "apt-get update"
run "apt-get upgrade -y"
end
end</pre><div style="margin-top: 10px; height: 15px;" class="zemanta-pixie"><a class="zemanta-pixie-a" href="http://reblog.zemanta.com/zemified/ab17d330-adbb-4aa0-ba7f-a000dbd5c009/" title="Zemified by Zemanta"><img style="border: medium none ; float: right;" class="zemanta-pixie-img" src="http://img.zemanta.com/reblog_e.png?x-id=ab17d330-adbb-4aa0-ba7f-a000dbd5c009" alt="Zemanta Pixie"></a></div><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3207985-7408550948774074738?l=affy.blogspot.com'/></div>David Medinetshttp://www.blogger.com/profile/16707286767120221163noreply@blogger.com1tag:blogger.com,1999:blog-3207985.post-21369704089482266182008-07-10T14:07:00.002-04:002008-07-10T14:14:50.161-04:00Using SCP with Capistrano<p>It took me several hours to find out how to send a file to my remote computer via <code>scp</code> using <a href="http://en.wikipedia.org/wiki/Capistrano" title="Capistrano" rel="wikipedia" class="zem_slink">Capistrano</a>. It's actually quite easy. There is a method called <code>upload</code> which has a <code>via</code> option. Here is an example of its use:</p>
<pre>upload("products.txt", "/home/medined", :via => :scp)</pre>
<p>If you need to change the files name, you can also specify it in the second parameter. For example,</p>
<pre>upload("products.txt", "/home/medined/products_new.txt", :via => :scp)</pre><div style="margin-top: 10px; height: 15px;" class="zemanta-pixie"><a class="zemanta-pixie-a" href="http://reblog.zemanta.com/zemified/d8ef19e1-0df3-40ea-8318-ce9458d45365/" title="Zemified by Zemanta"><img style="border: medium none ; float: right;" class="zemanta-pixie-img" src="http://img.zemanta.com/reblog_e.png?x-id=d8ef19e1-0df3-40ea-8318-ce9458d45365" alt="Zemanta Pixie"></a></div><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3207985-2136970408948226618?l=affy.blogspot.com'/></div>David Medinetshttp://www.blogger.com/profile/16707286767120221163noreply@blogger.com3tag:blogger.com,1999:blog-3207985.post-53012459083453183112008-07-09T19:35:00.002-04:002008-07-09T19:43:38.722-04:00Capistrano, ElasticFox & EC2<p>What a nice combination of tools! I just installed Capistrano and created a <code>capfile</code>. From then on, I could run commands across all my virtual istances in one shot. This setup took just minutes. The only change that I made to my existing instances was to add a <code>capistrano</code> userid. My <code>capfile</code> looks like this:</p>
<pre>role :files,
"capistrano@ec2-75-101-225-105.compute-1.amazonaws.com",
"capistrano@ec2-67-202-59-118.compute-1.amazonaws.com"
namespace :files do
desc "Show free disk space"
task :show_free_space, :roles => :files do
run "df -h /"
end
end
</pre>
<p>The best thing of all? No XML configuration!</p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3207985-5301245908345318311?l=affy.blogspot.com'/></div>David Medinetshttp://www.blogger.com/profile/16707286767120221163noreply@blogger.com0tag:blogger.com,1999:blog-3207985.post-61962396230220771282008-07-07T10:24:00.003-04:002008-07-07T10:33:06.470-04:00ElasticFox: How to SSH to Amazon EC2 Image Without Entering a Password1. Download and install the ElasticFox plugin.<br/>
2. Enter your credentials.<br/>
3. Enter your account information.<br/>
4. Select the KeyPairs tab.<br/>
5. Click Create a New Pair.<br/>
6. Save to a file; for example ~/.ec2/affy.pem.<br/>
7. Select the AMIs and Instances tab.<br/>
8. Click Launch Instance(s).<br/>
9. In the dialog box, select the keypair that you created in step 5.<br/>
10. When the AMI is running, you should be able to connect to it without a password prompt.<br/><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3207985-6196239623022077128?l=affy.blogspot.com'/></div>David Medinetshttp://www.blogger.com/profile/16707286767120221163noreply@blogger.com6tag:blogger.com,1999:blog-3207985.post-61735787602100624072008-07-06T18:16:00.001-04:002008-07-06T18:18:29.037-04:00Captain Kirk Teaches SCRUM and Agile Development<h2>Episode One: Change the Playing Field</h2>
<blockquote id="nv3p">"The odds are against us and the situation is grim." - <i id="o4bl">Star Trek: Generations</i></blockquote>
<br id="nv3p1">
STARDATE 11234.2<br id="y_g9">
<br id="y_g90">
Students, Starfleet has asked to me say a few words about SCRUM while I'm visiting your base. Fortunately, my meeting with the Ambassadors isn't until 0930 so I have just enough time to talk and then answer a few questions.<br id="vj00">
<br id="vj000">
Some years ago, I was in a situation that by most accounts (especially Bones') would be considered bleak. Our software team was handed a Klingon application to calculate the expansion rate of exploding warheads. Our Quality Assurance staff was located in the beta quadrant. While my Klingon interpreter and product owner (Kveld of house K'mpok) was in the brig for attempting to kill Scottie. I needed to act, and fast! But what were my options?<br id="utt9">
<br id="utt90">
Yes, I could have outsourced the work to the Romulons. But they are the enemy! Let's get serious. Other suggestions?<br id="utt91">
<br id="utt92">
Ok, that's another approach. We could bring everyone together onto a single starbase to form a co-located team. That suggestion is a classic. And workable except for the inter-species issues. My product owner, the klingon in the brig, is also responsible for other projects. He can't be co-located for all of them, can he? Additionally, co-location means additional costs in the form of housing, food, time away from family. In this situation, co-location is not possible.<br id="hufj">
<br id="hufj0">
Hmm. Good idea. Use the holodeck as a virtual meeting room. I like that and that is the approach that we took. Along with some others as well.<br id="m0tc">
<br id="m0tc0">
Since the team is so dispersed the issue of time was quite important. The team agreed to a daily standup (a scrum, some like to say) but at what time? The meeting time changed every three months. Thus, no one location was impacted more than another - all were inconvenienced equally.<br id="jxeb">
<br id="jxeb0">
Scottie agreed to import a case of Ra'taj for Kveld and to refrain from further mentioning his mother's similarity to a Gagh.<br id="ptqh">
<br id="ptqh0">
The approach that I take to every situation is: <br id="sm3y">
<br id="sm3y0">
<blockquote id="p4en">What is the operant set of relationships and rules? And how can they be changed to resolve the issue?<br id="d01o">
</blockquote>
Once you know how the forces arrayed against you are deployed, you can find the levers needed to tip the scale in your direction.<br id="qcht">
<br id="qcht0">
Any questions?<br id="qcht1">
<br id="jqt4">
<br id="jqt40">
Thank you. <i id="jqt41"><br id="jqt42">
<br id="jqt43">
Dup dor a'az Mubster (live long and prosper)<br id="mvwe">
</i><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3207985-6173578760210062407?l=affy.blogspot.com'/></div>David Medinetshttp://www.blogger.com/profile/16707286767120221163noreply@blogger.com0tag:blogger.com,1999:blog-3207985.post-37964294481984192602008-06-02T08:22:00.002-04:002008-06-02T08:33:52.619-04:00Getting flickrfs to Work on Ubuntu Heron<p>I found this <a href="http://manishrjain.googlepages.com/flickrfs#ubuntu">site</a> which provides step-by-step instructions how to use <code>flickrfs</code> in order to mount your Flickr account as a file system. The steps required a little tweaking to work. Here are the steps that I followed:</p>
<ol>
<li><code>sudo apt-get install libfuse2 fuse-utils python2.4-fuse imagemagick</code> - the original instructions used a capital i for imagemagick.</li>
<li><code>sudo modprobe fuse</code></li>
<li><code>sudo chmod 755 /bin/fusermount</code> - the original instructions used /usr/bin</li>
<li><code>sudo chmod u+s /bin/fusermount</code> - the original instructions used /usr/bin</li>
<li><code>sudo chmod 666 /dev/fuse</code></li>
<li><code>cd ~</code></li>
<li>Download <a href="http://sourceforge.net/project/showfiles.php?group_id=151995"><code>flickrfs</code></a> package from sourceforge.</li>
<li><code>tar -xzvf flickrfs-*.tar.gz</code></li>
<li><code>screen -S flickrfs</code></li>
<li><code>lsmod | grep -i fuse</code> # Rerun commands in step 2 if not loaded.</li>
<li><code>cd flickrfs-1.3.95</code> - make sure to check the version number.</li>
<li><code>mkdir ~/flickrfs/mount</code> - use a mount point under your home directory or use <code>sudo</code></li>
<li><code>mkdir ~/flickrfs/mount/stream</code></li>
<li><code>python flickrfs.py ~/flickrfs/mount</code></li>
<li><code>tail -f ~/.flickrfs/log</code></li>
</ol><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3207985-3796429448198419260?l=affy.blogspot.com'/></div>David Medinetshttp://www.blogger.com/profile/16707286767120221163noreply@blogger.com0tag:blogger.com,1999:blog-3207985.post-60189851974622396682008-05-04T18:01:00.006-04:002008-05-04T18:57:45.639-04:00Installation and Configuration of LocalSolr.<p>A client of mine asked me to investigate <code>localsolr</code> which= extends Apache Solr server with the ability to perform text searches filtered on geographical distance from a given point specified by latitude and longitude. Here are the steps that I followed:</p>
<p><strong>Download the Software</strong></p>
<ol>
<li>Downland Ant from <a href="http://apache.mirror99.com/ant/binaries/apache-ant-1.7.0-bin.tar.gz">http://apache.mirror99.com/ant/binaries/apache-ant-1.7.0-bin.tar.gz</a></li>
<li>Download Tomcat from <a href="http://mirror.nyi.net/apache/tomcat/tomcat-6/v6.0.16/bin/apache-tomcat-6.0.16.tar.gz">http://mirror.nyi.net/apache/tomcat/tomcat-6/v6.0.16/bin/apache-tomcat-6.0.16.tar.gz</a></li>
<li>Download LocalLucene from <a href="http://downloads.sourceforge.net/locallucene/locallucene-r1.5.tar.gz">http://downloads.sourceforge.net/locallucene/locallucene-r1.5.tar.gz</a></li>
<li>Download LocalSolr from <a href="http://downloads.sourceforge.net/locallucene/localsolr-r1.5.tar.gz">http://downloads.sourceforge.net/locallucene/localsolr-r1.5.tar.gz</a></li>
<li>Download Solr-1.3-dev, via svn, to get the source code
<pre>svn checkout http://svn.apache.org/repos/asf/lucene/solr/trunk apache-solr-1.3.dev</pre></li>
<li>Uncompress all of the software packages.</li>
</ol>
<p><strong>Create Environment Variables</strong></p>
<ol>
<li>In Unix variants, update your <code>.bash_login</code> script to include the following. Of course, you'll need to set the variables correctly according to where you uncompressed the software. And don't forget to <i>source</i> the <code>.bash_login</code> file after you have changed it.
<pre>export SUPPORT_DIR=/home/medined/support
export LOCAL_LUCENE_HOME=$SUPPORT_DIR/locallucene-r1.5
export LOCAL_SOLR_HOME=$SUPPORT_DIR/localsolr-r1.5
export SOLR_HOME=$SUPPORT_DIR/apache-solr-1.3-dev
export SOLR_CONFIG=/home/medined/.solr
export TOMCAT_HOME=$SUPPORT_DIR/apache-tomcat-6.0.16
export JAVA_OPTS="$JAVA_OPTS -Dsolr.solr.home=$SOLR_CONFIG"</pre>
</li></ol>
<p><strong>Create Apache Solr War</strong></p>
<ol>
<li><code>cd $SOLR_HOME</code></li>
<li><code>ant dist</code></li>
</ol>
<p><strong>Configure Local Solr</strong></p>
<ol>
<li><code>cp -R $SOLR_HOME/example/solr $SOLR_CONFIG</code></li>
<li><code>cp $SOLR_HOME/libs/solr/apache-solr-1.3-dev.war $TOMCAT_HOME/webapps/solr.war
mkdir $SOLR_CONFIG/lib</code></li>
<li><code>cp $LOCAL_LUCENE_HOME/dist/locallucene.jar $SOLR_CONFIG/lib</code></li>
<li><code>cp $LOCAL_SOLR_HOME/dist/localsolr.jar $SOLR_CONFIG/lib</code></li>
<li><code>cp $LOCAL_LUCENE_HOME/lib/gt2-referencing-2.3.1.jar $SOLR_CONFIG/lib</code></li>
<li><code>cp $LOCAL_LUCENE_HOME/lib/geoapi-nogenerics-2.1-M2.jar $SOLR_CONFIG/lib</code></li>
<li><code>cp $LOCAL_LUCENE_HOME/lib/jsr108-0.01.jar $SOLR_CONFIG/lib</code></li>
<li>Add the following to the end of <code>$SOLR_CONFIG/conf/solrconfig.xml</code> (just before the closing CONFIG tag:<pre> <updateRequestProcessor>
<factory name="standard" class="solr.ChainedUpdateProcessorFactory" default="true">
<chain class="com.pjaol.search.solr.update.LocalUpdateProcessorFactory">
<str name="latField">lat</str>
<str name="lngField">lng</str>
<int name="startTier">9</int>
<int name="endTier">17</int>
</chain>
<chain class="solr.LogUpdateProcessorFactory" >
<!-- <int name="maxNumToLog">100</int> -->
</chain>
<chain class="solr.RunUpdateProcessorFactory" />
</factory>
</updateRequestProcessor>
<requestHandler name="geo" class="com.pjaol.search.solr.LocalSolrRequestHandler">
<!-- Custom latitude longitude fields, below are the defaults if not otherwise
specified -->
<str name="latField">lat</str>
<str name="lngField">lng</str>
</requestHandler></pre></li>
<li>Add the following to the <code>fields</code> tag of <code>$SOLR_CONFIG/conf/schema.xml</code><pre><field name="lat" type="sdouble" indexed="true" stored="true"/>
<field name="lng" type="sdouble" indexed="true" stored="true"/>
<dynamicField name="_local*" type="sdouble" indexed="true" stored="true"/></pre></li>
</ol>
<p><strong>Controlling Tomcat</strong></p>
<ul>
<li><code>$TOMCAT_HOME/bin/startup.sh</code> - this command starts Tomcat.</li>
<li><code>tail -f $TOMCAT_HOME/logs/catalina.out</code> - this command lets you watch Tomcat's output log.</li>
<li><code>$TOMCAT_HOME/bin/shutdown.sh</code> - this command stops Tomcat.</li>
</ul>
<p>If you're lucky enough to be using Unix then combine the first two commands onto one line:<pre>$TOMCAT_HOME/bin/startup.sh; tail -f $TOMCAT_HOME/logs/catalina.out</pre></p>
<p><strong>Importing Data Into Apache Solr</strong></p>
<p>When LocalSolr is deployed into Tomcat, the default port is 8080. However, the Apache Solr import tools use a different <i>hardcoded</i> port. This causes me a but of angst until I realized that I could easily copy the SimplePostTool and change the port. So copy <code>$SOLR_HOME/src/java/org/apache/solr/util/SimplePostTool.java</code>, change the port specified on line 46 (see below) and compile it.<pre>public static final String DEFAULT_POST_URL = "http://localhost:8080/solr/update";</pre></p>
<p>I create a data file that looked like this<pre><add>
<doc>
<field name="id">01</field>
<field name="name">HOUSE01</field>
<field name="lat">39.36</field>
<field name="lng">-77.4027</field>
<field name="text">zxy</field>
</doc>
<doc>
<field name="id">02</field>
<field name="name">HOUSE02</field>
<field name="lat">38.36</field>
<field name="lng">-77.4027</field>
<field name="text">zxy</field>
</doc>
</add></pre></p>
<p>Then I simply executed the SimplePostTool program passing it the name of the data file as the program argument.</p>
<p><strong>Apache Solr Admin Screen</strong></p>
<p>With Tomcat running, you should be able to connect with <a href="http://localhost:8080/solr/admin/">http://localhost:8080/solr/admin/</a></p>
<p><strong>Local Solr GIS Query</strong></p>
<p>With Tomcat running, you should be able to execute a GIS-based query by connecting to <a href="http://localhost:8080/solr/select?&qt=geo&lat=38.8700&long=-77.4027&q=zxy&radius=1">http://localhost:8080/solr/select?&qt=geo&lat=38.8700&long=-77.4027&q=zxy&radius=1</a>. The <code>q=zxy</code> tells Apache Solr to return all documents. The <code>lat</code> and <code>long</code> parameters indicate the center of the circle to search using decimal degrees. While the <code>radius</code> parameter indicates the radius, in miles, of the circle.</p>
<p>Good Luck!</p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3207985-6018985197462239668?l=affy.blogspot.com'/></div>David Medinetshttp://www.blogger.com/profile/16707286767120221163noreply@blogger.com1tag:blogger.com,1999:blog-3207985.post-84948219817667794482008-04-30T14:47:00.002-04:002008-04-30T14:55:23.585-04:00Struts Error/Exception: No getter method available for property name for bean under name<p>Recently I was using Struts v1.x and I needed to display a select list. The information about how to use the html:optionsCollection tag was sketchy. I was able to get the tag working this way:</p>
<p>On the JSP page, I added this inside the html:form tag:</p>
<pre><html:select property="selectedEquipment">
<html:optionsCollection property="equipment" label="name" value="id"/>
</html:select></pre>
<p>Then I create a Java class called SelectOption like this:</p>
<pre>package com.codebits.struts;
public class SelectOption {
String id;
String name;
SelectOption() {
}
SelectOption(final String _id, final String _name) {
setId(_id);
setName(_name);
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}</pre>
<p>Next I created an ActionForm bean:<p>
<pre>package com.codebits.struts;
public class AddForm extends ActionForm {
private Integer selectedEquipment = null;
private List equipment = new ArrayList();
public Integer getSelectedEquipment() {
return selectedEquipment;
}
public void setSelectedEquipment(Integer selectedEquipment) {
this.selectedEquipment = selectedEquipment;
}
public List getEquipment() {
return equipment;
}
public void addEquipment(final String equipmentId, final String emtEquipmentId) {
this.equipment.add(new SelectOption(equipmentId, emtEquipmentId));
}
public void setEquipment(List equipment) {
this.equipment = equipment;
}
}</pre>
<p>And finally, in my action class, I prepopulated the ActionForm bean:</p>
<pre> AddForm addForm = (AddForm)form;
addForm.addEquipment("1", "AAA");
addForm.addEquipment("2", "BBBB");
</pre><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3207985-8494821981766779448?l=affy.blogspot.com'/></div>David Medinetshttp://www.blogger.com/profile/16707286767120221163noreply@blogger.com1tag:blogger.com,1999:blog-3207985.post-18829340634261986242008-04-22T16:01:00.002-04:002008-04-22T16:07:41.135-04:00How to Format Dates in Ruby & RailsI have seen several techniques used to format dates in blogs and forums threads. This is the technique that worked for me.
<ol><li>Create a file called <code>config/initializers/date_formats.rb</code> with the following contents:
<pre>ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge!(
:date => '%m/%d/%Y',
:date_time12 => "%m/%d/%Y %I:%M%p",
:date_time24 => "%m/%d/%Y %H:%M"
)</pre></li>
<li>Set the date variable:
<pre>@cacheExpiresAt = 10.minutes.ago</pre></li>
<li>Format the date:
<pre><%= @cacheExpiresAt.to_s(<b>:date_time12</b>) %></pre></li>
</ol>
The <code>:date_time12</code> parameter to the <code>to_s</code> method simply chooses the formatting from the <code>DATE_FORMATS</code> hash. This technique lets you centralize all date formatting in your application.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3207985-1882934063426198624?l=affy.blogspot.com'/></div>David Medinetshttp://www.blogger.com/profile/16707286767120221163noreply@blogger.com0tag:blogger.com,1999:blog-3207985.post-5231215177267941632008-04-18T09:42:00.003-04:002008-04-18T09:44:37.505-04:00Workaround For Minor Hibernate Bug - Blank hibernate.default_schema Property Adds PeriodWe are using the hibernate.default_schema property with Oracle in production. Today I tried to use HSQL for our integration tests. When I blanked the hibernate.default_schema property, Hibernate tried to create tables named like '.FOO' - notice that pesky leading period!
You can workaround this issue for HSQL by setting hibernate.default_schema to 'sa'.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3207985-523121517726794163?l=affy.blogspot.com'/></div>David Medinetshttp://www.blogger.com/profile/16707286767120221163noreply@blogger.com0tag:blogger.com,1999:blog-3207985.post-17892400910757776282008-04-09T00:11:00.003-04:002008-04-22T16:09:09.012-04:00ActiveRecord Without Rails, Refined<p>About a year ago Aizat Faiz, a software developer in Malaysia wrote a blog entry about using ActiveRecord outside of the Rails framework. This is definitely something that I want to do for a variety of reasons, the simplest being that I'd like to write utility programs that access the database without needing to also write a user interface for them.</p>
<p>In any case, Aizat wrote a nice understandable entry. However, he seemed to make the assumption that developers using ActiveRecord without Rails would not have a Rails application at all. This is not the case for me.</p>
<p>If your utility script resides in the top level directory, then you can use your already existing database.yml file instead of creating a new one. Just use the following as a guide.</p>
<pre>dbconfig = YAML::load(File.open('config/database.yml'))
ActiveRecord::Base.establish_connection(dbconfig['development'])</pre>
<p>Also, there is no reason to have your models in your script when they are already in your Rails application. You can load existing modesl like this:</p>
<pre>require 'app/models/event.rb'
require 'app/models/senator.rb'</pre>
<p>That's it. Very simple and no duplication of code.</p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3207985-1789240091075777628?l=affy.blogspot.com'/></div>David Medinetshttp://www.blogger.com/profile/16707286767120221163noreply@blogger.com2tag:blogger.com,1999:blog-3207985.post-17410840009568494102008-04-04T09:51:00.002-04:002008-04-04T09:57:23.882-04:00How To Add a Datasource To Tomcat Server.XML File.<Server>
...
<GlobalNamingResources>
...
<Resource
auth="Container" name="jdbc/project_datasource_name" scope="sharable"
type="oracle.jdbc.pool.OracleDataSource"
/>
<Resource
auth="Container" description="..." name="UserDatabase"
type="org.apache.catalina.UserDatabase"
/>
<ResourceParams name="jdbc/project_datasource_name">
<parameter>
<name>factory</name>
<value>oracle.jdbc.pool.OracleDataSourceFactory</value>
</parameter>
<parameter>
<name>validationQuery</name>
<value>select 1 from dual</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:oracle:thin:USERNAME/PASSWORD@localhost:1521:XE</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>4</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>5000</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>oracle.jdbc.OracleDriver</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>2</value>
</parameter>
</ResourceParams>
...
</GlobalNamingResources>
..
</Server><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3207985-1741084000956849410?l=affy.blogspot.com'/></div>David Medinetshttp://www.blogger.com/profile/16707286767120221163noreply@blogger.com0