Skip to content

Instantly share code, notes, and snippets.


John Bolliger skunkworker

View GitHub Profile
skunkworker / example.rb
Last active Jun 13, 2020
How to append to a json column array in Rails 5.
View example.rb
# assuming Model is your model and options is a json/jsonb column.
# This uses the Postgres json append || operator.
# And wraps the option inside an array.
# producing [{},{}] multiple hashes inside a top level json array.
# It is very important that the hash is [{}] NOT {} as not having the array on the
# outside will cause the hash to replace the contents instead of appending to them.
new_option = [{
name: option_name,
skunkworker / VolumeMac.ahk
Last active Nov 16, 2018
AutoHotkey mac keyboard play/pause, back/next, volume up, down, mute
View VolumeMac.ahk
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
Sendinput, {F10}
skunkworker / migrations.rake
Created Oct 18, 2018
Generate clean sql migrations from lol_dba
View migrations.rake
namespace :migrations do
desc 'Generate clean SQL migrations from lol_dba'
task clean_sql: :environment do
sql_migration_files = Dir[Rails.root.join("db", "migrate_sql")+"*.sql"]
sql_migration_files.each_with_index do |sql_file,i|
skunkworker / config annotate.yml
Last active Oct 11, 2018
Add custom models to Annotate Gem
View config annotate.yml
- interactions/foo/
- interactions/user/bar/
- interactions/baz.rb
- interactions/bar/
- interactions/user/bar/
skunkworker / readme.txt
Last active Sep 20, 2018
How to fix valgrind ignoring sigreturn errors on mac os x high sierra.
View readme.txt
git clone;
cd valgrind/
# time to edit some files (see below)
./configure --disable-dependency-tracking --enable-only64bit --build=amd64-darwin
./make install
# done.
skunkworker / dotenv.zsh
Created Feb 17, 2018
fixed dotenv.zsh for loading and excluding comments.
View dotenv.zsh
#! /bin/zsh
function dotenv () {
if [[ $1 =~ $regex ]]; then
if [[ -f $file_name ]]; then
source_env $file_name
skunkworker / nbody.rb
Last active Feb 25, 2018
TruffleRuby is insanely fast. 641s on MRI 2.5.0, (302s on MRI 2.6-preview1 --jit) vs 16.2s on TruffleRuby.
View nbody.rb
# The Computer Language Benchmarks Game
# Optimized for Ruby by Jesse Millikan
# From version ported by Michael Neumann from the C gcc version,
# which was written by Christoph Bauer.
require 'benchmark'
puts Benchmark.measure {
skunkworker / test_job_helper.rb
Created Dec 30, 2017
ActiveJob run enqueued jobs without block for testing.
View test_job_helper.rb
# this pulls out each job and runs it, then clears the job queue.
# helpful when you don't want to run inside a block.
def perform_enqueued_jobs_now
enqueued_jobs = ActiveJob::Base.queue_adapter.enqueued_jobs
enqueued_jobs.each do |item|
ActiveJob::Base.queue_adapter.performed_jobs << item
skunkworker / annotate_models.rb
Created Nov 26, 2017
How to extend annotate gem for more models.
View annotate_models.rb
# add to app/initializers/annotate_models.rb
module AnnotateModels
class << self
# add your type
MATCHED_TYPES = %w(test fixture factory serializer scaffold controller helper serializable).freeze
# the directory they live in, can be more than 1 here
SERIALIZABLE_DIR = File.join('app', "serializers")
skunkworker / .travis.yml
Created Sep 2, 2017
Compile Vips 8.5.8 on Travis CI
View .travis.yml
dist: trusty
- chmod +x
- ./
- vips-8.5.8