{{ message }}

Instantly share code, notes, and snippets.

Matt Jones al2o3cr

• Columbus, OH
Created May 23, 2021
Solution for "four fours" problem

Fours

A partial solution to the problem posed here: https://twitter.com/mikelikesbikes/status/1396159019837018117

This solution represents the expressions in reverse Polish notation (RPN) - see also Forth and HP48s.

The version presented here does NOT produce all values from 1 to 100, as it does not use enough operators.

Extending the search to additional operators only requires adding the value to `@operators` and a clause to `eval` to handle it.

Created Jan 15, 2019
View response.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 [][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]((![]+[])[+!+[]]+(![]+[])[!+[]+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]+(!![]+[])[+[]]+(![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+
Created Jun 25, 2018
STI method generation optimization

Reducing STI memory usage

if there are many STI child classes, ActiveRecord generates methods for each one individually. This is wasteful in the typical case, since all the children share the same underlying columns.

The small patch included here causes those methods to instead be generated in the parent class, shared amongst all the subclasses.

DO NOT use this if you call methods like `attribute :foo` to adjust the typecasting of columns in individual models.

Last active Sep 29, 2017
Test case for rails/rails #28536
View test_association_save.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 # frozen_string_literal: true begin require "bundler/inline" rescue LoadError => e \$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler" raise e end gemfile(true) do
Created Jan 14, 2017
Reproduction script for rails/rails #27666
View test_aliased_through.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 begin require "bundler/inline" rescue LoadError => e \$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler" raise e end gemfile(true) do source "http://rubygems.org" # Activate the gem you are reporting the issue against.
Created Nov 13, 2016
A further variation from https://gist.github.com/jamesdabbs/a85fa5553df7dba0ba3dbb25f4cafe4b
View 💩 🚌👏 .rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 require 'thwait' class Voice BASELINE = %w( there is no - poop ing - on - the bus - ) VOICES = `say -v '?'`.lines.map { |line| line.split.first } attr_reader :voice_name, :rate def initialize(voice_name, rate) @i = 0
Last active Nov 13, 2016
A further variation from https://gist.github.com/jamesdabbs/a85fa5553df7dba0ba3dbb25f4cafe4b
Created Sep 20, 2015
inverse_of regression in 4.2
View test_case.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 begin require 'bundler/inline' rescue LoadError => e \$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler' raise e end gemfile(true) do source 'https://rubygems.org' # NOTE: tests pass on 4.1.x, fail on 4.2
Created Sep 3, 2015
Attempted repro for rails/rails #21466
View test_associations.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 begin require 'bundler/inline' rescue LoadError => e \$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler' raise e end gemfile(true) do source 'https://rubygems.org' gem 'activerecord', '4.2.4'
Last active Sep 3, 2015
Issue found investigating rails/rails #21466
View test_association.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 begin require 'bundler/inline' rescue LoadError => e \$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler' raise e end gemfile(true) do source 'https://rubygems.org' # NOTE: test passes on 4.1.13, fails against 4.2.0+