Q: How does an app become bloated?
A: One reasonable feature request at a time
— via
awk -v ver="$(npm -v)" 'BEGIN { if (ver > 2.0) exit 1; }' && npm i -g npm@2 |
#!/bin/bash | |
function upsearch () { | |
test / == "$PWD" && return || test -e "$1" && cat "$PWD/$1" && return || cd .. && upsearch "$1" | |
} | |
ruby_version=$(upsearch ".ruby-version") | |
$HOME/.rvm/bin/rvm ${ruby_version:-default} do bundle exec rubocop $@ |
class Task | |
def model | |
fail "Must be implemented in sub-class" | |
end | |
# ... | |
end | |
def Task(model) | |
Class.new(Task) { cattr_reader :model; @model = model } | |
end |
// http://lea.verou.me/2012/04/background-attachment-local/ | |
@mixin scroll-shadow($color: #fff, $width: 100%, $offset: 0) { | |
background-image: /* Legacy - prefixed */ | |
/* Shadow covers */ | |
-webkit-linear-gradient($color 30%, rgba($color, 0)), | |
-webkit-linear-gradient(rgba($color, 0), $color 70%), | |
/* Shadows */ | |
-webkit-radial-gradient(50% 0, farthest-side, rgba(0, 0, 0, .2), rgba(0, 0, 0, 0)), | |
-webkit-radial-gradient(50% 100%, farthest-side, rgba(0, 0, 0, .2), rgba(0, 0, 0, 0)); | |
background-image: /* Legacy */ |
function callbackAsPromise(fn, scope) { | |
return function() { | |
var args = Array.prototype.slice.apply(arguments); | |
return new Promise(function(resolve, reject) { | |
fn.apply(scope, args.concat(function(err, data) { | |
if (err) reject(err); | |
resolve(data); | |
})); | |
}); | |
} |
require "pathname" | |
Pathname.class_eval { alias join / } | |
Pathname.new("foo") / "bar" / "baz" # => #<Pathname:foo/bar/baz> |
Q: How does an app become bloated?
A: One reasonable feature request at a time
— via
require "addressable/template" | |
require "redsnow" | |
require "sinatra" | |
class BlueprintMockServer | |
def initialize(base_url, blueprint) | |
@mocks = {} | |
api = RedSnow.parse(File.read(blueprint.to_s)) | |
api.ast.resource_groups.flat_map(&:resources).each do |resource| | |
uri_template = Addressable::Template.new(base_url + resource.uri_template) |
Capistrano::Configuration.instance(true).load do | |
namespace :db do | |
desc "Create database user for current site" | |
task :create_user, roles: :db do | |
config = Pathname.new(__dir__).join("..", "database.yml") | |
config = ERB.new(config.read).result(binding) | |
config = YAML.load(config) | |
fail "No database config for #{stage}" unless config[stage.to_s] | |
username, password = config[stage.to_s].values_at("username", "password") | |
run "#{sudo as: 'postgres'} psql -d postgres" do |channel, _, _| |
This allows you to use the following video streaming services outside of the US from your Mac without having to use a proxy or VPN, so no big bandwidth issues: