Skip to content

Instantly share code, notes, and snippets.

View johnbender's full-sized avatar

John Bender johnbender

View GitHub Profile
Vagrant::Config.run do |config|
# All Vagrant configuration is done here. For a detailed explanation
# and listing of configuration options, please check the documentation
# online.
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "base"
# Enable chef
config.vm.provisioner = :chef_solo
before :all do
user = mock(Facebooker::User)
user.should_receive(:id).any_number_of_times.and_return(1)
friend = mock('friend')
friend.should_receive(:id).any_number_of_times.and_return(4800015)
user.should_receive(:friends).any_number_of_times.and_return([friend])
user.should_receive(:friends_with_this_app).any_number_of_times.and_return([friend])
ActiveRecord::SubclassNotFound Exception: The single-table inheritance mechanism failed to locate the subclass: 'DataSource::MySpace'. This error is raised because the column 'type' is reserved for storing the class in case of inheritance. Please rename this column if you didn't intend it to be used for storing the inheritance class or overwrite DataSource.inheritance_column to use another column for that information.
class OAuthCredentialsController < ApplicationController
before_filter :source, :already_authed?
def new
#build initial request tokens
request_token, session[:unauthed_token] = @source.request_tokens
#TODO callback should be call_back_path from source id or some such
redirect_to @source.auth_url(request_token, "http://localhost:3000#{oauth_callback_path(@source.id)}")
end
class DataSource::MySpace < DataSource
#TODO move to parent OAuthDataSource class
def self.set_tokens(key, secret)
@@key = key
@@secret = secret
end
def request_tokens
#req token
class Foo < ActiveRecord::Base
end
class Bar < Foo
end
myspace.get_friends(user_id)
# resulted in
{"topFriends"=>"http://api.myspace.com/v1/users/498253142/friends?list=top",
"Friends"=>
[{"name"=>"Tom",
"uri"=>"http://api.myspace.com/v1/users/6221",
"webUri"=>"http://www.myspace.com/tom",
"largeImage"=>"http://b2.ac-images.myspacecdn.com/00000/20/52/2502_l.jpg",
"userType"=>"RegularUser",
"userId"=>6221,
data Position = Position { original :: Char,
rand_char :: Maybe Char }
instance Show Position where
show (Position x (Just y)) = show y
show (Position x (Nothing)) = show x
randomize = id
position_list :: [Char] -> [Position]
require 'myspace'
require 'pp'
#CONSUMER/SECRET removed
#our "session"
session = {}
#Build our consumer
myspace = MySpace::MySpace.new(CONSUMER_KEY, CONSUMER_SECRET)
data Position = Position { original :: Char,
rand_char :: Maybe Char }
instance Show Position where
show (rand_char x) | Just y = show y
| otherwise = show $ orignal x