Skip to content

Instantly share code, notes, and snippets.

View ltw's full-sized avatar

Lucas Willett ltw

View GitHub Profile
@ltw
ltw / best_model.rb
Created February 21, 2011 01:29
Order of a standard Model
class Model < ParentModel
include Foo::Bar
extend Bar::Baz
acts_as_authentic
dsl_specific_flags
module InternalModule
...
end
[:last, :this, :next].each do |week|
define_method("#{week}_week") { schedule(week) }
end
def schedule(week)
@schedule ||= YAML.load_file('schedule.yml')["schedule"]
@schedule.select {|d| date_range(week.to_sym).include?(d)}
end
def date_range(week)
def self.generate_planned_simulation(model_package_id, start_date, finish_date, increment)
start_date = Date.strptime(start_date,'%B %d, %Y')
finish_date = Date.strptime(finish_date, '%B %d, %Y')
dates = get_dates_with_interval(start_date, finish_date, increment)
activities = Activity.all(
:conditions => [
'(start_date <= :finish_date OR finish_date <= :finish_date) AND model_package_id = :model_package_id',
{ :finish_date => finish_date, :model_package_id => model_package_id }
],
test1 = [1,2,3]
test2 = [2,3,4,5,6,7,8]
unknown, known = *[test1 - test2, test1 & test2]
#=> [[1],[2,3]]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content="HTML Tidy for Windows (vers 14 February 2006), see www.w3.org" />
<title></title>
<meta http-equiv="Content-Type"
content="text/html; charset=us-ascii" />
<link href="main.css" rel="stylesheet" type="text/css" />
<!--[if lte IE 6]>