Tagged: ruby

Omniauth, Devise and Facebook Client Login Don't Play Nice

I've had to use Facebook login inside an iframe twice now. Combine Devise with omniauth and omniauth-facebook and you have a pretty great user authentication system. Now try to login via Facebook inside an iframe and nothing will happen. If you check your Javascript console you'll see a error that looks something like this:

Refused to display 'https://www.facebook.com/login.php?skip_api_login=1&api_key=asdfasdf%23_%3D_&display=page' in a frame because it set 'X-Frame-Options' to 'DENY'.

Facebook won't render their UI inside of an iframe. A lot of sites do that these days. However, you can use the Facebook Javascript client and everything will just work - sort of. Omniauth-facebook documents a Client side flow which looks like the perfect solution to our problem but as I've learned it's not rainbows and unicorns.

If you do follow the advice provided by the documentation you'll spend hours saying things to your computer that yo...

Continue Reading →

Brew Install MySQL Issue

I ran into a problem while trying to install mysql using homebrew:

~/projects/oerglue (master)$ brew install mysql
==> Downloading http://downloads.mysql.com/archives/mysql-5.5/mysql-5.5.12.tar.gz
curl: (7) couldn't connect to host
Error: Failure while executing: /usr/bin/curl -f#LA Homebrew 0.8 (Ruby 1.8.7-174; Mac OS X 10.6.8) http://downloads.mysql.com/archives/mysql-5.5/mysql-5.5.12.tar.gz -o /Users/jbasdf/Library/Caches/Homebrew/mysql-5.5.12.tar.gz

Basically, the script couldn't find the mysql source code.

Luckily homebrew uses ruby. So fixing the problem was really easy. Just edit the mysql.rb homebrew formula found here:

/usr/local/Library/Formula/mysql.rb

I just changed the url and md5 like so:

url 'http://mirror.services.wisc.edu/mysql/Downloads/MySQL-5.5/mysql-5.5.13.tar.gz'
md5 'f0e519e90ee7c00fceb0730edf859d7b'

Then everything worked great. One note, if you want to change the version or use a different mirror for mysql be sure to get the 'Source Code' version...

Continue Reading →

Textmate RSpec Bundle Error

After installing the Textmate RSpec bundle I started getting this error:

/Applications/TextMate.app/Contents/SharedSupport/Support/lib/builder.rb:86:in blank_slate_method_added': stack level too deep (SystemStackError) from /Applications/TextMate.app/Contents/SharedSupport/Support/lib/builder.rb:86:inblank_slate_method_added' from /Library/Ruby/Gems/1.8/gems/builder-2.1.2/lib/blankslate.rb:84:in method_added' from /Library/Ruby/Gems/1.8/gems/builder-2.1.2/lib/blankslate.rb:104 from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:ingem_original_require' from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in require' from /Users/jbasdf/projects/red/vendor/rails/activesupport/lib/active_support/basic_object.rb:21 from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:ingem_original_require' from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in require' ... 32 levels... from /Users/jbasdf/Library/Application Support/TextMate/Bundles/RSpec.t...

Continue Reading →

Fireeagle and PortableContacts Don’t Get Along. That Makes Daddy Mad.

I have some code that looks like this:


  user.google.portable_contacts.all
As long as user.google is a valid token provided by oauth you will get back a list of the user's contacts from gmail.

That is unless you have the Fireeagle gem included in your application. In that case you will spend the night swearing like a sailor and then weeping openly like a little girl. If you include fireeagle 0.8.0.1 in your project and make that call you will get an error like this:


ActionView::TemplateError (wrong number of arguments (1 for 0)) on line #7 of /Library/Ruby/Gems/1.8/gems/muck-invites-0.1.12/app/views/invites/_gmail_oauth.erb:
    /Library/Ruby/Gems/1.8/gems/oauth-0.4.0/lib/oauth/consumer.rb:154:in create_http'
    /Library/Ruby/Gems/1.8/gems/oauth-0.4.0/lib/oauth/consumer.rb:154:inrequest'
    /Library/Ruby/Gems/1.8/gems/oauth-0.4.0/lib/oauth/tokens/consumer_token.rb:25:in request'
    /Library/Ruby/Gems/1.8/gems/oauth-0.4.0/lib/oauth/tokens/access_token.rb:11:inreque...

