Skip to content

Instantly share code, notes, and snippets.

View willcosgrove's full-sized avatar
🏠
Working from home

Will Cosgrove willcosgrove

🏠
Working from home
View GitHub Profile
class Sync.Server extends Sync.View
constructor: (@$el, @name) ->
@vue = new Vue
el: @$el[0]
data:
editing: false
@willcosgrove
willcosgrove / application_helper.rb
Last active August 29, 2015 14:18
blank_or - View helper to render blank text if a value is blank, or ...
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
@willcosgrove
willcosgrove / client_id.rb
Created May 14, 2015 21:39
The ClientID concern is for facilitating a passthrough of client IDs, useful for reconciling created records with their non-ID'd client counterpart.
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 / gist:988190
Created May 24, 2011 05:54
CherryCard API responce to a new card call
{
bundle: {
created_at: 2011-04-25T02:12:13Z
cards: [
{
created_at: 2011-04-25T02:12:13Z
code: J76ZKWNC
bundle_id: 20
updated_at: 2011-04-25T02:12:13Z
retailer_id: 7
@willcosgrove
willcosgrove / Homework3_1.cpp
Created February 15, 2012 03:31
Bulls and Cows game from chapter 5
/*
Will Cosgrove
121007913
will@willcosgrove.com
Section 509
1/31/2012
Homework 3, Problem 1
*/
#include "std_lib_facilities.h"
@willcosgrove
willcosgrove / gist:1875267
Created February 21, 2012 08:54
The JSON output of a birdfeeder feed
{
"items":[
{
"description":"State-owned Royal Bank of Scotland set to reveal profits of 500m - Scottish Daily Record",
"source":"http://news.google.com/news/url?sa=t&fd=R&usg=AFQjCNGSlm4dglV7QbkOJ20PeK79LjixUA&url=http://www.dailyrecord.co.uk/news/scottish-news/2012/02/05/state-owned-royal-bank-of-scotland-set-to-reveal-profits-of-500m-86908-23736183/",
"published_at":"2012-02-05"
},
{
"description":"BSP To Print Smaller Denominations - Manila Bulletin",
"source":"http://news.google.com/news/url?sa=t&fd=R&usg=AFQjCNGC-zXs6CXkvJJOYb8wjJ6OTqM5tQ&url=http://www.mb.com.ph/articles/350361/bsp-to-print-smaller-denominations",
@willcosgrove
willcosgrove / Gemfile
Created March 24, 2012 23:38
NDE tif -> jpg
source 'http://rubygems.org'
gem 'rmagick', '~> 2.13.1'
gem 'listen', '~> 0.3.3'
@willcosgrove
willcosgrove / index.html
Created April 10, 2012 15:53
Full Trace + Template
<!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>
@willcosgrove
willcosgrove / full stack
Created April 10, 2012 16:01
Locomotive CMS - Undefined method count for nil:NilClass
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 / syntax_highlighting.py
Created April 17, 2012 17:40 — forked from norbajunior/syntax_highlighting.py
Ruby on Rails syntax highlight switcher for Sublime Text 2
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()