Skip to content

Instantly share code, notes, and snippets.

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 / 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,
<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 / 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);
}
@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 / Gemfile
Last active October 31, 2016 04:35
strict-templates-examples
gem 'strict_templates'
@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
}
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 / 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
@kellysutton
kellysutton / bigger_user_spec.rb
Last active June 16, 2017 15:24
Count the Contexts
RSpec.describe User do
describe '#full_name' do
subject do
described_class.new(first_name, middle_name, last_name)
end
let(:first_name) { 'Roy' }
let(:last_name) { 'Biv' }
context 'middle name is given' do
let(:middle_name) { 'Gee' }