Skip to content

Instantly share code, notes, and snippets.

View traviskroberts's full-sized avatar

Travis Roberts traviskroberts

View GitHub Profile
@traviskroberts
traviskroberts / gist:2830535
Created May 29, 2012 20:33
FactoryGirl Polymorphic Association
class Alert < ActiveRecord::Base
belongs_to :alertable, :polymorphic => true
end
class Region < ActiveRecord::Base
has_many :alerts, :as => :alertable
end
@traviskroberts
traviskroberts / _instructions.md
Last active April 17, 2018 17:33
Simple rake task to deploy staging and production apps to Heroku. Based on: https://gist.github.com/njvitto/362873

Deploying Via Rake Task

  • Edit the PRODUCTION_APP and STAGING_APP variables at the top of the file.
  • Set the heroku remotes by running rake:set_remotes
  • Once you're ready to deploy, you can run rake deploy:production or rake deploy:staging
@traviskroberts
traviskroberts / rake.rb
Created January 17, 2013 15:57
Rspec shared context for testing rake tasks.
require "rake"
shared_context "rake" do
let(:rake) { Rake::Application.new }
let(:task_name) { self.class.top_level_description }
let(:task_path) { "lib/tasks/#{task_name.split(":").first}" }
subject { rake[task_name] }
def loaded_files_excluding_current_rake_file
$".reject {|file| file == Rails.root.join("#{task_path}.rake").to_s }
# run in non-daemonized mode (so you can monitor it) with `god -c /path/to/mysql.god -D`
# run normally with `god -c /path/to/mysql.god`
# Settings for email notifications (optional)
God::Contacts::Email.defaults do |d|
d.from_email = 'god@my-app.com'
d.from_name = 'God'
d.delivery_method = :smtp # this can also be :sendmail
d.server_host = 'smtp.myapp.com'
d.server_port = 25
gulp = require 'gulp'
gutil = require 'gulp-util'
# contrib modules
streamee = require 'streamee'
concat = require 'gulp-concat'
coffee = require 'gulp-coffee'
uglify = require 'gulp-uglify'
sass = require 'gulp-sass'
@traviskroberts
traviskroberts / .htaccess
Created November 9, 2013 20:10
Basic maintenance page.
# Don't forget to turn on the rewrite engine
RewriteEngine on
# Maintenance Redirection (lets images and styles through)
RewriteCond %{REQUEST_URI} !maintenance.html
RewriteCond %{REQUEST_FILENAME} !(styles|images).+$
RewriteRule (.*) /maintenance.html [R,L]
#!/bin/sh
CURRENT=`git branch | grep '\*' | awk '{print $2}'`
TARGET=$1
: ${TARGET:="master"}
echo "\033[33m=> git checkout ${TARGET}\033[0m"
git checkout ${TARGET}
echo "\033[33m=> git pull origin ${TARGET}\033[0m"
gem 'taps'
gem 'sqlite3' # dependency of taps
// FIXES FOR WYSIWYG EDITOR
li.tinymce {
overflow: auto;
> div {
float: left;
width: 76%;
}
}
describe 'it should regenerate the guid if one already exists' do
FactoryGirl.create(:user, guid: '123456')
SecureRandom.stub(:hex).and_return('123456', '456789')
user = User.new(email: 'john@email.com', total_budget: 250.00)
user.save
expect(user.reload.guid).to eq(6)
end