<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2402523218364829873</id><updated>2011-08-05T14:32:03.593-07:00</updated><category term='Command Line'/><category term='pc'/><category term='actionmailer'/><category term='Firefox'/><category term='terminal'/><category term='Ubiquity'/><category term='Ruby'/><category term='Mozilla'/><category term='rails'/><category term='mac'/><category term='sinatra'/><category term='email'/><category term='testing'/><category term='merb'/><category term='stmp_tls'/><category term='datamapper'/><category term='gmail'/><category term='itunes'/><category term='database'/><title type='text'>Mark Tucker's Brainwork</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://marktucks.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2402523218364829873/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://marktucks.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Mark Tucker</name><uri>http://www.blogger.com/profile/03969099524750502555</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>8</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2402523218364829873.post-6584123473971613529</id><published>2010-11-06T06:17:00.001-07:00</published><updated>2010-11-06T06:36:32.454-07:00</updated><title type='text'>Good Design</title><content type='html'>&lt;blockquote&gt;Good design should be innovative.&lt;br /&gt;&lt;br /&gt;Good design should make a product useful.&lt;br /&gt;&lt;br /&gt;Good design is aesthetic design.&lt;br /&gt;&lt;br /&gt;Good design will make a product understandable.&lt;br /&gt;&lt;br /&gt;Good design is honest.&lt;br /&gt;&lt;br /&gt;Good design is unobtrusive.&lt;br /&gt;&lt;br /&gt;Good design is long-lived.&lt;br /&gt;&lt;br /&gt;Good design is consistent in every detail.&lt;br /&gt;&lt;br /&gt;Good design is environmentally friendly.&lt;br /&gt;&lt;br /&gt;Last but not least, good design is as little design as possible.&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;div style="text-align: right;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px; line-height: 5px; "&gt;Dieter Rams&lt;/span&gt;&lt;/div&gt;&lt;small style="line-height:5px"&gt;&lt;div style="text-align: right;"&gt;Former Design Director, Braun&lt;/div&gt;&lt;/small&gt;&lt;br /&gt;Quote from &lt;a href="http://www.objectifiedfilm.com/"&gt;Objectified&lt;/a&gt; by Gary Hustwit.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2402523218364829873-6584123473971613529?l=marktucks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://marktucks.blogspot.com/feeds/6584123473971613529/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2402523218364829873&amp;postID=6584123473971613529' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2402523218364829873/posts/default/6584123473971613529'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2402523218364829873/posts/default/6584123473971613529'/><link rel='alternate' type='text/html' href='http://marktucks.blogspot.com/2010/11/good-design.html' title='Good Design'/><author><name>Mark Tucker</name><uri>http://www.blogger.com/profile/03969099524750502555</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2402523218364829873.post-1983493539444434783</id><published>2009-09-06T12:25:00.001-07:00</published><updated>2009-09-07T13:48:05.908-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='email'/><category scheme='http://www.blogger.com/atom/ns#' term='gmail'/><category scheme='http://www.blogger.com/atom/ns#' term='sinatra'/><category scheme='http://www.blogger.com/atom/ns#' term='stmp_tls'/><category scheme='http://www.blogger.com/atom/ns#' term='actionmailer'/><title type='text'>Sending Email Using Gmail and Action Mailer</title><content type='html'>I've used this for a new &lt;a href="http://lazysuperhero.com" title="lazy superhero web design"&gt;site&lt;/a&gt;, which I'll be mentioning very soon. It took me quite some time to figure out and get right.&lt;br /&gt;&lt;br /&gt;The first thing to do is download the &lt;a href="http://gist.github.com/raw/122114/f761da267ef4b12affb09888d3dadc71b085478a/smtp_tls.rb"&gt;smtp_tls.rb&lt;/a&gt; file. I saved it in my Sinatra app, under &lt;span style="font-style: italic;"&gt;lib&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;Next create a file called mailer.rb in the same &lt;span style="font-style: italic;"&gt;lib&lt;/span&gt; directory with the following contents:&lt;br /&gt;&lt;pre&gt;require 'lib/smtp_tls'&lt;br /&gt;require 'action_mailer'&lt;br /&gt;&lt;br /&gt;class Mailer &lt; ActionMailer::Base&lt;br /&gt;  def my_email(from_email, from_name, message)&lt;br /&gt;    recipients "marktucks@gmail.com"&lt;br /&gt;    from       from_email&lt;br /&gt;    subject    "Contact from " + from_name&lt;br /&gt;&lt;br /&gt;    body       :name =&gt; from_name, :email =&gt; from_email, :message =&gt; message&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;Mailer.template_root = File.dirname(__FILE__)&lt;br /&gt;Mailer.delivery_method = :smtp&lt;br /&gt;Mailer.smtp_settings = {&lt;br /&gt;  :address =&gt; "smtp.gmail.com",&lt;br /&gt;  :port =&gt; "587",&lt;br /&gt;  :domain =&gt; "YOUR_DOMAIN",       &lt;br /&gt;  :authentication =&gt; :plain,&lt;br /&gt;  :enable_starttls_auto =&gt; true,&lt;br /&gt;  :user_name =&gt; "YOUR_USERNAME",&lt;br /&gt;  :password =&gt; "YOUR_PASSWORD",&lt;br /&gt;  :raise_delivery_errors =&gt; true&lt;br /&gt;}&lt;br /&gt;Mailer.logger = Logger.new(STDOUT)&lt;/pre&gt;&lt;br /&gt;NB: I did have the from address as from_email "&lt;" + from_name + "&gt;" but it recently gave me a syntax error, so I removed it which fixed this issue.&lt;br /&gt;&lt;br /&gt;As our class above is called Mailer, create a directory under lib called mailer, which is where our email template will go. As we have a method called my_email in our Mailer class, we need to call our template my_email.erb with the following simple contents:&lt;br /&gt;&lt;pre&gt;Enquiry from &lt;%= h @name %&gt;,&lt;br /&gt;Email: &lt;%= h @email %&gt;&lt;br /&gt;Message:&lt;br /&gt;&lt;%= h @message %&gt;&lt;/pre&gt;&lt;br /&gt;The variables match the ones we passed in from our Mailer class on this line:&lt;br /&gt;&lt;pre&gt;body       :name =&gt; from_name, :email =&gt; from_email, :message =&gt; message&lt;/pre&gt;&lt;br /&gt;Lastly, we send the email:&lt;br /&gt;&lt;pre&gt;begin&lt;br /&gt;   Mailer.deliver_my_email(@email, @name, @message)&lt;br /&gt;   @sent = true&lt;br /&gt;rescue Exception =&gt; e&lt;br /&gt;   @sent = false&lt;br /&gt;end&lt;/pre&gt;&lt;br /&gt;As shown in the &lt;a href="http://api.rubyonrails.org/classes/ActionMailer/Base.html"&gt;ActionMailer&lt;/a&gt; docs, we are just calling a dynamically generated method, which simply prefixed deliver_ to  to the name of our my_email method from the Mailer class. This method will raise Exceptions if something goes wrong, so we've rescued this if it happens so our lovely users aren't exposed to it.&lt;br /&gt;&lt;br /&gt;Comments, better ways of doing this, general discussion welcome just throw me a comment.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2402523218364829873-1983493539444434783?l=marktucks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://marktucks.blogspot.com/feeds/1983493539444434783/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2402523218364829873&amp;postID=1983493539444434783' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2402523218364829873/posts/default/1983493539444434783'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2402523218364829873/posts/default/1983493539444434783'/><link rel='alternate' type='text/html' href='http://marktucks.blogspot.com/2009/09/sending-email-using-gmail-and-action.html' title='Sending Email Using Gmail and Action Mailer'/><author><name>Mark Tucker</name><uri>http://www.blogger.com/profile/03969099524750502555</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2402523218364829873.post-7793421802790090241</id><published>2008-12-23T15:29:00.001-08:00</published><updated>2009-01-28T08:36:51.709-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='rails'/><category scheme='http://www.blogger.com/atom/ns#' term='testing'/><title type='text'>Unit Testing Using Context</title><content type='html'>&lt;style type="text/css"&gt;pre {font-family:monaco, lucida console, lucida sans, courier new, sans;font-size:85%}&lt;/style&gt;&lt;a href="http://www.omgbloglol.com/"&gt;Jeremy McAnally&lt;/a&gt; has released a gem called &lt;a href="http://github.com/jeremymcanally/context/tree/master"&gt;context&lt;/a&gt; allowing contexts in Test::Unit tests. It's all the rage, even those crazy &lt;a href="http://www.rubyonrails.org/"&gt;Rails&lt;/a&gt; guys are doing it (although I did check out some of their unit tests earlier and couldn't find any).&lt;br /&gt;&lt;br /&gt;Anyway, I'm way behind on my &lt;a href="http://en.wikipedia.org/wiki/Test-driven_development"&gt;TDD&lt;/a&gt; and &lt;a href="http://en.wikipedia.org/wiki/Behavior_driven_development"&gt;BDD&lt;/a&gt; and all other testing acronyms so I decided to give it a go. These are way simple tests and I actually did it the normal Rails way initially before "converting" to the context way of doing it.&lt;br /&gt;&lt;br /&gt;I've got converting up there in quotes because it was really, really simple and I hardly did &lt;span style="font-style: italic;"&gt;anything&lt;/span&gt; which is fantastic because the easier something that's good is to do, the more people will eventually do it; think Rails conventions.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Getting Started&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Get the gem:&lt;br /&gt;&lt;pre&gt;$ gem sources -a http://gems.github.com&lt;br /&gt;$ sudo gem install jeremymcanally-context&lt;/pre&gt;That is outlined as the install procedure, but you can't just use it as you must require that bad boy for your Rails app to use it - so put this in your test_helper.rb:&lt;br /&gt;&lt;pre&gt;require 'context'&lt;/pre&gt;This allows it to be used in all tests that require the test_helper. I've also put some other helper methods (where else) in here, just simple stuff like:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;def get_post(*id)&lt;br /&gt;  if id.nil?&lt;br /&gt;    Post.new&lt;br /&gt;  else&lt;br /&gt;    Post.find(id)&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;I also noticed that in your individual Unit Tests you don't need to explicitly put &lt;pre&gt;fixtures :comment&lt;/pre&gt; and the like because &lt;pre&gt;fixtures :all&lt;/pre&gt; is declared in this file allowing you to just access your fixtures like so:&lt;br /&gt;&lt;pre&gt;comment = comments(:comment_1)&lt;/pre&gt;Here I have a comments.yml fixture which can be accessed via &lt;pre style="display: inline;"&gt;comments&lt;/pre&gt; and I have an individual record &lt;pre style="display: inline;"&gt;:comment_1&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;On to the test, finally&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;So here's my edited Unit test class:&lt;br /&gt;&lt;pre&gt;require File.dirname(__FILE__) + '/../test_helper'&lt;br /&gt;&lt;br /&gt;class CommentTest &lt; Test::Unit::TestCase&lt;br /&gt;&lt;br /&gt;  context "A new comment" do&lt;br /&gt;    test "should be valid with both name and body" do&lt;br /&gt;      comment = Comment.new(:name =&gt; 'My User',&lt;br /&gt;                            :email =&gt; 'myuser@example.com',&lt;br /&gt;                            :url =&gt; 'http://www.example.com',&lt;br /&gt;                            :body =&gt; "Here's my comment for ya!")&lt;br /&gt;      assert comment.valid?&lt;br /&gt;      assert comment.errors.empty?&lt;br /&gt;    end&lt;br /&gt;&lt;br /&gt;    test "should be invalid with name but no body" do&lt;br /&gt;      comment = Comment.new(:name =&gt; 'My User',&lt;br /&gt;                            :email =&gt; 'myuser@example.com',&lt;br /&gt;                            :url =&gt; 'http://www.example.com')&lt;br /&gt;      assert !comment.valid?&lt;br /&gt;      assert comment.errors.invalid?(:body)&lt;br /&gt;    end&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  context "An existing comment" do&lt;br /&gt;    test "should be valid" do&lt;br /&gt;      comment = comments(:comment_1)&lt;br /&gt;      assert comment.valid?&lt;br /&gt;      assert comment.errors.empty?&lt;br /&gt;    end&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;As you can see it's pretty much the same as any normal Rails Unit test, except for a couple of minor changes / improvements:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;The class inherits from Test::Unit::TestCase instead of ActiveSupport::TestCase&lt;/li&gt;&lt;li&gt;We've added two context blocks in there to wrap our tests, creating a more readable and elegant test&lt;/li&gt;&lt;li&gt;We're not &lt;pre style="display: inline;"&gt;def&lt;/pre&gt;ining our test methods, we instead have test blocks, which, again, makes the whole thing read like a sentence; some would say the sign of beautiful code&lt;/li&gt;&lt;li&gt;We can also have before and after blocks (my before block is kinda lame but yours could do whatever you want, creating multiple objects for use in your tests for example, so you don't have to create new ones for every test) much like setUp and tearDown in &lt;a href="http://www.junit.org/"&gt;JUnit&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;On the second and third points; if you read your tests out loud they should flow like a sentence. So in the simple tests I have created we have:&lt;br /&gt;&lt;br /&gt;"A new comment should be invalid with no body or name" - the context and the test name form a flowing sentence. "An existing comment should be valid" etc.&lt;br /&gt;&lt;br /&gt;All of my tests start with the word should, but there is no reason they couldn't start with anything else as long as they create a sentence like structure. They could be rewritten "A new comment could be accepted as long as a user is present", it's a bit more verbose, but it still reads like a sentence and everyone looking at that test will know what it's meant to be testing.&lt;br /&gt;&lt;br /&gt;There is still a lot to learn, like Mocks, Integration Tests, Functional Tests and even more on Unit Tests - like writing them &lt;span style="font-style: italic;"&gt;before&lt;/span&gt; the code.&lt;br /&gt;&lt;br /&gt;But my first foray was an enjoyable one and something I will definitely keep doing and I hope this is a help to even just one person and gives them a boost to create their own tests, making their software more stable and maintainable.&lt;br /&gt;&lt;br /&gt;Thoughts, comments, corrections and/or improvements welcome.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2402523218364829873-7793421802790090241?l=marktucks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://marktucks.blogspot.com/feeds/7793421802790090241/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2402523218364829873&amp;postID=7793421802790090241' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2402523218364829873/posts/default/7793421802790090241'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2402523218364829873/posts/default/7793421802790090241'/><link rel='alternate' type='text/html' href='http://marktucks.blogspot.com/2008/12/unit-testing-using-context.html' title='Unit Testing Using Context'/><author><name>Mark Tucker</name><uri>http://www.blogger.com/profile/03969099524750502555</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2402523218364829873.post-1237055055370663724</id><published>2008-12-23T14:18:00.000-08:00</published><updated>2008-12-23T15:28:44.850-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mac'/><category scheme='http://www.blogger.com/atom/ns#' term='terminal'/><title type='text'>Rebuild the locate database on Mac</title><content type='html'>Just because I always forget.&lt;br /&gt;&lt;pre style="font-family:monaco,lucida console,courier new"&gt;&lt;span style="font-size:85%;"&gt;$ sudo /usr/libexec/locate.updatedb&lt;/span&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2402523218364829873-1237055055370663724?l=marktucks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://marktucks.blogspot.com/feeds/1237055055370663724/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2402523218364829873&amp;postID=1237055055370663724' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2402523218364829873/posts/default/1237055055370663724'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2402523218364829873/posts/default/1237055055370663724'/><link rel='alternate' type='text/html' href='http://marktucks.blogspot.com/2008/12/rebuild-locate-database-on-mac.html' title='Rebuild the locate database on Mac'/><author><name>Mark Tucker</name><uri>http://www.blogger.com/profile/03969099524750502555</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2402523218364829873.post-8732740793612349351</id><published>2008-11-09T06:53:00.000-08:00</published><updated>2009-01-28T08:37:41.223-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='merb'/><title type='text'>Merb 1.0</title><content type='html'>So &lt;a href="http://brainspl.at/articles/2008/11/08/merb-1-0"&gt;Merb 1.0&lt;/a&gt; was released 2 days ago during RubyConf, just &lt;pre  style="display: inline;font-family:monaco,lucida console,courier new;"&gt;&lt;span style="font-size:85%;"&gt;sudo gem install merb&lt;/span&gt;&lt;/pre&gt; to update.&lt;br /&gt;&lt;br /&gt;I had to update my config/dependencies.rb file to read &lt;pre  style="display: inline;font-family:monaco,lucida console,courier new;"&gt;&lt;span style="font-size:85%;"&gt;merb_gems_version = "1.0"&lt;/span&gt;&lt;/pre&gt; and also &lt;pre  style="display: inline;font-family:monaco,lucida console,courier new;"&gt;&lt;span style="font-size:85%;"&gt;sudo gem install webrat&lt;/span&gt;&lt;/pre&gt;, which is a Ruby Acceptance Testing plugin. &lt;a href="http://github.com/brynary/webrat/tree/master"&gt;Here&lt;/a&gt;'s the Git repo if you want to check it out.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2402523218364829873-8732740793612349351?l=marktucks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://marktucks.blogspot.com/feeds/8732740793612349351/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2402523218364829873&amp;postID=8732740793612349351' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2402523218364829873/posts/default/8732740793612349351'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2402523218364829873/posts/default/8732740793612349351'/><link rel='alternate' type='text/html' href='http://marktucks.blogspot.com/2008/11/merb-10.html' title='Merb 1.0'/><author><name>Mark Tucker</name><uri>http://www.blogger.com/profile/03969099524750502555</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2402523218364829873.post-1544646367746128229</id><published>2008-11-06T15:19:00.000-08:00</published><updated>2008-11-06T15:42:11.066-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='datamapper'/><category scheme='http://www.blogger.com/atom/ns#' term='merb'/><category scheme='http://www.blogger.com/atom/ns#' term='database'/><title type='text'>Getting the Database name in Merb and DataMapper</title><content type='html'>After a lot of searching and banging my head against my keyboard I finally found how to get the database name for my Merb application:&lt;br /&gt;&lt;pre  style="font-family:monaco,lucida console,courier new;"&gt;&lt;span style="font-size:85%;"&gt;Macintosh:ruby-rss-feeds marktucks$ merb -i&lt;br /&gt;...&lt;br /&gt;&gt;&gt; repository(:default).adapter&lt;br /&gt;=&gt; #&lt;datamapper::adapters::sqlite3adapter:0x1969fb4 field_naming_convention="DataMapper::NamingConventions::Field::Underscored," resource_naming_convention="DataMapper::NamingConventions::Resource::UnderscoredAndPluralized," uri="#&amp;lt;struct" scheme="sqlite3" user="nil," password="nil," host="nil," port="nil," specified_port="nil," path="sample_development.db" query="nil," fragment="nil"&gt;, @name=:default, @transactions={}&gt;&lt;br /&gt;&gt;&gt; repository(:default).adapter.uri&lt;br /&gt;=&gt; #&lt;struct scheme="sqlite3" user="nil," password="nil," host="nil," port="nil," specified_port="nil," path="sample_development.db" query="nil," fragment="nil"&gt;&lt;br /&gt;&gt;&gt; repository(:default).adapter.uri.path&lt;br /&gt;=&gt; "sample_development.db" # YAY!&lt;/struct&gt;&lt;/datamapper::adapters::sqlite3adapter:0x1969fb4&gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;I'm sure there must be a better way to do this. A Rails::Configuration.database_configuration equivalent? But I just cannot find it. The &lt;pre style="font-family: monaco,lucida console,courier new;display:inline"&gt;&lt;span style="font-size:85%;"&gt;Merb.config&lt;/span&gt;&lt;/pre&gt; doesn't seem to have a database property / method. You can get stuff like the host (&lt;pre style="font-family: monaco,lucida console,courier new; display: inline;"&gt;&lt;span style="font-size:85%;"&gt;Merb.config[:host]&lt;/span&gt;&lt;/pre&gt;).&lt;br /&gt;&lt;br /&gt;Any suggestions / better solutions are welcome.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2402523218364829873-1544646367746128229?l=marktucks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://marktucks.blogspot.com/feeds/1544646367746128229/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2402523218364829873&amp;postID=1544646367746128229' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2402523218364829873/posts/default/1544646367746128229'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2402523218364829873/posts/default/1544646367746128229'/><link rel='alternate' type='text/html' href='http://marktucks.blogspot.com/2008/11/getting-database-name-in-merb-and.html' title='Getting the Database name in Merb and DataMapper'/><author><name>Mark Tucker</name><uri>http://www.blogger.com/profile/03969099524750502555</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2402523218364829873.post-6849222464138325434</id><published>2008-09-26T02:21:00.000-07:00</published><updated>2008-09-26T02:48:18.996-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='pc'/><category scheme='http://www.blogger.com/atom/ns#' term='mac'/><category scheme='http://www.blogger.com/atom/ns#' term='itunes'/><title type='text'>iTunes Library from PC to Mac</title><content type='html'>About a couple of months ago I switched from my PC to a MacBook and have never looked back since. I don't miss anything from my PC, except my iTunes Library. And contrary to my colleague's advice it seems as though you can't just copy all that iTunes guff from your PC to your Mac.&lt;br /&gt;&lt;br /&gt;So I found &lt;a href="http://lifehacker.com/software/itunes/geek-to-live--how-to-move-an-itunes-library-from-a-pc-to-mac-and-back-242468.php"&gt;this article&lt;/a&gt; on how to convert my iTunes library and copy all the music files from the PC to the Mac.&lt;br /&gt;&lt;br /&gt;One small edit to this post is that in new iTunes 8, "Import Library" is now, for some confusing reason; File &gt; Library &gt; Import Playlist. "Consolidate Library" is also under File &gt; Library.&lt;br /&gt;&lt;br /&gt;It almost worked like a charm, but apparently it couldn't find some of my music, maybe something to do with the special characters in my Library.xml?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2402523218364829873-6849222464138325434?l=marktucks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://marktucks.blogspot.com/feeds/6849222464138325434/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2402523218364829873&amp;postID=6849222464138325434' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2402523218364829873/posts/default/6849222464138325434'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2402523218364829873/posts/default/6849222464138325434'/><link rel='alternate' type='text/html' href='http://marktucks.blogspot.com/2008/09/itunes-library-from-pc-to-mac.html' title='iTunes Library from PC to Mac'/><author><name>Mark Tucker</name><uri>http://www.blogger.com/profile/03969099524750502555</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2402523218364829873.post-1530070536074142371</id><published>2008-08-27T04:41:00.000-07:00</published><updated>2008-11-06T12:06:30.337-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Mozilla'/><category scheme='http://www.blogger.com/atom/ns#' term='Command Line'/><category scheme='http://www.blogger.com/atom/ns#' term='Ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='Ubiquity'/><category scheme='http://www.blogger.com/atom/ns#' term='Firefox'/><title type='text'>Ubiquity: Firefox Command Line Awesomeness</title><content type='html'>&lt;a href="http://labs.mozilla.com/2008/08/introducing-ubiquity/"&gt;Ubiquity&lt;/a&gt; - "a &lt;a id="g2uy" title="Mozilla Labs" href="http://labs.mozilla.com/"&gt;Mozilla Labs&lt;/a&gt; experiment into connecting the Web with language in an attempt to find new user interfaces that could make it possible for everyone to do common Web tasks quicker and easier."&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Getting started&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Install the &lt;a href="https://people.mozilla.com/%7Eavarma/ubiquity-0.1.xpi"&gt;Plugin&lt;/a&gt;, which will restart Firefox / Mozilla.&lt;br /&gt;*Note: if you are using a Mac you'll need to install &lt;a href="http://growl.info/"&gt;Growl&lt;/a&gt; to get the notifications to work. Windows works out of the box, popping up those little toaster notifications in the bottom right of your screen. No messages on Linux just yet, but I'm sure there is someone out there clever enough to get this working or know how to get it working.&lt;br /&gt;&lt;br /&gt;Once restarted, hit CTRL+SPACE for Windows or OPTION+SPACE for Mac and you'll see Ubiquity pop up below your open tabs.&lt;br /&gt;&lt;br /&gt;There are already quite a few commands built in (type "command-list" into Ubiquity to see them all), follow &lt;a href="https://wiki.mozilla.org/Labs/Ubiquity/Latest_Ubiquity_User_Tutorial"&gt;this tutorial&lt;/a&gt; to get up and running.&lt;br /&gt;&lt;br /&gt;One of the sweet things about it is creating your own commands using the command editor ("command-editor" in Ubiquity). Just create your command in the editor using Javascript and &lt;a href="https://wiki.mozilla.org/Labs/Ubiquity/Ubiquity_0.1_Author_Tutorial"&gt;the tutorial provided&lt;/a&gt; and without needing to restart the browser, it's ready to use.&lt;br /&gt;&lt;br /&gt;I've been mucking about with it today and created a Ruby-Doc search command just to kick the tyres:&lt;br /&gt;&lt;pre style="font-family: monaco,courier new;"&gt;&lt;span style="font-size:85%;"&gt;var noun_type_ruby_keyword = {&lt;br /&gt; _name: "ruby keyword",&lt;br /&gt; suggest: function( text, html ) {&lt;br /&gt;   var suggestions = [CmdUtils.makeSugg(text)];&lt;br /&gt;   return suggestions;&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;CmdUtils.CreateCommand({&lt;br /&gt; name: "ruby-api",&lt;br /&gt; takes: {keyword: noun_type_ruby_keyword},&lt;br /&gt; icon: "http://www.ruby-doc.org/_img/favicon.ico",&lt;br /&gt; description: "Searches Ruby-Doc for the keyword(s)",&lt;br /&gt; preview: function(pblock, directObject) {&lt;br /&gt;   searchTerm = jQuery.trim(directObject.text);&lt;br /&gt;&lt;br /&gt;   var pTemplate = "Searches Ruby-Doc for ${query}";&lt;br /&gt;   var pData = {query: searchTerm}&lt;br /&gt;   pblock.innerHTML = CmdUtils.renderTemplate(pTemplate, pData);&lt;br /&gt;   var url = "http://ajax.googleapis.com/ajax/services/search/web";&lt;br /&gt;   var params = { v: "1.0", q: searchTerm };&lt;br /&gt;&lt;br /&gt;   jQuery.get(url, params, function(data) {&lt;br /&gt;     var numToDisplay = 3;&lt;br /&gt;     var results = data.responseData.results.splice( 0, numToDisplay );&lt;br /&gt;&lt;br /&gt;     pblock.innerHTML = CmdUtils.renderTemplate( {file:"google-search.html"},&lt;br /&gt;     {results:results}&lt;br /&gt;   );&lt;br /&gt;   }, "json");&lt;br /&gt; },&lt;br /&gt; execute: function(directObject) {&lt;br /&gt;   var url = "http://www.google.com/search?q=site%3Awww.ruby-doc.org+{QUERY}"&lt;br /&gt;   var query = directObject.text;&lt;br /&gt;   var urlString = url.replace("{QUERY}", query);&lt;br /&gt;   Utils.openUrlInBrowser(urlString);&lt;br /&gt; }&lt;br /&gt;});&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;As you can see, it's got JQuery built in (along with many other helper functions) so it's easy to do Ajax and all sorts of goodness. I'm very impressed, especially as it's currently a Prototype - looking forward to future releases and the community of commands.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2402523218364829873-1530070536074142371?l=marktucks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://marktucks.blogspot.com/feeds/1530070536074142371/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2402523218364829873&amp;postID=1530070536074142371' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2402523218364829873/posts/default/1530070536074142371'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2402523218364829873/posts/default/1530070536074142371'/><link rel='alternate' type='text/html' href='http://marktucks.blogspot.com/2008/08/ubiquity.html' title='Ubiquity: Firefox Command Line Awesomeness'/><author><name>Mark Tucker</name><uri>http://www.blogger.com/profile/03969099524750502555</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
