Skip to content

Instantly share code, notes, and snippets.

@kellysutton
kellysutton / best_payroll_runner.rb
Last active June 12, 2017 00:10
Replace Side Effects with Return Values
class PayrollRunner
def run!
TaxEngineWrapper.new(tax_engine).apply(commands)
computed_taxes = tax_engine.calculate_taxes
payroll.assign_taxes(computed_taxes)
end
# This is now a pure function from the view of its callers.
# Sweet!
def commands
class TaxCalculationSaver
def self.save_taxes!(payroll)
total_tax_amount = payroll.employees.map do |employee|
TaxCalculator.calculate(payroll, employee)
end.sum
PayrollSaver.save!(payroll, total_tax_amount: total_tax_amount)
end
end
@kellysutton
kellysutton / graphql-example.txt
Last active January 2, 2017 20:52 — forked from anonymous/graphql-example.txt
Do we need GraphQL?
POST /graphql
Content-Type: application/graphql
{
post(id: 1) {
id
title
comments {
id
body
}
@kellysutton
kellysutton / Gemfile
Last active October 31, 2016 04:35
strict-templates-examples
gem 'strict_templates'
@kellysutton
kellysutton / application.js
Last active September 10, 2016 20:00
Real-time Recipe for Rails and Ember using Pusher
// app/routes/application.js
import Ember from 'ember';
export default Ember.Route.extend({
currentUser: Ember.inject.service(),
pusher: Ember.inject.service(),
activate() {
this._listenToPusherEvents();
},
@kellysutton
kellysutton / generative-utility-colors.sass
Last active July 27, 2016 18:05
Generating Color Utility Classes in SASS
$color-list {
red #f00,
green #0f0,
blue #00f
}
@each $value in $color-list {
.#{nth($value, 1)} {
color: nth($value, 2);
}
<img srcset="https://assets.imgix.net/flower.jpg?w=50 50w,
https://assets.imgix.net/flower.jpg?w=100 100w,
https://assets.imgix.net/flower.jpg?w=150 150w,
...
https://assets.imgix.net/flower.jpg?w=5200 5200w,
https://assets.imgix.net/flower.jpg?w=5260 5260w"
src="https://assets.imgix.net/flower.jpg?w=540"
alt="A white flower"
/>
@kellysutton
kellysutton / img.html
Created April 20, 2016 05:35
srcset insanity
<img srcset="https://assets.imgix.net/flower.jpg?w=50 50w,
https://assets.imgix.net/flower.jpg?w=100 100w,
https://assets.imgix.net/flower.jpg?w=150 150w,
https://assets.imgix.net/flower.jpg?w=200 200w,
https://assets.imgix.net/flower.jpg?w=250 250w,
https://assets.imgix.net/flower.jpg?w=300 300w,
https://assets.imgix.net/flower.jpg?w=350 350w,
https://assets.imgix.net/flower.jpg?w=400 400w,
https://assets.imgix.net/flower.jpg?w=450 450w,
https://assets.imgix.net/flower.jpg?w=500 500w,
curl -v \
-o /dev/null \
"https://layervault-preview.imgix.net/remote_preview_data/436751/original/.1366399179.726358.preview_Front_Page.psd20130419-9702-55ihns.png?fit=max&w=620&dpr=2&s=f1a5c768644356087baf28d5cabf9c74"
---- 200: Request includes CORS headers ----
curl -i \
-H "If-Modified-Since:Fri, 19 Apr 2013 19:19:49 GMT" \
"https://layervault-preview.imgix.net/remote_preview_data/436751/original/.1366399179.726358.preview_Front_Page.psd20130419-9702-55ihns.png?fit=max&w=620&dpr=2&s=f1a5c768644356087baf28d5cabf9c74"
@kellysutton
kellysutton / gist:6335882
Created August 25, 2013 19:49
rap genius offer
I have an incredible team I’m sure you’ve heard of in New York and looking for another Ruby engineer to join the team. I'm working with the founder of RapGenius, Tom Lehman, on this opportunity and have multiple openings for mid level to sr/principal/lead developers. I helped these guys staff 2 Ruby on Rails engineers, both from well-known companies, let me know if you’d be interested in checking them out.
They pinned down $15M from Ben Horowitz and have been getting a ton of attention. I would be interested in hearing your thoughts.
www.rapgenius.com
http://rapgenius.com/Marc-andreessen-why-andreessen-horowitz-is-investing-in-rap-genius-lyrics (Definitely check this one out)
http://news.ycombinator.com/item?id=4698010 and http://rapgenius.com/posts/Rap-genius-is-hiring
We raised $15M from Andreessen Horowitz to build the Internet Talmud™ (read more here: http://goo.gl/LKNHO).