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
module DigestQueries | |
def predicate_builder | |
@predicate_builder ||= super.tap do |pb| | |
pb.register_handler(Digest::Instance, DigestHandler.new(pb)) | |
end | |
end | |
class DigestHandler | |
def initialize(predicate_builder) | |
@predicate_builder = predicate_builder |
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
module FrequencyExtension | |
def most_frequent | |
frequency_order.take | |
end | |
def frequency_order | |
group(arel_attribute(primary_key).order(arel_attribute(primary_key).count.desc) | |
end | |
end |
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
y = ->(f) { | |
->(x) { x.(x) }.( | |
->(x) { f.(->(v) { x.(x).(v) }) } ) | |
} | |
fib = y.(->(f) { | |
->(n) { n < 2 ? Array(0..n) : f[n-1].then { _1 << _1[-1] + _1[-2] } } | |
}) | |
fib[6] #=> [0, 1, 1, 2, 3, 5, 8] |
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
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Sid": "VisualEditor0", | |
"Effect": "Allow", | |
"Action": [ | |
"ec2:DescribeNetworkInterfaces", | |
"ec2:AssignIpv6Addresses" | |
], |
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 | |
require "bundler/inline" | |
gemfile(true) do | |
source "https://rubygems.org" | |
gem "rails", github: "rails/rails" | |
gem "sqlite3" | |
end | |
require "active_record" |
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 | |
require "bundler/inline" | |
gemfile true, quiet: true do | |
source "https://rubygems.org" | |
gem "rails", "6.0.0" | |
gem "sqlite3" | |
gem "pry" | |
end |
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
class Array | |
class << self | |
def fold((head, *tail), &block) | |
block::(head, *tail) | |
end | |
end | |
def fold(&block) | |
self.class.fold(self, &block) | |
end |
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 | |
require "bundler/inline" | |
gemfile(true) do | |
source "https://rubygems.org" | |
git_source(:github) { |repo| "https://github.com/#{repo}.git" } | |
ruby "~> 2.7" | |
gem "rails", github: "rails/rails" | |
gem "sqlite3" |
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 | |
require 'action_view/template' | |
module LiquidMarkdown | |
class Handler | |
cattr_accessor :markdown_options, default: { autolink: true, tables: true, no_intra_emphasis: true } | |
cattr_accessor :strict_liquid, default: true | |
def self.call(template, source = nil) |
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
#!/bin/bash | |
TMPDIR="$(mktemp -d)" | |
CORES=$(sysctl -n hw.ncpu 2>/dev/null || nproc) | |
echo "==> testing with $CORES cores in $TMPDIR" | |
cd $TMPDIR | |
RUBY_VERSION=$(rbenv version-name) | |
TIME=$(which time) |