Skip to content

Instantly share code, notes, and snippets.

View application.rb
# ...
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
# TODO: remove once gems no longer need it. See required file for details.
# Patches Rails before initializing Gems. Also covers rake tasks that don't depend on :environment.
if Rails.gem_version >='6.1') # Forward-port methods removed in 6.1
require_relative "../lib/extensions/core_ext/module/introspection"
ansonhoyt / Gemfile
Created Jun 27, 2020 — forked from dhh/Gemfile
HEY's Gemfile
View Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers
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;