This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# example list of names generated from http://listofrandomnames.com/ | |
# tweakable values | |
PREFIX = 3 | |
MAX_LENGTH = 30 | |
MIN_WORDS = 2 | |
MAX_WORDS = 3 | |
# create dictionary from corpus of names | |
dict = Hash.new { |h,k| h[k] = [] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MNB | |
def initialize(examples) | |
@examples = examples.map { |ex| [ex.first.gsub(/[^a-zA-Z]/, ' ').downcase.split, ex.last] } | |
@buckets = @examples.map { |ex| ex.last }.uniq | |
@vocab_size = @examples.map { |ex| ex.first }.flatten.uniq.count | |
@prob_bucket = Hash.new do |hash, bucket| | |
hash[bucket] = @examples.count { |ex| ex.last == bucket } / @examples.count.to_f | |
end | |
@prob_word_given_bucket = Hash.new do |hash, word_bucket| | |
word, bucket = word_bucket.split('__') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[user] | |
email = <YOUR EMAIL> | |
name = <YOUR NAME> | |
[color] | |
diff = auto | |
status = auto | |
branch = auto | |
interactive = auto | |
ui = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source ~/git-prompt.sh | |
source ~/git-completion.bash | |
PS1='\u:\w\[\033[32m\]$(__git_ps1)\[\033[0m\]$ ' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sys import argv | |
from collections import defaultdict | |
from random import choice | |
class DefaultList(list): | |
def __getitem__(self, idx): | |
try: | |
return super().__getitem__(idx) | |
except IndexError: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'json' | |
require 'haml' | |
require 'sinatra' | |
get '/' do | |
haml :view | |
end | |
get '/request' do | |
content_type :json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
require 'haml' | |
require 'json' | |
enable :sessions | |
get '/' do | |
session[:answer] = %w[A B C D].sample | |
haml :index | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
require 'jimson' | |
class Api | |
extend Jimson::Handler | |
def get_data | |
{'foo' => 'bar'} | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%w[sinatra watir-webdriver].each { |gem| require gem } | |
class MyApp < Sinatra::Base | |
get('/') { "hello world" } | |
end | |
class AppRunner | |
def initialize |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# R. Scott Reis - Implementation of Prim's Algorithm | |
# http://en.wikipedia.org/wiki/Prim%27s_algorithm | |
require 'sinatra' | |
require 'haml' | |
require 'json' | |
module Prim | |
class << self | |
def get_graph |