Skip to content

Instantly share code, notes, and snippets.

View TheLarkInn's full-sized avatar
🦀
Getting Rusty

Sean Larkin TheLarkInn

🦀
Getting Rusty
View GitHub Profile
@TheLarkInn
TheLarkInn / TableModelGeneratorSequel.rb
Created September 19, 2013 15:26
Way to create models for all tables in a MySQL database using Sequel, and Sequel's Sequel::Model() command.
require 'sequel'
DB = Sequel.connect('mysql://root@localhost/macpractice')
tables_array = DB["show tables"].all.map {|x| x[:"Tables_in_macpractice"]}
tables_array.each {|table_name| instance_variable_set("@#{table_name}", Sequel::Model(table_name.to_sym))}
@TheLarkInn
TheLarkInn / MakeUp.coffee
Created September 12, 2013 18:39
MakeUp.coffee
class window.MakeUp
keyMap: {65:'a', 66:'b', 67:'c', 68:'d', 69:'e', 70:'f', 71:'g', 72:'h', 73:'i', 74:'j', 75:'k', 76:'l', 77:'m', 78:'n', 79:'o', 80:'p', 81:'q', 82:'r', 83:'s', 84:'t', 85:'u', 86:'v', 87:'w', 88:'x', 89:'y', 90:'z', 48:0, 49:1, 50:2, 51:3, 52:4, 53:5, 54:6, 55:7, 56:8, 57:9, 96:0, 97:1, 98:2, 99:3, 100:4, 101:5, 102:6, 103:7, 104:8, 105:9, 190:'.', 8:"delete", 37:"left", 39:"right", 91:"cmd", 9:"tab", 16:"shift"}
format: ''
constructor: (inputType, @el) ->
switch inputType
when "phone" then @formatForPhone()
when "date" then @formatForDate()
when "numbers" then @formatForNumbers()
when "numbers-with-decimals" then @formatForNumbers("decimals")
when "email" then @formatForEmail()
@TheLarkInn
TheLarkInn / benchmarktest.rb
Created May 17, 2013 15:07
Benchmarking test requested from stackoverflow for a question.
n = 50_000_000
bmp = Proc.new do
Benchmark.bm do |x|
x.report {n.times do; a = "1"; end}
x.report {n.times do; a = "1"; end}
x.report {n.times {a = "1"}}
end
end