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:
# Takes a table name, and an array of hashes where keys are column names and values are values. | |
# Expects hashes to all contain the same keys. | |
def bulk_insert(table, rows) | |
columns = rows.first.keys | |
to_insert = rows.map do |d| | |
vals = columns.map {|k| d[k] } | |
ActiveRecord::Base.send(:replace_bind_variables, "(#{vals.length.times.collect {'?'}.join(',')})", vals) | |
end |
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) |
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 |
// 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 "$@" |
--- | |
# ^^^ 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. |
I hereby claim:
To claim this, I am signing this object:
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 |
/** | |
* Source: http://nicolasgallagher.com/micro-clearfix-hack/ | |
* | |
* For modern browsers | |
* 1. The space content is one way to avoid an Opera bug when the | |
* contenteditable attribute is included anywhere else in the document. | |
* Otherwise it causes space to appear at the top and bottom of elements | |
* that are clearfixed. | |
* 2. The use of `table` rather than `block` is only necessary if using | |
* `:before` to contain the top-margins of child elements. |
namespace :delayed_job do | |
def args | |
fetch(:delayed_job_args, "") | |
end | |
def delayed_job_roles | |
fetch(:delayed_job_server_role, :app) | |
end |