Skip to content

Instantly share code, notes, and snippets.

View lardawge's full-sized avatar

Larry Sprock lardawge

  • Los Angeles, CA
View GitHub Profile
Rfm::Base.setup do |config| # in initializer folder
config.host 'my.host.name', 20000
config.auth 'account', 'password'
config.pem 'path/to/pem_file.pem'
config.database 'company_database'
end
Rfm::Base.host = 'my.diff_host.name' # can be overridden individually
class FmUser < Rfm::Base
@lardawge
lardawge / users_controller.rb
Created November 8, 2010 17:23
Failing spec
Failures:
1) UsersController#index returns a paginated collection
Failure/Error: assigns[:users].should be_an_instance_of(WillPaginate::Collection)
expected [#<User id: 1, name: "name-1", created_at: "2010-11-08 17:20:42", updated_at: "2010-11-08 17:20:42">, #<User id: 2, name: "name-2", created_at: "2010-11-08 17:20:42", updated_at: "2010-11-08 17:20:42">, #<User id: 3, name: "name-3", created_at: "2010-11-08 17:20:42", updated_at: "2010-11-08 17:20:42">, #<User id: 4, name: "name-4", created_at: "2010-11-08 17:20:42", updated_at: "2010-11-08 17:20:42">, #<User id: 5, name: "name-5", created_at: "2010-11-08 17:20:42", updated_at: "2010-11-08 17:20:42">] to be an instance of WillPaginate::Collection
# /Users/lar/.rvm/gems/ruby-1.9.2-p0@rspec_bug/gems/rspec-expectations-2.1.0/lib/rspec/expectations/fail_with.rb:29:in `fail_with'
# /Users/lar/.rvm/gems/ruby-1.9.2-p0@rspec_bug/gems/rspec-expectations-2.1.0/lib/rspec/expectations/handler.rb:21:in `handle_matcher'
# /Users/lar/.rvm/gems/
@lardawge
lardawge / gist:703988
Created November 17, 2010 20:12
Failing specs with rails 3.0.3 commit f1c13b0 example
class Joins < ActiveRecord::Base
belongs_to :parent
belongs_to :child
validates_presence_of :parent_id, :child_id
end
class Parent < ActiveRecord::Base
has_many :joins
has_many :children,
@lardawge
lardawge / gist:711050
Created November 23, 2010 01:00
Formtastic 1.9.2 failures
(in /Users/lar/Sites/formtastic)
.............................................................................................................................................................................................................FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................FF.FFFF..FF..............FF.........................
Failures:
1) check_boxes input for a has_many association should have input wrapper with class 'check_boxes'
@lardawge
lardawge / sunspot_kaminari_support.rb
Created June 24, 2011 16:58
Override to allow sunspot to return an array that can be used by Kaminari
module Sunspot
module Search
class AbstractSearch
private
def maybe_will_paginate(collection)
collection.instance_eval <<-RUBY, __FILE__, __LINE__ + 1
def current_page
#{@query.page}
@lardawge
lardawge / STYLEGUIDE.md
Created June 22, 2012 19:42
Myfdb Style Guide

Git

Write a good commit message.

[#123] Summary of changes under 50 characters

* More information about commit (under 72 characters)
* More information about commit (under 72 characters)
@lardawge
lardawge / custom.js
Created October 9, 2012 08:17 — forked from drewjoh/custom.js
Dynamic (AJAX) loaded Bootstrap Modal (Bootstrap 2.1)
$(document).ready(function() {
// Support for AJAX loaded modal window.
// Focuses on first input textbox after it loads the window.
$('[data-toggle="modal"]').click(function(e) {
e.preventDefault();
var url = $(this).attr('href');
if (url.indexOf('#') == 0) {
$(url).modal('open');
} else {
@lardawge
lardawge / gist:5026455
Created February 25, 2013 00:27
Cleaner way to check for partial in rails 3.2
<% if lookup_context.template_exists?("custom_header/#{@object.key}", 'parent_path', true) %>
<%= render "custom_header/#{@object.key}" %>
<% else %>
Stock header
<% end %>
@lardawge
lardawge / server_security_setup.md
Last active December 16, 2015 08:39
Initial setup for Linux

Server setup

Add

Adding initial software and deploy user

ssh root@<ip_address>
apt-get -y update
apt-get -y install curl git-core python-software-properties
apt-get -y install software-properties-common # ubuntu >= 12.10
@lardawge
lardawge / deploy.rb
Last active December 18, 2015 18:19
Restart resque workers on capistrano deploy
desc "Kill resque workers"
task :kill_processes, :roles => :god, :on_no_matching_servers => :continue do
run "cd #{deploy_to}/current && rake resque:restart_workers RAILS_ENV=#{rails_env}" do |ch, stream, data|
puts data
end
end
end