Skip to content

Instantly share code, notes, and snippets.

Avatar

John Bolliger skunkworker

View GitHub Profile
@skunkworker
skunkworker / set_solver.rb
Last active Jan 6, 2019
New York Times SET puzzle solver
View set_solver.rb
# Brute force NYT set Solver.
# from https://www.nytimes.com/puzzles/set - Accessed Jan 6
require 'set'
class Item
include Comparable
attr_accessor :color, :shape, :pattern, :item_count
@skunkworker
skunkworker / fast-font.css
Created Dec 30, 2018
Fast font to look consistent everywhere.
View fast-font.css
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
@skunkworker
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.
;F10
^F10::
Sendinput, {F10}
Return
@skunkworker
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
Rake::Task["db:migrate_sql"].invoke
sql_migration_files = Dir[Rails.root.join("db", "migrate_sql")+"*.sql"]
sql_migration_files.each_with_index do |sql_file,i|
@skunkworker
skunkworker / config annotate.yml
Last active Oct 11, 2018
Add custom models to Annotate Gem
View config annotate.yml
Foo:
- interactions/foo/
- interactions/user/bar/
- interactions/baz.rb
Bar:
- interactions/bar/
- interactions/user/bar/
@skunkworker
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 https://sourceware.org/git/valgrind.git;
cd valgrind/
# time to edit some files (see below)
./autogen.sh
./configure --disable-dependency-tracking --enable-only64bit --build=amd64-darwin
./make
./make install
# done.
@skunkworker
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
# http://benchmarksgame.alioth.debian.org
#
# 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
skunkworker / dotenv.zsh
Created Feb 17, 2018
fixed dotenv.zsh for loading and excluding comments.
View dotenv.zsh
#! /bin/zsh
function dotenv () {
regex="DOT_ENV\=(\w+)"
if [[ $1 =~ $regex ]]; then
env="${match[1]}"
file_name=".env.${env}"
if [[ -f $file_name ]]; then
source_env $file_name
return
@skunkworker
skunkworker / .travis.yml
Last active Dec 12, 2017
Rails 5.1 system tests with Travis-ci.com
View .travis.yml
dist: trusty
before_script:
- wget http://chromedriver.storage.googleapis.com/2.34/chromedriver_linux64.zip
- unzip chromedriver_linux64.zip
- sudo apt-get install libnss3
- sudo apt-get --only-upgrade install google-chrome-stable
- sudo cp chromedriver /usr/local/bin/.
- sudo chmod +x /usr/local/bin/chromedriver
- export DISPLAY=:99.0
@skunkworker
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")