Skip to content

Instantly share code, notes, and snippets.

View tygern's full-sized avatar

Tyson Gern tygern

View GitHub Profile
@tygern
tygern / name_probability
Created July 9, 2013 13:37
Calculate the probability that two people in a given group will have the same first initial and last name.
#!/usr/bin/env ruby
# Get name file from https://www.census.gov/genealogy/www/data/1990surnames/names_files.html
names = File.readlines('dist.male.first.txt')
list = {}
letters = ('A'..'Z')
total_people = 40000
last_name_freq = 0.01006 # Smith
letters.each do |letter|
@tygern
tygern / external_service_spec.rb
Last active August 29, 2015 13:57
External service test environment
class ExternalEnvironment
def initialize
@account_ids = []
yield self
ensure
clean_up
end
def create_account(data)
account = External::Account.create(data)
@tygern
tygern / application_controller.rb
Last active August 29, 2015 14:06
Repositories Provider
def repositories(repositories_provider = RepositoriesProvider)
@repositories ||= repositories_provider.new()
end
@tygern
tygern / python_resources.md
Last active August 29, 2015 14:08
Python Resources

Python Resources

Repositories

  • Mercury is a sample todo api app that I've been working on.
  • Overholt is a large, well-structured Flask app. It has great documentation and explanations here.
  • There's also a very nice large Flask app example here.
  • Flask OpenID example

Official documentation

@tygern
tygern / gist:6e22a66b08077027ea4c
Last active August 29, 2015 14:22
component generators
rails plugin new components/users --full --mountable --skip-sprockets --skip-spring --database=postgresql --skip-javascript --skip-turbolinks --skip-test-unit --skip-git --skip-keeps --dummy-path=spec/dummy --full --skip-bundle
rails plugin new components/users --full --mountable --skip-sprockets --skip-spring --skip-javascript --skip-turbolinks --skip-test-unit --skip-git --skip-keeps --dummy-path=spec/dummy --full --skip-bundle --skip-active-record
@tygern
tygern / addRemote.sh
Created August 26, 2015 11:17
Git Subtrees - add remote
git remote add ghpages \
https://github.com/[USERNAME]/[USERNAME].github.io.git
git add .
git commit -m "Initial deploy to GitHub Pages"
git subtree push --prefix dist gh-pages master
@tygern
tygern / folderStructure.txt
Created August 26, 2015 13:11
Git Subtrees - folder structure
my_application/
server/
client/
@tygern
tygern / push.sh
Created August 26, 2015 13:12
Git Subtrees - push command
git subtree push --prefix server heroku master
@tygern
tygern / zippy_environment.rb
Created August 26, 2015 13:13
Testing External Services - ZippyEnvironment
class ZippyEnvironment
def initialize
@account_ids = []
yield self
ensure
clean_up
end
def create_account(data)
account = Zippy::Account.create(data)
@tygern
tygern / sample_spec.rb
Created August 26, 2015 13:15
Testing External Services - Sample Spec
describe "Some feature" do
it "behaves as expected" do
ZippyEnvironment.new do |zippy|
account = zippy.create_account(
name: "Pat",
email: "[email protected]"
)
# test your feature here
end