Skip to content

Instantly share code, notes, and snippets.

View ulfmagnetics's full-sized avatar

John Berry ulfmagnetics

  • Ulf Magnetics, LLC
  • Pittsburgh, PA
View GitHub Profile
@maxivak
maxivak / readme.md
Last active January 12, 2024 06:53
Integrating Gem/Engine and Main Rails App
@demisx
demisx / active_record_objects_autosave.md
Last active February 26, 2024 17:31
When Active Record Child Objects are Autosaved in Rails

belongs_to:

  1. Assigning an object to a belongs_to association does not automatically save the object. It does not save the associated object either.

has_one:

  1. When you assign an object to a has_one association, that object is automatically saved (in order to update its foreign key).
  2. In addition, any object being replaced is also automatically saved, because its foreign key will change too
  3. If either of these saves fails due to validation errors, then the assignment statement returns false and the assignment itself is cancelled.
  4. If the parent object (the one declaring the has_one association) is unsaved (that is, new_record? returns true) then the child objects are not saved. They will automatically when the parent object is saved.
@tomas-stefano
tomas-stefano / Capybara.md
Last active April 10, 2024 15:27
Capybara cheatsheet

Capybara Actions

# Anchor
click_link 'Save'

# Button
click_button 'awesome'

# Both above
@rschuman
rschuman / install_tmux_centos.md
Last active July 26, 2018 12:51
Installation of most recent libevent2 and tmux on CentOS. Compile flags borrowed from https://gist.github.com/sturadnidge/4185338
@ulfmagnetics
ulfmagnetics / gist:2040692
Created March 15, 2012 00:27
Chef on EC2
# -- assuming homebrew is up and running already
$ brew install ec2-api-tools
# -- get root X509 credentials from the AWS Security Credentials page
# -- place pk and cert pem files in $HOME/.ec2
# -- add the following into $HOME/.bash_profile:
# export REGION='us-west-1'
# export EC2_KEYPAIR="$HOME/.ssh/ec2-$REGION.pem"
@levity
levity / rspec-syntax-cheat-sheet.rb
Created November 28, 2011 20:10 — forked from dnagir/rspec-syntax-cheat-sheet.rb
RSpec 2 syntax cheat sheet by example
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
@shapeshed
shapeshed / unicorn
Created September 16, 2011 10:12
Unicorn / Monit setup
#!/bin/sh
set -e
# Example init script, this can be used with nginx, too,
# since nginx and unicorn accept the same signals
# Feel free to change any of the following variables for your app:
TIMEOUT=${TIMEOUT-60}
APP_ROOT=/path/to/your/app/current
PID=$APP_ROOT/tmp/pids/unicorn.pid
ENVIRONMENT=production
@igrigorik
igrigorik / ruby-1.9-tips.rb
Created February 3, 2011 17:19
Ruby 1.9 features, tips & tricks you may not know about...
def tip(msg); puts; puts msg; puts "-"*100; end
#
# 30 Ruby 1.9 Tips, Tricks & Features:
# http://www.igvita.com/2011/02/03/new-ruby-19-features-tips-tricks/
#
tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2"
tip "Ruby 1.9 supports named captures in regular expressions!"