def start_timer
setTimeout(time_is_up, 2000)
end
def time_is_up
alert "Time's up!"
| # Want to show hidden files and folders in your TextMate project drawer? Simple, just modify the file and folder patterns in TextMate's preferences. | |
| # Instructions: | |
| # Go to TextMate > Preferences... | |
| # Click Advanced | |
| # Select Folder References | |
| # Replace the following: | |
| # File Pattern |
| # The current way to define and run a method in CoffeeScript: | |
| hello = (name) -> | |
| alert 'Hello ' + name | |
| hello 'Chris' | |
| # JavaScript output: | |
| var hello; |
| # Cucumber Step | |
| Then /^I should see the link "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector| | |
| matching_link = nil | |
| with_scope(selector) do | |
| all('a').each do |link| | |
| matching_link = link if link.has_content?(text) | |
| end | |
| end | |
| assert matching_link != nil, "No matching link was found" | |
| end |
| # Ruby 1.9 | |
| # Object.tap | |
| # Here we use tap to set the post factory's author (since Factory Girl doesn't create singleton instances). | |
| # Using tap passes a block where you can "tap" into the object. | |
| # At the end of the block, the object is returned. | |
| let(:author) { Factory(:author) } | |
| let(:post) { | |
| Factory(:post).tap do |p| | |
| post.update_attribute(:author, author) |
| # Validator: | |
| # /app/validators/date_validator.rb | |
| class DateValidator < ActiveModel::EachValidator | |
| def validate_each(record, attribute, value) | |
| unless value.to_s =~ /^\d{4}-\d{2}-\d{2}$/i | |
| record.errors[attribute] << (options[:message] || "is an invalid date") | |
| end | |
| end | |
| if reflection.options[:conditions] | |
| reflection_table = (reflection.options[:class_name] || reflection.options[:source] || reflection.name).gsub('::', '_').tableize | |
| if reflection.options[:conditions].to_s.include?("#{reflection_table}") | |
| send(through.name).select("DISTINCT #{through.quoted_table_name}.#{primary_key}").joins(reflection.options[:source]).where(reflection.options[:conditions]).map! { |r| r.send(primary_key) } | |
| else | |
| send(through.name).select("DISTINCT #{through.quoted_table_name}.#{primary_key}").where(reflection.options[:conditions]).map! { |r| r.send(primary_key) } | |
| end | |
| else | |
| send(through.name).select("DISTINCT #{through.quoted_table_name}.#{primary_key}").map! { |r| r.send(primary_key) } |
| // Simple SCSS mixin for adding colored bullets to your <li> elements | |
| @mixin colored-bullet($color){ | |
| list-style:none; | |
| text-indent:-19px; // Adjust the text-indent to your specific needs based on your font-size and the typeface you're using | |
| &:before{ | |
| content:"\002022\00a0\00a0\00a0"; // Add a bullet character and three spaces before your <li> content starts | |
| color:$color; // Add color to the bullet | |
| } | |
| } |
| rm -rf ~/Library/Application\ Support/TextMate/Cache/* |
| # Gemfile | |
| gem 'rails', '4.0.0' | |
| gem 'pg' | |
| gem 'sass-rails', '~> 4.0.0' | |
| gem 'compass-rails', github: 'Compass/compass-rails', branch: 'rails4-hack' | |
| gem 'uglifier', '>= 1.3.0' | |
| gem 'coffee-rails', '~> 4.0.0' | |
| # etc... | |
| # config/initializers/compass.rb |