Skip to content

Instantly share code, notes, and snippets.

Mike Manewitz manewitz

View GitHub Profile
manewitz / token.rb
Created May 26, 2015
Ruby String Token Generator
View token.rb
# Extracted library from a deprecated app
class Token
PREFIXES = ['ab', 'ac', 'acr', 'acl', 'ad', 'adr', 'ah', 'ar', 'aw', 'ay', 'br', 'bl', 'cl', 'cr', 'ch', 'dr', 'dw', 'en', 'ey', 'in', 'im', 'iy', 'oy', 'och', 'on', 'qu', 'sl', 'sh', 'sw', 'tr', 'th', 'thr', 'un', 'st', 'str', 'kn']
DIPTHONGS = ['ae', 'au', 'ea','ou','ei','ie','ia','ee','oo','eo','io']
CONSONANT_PAIRS = ['bb', 'bl', 'br', 'ck', 'cr', 'ch', 'dd', 'dr', 'gh', 'gr', 'gn', 'gg', 'lb', 'ld', 'lk', 'lp', 'mb', 'mm', 'nc', 'nch', 'nd', 'ng', 'nn', 'nt', 'pp', 'pl', 'pr', 'rr', 'rch', 'rs', 'rsh', 'rt', 'sh', 'th', 'tt', 'st', 'str']
POSTFIXES = ['able', 'act', 'am', 'ams', 'ect', 'ed', 'edge', 'en', 'er', 'ful', 'ia', 'ier', 'ies', 'illy', 'im', 'ing', 'ium', 'is', 'less', 'or', 'up', 'ups', 'y', 'igle', 'ogle', 'agle', 'ist', 'est']
VOWELS = ['a', 'e', 'i', 'o', 'u']
CONSONANTS = ('a'..'z').to_a - VOWELS
manewitz / progress_bar.rb
Created Jul 24, 2012
Formatador Progress Bar Example
View progress_bar.rb
# This is an example of using the progress bar feature of Formatador.
require "rubygems"
require "formatador"
require "rake"
current = 0
total = 100
# get terminal width
manewitz / 01_ubb_tracks.rb
Created Oct 9, 2012
Ultimate Breaks and Beats data
View 01_ubb_tracks.rb
# The Limit - "She's So Divine" (from CP-721 12" single) (1982)
# Kashif - "I Just Gotta Have You (Lover Turn Me On)" (from CP-728 12" single) (1982)
# Kenton Nix featuring Bobby Youngblood - "There's Never Been (No One Like You)" (from WES 22130 12" single) (1980)
# Mr. Magic - "Magic's Message (There Has to Be a Better Way)" (from POS-1213 12" single) (1984)
# Tia Monae - "Don't Keep Me Waiting" (from CART-320 12" single) (1983)
# Cloud One - "Flying High" (from HS-1010 12" single) (1982)
# Ednah Holt - "Serious, Sirius Space Party" (from WES 22138 12" single) (1981)
# Conversion - "Let's Do It" (from S-12336 12" single) (1980)
# The Monkees - "Mary Mary"* (from More of the Monkees) (1967) Colgems Records
# Wilbur "Bad" Bascomb - "Black Grass"* (from PAS-6048 7" single) (1972) Paramount Records
manewitz / rock_paper_scissors.rb
Created Oct 14, 2012
Rock Paper Scissors in Ruby
View rock_paper_scissors.rb
class WrongNumberOfPlayersError < StandardError ; end
class NoSuchStrategyError < StandardError ; end
def rps_game_winner(game)
raise WrongNumberOfPlayersError unless game.count == 2
game.each do |move|
unless VALID_MOVES.include?(move[1])
manewitz / color_demo.rb
Last active Oct 12, 2015
Formatador Presentation
View color_demo.rb
#! /usr/bin/env ruby
require "rubygems"
require "formatador"
styles = [
manewitz / fql_music_likes.rb
Created Jul 4, 2013
Playing with the Facebook API. This is aggregates music 'Likes' from your Facebook Friends list. Visit, click "Get Access Token", and assign appropriate permissions to get your token, assigning it to the FACEBOOK_GRAPH_ACCESS_TOKEN constant.
View fql_music_likes.rb
# Aggregated music 'Likes' from my Facebook Friends list
require 'koala'
# Visit
# and click "Get Access Token", assigning appropriate permissions
@graph =

Ruby/Rails Tutorial Resources

Deep breath...


manewitz / irbrc_additions.rb
Last active Jan 17, 2018
.irbrc convenience method to cleanly display Rails model associations in Rails Console
View irbrc_additions.rb
# is ActiveRecord loaded? (so it doesn't blow up IRB)
unless defined?(ActiveRecord::Base).nil?
class ActiveRecord::Base
def self.get_associations{|m| {m.class_name => m.macro} }.inject(&:merge)
View Lunch List
24 Diner
Austin Ale House
Austin Java
Bar Chi
Barley Swine
Biscuits and Groovy
Black Sheep Lodge
Black Star Co-op
You can’t perform that action at this time.