Skip to content

Instantly share code, notes, and snippets.

View mulder's full-sized avatar

Nicholas Mulder mulder

  • Wealthsimple
  • Waterloo, Ontario
View GitHub Profile
@mulder
mulder / random_time.rb
Created November 24, 2009 16:06
Random Time
def random_time(no_older_then = 432000, now = Time.now)
oldest = now - no_older_then
Time.at(rand(no_older_then) + oldest.to_i)
end
Relation.find_all_by_to_type('Content::Article').each {|r| r.from_type,r.from_id,r.to_type,r.to_id = r.to_type,r.to_id,r.from_type,r.from_id; r.save}
Help me I git reset --hard
It is possible to recover it if Git hasn't garbage collected yet.
Get an overview of dangling commits with fsck:
$ git fsck --lost-found
dangling commit b72e67a9bb3f1fc1b64528bcce031af4f0d6fcbf
Recover the dangling commit with rebase:
@mulder
mulder / .gems
Created November 27, 2009 15:39
Host Jekyll site on Heroku!
jekyll
rails new bdd_sandbox -T
source 'http://rubygems.org'
gem 'rails', '3.0.0'
gem 'sqlite3-ruby', :require => 'sqlite3'
group :development, :test do
gem "rspec-rails", ">= 2.0.0.rc"
gem 'remarkable_activerecord', '4.0.0.alpha4'
gem install bundler
bundle install
./script/rails generate rspec:install
=> create .rspec
create spec
create spec/spec_helper.rb
create autotest
create autotest/discover.rb
rake db:migrate
rake spec
=> No examples matching ./spec/**/*_spec.rb could be found
gem install autotest autotest-growl colored
# ~/.autotest
require 'autotest/growl'
# ~/.rspec
--color
--format nested