Skip to content

Instantly share code, notes, and snippets.

View mskeen's full-sized avatar

Mike Skeen mskeen

View GitHub Profile
@mskeen
mskeen / database_cleaner.rb
Created December 15, 2014 00:52
Selenium driver fix for transactions
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
end
config.before(:each) do
DatabaseCleaner.strategy = :transaction
end
@mskeen
mskeen / mail.rb
Last active August 29, 2015 14:10 — forked from noxqsgit/mail.rb
#!/usr/bin/env ruby
require 'net/smtp'
unless (2..3).include? ARGV.length
puts 'Usage: mail.rb SUBJECT TO [FROM]'
exit 1
end
subject, to, from_ = ARGV
@mskeen
mskeen / datashift.sublime-project
Created February 25, 2014 03:02
Sublime: sample project file for rails
{
"folders":
[
{
"follow_symlinks": true,
"path": ".",
"folder_exclude_patterns": ["tmp", "log", "coverage"]
}
],
@mskeen
mskeen / preview.js.erb
Last active April 25, 2023 09:33
rails: insert a partial via javascript
$('#graph-preview').replaceWith("<%=j render partial: 'preview' %>");
@mskeen
mskeen / tokenable.rb
Created February 3, 2014 13:51
rails: random token for a model
module Tokenable
extend ActiveSupport::Concern
included do
before_create :generate_token
end
protected
def generate_token
@mskeen
mskeen / toggle.js
Created November 7, 2013 00:35
javascript: module pattern - prototype
var Toggler = (function() {
var totalTogglers = 0;
var Toggler = function() {
this.linkSelector = ".detail_toggle";
this.detailSelector = ".detail";
this.hiddenClass = "hidden";
this.hideText = "Hide Details";
this.showText = "Show Details";
};
@mskeen
mskeen / gist:7156739
Created October 25, 2013 15:42
rails: use class_name - same model multiple times
class AirplaneClass < ActiveRecord::Base
attr_accessible :name, :description, :organization_id, :stations_attributes,
:ifr_certified, :currency_if_over_150, :min_hours_to_qualify,
:max_wind_limitation, :min_weight, :max_weight, :datapoints_attributes,
:cruise_performance_chart_id, :landing_distance_chart_id,
:takeoff_distance_chart_id
belongs_to :organization
has_many :airplanes
has_many :stations