Skip to content

Instantly share code, notes, and snippets.

Working from home

Weston Triemstra thermistor

Working from home
View GitHub Profile
thermistor / oneliners.js
Last active Apr 1, 2019 — forked from mikowl/oneliners.js
👑 Awesome one-liners you might find useful while coding.
View oneliners.js
// By @coderitual
// Remove any duplicates from an array of primitives.
const unique = [ Set(arr)]
// Sleep in async functions. Use: await sleep(2000).
const sleep = (ms) => (new Promise(resolve => setTimeout(resolve, ms)));
// Type this in your code to break chrome debugger in that line.
View gist:7a6ea74bd1e74ad1a79eed711f6c0c96
require 'resolv'
class EmailValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
if"@").last, Resolv::DNS::Resource::IN::MX).empty?
record.errors[attribute] << (options[:message] || "does not have a valid domain")
rescue Resolv::ResolvError, Resolv::ResolvTimeout
record.errors[attribute] << (options[:message] || "does not have a valid domain")


All preferences for the DNS-over-HTTPS functionality in Firefox are located under the "network.trr" prefix (TRR == Trusted Recursive Resolver). The support for these are targeted for shipping in release Firefox 62.


set which resolver mode you want.

0 - Off (default). use standard native resolving only (don't use TRR at all)

1 - Race native against TRR. Do them both in parallel and go with the one that returns a result first.

thermistor /
Last active Jul 28, 2018 — forked from tkfm-yamaguchi/
source-highlight's language definition file for YAML
@@ -169,3 +169,5 @@
groovy = groovy.lang
json = json.lang
feature = feature.lang
+yaml = yaml.lang
+yml = yaml.lang
thermistor / 1-activerecord.rb
Created Mar 14, 2018 — forked from janko/1-activerecord.rb
INSERTing 50,000 records into a database in ActiveRecord, Arel, SQL, activerecord-import and Sequel.
View 1-activerecord.rb
require "active_record"
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
ActiveRecord::Migration.class_eval do
create_table(:records) do |t|
t.string :column
data = { |i| Hash[column: "Column #{i}"] }
thermistor / bulk_insert.rb
Created Mar 14, 2018 — forked from maxjustus/bulk_insert.rb
Simple SQL bulk insert in Rails
View bulk_insert.rb
# 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 = do |d|
vals = {|k| d[k] }
ActiveRecord::Base.send(:replace_bind_variables, "(#{vals.length.times.collect {'?'}.join(',')})", vals)
thermistor / gist:bbb43eb76a3b164f69611bff2338b2bc
Created Dec 19, 2017 — forked from giannisp/gist:ebaca117ac9e44231421f04e7796d5ca
Upgrade PostgreSQL 9.6.5 to 10.0 using Homebrew (macOS)
View gist:bbb43eb76a3b164f69611bff2338b2bc
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
View gist:c525ba6d07b04a15c7b4b5e66d9192d9
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 / pedantically_commented_playbook.yml
Created May 29, 2016 — forked from marktheunissen/pedantically_commented_playbook.yml
Insanely complete Ansible playbook, showing off all the options
View pedantically_commented_playbook.yml
# ^^^ 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.
View assets.rake
require 'non_digest_assets'
namespace :assets do
task :non_digested do
You can’t perform that action at this time.