Skip to content

Instantly share code, notes, and snippets.

@jraines
jraines / deployment.md
Created May 17, 2011 21:06
21 Deployment Tips in 50 minutes

Vagrant

gem install vagrant

vagrant up

vagrant halt

  • Ruby DSL for provisioning VirtualBox VMs
  • creates a user named vagrant, with password 'vagrant'
@jraines
jraines / confident-code.md
Created May 17, 2011 19:05
Notes on Avdi Grimm's "Confident Code"

Confident Code

timid code

  • Randomly mixes input gathering, error handling, and business logic
  • imposes cognitive load on the reader

confident code

  • no digressions
@jraines
jraines / persistence.md
Created May 17, 2011 18:30
Notes on Adam Keys' presentation "Mixing a persistence cocktail"
  • Marshaling AR objects: dangerous if internal structure of AR object changes with Rails change

Relaxing consistency requirements

  • Is it ok for users to see slightly older data?

Configuring

  • Initializer that loads yaml file that loads different connections per Rails environtment
@jraines
jraines / as_dependencies_patch.rb
Created May 11, 2011 20:54 — forked from cowboycoded/as_dependencies_patch.rb
patch ActiveSupport::Dependencies to allow loading of same-name models, controllers, etc. from base Rails app and attached engines
#This goes in application.rb
require 'active_support/dependencies'
module ActiveSupport::Dependencies
alias_method :require_or_load_without_multiple, :require_or_load
def require_or_load(file_name, const_path = nil)
if file_name.starts_with?(Rails.root.to_s + '/app')
relative_name = file_name.gsub(Rails.root.to_s, '')
@engine_paths ||= Rails::Application::Railties.engines.collect{|engine| engine.config.root.to_s }
@engine_paths.each do |path|
@jraines
jraines / cucumber.md
Created May 1, 2011 21:07
Cucumber intro

##Scope and intro

I will be focusing on Rails 3 since this will be most applicable for greenfield development, and because there are Rails 2 bugs. To get started add the following to the Gemfile:

group :test do
  gem 'cucumber'
  gem 'cucumber-rails'
  gem 'capybara'
 gem 'database_cleaner'
@jraines
jraines / MacVim-Janus.md
Created May 1, 2011 20:03
Macvim & Janus

##Intro

Janus is a "basic distribution of vim plugins and tools intended to be run on top of the latest MacVIM snapshot." It is maintained by Yehuda Katz and Carl Lerche.

I recently whinged on Twitter that all I really want is vim with TextMate's Command-T go-to-file functionality and some efficient visual tab/buffer navigation. Turns out MacVim + Janus, with just a few tweaks, is all that and more.

Installing Janus

Follow the installation instructions on the git page

@jraines
jraines / gitworkflow.md
Created April 26, 2011 18:00
Git workflow

Before starting work on a feature, check out a topic branch

git checkout -b topic

If the branch is already in progress and already exists on the remote repo, check it out as a tracking branch

git checkout --track -b topic origin/topic

Push the branch to your remote repo so others can work on it

#two questions -- why does .count not return the narrowed down result set size, and why does .where seem to alter variable a?
a = Star.where(:brightness => 0)
=> #<Mongoid::Criteria:0xb6af2948 @documents=[], @options={}, @selector={:brightness=>0}, @klass=Star>
a.size
=> 1430
a.count
=> 1430
#testing the speed of creating a new object via the association with mongoid
c = Club.first
####### 43 seconds #######
begin
500.times do |i|
c.people.create(:name => 'Jim')
end
end
-unless current_user.workouts.member?(workout)
=link_to image_tag('checkin.png'), checkin_url(:workout_id => workout.id, :user_id => current_user.id)
-else
=image_tag('done.png')