Skip to content

Instantly share code, notes, and snippets.

View tylerpearson's full-sized avatar

Tyler Pearson tylerpearson

View GitHub Profile
@tylerpearson
tylerpearson / array.rb
Created October 6, 2014 01:46
PayPal blocked 2 letter country codes
['AF', 'AQ', 'CI', 'CU', 'BY', 'BV', 'IO', 'CM', 'CF', 'CX', 'HT', 'HM', 'IR', 'IQ', 'KR', 'LA', 'LB', 'LR', 'LY', 'MM', 'NG', 'PK', 'PG', 'RS', 'SD', 'SY', 'ZW', 'VN', 'BD']
@tylerpearson
tylerpearson / copy_github_labels.rb
Last active January 11, 2022 15:27
Super simple script to copy Github tag labels from one repository to another. Uses the Octokit gem.
require 'octokit'
# https://help.github.com/articles/creating-an-access-token-for-command-line-use/
client = Octokit::Client.new(:access_token => "getmefromgithub")
COPY_FROM_REPO = "repo/old"
COPY_TO_REPO = "repo/new"
current_labels = client.labels(COPY_FROM_REPO)
@tylerpearson
tylerpearson / remove.md
Last active August 29, 2015 14:12
remove conflicted dropbox files

find . -type f -name "* conflicted *" -exec rm -f {} \;

@tylerpearson
tylerpearson / results.txt
Created January 4, 2015 00:41
most common words in my Twitter followers' bios (with punctuation stripped and stop words skipped)
i: 135
west: 89
virginia: 74
media: 55
marketing: 51
wv: 49
social: 46
news: 38
political: 38
love: 37
@tylerpearson
tylerpearson / results.txt
Last active August 29, 2015 14:12
most common words in the bios of the people I follow on Twitter (downcased, with most punctuation stripped and stop words removed)
director: 66
news: 61
web: 54
digital: 53
politics: 52
twitter: 50
design: 49
founder: 44
tweets: 43
former: 43
@tylerpearson
tylerpearson / twitter_bio_word_analyzer.rb
Last active August 29, 2015 14:12
A Ruby script to find the most commonly used words in the bios of accounts a user follows on Twitter
require 'twitter'
# change this to your own info to get the script to work
# get it from https://apps.twitter.com/
client = Twitter::REST::Client.new do |config|
config.consumer_key = "XXX"
config.consumer_secret = "XXX"
config.access_token = "XXX"
config.access_token_secret = "XXX"
@tylerpearson
tylerpearson / nyt.txt
Last active August 29, 2015 14:12
most common words in the Twitter bios of New York Times staff (downcased, with most punctuation stripped and stop words removed)
new: 514
times: 497
york: 483
editor: 264
reporter: 138
@nytimes: 101
author: 83
correspondent: 71
bureau: 60
nyt: 60
@tylerpearson
tylerpearson / pass_with_subjects.rb
Last active August 29, 2015 14:20
Calculate the percentage of sponsored bills passed (as primary and cosponsor) for each delegate with a breakdown of bill subjects. These results are for WV House during the 2011 session, but the script should be able to be modified to be used with any JSON dump from the Sunlight Foundation Open States API.
require 'httparty'
require 'json'
require 'pp'
require 'uri'
require 'hashie'
def load_json(filename)
Hashie::Mash.new(JSON.parse(IO.read(filename)))
end
var fs = require('fs');
var request = require('request');
var cheerio = require('cheerio');
console.log("Starting scraping");
var allResults = [];
for (var chapter=1; chapter <= 168; chapter++) {
@tylerpearson
tylerpearson / unicorn.rb
Created June 1, 2015 23:14
Unicorn + Octopus on Heroku
worker_processes Integer(ENV["WEB_CONCURRENCY"] || 4)
timeout 15
preload_app true
before_fork do |server, worker|
Signal.trap 'TERM' do
puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
Process.kill 'QUIT', Process.pid
end