Skip to content

Instantly share code, notes, and snippets.

View allspiritseve's full-sized avatar

Cory Kaufman-Schofield allspiritseve

  • Dexter, MI
View GitHub Profile
@allspiritseve
allspiritseve / bundler_cmd.sh
Last active December 14, 2015 12:18
Alias to bundle exec for common rails commands
# Source : http://marc-bowes.com/2011/09/21/dry-your-bundle-exec-tears.html
#
# Add to ~/.bash_profile or ~/.bashrc
bundle_commands="rake rails unicorn"
function run_bundler_cmd () {
if [ -r ./Gemfile ]; then
bundle exec $@
else
@allspiritseve
allspiritseve / bookmarkletize.rb
Created January 21, 2013 17:05
Script to turn a readable javascript file with whitespace into a URL-encoded bookmarklet string. It doesn't automatically add a self-executing anonymous function, because you guys are smart and should be doing that already. Usage: $ ./bookmarkletize bookmarklet.js #=> "javascript:..."
#!/usr/bin/env ruby
#
# Bookmarkletize is a lil script to turn a normal javascript file into a
# (virtually unreadable) URL-escaped string that can be used in a
# bookmarklet.
#
# Inspiration: http://daringfireball.net/2007/03/javascript_bookmarklet_builder
#
# I could use his script, but come on. It's perl.
@allspiritseve
allspiritseve / gist:4582992
Created January 21, 2013 01:31
Mixin to handle storing currency as integers.
module Centsify
extend ActiveSupport::Concern
module ClassMethods
def centsify(*columns)
columns = [columns] unless columns.is_a?(Array)
columns.each do |column|
define_method column do
self.send("#{column}_cents").to_i / 100.0
end
@allspiritseve
allspiritseve / gist:3969109
Created October 28, 2012 16:41
Nginx configuration
# /etc/nginx/sites-available/sitename.com
server {
listen 443 ssl;
server_name *.sitename.com;
keepalive_timeout 70;
ssl on;
ssl_certificate /etc/ssl/certs/sitename-bundle.crt;
ssl_certificate_key /etc/ssl/private/sitename.key;
root /var/www/sitename.com/public;
@allspiritseve
allspiritseve / deploy.rake
Created August 19, 2012 20:39
Heroku deploy script
# lib/tasks/deploy.rake
namespace :deploy do
desc 'Deploy to production'
task(:production) { deploy }
desc 'Deploy to staging'
task(:staging) { deploy :staging }
private
@allspiritseve
allspiritseve / sample.rake
Created August 15, 2012 15:34
Rails rake task to install sample data
# lib/tasks/db/sample.rake
namespace :db do
desc "Clear out the database and replace it with sample data"
task :sample => ['db:ensure_development_or_staging','environment','db:drop','db:setup'] do
sample_file = 'db/samples.rb'
load(sample_file) if File.exists?(sample_file)
end
task :ensure_development_or_staging do
@allspiritseve
allspiritseve / Rakefile
Created July 24, 2012 16:16
Jekyll tasks
task :deploy do
system 'jekyll && rsync -avz --delete -e ssh _site/ ck:blog.corykaufman.com && git push origin master'
end