Skip to content

Instantly share code, notes, and snippets.

Working from home

Weston Triemstra thermistor

Working from home
Block or report user

Report or block thermistor

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
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 / interactor_ext.rb
Created Feb 23, 2018
Re-open Interactor and add method to validate context
View interactor_ext.rb
module Interactor
def require_in_context(*names)
context_keys = context.keys
names.each do |name|
if !context_keys.include?(name)
raise "Interactor #{} requires #{name.inspect} but it wasn't found in context."
end do |name|
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
thermistor / set_param.js
Last active Sep 14, 2016
Set/update a query param via javascript function
View set_param.js
// from
function setParam(uri, key, val) {
return uri
.replace(new RegExp("([?&]"+key+"(?=[=&#]|$)[^#&]*|(?=#|$))"), "&"+key+"="+encodeURIComponent(val))
.replace(/^([^?&]+)&/, "$1?");
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 "$@"
You can’t perform that action at this time.