Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Will Cosgrove willcosgrove

🏠
Working from home
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am willcosgrove on github.
  • I am willcosgrove (https://keybase.io/willcosgrove) on keybase.
  • I have a public key ASCgfVUsESgwzlDDf7XB5Oui4uzbJyrKNcQZrVa3OISqQQo

To claim this, I am signing this object:

@willcosgrove
willcosgrove / client_id.rb
Created May 14, 2015
The ClientID concern is for facilitating a passthrough of client IDs, useful for reconciling created records with their non-ID'd client counterpart.
View client_id.rb
module ClientID
extend ActiveSupport::Concern
included do
attr_writer :cid
after_commit :_save_cid, on: :create, if: -> { @cid.present? }
end
def cid
Thread.current[_cid_key]
@willcosgrove
willcosgrove / application_helper.rb
Last active Aug 29, 2015
blank_or - View helper to render blank text if a value is blank, or ...
View application_helper.rb
def blank_or(attribute, blank_text: "N/A", blank_test: :blank?)
if attribute.send(blank_test)
return blank_text
else
return yield(attribute) if block_given?
return attribute
end
end
View sync.server.js.coffee
class Sync.Server extends Sync.View
constructor: (@$el, @name) ->
@vue = new Vue
el: @$el[0]
data:
editing: false
View gist:4082189
Supplier Load (0.5ms) SELECT "suppliers".* FROM "suppliers" WHERE "suppliers"."name" = 'S. Rothe' LIMIT 1
PurchaseOrder Load (0.4ms) SELECT "purchase_orders".* FROM "purchase_orders" WHERE (("purchase_orders"."supplier_id" = 43 AND "purchase_orders"."created_at" = '2011-10-31 00:00:00')) LIMIT 1
Winery Load (0.7ms) SELECT "wineries".* FROM "wineries" WHERE "wineries"."name" = 'Robert Keenan' LIMIT 1
Wine Load (0.3ms) SELECT "wines".* FROM "wines" WHERE "wines"."wine_id" = 174385 LIMIT 1
(0.4ms) BEGIN
SQL (0.7ms) INSERT INTO "bottles" ("active", "active_on_winesearcher", "condition", "cost_in_cents", "created_at", "employee_purchase_price_in_cents", "last_sold_on", "marketing_text", "max_quantity_display", "name", "notes", "original_uploaded_quantity", "pick_location", "picture", "purchase_order_id", "purchase_source_type", "quantity", "retail_price_in_cents", "sku", "status", "stock_status", "updated_at", "wine_id", "winesearcher_display_name") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $1
View gist:4082188
Supplier Load (0.5ms) SELECT "suppliers".* FROM "suppliers" WHERE "suppliers"."name" = 'S. Rothe' LIMIT 1
PurchaseOrder Load (0.4ms) SELECT "purchase_orders".* FROM "purchase_orders" WHERE (("purchase_orders"."supplier_id" = 43 AND "purchase_orders"."created_at" = '2011-10-31 00:00:00')) LIMIT 1
Winery Load (0.7ms) SELECT "wineries".* FROM "wineries" WHERE "wineries"."name" = 'Robert Keenan' LIMIT 1
Wine Load (0.3ms) SELECT "wines".* FROM "wines" WHERE "wines"."wine_id" = 174385 LIMIT 1
(0.4ms) BEGIN
SQL (0.7ms) INSERT INTO "bottles" ("active", "active_on_winesearcher", "condition", "cost_in_cents", "created_at", "employee_purchase_price_in_cents", "last_sold_on", "marketing_text", "max_quantity_display", "name", "notes", "original_uploaded_quantity", "pick_location", "picture", "purchase_order_id", "purchase_source_type", "quantity", "retail_price_in_cents", "sku", "status", "stock_status", "updated_at", "wine_id", "winesearcher_display_name") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $1
@willcosgrove
willcosgrove / syntax_highlighting.py
Created Apr 17, 2012 — forked from norbajunior/syntax_highlighting.py
Ruby on Rails syntax highlight switcher for Sublime Text 2
View syntax_highlighting.py
import sublime, sublime_plugin
import os
class DetectFileTypeCommand(sublime_plugin.EventListener):
""" Detects current file type if the file's extension isn't conclusive """
""" Modified for Ruby on Rails and Sublime Text 2 """
""" Original pastie here: http://pastie.org/private/kz8gtts0cjcvkec0d4quqa """
def on_load(self, view):
filename = view.file_name()
@willcosgrove
willcosgrove / full stack
Created Apr 10, 2012
Locomotive CMS - Undefined method count for nil:NilClass
View full stack
locomotive-mongoid-tree (0.6.2) lib/mongoid/tree.rb:183:in `depth'
/Users/Will/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/bundler/gems/engine-95eb58bb360e/app/models/locomotive/page.rb:61:in `index?'
/Users/Will/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/bundler/gems/engine-95eb58bb360e/app/helpers/locomotive/pages_helper.rb:6:in `block in css_for_page'
/Users/Will/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/bundler/gems/engine-95eb58bb360e/app/helpers/locomotive/pages_helper.rb:5:in `each'
/Users/Will/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/bundler/gems/engine-95eb58bb360e/app/helpers/locomotive/pages_helper.rb:5:in `inject'
/Users/Will/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/bundler/gems/engine-95eb58bb360e/app/helpers/locomotive/pages_helper.rb:5:in `css_for_page'
/Users/Will/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/bundler/gems/engine-95eb58bb360e/app/views/locomotive/pages/_page.html.haml:4:in `___sers__ill__rbenv_versions_______p____lib_ruby_gems_______bundler_gems_engine_
@willcosgrove
willcosgrove / index.html
Created Apr 10, 2012
Full Trace + Template
View index.html
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="New Venture Prep| Accelerated Instructor-led and online courses in financial training in financial modeling, private equity, accounting and statement analysis with a customized curriculum" name="title"/>
<meta content="financial training, investment banking, financial valuation, modeling, accounting, statement analysis, financial engineering, investment banking academy, private equity, new venture prep" name="keywords"/>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
<title>New Venture Prep</title>
<!--Stylesheet-->
<link href="http://new-venture-prep.herokuapp.com/assets/application-35c94d282c8d2fc5a05bd1dfc30dd53e.css" media="screen" rel="stylesheet" type="text/css" />
<!--Javascript-->
<script src="http://new-venture-prep.herokuapp.com/assets/application-87c9c31f6b08ac355b248171b2778b6c.js" type="text/javascript"></script>
View Gemfile
source 'http://rubygems.org'
gem 'rmagick', '~> 2.13.1'
gem 'listen', '~> 0.3.3'
You can’t perform that action at this time.