Skip to content

Instantly share code, notes, and snippets.

View johnnaegle's full-sized avatar
🐈
I'm here live, I'm not a cat

John Naegle johnnaegle

🐈
I'm here live, I'm not a cat
View GitHub Profile
@johnnaegle
johnnaegle / gist:4693506
Created February 1, 2013 19:32
Timezones in Rails
(GMT-11:00) American Samoa,
(GMT-11:00) International Date Line West,
(GMT-11:00) Midway Island,
(GMT-10:00) Hawaii,
(GMT-09:00) Alaska,
(GMT-08:00) Pacific Time (US & Canada),
(GMT-08:00) Tijuana,
(GMT-07:00) Arizona,
(GMT-07:00) Chihuahua,
(GMT-07:00) Mazatlan,
@johnnaegle
johnnaegle / gist:5545229
Last active December 17, 2015 03:39
Initialize a new git repo in the local file system
~/projects> mkdir scratch
~/projects> cd scratch/
~/projects/scratch> git init .
Initialized empty Git repository in /Users/johnnaegle/projects/scratch/.git/
~/projects/scratch> touch README.md
~/projects/scratch> git commit -m "Create Empty Repository"
[master (root-commit) bda9f27] Create Empty Repository
0 files changed
create mode 100644 README.md
@johnnaegle
johnnaegle / gist:5545313
Last active December 17, 2015 03:39
Create a new rails plugin
~/projects/scratch> rails plugin new .
create README.rdoc
create Rakefile
create scratch.gemspec
create MIT-LICENSE
create .gitignore
create Gemfile
create lib/scratch.rb
create lib/tasks/scratch_tasks.rake
create lib/scratch/version.rb
@johnnaegle
johnnaegle / 0 - scratch.gemspec
Last active December 17, 2015 03:48
Convert from using test-unit to rspec for a dummy application in a gem
s.add_development_dependency "rspec-rails"
@johnnaegle
johnnaegle / scratch.gemspec
Created May 9, 2013 03:32
Add a dependency to your gemspec
...
s.add_development_dependency "rspec-rails"
...
@johnnaegle
johnnaegle / bundle install
Created May 9, 2013 03:33
Bundle install
~/projects/scratch> bundle install
Using rspec-core (2.12.2)
Using rspec-expectations (2.12.1)
Using rspec-mocks (2.12.1)
Using rspec-rails (2.12.0)
Using scratch (0.0.1) from source at .
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
@johnnaegle
johnnaegle / gist:5545373
Created May 9, 2013 03:34
Convert from test-unit to rspec
~/projects/scratch> rspec --init
create spec/spec_helper.rb
create .rspec
~/projects/scratch> mv test/dummy spec/
~/projects/scratch> rm -rf test
@johnnaegle
johnnaegle / spec_helper.rb
Last active December 17, 2015 03:48
Spec Helper Modifications
ENV["RAILS_ENV"] = "test"
require File.expand_path("../dummy/config/environment.rb", __FILE__)
require "rails/test_help"
require 'scratch' # Replace this with the name of your gem
Rails.backtrace_cleaner.remove_silencers!
@johnnaegle
johnnaegle / log_formatting.rb
Last active December 21, 2015 01:09
A Rails 3.2 initializer that adds formatted time and process IDs to the log file
class ActiveSupport::BufferedLogger
def formatter=(formatter)
@log.formatter = formatter
end
end
class Formatter
SEVERITY_TO_COLOR_MAP = {'DEBUG'=>'0;37', 'INFO'=>'32', 'WARN'=>'33', 'ERROR'=>'31', 'FATAL'=>'31', 'UNKNOWN'=>'37'}
def call(severity, time, progname, msg)
class Api::UsersController < ApplicationController
def show
if stale?(:last_modified => current_user.updated_at, :etag => current_user.updated_at)
end
end
end