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 'active_record' | |
# | |
# When run from the root directory of a Rails project, this code will dump the data | |
# of all models inheriting from ActiveRecord. The data is dumped to .yml files in the | |
# db directory of the Rails app. | |
# | |
# This code is not very fast, as it starts up Rake for each model. It could use improvement. | |
# | |
# ------ Dependency on ar_fixtures ------- |
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
pry(main)> load "#{Rails.root}/lib/yourfile.rb" | |
Thanks to "NulRef" | |
This info from http://stackoverflow.com/questions/6361401/can-rails-console-reload-modules-under-lib |
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
def current_club | |
if session[:user_id].nil? | |
@club = Club.find(1) | |
else | |
Club.find(current_member.club_id) | |
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
# 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', |
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 DataType | |
def self.STRING | |
:STRING | |
end | |
def self.DATE | |
:DATE | |
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
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 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 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 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 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 |
OlderNewer