Skip to content

Instantly share code, notes, and snippets.

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

Weston Triemstra thermistor

🏠
Working from home
View GitHub Profile
@thermistor
thermistor / interactor_ext.rb
Created February 23, 2018 22:00
Re-open Interactor and add method to validate context
module Interactor
def require_in_context(*names)
context_keys = context.keys
names.each do |name|
if !context_keys.include?(name)
raise "Interactor #{self.class.name} requires #{name.inspect} but it wasn't found in context."
end
end
names.map do |name|
self.send(name)
@thermistor
thermistor / gist:bbb43eb76a3b164f69611bff2338b2bc
Created December 19, 2017 22:55 — forked from giannisp/gist:ebaca117ac9e44231421f04e7796d5ca
Upgrade PostgreSQL 9.6.5 to 10.0 using Homebrew (macOS)
After automatically updating Postgres to 10.0 via Homebrew, the pg_ctl start command didn't work.
The error was "The data directory was initialized by PostgreSQL version 9.6, which is not compatible with this version 10.0."
Database files have to be updated before starting the server, here are the steps that had to be followed:
# need to have both 9.6.x and latest 10.0 installed, and keep 10.0 as default
brew unlink postgresql
brew install postgresql@9.6
brew unlink postgresql@9.6
brew link postgresql
@thermistor
thermistor / set_param.js
Last active September 14, 2016 00:11
Set/update a query param via javascript function
// from https://gist.github.com/stinoga/8101816#gistcomment-1842990
function setParam(uri, key, val) {
return uri
.replace(new RegExp("([?&]"+key+"(?=[=&#]|$)[^#&]*|(?=#|$))"), "&"+key+"="+encodeURIComponent(val))
.replace(/^([^?&]+)&/, "$1?");
}
man() {
env \
LESS_TERMCAP_mb=$(printf "\e[1;31m") \
LESS_TERMCAP_md=$(printf "\e[1;31m") \
LESS_TERMCAP_me=$(printf "\e[0m") \
LESS_TERMCAP_se=$(printf "\e[0m") \
LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
LESS_TERMCAP_ue=$(printf "\e[0m") \
LESS_TERMCAP_us=$(printf "\e[1;32m") \
man "$@"
@thermistor
thermistor / pedantically_commented_playbook.yml
Created May 29, 2016 05:21 — forked from marktheunissen/pedantically_commented_playbook.yml
Insanely complete Ansible playbook, showing off all the options
---
# ^^^ YAML documents must begin with the document separator "---"
#
#### Example docblock, I like to put a descriptive comment at the top of my
#### playbooks.
#
# Overview: Playbook to bootstrap a new host for configuration management.
# Applies to: production
# Description:
# Ensures that a host is configured for management with Ansible.

Keybase proof

I hereby claim:

  • I am thermistor on github.
  • I am thermistor (https://keybase.io/thermistor) on keybase.
  • I have a public key ASBiX2KnZb1zYnuWNsGrScjM7ZlOaPVS0bjWdF99-UlV3go

To claim this, I am signing this object:

@thermistor
thermistor / gist:08e039f912795166d567
Last active January 29, 2016 00:39
Rollbar deploy notification using ENV variable from dotenv
require 'dotenv/tasks'
task notify_rollbar: :dotenv do
on roles(:app) do |h|
revision = `git log -n 1 --pretty=format:"%H"`
local_user = `whoami`.chomp
rollbar_token = ENV['ROLLBAR_ACCESS_TOKEN']
rails_env = fetch(:rails_env, 'production')
execute :curl, "https://api.rollbar.com/api/1/deploy/ -F access_token=#{rollbar_token} -F environment=#{rails_env} -F revision=#{revision} -F local_username=#{local_user} >/dev/null 2>&1", :once => true
end
require 'non_digest_assets'
namespace :assets do
task :non_digested do
NonDigestAssets.new.generate
end
end
@thermistor
thermistor / readme.md
Last active August 29, 2015 14:16 — forked from paulirish/readme.md

console.log wrap resolving for your wrapped console logs

I've heard this before:

What I really get frustrated by is that I cannot wrap console.* and preserve line numbers

We enabled this in Chrome DevTools via blackboxing a bit ago.

If you blackbox the script file the contains the console log wrapper, the script location shown in the console will be corrected to the original source file and line number. Click, and the full source is looking longingly into your eyes.

@thermistor
thermistor / perfect_mock.rb
Last active August 29, 2015 14:15
A perfect ruby mock
# from http://taylor.fausak.me/2014/05/24/class-comparison-in-ruby/
require 'forwardable'
def fake(klass)
Class.new(BasicObject) do
eigenclass = class << self; self end
eigenclass.extend Forwardable
eigenclass.def_delegators klass, *%i[
<
<=