Skip to content

Instantly share code, notes, and snippets.

View kenmazaika's full-sized avatar

ken mazaika kenmazaika

View GitHub Profile
@kenmazaika
kenmazaika / ebay.yml
Created November 9, 2010 03:49
Call the eBay API from Rails using HTTParty. Works in Rails 3, since it's calling the API directly.
development:
dev_id: 00000000000000000
app_id: 00000000000000000
cert_id: 0000000000000000
uri: https://api.sandbox.ebay.com/ws/api.dll
auth_token: 00000000000000
@kenmazaika
kenmazaika / zip_strip_split_flatten.rb
Created December 6, 2010 19:18
Turn a line into a hash of symbols delineated by a tab
Hash[*([:field1, :field2].zip(l.strip.split(/\t/)).flatten)]
@kenmazaika
kenmazaika / routes.rb
Created December 9, 2010 16:31
Allow a period to be restfully passed in url
post 'magic_wand/:id' => 'controller#action', :constraints => { :email => /.*/ }
@kenmazaika
kenmazaika / Gemfile
Created December 27, 2010 21:24
Access Facebook API through Koala interface using Authlogic Connect Login
gem 'koala'
@kenmazaika
kenmazaika / Gemfile
Created December 27, 2010 21:33
Post to twitter after going through Oauth for Twitter
gem 'twitter_oauth', :git => 'git://github.com/moomerman/twitter_oauth.git'
@kenmazaika
kenmazaika / git_commands
Created December 29, 2010 15:37
Non-Trivial Git Commands I occasionally use
Uncommit. Set the head of the branch to 1-head and stage the changes.
git reset --soft HEAD^
@kenmazaika
kenmazaika / authlogic_connect_facebook_oauth_key.rb
Created December 30, 2010 16:02
Grab a new facebook token using AuthLogic connect
def facebook
if(params[:code])
token = HTTParty.get('https://graph.facebook.com/oauth/access_token', :query => {'client_id' => AuthlogicConnect.config[:connect][:facebook][:key], 'redirect_uri' => facebook_url, 'client_secret' => AuthlogicConnect.config[:connect][:facebook][:secret], 'code' => params[:code]}).body.gsub(/\Aaccess_token=/, '')
return render :text => {:token => token }.inspect
end
# Bounce the user to the Facebook, this gets hit on the first entrance to the url
params.merge!({:oauth_provider => 'facebook', :authentication_type => 'session'})
@user_session = UserSession.new
@kenmazaika
kenmazaika / test_helper.rb
Created January 5, 2011 21:33
Auto Hooks up tests to use VCR.
module Module
class Klass
class << self
def find_with_vcr(*args)
VCR.use_cassette('klass', :record => :new_episodes) do
find_without_vcr(*args)
end
end
alias_method_chain :find, :vcr
end
@kenmazaika
kenmazaika / gist:786357
Created January 19, 2011 16:01
formtastic_non_ar.rb
include ActiveModel::Conversion
@kenmazaika
kenmazaika / Combo-Selector-In-Ruby-Test.rb
Created February 2, 2011 16:57
CSS Selector in Ruby Test
try this if need to again:
assert_select option[selected='selected'], /9pm/