This file contains hidden or 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 'date' | |
| require_relative './persistence.rb' | |
| require_relative './mailing_address.rb' | |
| require_relative './government_id.rb' | |
| class Person < Persistence |
This file contains hidden or 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 'securerandom' | |
| require 'pp' | |
| require 'date' | |
| # all of the associations will reference a contest season | |
| class Database | |
| def self.where &block | |
| @@data[self].select &block | |
| end |
This file contains hidden or 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
| This is a gist |
This file contains hidden or 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
| pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start |
This file contains hidden or 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 Array | |
| def to_range | |
| self.sort! | |
| highs = self.select { |x| !self.include?(x+1) } | |
| lows = self.select { |x| !self.include?(x-1) } | |
| lows.zip(highs).map { |a,b| a..b } | |
| end | |
| end |
This file contains hidden or 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 Array | |
| def to_range | |
| highs = self.select { |x| !self.include?(x+1) }.sort_by { |x| x } | |
| lows = self.select { |x| !self.include?(x-1) }.sort_by { |x| x } | |
| lows.zip(highs).map { |a,b| a..b } | |
| end | |
| end | |
| # Running tests: |
This file contains hidden or 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 'pp' | |
| require 'date' | |
| def to_range low, high, input, output | |
| if high > input.length | |
| return output.each_slice(2).map {|a| a }.map { |x| x[0]..x[1]} | |
| end | |
| if low == 0 |
This file contains hidden or 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 TimeParser | |
| attr_reader :hour, :minute, :am_pm | |
| def initialize time | |
| matched = /(1[012]|^[1-9]):[0-5][0-5] (am|pm|AM|PM)/.match(time.lstrip.squeeze(' ')) | |
| if matched | |
| @valid = true | |
| parts = matched[0].split(/[\s:]/) | |
| @hour = parts[0].to_i |
This file contains hidden or 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 DataType | |
| def self.STRING | |
| :STRING | |
| end | |
| def self.DATE | |
| :DATE | |
| end |
This file contains hidden or 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
| # the big picture... what data we're getting from where and its destination | |
| @data_binding_hash = { | |
| :@pSMSR_GRGR_ID=> [ :GRGR_ID, 'facets_field', DataType.STRING, DataSource.FACETS, '@pSMSR_GRGR_ID=""' , nil ], | |
| :@pSMSR_SBSB_ID=> [ :SBSB_ID, 'facets_field', DataType.STRING, DataSource.FACETS, '@pSMSR_SBSB_ID=""' , nil ], | |
| :@pSMSR_REL=> [ :patient_rel_code, 'rel_code', DataType.STRING, DataSource.LOOKUP, '@pSMSR_REL=""' , nil ], | |
| :@pSMSR_SSN=> [ :MEME_SSN, 'facets_field', DataType.STRING, DataSource.FACETS, '@pSMSR_SSN=""' , nil ], | |
| :@pSMSR_LNAME=> [ :SBSB_LAST_NAME, 'facets_field', DataType.STRING, DataSource.FACETS, '@pSMSR_LNAME=""' , nil ], | |
| :@pSMSR_FNAME=> [ :SBSB_FIRST_NAME, 'facets_field', |