Skip to content

Instantly share code, notes, and snippets.

Anson Hoyt ansonhoyt

Block or report user

Report or block ansonhoyt

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
ansonhoyt / invalid_query_active_record_523.rb
Created Jun 24, 2019
ActiveRecord :has_many only partially applies a scoped :through association where the scope has #merge conditions.
View invalid_query_active_record_523.rb
# frozen_string_literal: true
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
gemfile(true) do
ansonhoyt / brew config
Last active Sep 26, 2018
Homebrew test case: brew doctor with 1.7.6-9-g2ea3aee and old linkage.db
View brew config
HOMEBREW_VERSION: 1.7.6-9-g2ea3aee
HEAD: 2ea3aee461f4b2f22ccc9b6f72b4426448bc1039
Last commit: 27 hours ago
Core tap ORIGIN:
Core tap HEAD: ae68a80c0257579b3c109cb56c53c6dcc979d984
Core tap last commit: 22 hours ago
CPU: octa-core 64-bit haswell
ansonhoyt /
Created Sep 25, 2018
Values that cause Homebrew's CacheStateDatabase.set to segfault

In CacheStoreDatabase.set(key, value) the statement db[key] = value fails for:




ansonhoyt / linkSelector.js
Created Mar 22, 2018
Download all link's target files for the given selector
View linkSelector.js
let linkSelector = '.download-button';
document.querySelectorAll(linkSelector).forEach(function(link) {
let clone = link.cloneNode(); // avoid existing event listeners
clone.setAttribute('download', ''); // indicate the download action; // trigger the download
ansonhoyt / Erb::scaffold_generator.rb
Last active Jan 3, 2016
`rails g scaffold` or `rails g scaffold_controller` never invokes my override of Erb::Generators::ScaffoldGenerator. I can workaround by setting `config.generators.template_engine :all` and moving the override there. That feels wrong.
View Erb::scaffold_generator.rb
# lib/generators/erb/scaffold/scaffold_generator.rb
# See
# require 'rails/generators/erb'
# require 'rails/generators/resource_helpers'
require 'rails/generators/erb/scaffold/scaffold_generator' # see
module Erb # :nodoc:
module Generators # :nodoc:
class ScaffoldGenerator < Erb::Generators::ScaffoldGenerator # :nodoc:
ansonhoyt / ability.rb
Last active Dec 16, 2015
Authorizing polymorphic association with CanCan 1.6.9
View ability.rb
class Ability
include CanCan::Ability
def initialize(user, session=nil)
@user = user
@session = session
@user ? user_rules : public_rules
def user_rules
ansonhoyt / puzzle.rb
Created Mar 27, 2013
Finds words of a given length that are made from the given letters. Helps solve puzzles in the "Four Pictures, One Word" game.
View puzzle.rb
#!/usr/bin/envy ruby
# Finds words of a given length that are made from the given letters.
# Helps solve "Four Pictures, One Word" puzzles.
# @author Anson Hoyt
require 'optparse'
# Parse command line arguments
def parse(args)
ansonhoyt / config.js
Created Sep 28, 2012
Demonstrate bugs in CKEditor 4 Beta
View config.js
/* Example Configuration for CKEditor Beta 4
CKEDITOR.editorConfig = function(config) {
config.toolbarStartupExpanded = false; // Bug: toolbar doesn't render at all.
// config.toolbarStartupExpanded = true; // This works fine. Toolbar can be collapsed.
config.toolbarCanCollapse = true;
ansonhoyt / excelToJson.rb
Created Mar 1, 2012
Convert Excel of Arbitrary Tasks to JSON
View excelToJson.rb
#!/usr/bin/env ruby
# Reads an Excel and writes as JSON
# - Assumes header row containing field names, first sheet is read
# - Keeps null values
# - accept filename and read based on extension (xlsx, xls, csv).
# - output actual JSON.
# - clean up.
You can’t perform that action at this time.