This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FactoryGirl.define do | |
| factory :user do | |
| sequence(:username) { |n| "bob-#{n}" } | |
| email { |u| "#{u.username}@example.com" } | |
| password 'password123' | |
| # the following works: | |
| factory :bob do username 'bob' end | |
| # but this does not: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'spec_helper' | |
| # spec/acceptance/thing_spec.rb | |
| feature "Viewing a thing" do | |
| let(:thing) { Factory.create(:thing, name: "I'm a thing!") } | |
| scenario "show a summary of the thing" do | |
| visit thing_path(thing) | |
| page.should have_text "I'm a thing!" | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This is a record, as in a vinyl. | |
| class Record < ActiveRecord::Base | |
| belongs_to :user | |
| belongs_to :album | |
| end | |
| class Album < ActiveRecord::Base | |
| has_many :records | |
| belongs_to :artist | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This is a record, as in a vinyl. | |
| class Record < ActiveRecord::Base | |
| belongs_to :user | |
| belongs_to :album | |
| # explicitly stating what is needed | |
| def from_library_for_album(collector, album) | |
| where(user_id: collector).where(album_id: album) | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class PageName | |
| @pages = { | |
| "Super Awesome Page" => "bad-ass-page-name-2", | |
| "Secret Page" => :secret_page_as_symbol | |
| } | |
| def self.[](name) | |
| @pages.fetch(name) { |n| n.gsub(/\s/, '') } | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace :db do | |
| desc 'export the shit' | |
| task :export => [:environment] do | |
| require 'csv' | |
| ActiveRecordize('Brewery', 'Beer', 'Style', 'Category', 'Geocode') do |model| | |
| CSV.open("#{model.table_name}.csv", 'wb') do |csv| | |
| csv << model.column_names | |
| model.find_each { |m| csv << m.attributes.values } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'win32ole' | |
| # Connect to the WMI WebAdministration namespace. | |
| web_admin = WIN32OLE.connect("winmgmts:root\\WebAdministration") | |
| app_pool = web_admin.get("ApplicationPool.Name='DefaultAppPool'") | |
| app_pool.stop | |
| app_pool.start | |
| app_pool.recycle |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # An example usage might look something like: | |
| class MyApp | |
| extend Verver::SandboxedExecute | |
| def initialize(options) | |
| # ... | |
| end | |
| # ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /etc/zshenv | |
| ~/.zshenv | |
| # if login shell | |
| /etc/zprofile | |
| ~/.zprofile | |
| #if interactive shell | |
| /etc/zshrc | |
| ~/.zshrc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # NOTE: I pulled this straight out of a Gem I wrote to help manage/automate | |
| # the CI environment at VersionOne - hence the names and why you won't | |
| # find Verver on http://rubygems.org. Sorry. | |
| require 'delegate' | |
| require 'win32ole' | |
| module Verver | |
| module IIS |