Skip to content

Instantly share code, notes, and snippets.

View mdarby's full-sized avatar
💭
pending validation

Matt Darby mdarby

💭
pending validation
View GitHub Profile
someFunction: (date) ->
startOfMonth = date.beginningOfMonth()
endOfMonth = date.endOfMonth()
console.log startOfMonth.format('{MM}-{DD}-{YYYY}')
console.log endOfMonth.format('{MM}-{DD}-{YYYY}')
console.log '---'
# I call someFunction() with the SugarJS Date objects representing "12-09-2011" and "01-09-2012" and get this in the console:
@mdarby
mdarby / gist:1334638
Created November 2, 2011 19:31 — forked from bramhaghosh/gist:1334453
something stupid w/ polymorphic associations
class Deal < ActiveRecord::Base
belongs_to :store
has_many :categories, :as => :categorizable
end
class Store < ActiveRecord::Base
has_many :deals
has_many :categories, :as => :categorizable
has_many :coupons, :through => :categories
end
class MeetingDates
def initialize
@crb_dates = []
@jam_dates = []
calc_meeting_dates
end
def calc_meeting_dates
start_date = Date.today.beginning_of_year
(0..12).inject([]){|s, num| dates_for_month(start_date + num.months)}
GameRouter = new Backbone.Router.extend
routes:
"draw": "draw"
initialize: ->
this.gameView = new GameView()
Backbone.history.start()
draw: ->
this.gameView.draw();
And I add all of the following vehicles | SerialNumber | Year | Make | Model/Body/Type | Vehicle Type | Cost | Vehicle Used For | Gross Weight | Usage | Radius | Type Operation | Additional Insured Apply | | 5FNRL386X7B036167 | 2007 | Honda | Odyssey Exl | Private Passenger | 31095 | Business Purposes | | | | | No | | 5TEUU42N88Z573326 | 2008 | Toyota | Tacoma Acces | Private Passenger | 23110 | Business Purposes | | | | | No |
@mdarby
mdarby / gist:1031444
Created June 17, 2011 13:49
asdfasdf
And I add all of the following vehicles
| SerialNumber | Year | Make | Model/Body/Type | Vehicle Type | Cost | Vehicle Used For | Gross Weight | Usage | Radius | Type Operation | Additional Insured Apply |
| 5FNRL386X7B036167 | 2007 | Honda | Odyssey Exl | Private Passenger | 31095 | Business Purposes | | | | | No |
| 5TEUU42N88Z573326 | 2008 | Toyota | Tacoma Acces | Private Passenger | 23110 | Business Purposes | | | | | No |
set list " Show special characters
set backspace=indent,eol,start " Make backspace behave
set nohidden " Close the buffer when I close the tab
set splitright " Open vertical splits to the right
set splitbelow " Open horizontal splits to the bottom
set foldmethod=syntax " Fold based on the code at hand
set foldnestmax=20 " Only fold three levels
set autoread " Read in changed files
set magic " Better regexes
set nobackup " Dont' worry about backing up files
Given I am on "page_name"
When I go to "page_name"
When I press "button"
When I follow "link"
When I follow "link" within "area"
When I fill in "text_field" with "text"
When I fill in "text" for "text field"
When I select "value" from "select box"
When I check "check_box"
When I uncheck "check_box"
class Car
attr_accessor :vin_number
end
my_car = Car.new
my_car.to_s => "Car#<79860879878>"
# to_s is already defined via Object.to_s. Since Car inherits from Object, we get it for free.
# We can also redefine it to make it more useful too:
set guioptions=aAce " Turn of MacVim's toolbar, scrollbars, etc.
set transparency=0 " No transparency
set guifont=Monaco:h12 " Default font
set list " Show special characters
set backspace=indent,eol,start " Make backspace behave
set nohidden " Close the buffer when I close the tab
set splitright " Open vertical splits to the right
set splitbelow " Open horizontal splits to the bottom
set foldmethod=syntax " Fold based on the code at hand
set foldnestmax=3 " Only fold three levels