Skip to content

Instantly share code, notes, and snippets.

View tomdepplito's full-sized avatar

Tom Depplito tomdepplito

View GitHub Profile
@tomdepplito
tomdepplito / utils_spec.rb
Created October 30, 2012 21:20
utils_spec.rb
context '#ban_devices' do
before :each do
@device1 = FactoryGirl.create(:device)
device2 = FactoryGirl.create(:device)
click1 = FactoryGirl.create(:click, :udid => @device1.id)
click2 = FactoryGirl.create(:click, :udid => device2.id)
notes = {'date' => '10/24/12', 'reason' => 'fraud'}
@click_hash = {click1.id => notes, click2.id => notes}
@num_banned = Utils.ban_devices(@click_hash)
end
@tomdepplito
tomdepplito / linkedin_parse.rb
Created July 10, 2012 04:09
Linkedin Parsing Example
require 'oauth'
require 'launchy'
require 'nokogiri'
class User
def authenticate(consumer_key, consumer_secret, site)
consumer = OAuth::Consumer.new(consumer_key, consumer_secret, site)
request_token = consumer.get_request_token
puts "Authorize Follower and then paste in the PIN:"
@tomdepplito
tomdepplito / Tweet Roulette
Created June 18, 2012 03:09
Tweet Roulette
require 'rubygems'
require 'twitter'
require 'oauth'
consumer_key = "xxx" #Enter your key here
consumer_secret = "xxx" #Enter your secret here
oauth_consumer = OAuth::Consumer.new(consumer_key, consumer_secret,
:site => 'http://api.twitter.com',
:request_endpoint => 'http://api.twitter.com',
@tomdepplito
tomdepplito / Book Class
Created June 15, 2012 05:33
This class creates a book with a user-generated title. The title method will then take the lowercase title string and capitalize only the important words.
class Book
attr_accessor :title
def title
low_words = ['the', 'in', 'a', 'an', 'and' ]
array_words = @title.split
first_word = array_words[0].split(//)
first_word[0].upcase!
array_words[0] = first_word.join
joined_words = []