Skip to content

Instantly share code, notes, and snippets.

View ricburton's full-sized avatar
🎯
Focusing

Richard Burton ricburton

🎯
Focusing
View GitHub Profile
@ricburton
ricburton / instascrape.rb
Created November 28, 2011 09:01
Instagram scraper using mechanize
require 'rubygems'
require 'mechanize'
require 'uri'
url = "http://instagr.am/p/WOkyj"
@mech = Mechanize.new
@page = @mech.get(url)
@ricburton
ricburton / kindling.rb
Created November 29, 2011 08:53
Kindling
=begin
The Kindle clippings are each accompanied with a lot of useful information. However, when you're scanning over them it can get annoying to keep seeing them formatted as such:
the mystical process of extracting value (money) from idle IP assets
==========
Essentials of Licensing Intellectual Property (Alexander I. Poltorak, Paul J. Lerner)
- Highlight on Page 16 | Added on Friday, 25 November 11 10:42:19 Greenwich Mean Time
The script below is a tiny bit of ruby that will strip out all the dross and leave behind:
@ricburton
ricburton / girl_text_parser.rb
Created December 6, 2011 13:45
How to know if a chick is into you.
if text.reply <= 1 hour
girl.interested = true
elsif text.reply.include? '?'
girl.interested = true
elsif
girl.interested = false
end
@ricburton
ricburton / Gemfile.rb
Created December 15, 2011 12:31
How to get rails 3.1 apps to run on Heroku
source 'http://rubygems.org'
gem 'rails', '3.1.1'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
gem 'execjs'
gem 'therubyracer'
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/HTML" xmlns:fb="http://www.facebook.com/2008/fbml" lang="en" xml:lang="en">
<head>
<!--
mm `7MM
MM MM
,pP"Ybd mmMMmm ,6"Yb. `7Mb,od8 MM ,MP'`7MMpMMMb. .gP"Ya ,pP"Ybd ,pP"Ybd
8I `" MM 8) MM MM' "' MM ;Y MM MM ,M' Yb 8I `" 8I `"
`YMMMa. MM ,pm9MM MM MM;Mm MM MM 8M"""""" `YMMMa. `YMMMa.
@ricburton
ricburton / dashboard_query
Created August 6, 2012 10:07
dashboard query in need of cosmetic surgery
class AnalyticsController < ApplicationController
def download
consumer = OAuth::Consumer.new('******.apps.googleusercontent.com', '******',
{:site => 'https://www.google.com',
:request_token_path => '/accounts/OAuthGetRequestToken',
:access_token_path => '/accounts/OAuthGetAccessToken',
:authorize_path => '/accounts/OAuthAuthorizeToken'}
@ricburton
ricburton / rails_adsense_API.rb
Created August 18, 2012 21:22
An attempt at accessing the AdSense API from Rails
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :check_auth
def check_auth
@client = Google::APIClient.new
@client.authorization.client_id = '************.apps.googleusercontent.com'
@client.authorization.client_secret = '***************'
@ricburton
ricburton / pipedrive_error.rb
Created September 25, 2012 08:11
Pipedrive API error
def self.create_deal(title, value)
post("/deals/title=#{title}&value=#{value}")
end
#threw this error: // #<HTTParty::Response:0x10f4cbf98 parsed_response={"success"=>false, "error"=>"Internal Server Error occurred. Pipedrive staff was notified about this."}, @response=#<Net::HTTPInternalServerError 500 Internal Server Error readbody=true>, @headers={"connection"=>["close"], "server"=>["nginx/0.7.67"], "access-control-allow-origin"=>["*"], "content-type"=>["application/json, charset=UTF-8"], "content-length"=>["100"], "x-powered-by"=>["PHP/5.3.3-7+squeeze8"], "date"=>["Tue, 25 Sep 2012 08:09:34 GMT"]}>
@ricburton
ricburton / visibility.rb
Created January 13, 2013 09:41
Visibility is not security.
class Test
attr_reader :state
def initialize(state)
@state = state
end
private
def update_state(state)
@state = state
%w(a b c d e f).map(&:to_s) # => ["a", "b", "c", "d", "e", "f"]
%w(a b c d e f).pop # => "f"
%w(a b c d e f).fetch(3) # => "d"
%w(a b c d e f).join(', ') # => "a, b, c, d, e, f"