Skip to content

Instantly share code, notes, and snippets.

@tannerwelsh
tannerwelsh / google_drive_parsing.rb
Created June 23, 2012 05:40 — forked from Pcushing/google_drive_parsing.rb
Log into google docs and parse the data, work in progress
require 'rubygems'
require 'google_drive'
require 'csv'
# Go get your consumer key, client_secret, and client_id for Google Drive here https://code.google.com/apis/console/
consumer_key = 'INSERT YOUR CONSUMER_KEY HERE'
client_secret = 'INSERT YOUR CLIENT_SECRET HERE'
client_id = 'INSERT YOUR CLIENT_ID HERE'
client = OAuth2::Client.new(
@tannerwelsh
tannerwelsh / twelsh_week4_ruby_solution.rb
Created July 12, 2012 21:08
Tanner's solution to the Week 4 Ruby Assessment
# DBC Week 4 Ruby Assessment
# Tanner Welsh
# ____________
######################################################################################
### PART 1 : OO Design ###############################################################
# module AddressBook
#
@tannerwelsh
tannerwelsh / recursive_touch.sh
Created September 4, 2012 22:25
Touch a new file in a directory and all of its subdirectories
#!/bin/bash
# UPDATE: This is a waste of code. This script can
# be executed in a single line:
# find * -type d -exec touch '{}/.gitkeep' \;
# Execution takes two arguments:
# 1: Name of directory to traverse
# 2: Name of file to create in each subdirectory
@tannerwelsh
tannerwelsh / find_missing_number.rb
Created September 19, 2012 05:45
Find Missing Number
# Setup an array of 99 numbers between 1 and 100, randomly sorted
@numbers = (1..1_000_000).to_a.shuffle
@numbers.delete_at(rand(1_000_000))
def sort_find
sorted = @numbers.sort
sorted.each_with_index do |n, i|
next if n == sorted[i-1] + 1 || n == 1
return n-1
#!/bin/bash
echo "Installing debugger gem..."
gem install 'debugger'
echo "Creating and modifying ~/.rdebugrc config file..."
touch ~/.rdebugrc
echo -e "set autolist\nset autoeval\nset autoreload" > ~/.rdebugrc
@tannerwelsh
tannerwelsh / gistclone
Last active December 16, 2015 15:19
Easily clone gists that you own using SSH instead of HTTP
#!/bin/bash
# <<< gistclone >>>
#
# Why clone gists with HTTP when you can use SSH?
#
# Just put this somewhere in your PATH, make it executable, and you're good to go.
#
# Usage:
# $ gistclone <gist_url> [<directory>]
require_relative "university"
University.open_db
student = University::Student.new('Tanner Welsh')
student.save
student = University::Student.new('Mike Busch')
student.save
@tannerwelsh
tannerwelsh / basicWords.js
Created March 30, 2017 19:37
Check if word is included in a set of 1000 basic English words
// List of 1000 basic English words from Wikipedia
// https://simple.wikipedia.org/wiki/Wikipedia:List_of_1000_basic_words
var BASIC_WORDS = ['a', 'about', 'above', 'across', 'act', 'active', 'activity', 'add', 'afraid', 'after', 'again', 'age', 'ago', 'agree', 'air', 'all', 'alone', 'along', 'already', 'always', 'am', 'amount', 'an', 'and', 'angry', 'another', 'answer', 'any', 'anyone', 'anything', 'anytime', 'appear', 'apple', 'are', 'area', 'arm', 'army', 'around', 'arrive', 'art', 'as', 'ask', 'at', 'attack', 'aunt', 'autumn', 'away', 'baby', 'back', 'bad', 'bag', 'ball', 'bank', 'base', 'basket', 'bath', 'be', 'bean', 'bear', 'beautiful', 'bed', 'bedroom', 'beer', 'behave', 'before', 'begin', 'behind', 'bell', 'below', 'besides', 'best', 'better', 'between', 'big', 'bird', 'birth', 'birthday', 'bit', 'bite', 'black', 'bleed', 'block', 'blood', 'blow', 'blue', 'board', 'boat', 'body', 'boil', 'bone', 'book', 'border', 'born', 'borrow', 'both', 'bottle', 'bottom', 'bowl', 'box', 'boy', 'branch', 'brave', '
@tannerwelsh
tannerwelsh / commitment.js
Created July 7, 2017 16:44
Reverse-engineering Promise (loosely)
// This is a very bare-bones (and incomplete) implementation of the idea
// behind Promise, using a new function called Commitment:
const Commitment = function(func) {
this.state = 'PENDING' // will be changed to 'FULFILLED' or 'REJECTED'
const resolve = (result) => {
this.state = 'FULFILLED'
this.resolver && this.resolver(result)
}
@tannerwelsh
tannerwelsh / Gemfile
Last active July 10, 2017 17:21
Piano Tutor
source 'https://rubygems.org'
gem 'unimidi'
gem 'midi-message'
gem 'activesupport', '~> 4.2.3'