Continue Reading →

Don’t Upgrade to Rails 2.3.8 Unless You Really Mean It

I just got a new laptop which means re-installing everything. This included Rails and I ended up with 2.3.8. Most of my projects use 2.3.5. I figured no big deal since various Rails versions have always played together in the past. I installed 2.3.5 with gem install rails -v=2.3.5 and figured all would be well.

I would be wrong in that assumption.

Instead of just working anytime I try to run a 2.3.5 app (most of my apps at the moment). I get this:

Missing the Rails 2.3.5 gem. Please `gem install -v=2.3.5 rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.

So my next step was to uninstall 2.3.8. I still get the error. I uninstalled and then reinstalled Rails and things seem to be working.

Heroku has the answer: .

This is why it's usually a good idea to wait a little while after a Rails update. I have to keep reminding myself of that.

Continue Reading →

Mountain West Ruby Conference

I spent last week at the Mountain West Ruby Conference which is by far the best conference I've ever attended due to the brilliant minds that gather from all over the country. This year Yukihiro Matsumoto (Matz), the creator of ruby came from Japan to provide his aura to to adoring minions. I had the fortune to go to dinner and hang out with him a bit which was not an insignificant opportunity. I have to admire someone who is passionate about a programming language for the sake of the language. His brainchild powers many of the latest startups and provides jobs for thousands if not hundreds of thousands of people. I asked what he thought about the significance of his contributions to the world. He said "ya, I guess it's pretty cool". For a guy that has every right to be impressed with himself he's really nice and humble. I think the ruby community not only owes thanks for a great tool, but also for a personality that helped breed a friendly, helpful bunch of peopl...

Continue Reading →

River – Amazon Wishlist Gem

One more post on Amazon Wishlist code. As another follow up to my post on Amazon Wishlist RSS, Ruby and Signing/Authenticating your Requests and the site I built to run the code My Amazon Feeds (post here) I've created a gem to contain all the code. Get it by running


  sudo gem install river

It's a pretty simple gem so working with the code is also pretty easy to do:


am = AmazonRequest.new(amazon_access_key_id, amazon_secret_access_key, ecs_to_rss_wishlist, amazon_associate_tag)
results = am.get_amazon_feeds(username) # username needs to be the user's Amazon email
feeds = results.collect { |result| OpenStruct.new(:url => result, :title => 'Amazon Wishlist', :name => 'wishlist') }

Get amazon_access_key_id and amazon_secret_access_key from your AWS console. The amazon_associate_tag parameter is optional. Throw it in there if you want your Amazon associate information in the feed. May as well :-).

The one parameter that might be confusing is &#...

Continue Reading →

noconfigured for

If you are using Jeweler and get this error:

no configured for

Check out the troubleshooting section:

You need to edit ~/.rubyforge/auto-config.yml and make sure processor_ids is set like this:

processor_ids:
        IA64: 6000
        AMD-64: 1500
        Any: 8000
        Sparc: 4000
        PPC: 2000
        Other: 9999
        Alpha: 7000
        i386: 1000
        UltraSparc: 5000
        MIPS: 3000

Continue Reading →

newgem

I've been using newgem to build Babelphish (translation helper thing). The docs from the ruby forge site are a bit out of date. If you use newgem to build anything be sure to look at this post from Dr Nic and pay attention to the options you can pass in. In particular I noticed that the instructions on the rubyforge site indicate the gem will build a default website. If you want to do that you need to pass in the -w option.

Continue Reading →

Mountain West Ruby Conference

I've been to a good number of conferences over the years. A lot of them cost a lot of money. If you are a geek and a ruby lover (who isn't?) then the best event you'll ever attend is the Mountain West Ruby conference. The schedule is up.

It's only a hundred bucks and the best of the best show up. Get registered now so you don't hate yourself in the morning.

Continue Reading →

Ruby Grand Masters

I spent two years in Japan. While there I met all kinds of interesting people. I remember one individual in particular because he was a chess grand master. He was also very good at Shogi. In fact he had written Shogi the video game for Nintendo.

I like chess and so we played a game. I thought I was a pretty good player. I used to be able to beat most casual players I met. He slaughtered me in about 10 moves. I kind of expected that. It was the most elegant butt kicking I have ever received. Grand masters think different than the rest of us. I don't remember how he beat me, but I do remember that it was smooth, quick and brutal.

This weekend I spent time with the Ruby Grand Masters. In my opinion there isn't a better Ruby conference than the Mountain West Ruby conference. The hackers show up. These guys are all about being the very best - not for money but for love of the language. Here's a list of the guys I could gather up. I am sure there were many others who didn't p...

Continue Reading →

More Ruby Conference

We missed the first talk this morning (sorry Devlin we suck). I slept till 9:30, but mainly because we were up till 4am. Dave South gave me some great info on using TestSpec. RSpec seems to be the hot thing right now, but I like how TestSpec is lightweight:

Install the gem: sudo gem install test-spec

Install the plugin: ./script/plugins install http://svn.techno-weenie.net/projects/plugins/test\_spec\_on_rails/

Require in test_helper: require 'test/spec/rails'

I spent a good part of last night rewriting some tests to use TestSpec. I also eavesdropped on a conversation the guys from EngineYard were having. They are showing their leadership in the Ruby community by sponsoring Rubinius, merb, and Datamapper, but when you listen to how knowledgeable their team you realize that they are going to play a large leadership role in the Ruby community going forward. They are awesome.

Continue Reading →

Using Amazon’s Web Services from Ruby – Jonathan Younger

Right Scale has a great gem: gem install right_aws RightScale RightAws::Sqs RightScale RightAws::Ec2

They will automatically retry errors for you.

gem install kato Kato - EC2 Pool Manager


require 'rubygems'
requrie 'right_aws'
RightAws::RightAWSParser.xml_lib = 'libxml'

SQS = RightAws::Sqs.new(access_id, access_key) #get an SQS object queue = SQS.queue("name_of_queue") #create a or get a reference to an existing queue queue.psuh "put message in the queue" #8k max queue.size # get an approximate number of message in the queue message = queue.receive # message.delete # if you don't delete your messages they will show up again


require 'rubygems'
requrie 'right_aws'
RightAws::RightAWSParser.xml_lib = 'libxml'
EC2 = RightAsw::Ec2.new(access_id, access_key)
EC2.describe_instances # get a hash of running instances
EC2.run_instances("name_of_ami", minium_instances_to, max) # start up instances
EC2.terminate_in...

Continue Reading →

Ruby fs-api

I am in the Ruby-fs API presentation now. Funding for the library came from USFamilyTree.com.

It is REST based.

Data model is: Person Person has many Assertions Assertion has one Contributor, Citation(not yet implemented), Note

Each person has a lot of data associated with them so you don't want to be parsing xml data on the fly.

Include the library with this: require 'family_tree_api/client'

The library will handle turning all the data into objects for you. This makes access to the API slick. I love ruby. ie


person = client.summary_person 'KW3B-2L7', descendants => 2
mother = person.mother
grandmother = person.mother.mother


search_params = {:givenName => 'Parker', :familyName => 'Flech'}
results = client.search search_params

As with all things Ruby this API makes it very easy to talk to FamilySearch. If you are in the genealogy space and know Ruby give it a try.

The good news is that they are open to patches. The project is in acti...

Continue Reading →

Review of Ozmozr code at Ruby Mountain West Conference

Jamis Buck blogged about the code review of Ozmozr he and Marcel did at the Mountain West Ruby Conference. The presentation was our favorite because of the insight it gave into our code and I think we came away as better programmers for it. Here is the link to the presentation on Conference Freaks and if you want the source code they reviewed you can find it on Source Forge.

Continue Reading →