This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ----- SimpleForm Styles ----- */ | |
.simple_form | |
div.input | |
margin-bottom: 10px | |
clear: both | |
label | |
float: left | |
width: 100px |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env /Users/fregini/.rbenv/versions/1.9.2-p318/bin/ruby | |
# | |
# A simple script to automate the creation of a new blog post. | |
# An automator task will pick the file name in output and open | |
# it with the default editor. | |
# | |
require 'rubygems' | |
require 'active_support/all' | |
require 'pathname' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
startline() { | |
echo "" | |
echo "" | |
echo "---------- $1 -------------------------" | |
echo "" | |
} | |
startline "CPU" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
after_fork do |server, worker| | |
log_path = Rails.root.join('log',"#{Rails.env}.#{worker.nr}.log") | |
new_logger = Logger.new(log_path) | |
new_logger.level = Logger::INFO | |
Rails.logger.flush | |
Rails.logger.close | |
Rails.logger = Rails.application.config.logger = ActiveSupport::TaggedLogging.new(new_logger) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :deploy do | |
task :load_schema, :roles => :db, :only => { :primary => true } do | |
rake = fetch(:rake, "rake") | |
rails_env = fetch(:rails_env, "production") | |
migrate_env = fetch(:migrate_env, "") | |
migrate_target = fetch(:migrate_target, :latest) | |
directory = case migrate_target.to_sym | |
when :current then current_path | |
when :latest then latest_release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function last-commit() { | |
git log --format=%H -n 1 | |
} | |
function last-file-change() { | |
git rev-list --max-parents=1 --max-count=1 --format=oneline HEAD -- $1 | cut -d " " -f 1 | |
} | |
function annotate-file() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AddPrivacyToSubscription < ActiveRecord::Migration | |
def change | |
add_column :subscriptions, :privacy, :boolean, :default => false, :null => false | |
change_column_default(:subscriptions, :privacy, nil) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Deploy and rollback on Heroku in staging and production | |
task :deploy_staging => ['deploy:set_staging_app', 'deploy:push', 'deploy:restart', 'deploy:tag'] | |
task :deploy_production => ['deploy:set_production_app', 'deploy:push', 'deploy:restart', 'deploy:tag'] | |
namespace :deploy do | |
PRODUCTION_APP = 'YOUR_PRODUCTION_APP_NAME_ON_HEROKU' | |
STAGING_APP = 'YOUR_STAGING_APP_NAME_ON_HEROKU' | |
task :staging_migrations => [:set_staging_app, :push, :off, :migrate, :restart, :on, :tag] | |
task :staging_rollback => [:set_staging_app, :off, :push_previous, :restart, :on] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :app do | |
task :nonfingerprint_assets => :environment do | |
fingerprint = /\-[0-9a-f]{32}\./ | |
filemap = {} | |
Dir["public/assets/**/*"].each do |file| | |
next if file !~ fingerprint | |
next if File.directory?(file) | |
next if file.split(File::Separator).last =~ /^manifest/ | |
nondigest = file.sub fingerprint, '.' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module DeskMultipass | |
URL_TEMPLATE = "https://%s.desk.com/customer/authentication/multipass/callback?multipass=%s&signature=%s" | |
def self.signed_url(user, redirect_to=nil) | |
raise "DESK_API_KEY is not set" if ENV['DESK_API_KEY'].blank? | |
raise "DESK_SUBDOMAIN is not set" if ENV['DESK_SUBDOMAIN'].blank? | |
# Create the encryption key using a 16 byte SHA1 digest of your api key and subdomain | |
key = Digest::SHA1.digest(ENV['DESK_API_KEY'] + ENV['DESK_SUBDOMAIN'])[0...16] |