Skip to content

Instantly share code, notes, and snippets.

Corey Woodcox cwoodcox

Block or report user

Report or block cwoodcox

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:097a053ab4804f86c07e
class StringJoiner
def call string1, string2
"#{string1}#{string2}"
end
end
join = StringJoiner.new
join.call("this ", "is normal")
# => "this is normal"
@cwoodcox
cwoodcox / tmux.conf
Created Nov 19, 2014
My interactive project opening thing
View tmux.conf
# Open a project interactively
unbind C-p
bind-key C-p \
command-prompt -p "client:","project:" "\
new-session -A -c ~/Projects/%1/%2 -s %2 -n code 'reattach-to-user-namespace -l vim'\;\
new-window -d -n console 'tail -f log/development.log'\;\
split-window -v -t 1 'rails c'\;\
next-window"
View logged-in
Started GET "/products/die-cut-stickers" for 127.0.0.1 at 2014-11-19 12:47:59 -0500
Processing by Spree::ProductsController#show as HTML
Parameters: {"id"=>"die-cut-stickers"}
Spree::Preference Load (0.4ms) SELECT "spree_preferences".* FROM "spree_preferences" WHERE "spree_preferences"."key" = 'spree/frontend_configuration/locale' LIMIT 1
Spree::User Load (0.3ms) SELECT "spree_users".* FROM "spree_users" WHERE "spree_users"."deleted_at" IS NULL AND "spree_users"."id" = 1 ORDER BY "spree_users"."id" ASC LIMIT 1
Spree::Store Load (0.3ms) SELECT "spree_stores".* FROM "spree_stores" WHERE (url like '%rockin-stickers.dev%') ORDER BY "spree_stores"."id" ASC LIMIT 1
Spree::Store Load (0.3ms) SELECT "spree_stores".* FROM "spree_stores" WHERE "spree_stores"."default" = 't' ORDER BY "spree_stores"."id" ASC LIMIT 1
Spree::Order Load (0.4ms) SELECT "spree_orders".* FROM "spree_orders" WHERE "spree_orders"."completed_at" IS NULL AND "spree_orders"."currency" = 'USD' AND "spree_orders"."guest_
View gist:6927382
# Create the associations for individual body_metrics and accept their nested
# attributes. This makes the biometrics form work and a few other things.
Dir['app/models/body_metric/*.rb'].collect { |file| File.basename(file).sub /\.rb/, '' }.each do |metric|
has_one :"current_#{metric}", -> { latest }, class_name: "BodyMetric::#{metric.camelize}"
accepts_nested_attributes_for :"current_#{metric}"
define_method("current_#{metric}") do
super() || self.send(:"build_current_#{metric}")
end
end
View policy.rb
class Policy
attr_reader :expires, :response
def initialize user
if user
@expires = 8.hours.from_now
content_length = 100..50.megabytes
user_id = user.email.split('@').reverse.join('/')
else
@expires = 30.minutes.from_now
@cwoodcox
cwoodcox / observable.rb
Created Aug 27, 2013
I just wrote this. Now I understand why it's a thing. BECAUSE IT'S COOL.
View observable.rb
module Shortwave
module Observable
def self.included(base)
base.send :include, InstanceMethods
end
module InstanceMethods
class Notification
attr_accessor :event, :id, :klass
@cwoodcox
cwoodcox / gist:5719467
Created Jun 6, 2013
the current state of my brew
View gist:5719467
ack
autoconf
automake
cmake
cowsay
curl-ca-bundle
ec2-api-tools
fortune
fping
freetype
@cwoodcox
cwoodcox / gist:5629263
Created May 22, 2013
Sometimes I do terrible things in Ruby. Terrible, horrible, wonderful things.
View gist:5629263
def create_stylesheet
stylesheet = StringIO.new
stylesheet << <<-EOS
@font-face {
font-family: 'badges';
src: url('#{font_eot.url}');
src: url('#{font_eot.url}') format('embedded-opentype'),
url('#{font_woff.url}') format('woff'),
url('#{font_ttf.url}') format('truetype'),
url('#{font_svg.url}') format('svg');
You can’t perform that action at this time.