Skip to content

Instantly share code, notes, and snippets.

require 'active_support/all'
require 'minitest/autorun'
require 'zeitwerk'
class ASITest < Minitest::Test
module CodeInflector
extend ActiveSupport::Inflector
def self.inflections
i = ActiveSupport::Inflector::Inflections.new
require 'benchmark'
require 'matrix'
v1 = [1, 1, 1, 1]
v2 = [2, 3, 2, 3]
v3 = [1, 1, 1, 1 ]
def sol_1(a,b,c)
sum = 0
zip = a.zip(b, c)
begin
# redacted = '13c7722bd7b3c830bea3dfbd89d447979b902335c5e517ffdba6ee091d01a1151a6c6d9609f6733a4a12116dd8bb88a0d20d62691ef3dc648393d492f6506e48e6946508783b94463d118113ae98a540a1dcb376b38751f1af8e95ddc70184b2b4d2f8844bf02de8a956b445d9c9fe886dd15c8a2b2e1c7bd2f3cc67b065f5383dca814898b5ead264adea9a88ed5accb31bd5654e2628e5958fe84bc2c79c12a9897d9b4820a81aac5999bc64c7edbbe592a52bf7c583efb9c26de9a11b42166e6fdbc527541278ff3861f0bd0c4a1c5b21d5e1d116b07def9ef8bb8b8b569b364d44edac389e936c8911541896308a9cb8e45e3406750edd35f6f8e804109042808a255f0f8660218e07c4374786ec5c32c9dab56bc0f7354852cf2acf6846bb6323ee7b488f68fb823b51dd819dc630d06569933839fc26acc4f8004387ff15e44090907dad8b5eef3ed8d0cbd3d03d6dfcf85494f67c61e34f055ef8af86c0244a8a6428168cf92e5fe7cd8215165dac197d944fdce3c71f61d0e83d98ea916bc0b8285c64b8590db7907af0bc302995b3669da2e05c13a8a4ce2bfaf431a43d8c0d719d049f012923e027128ab45e0a72d00e92096d4b5414599068ed665d1baf52fb283aeee06d0f67b35d2e4b766d0f0557d6150170fa9a16fe42af914ff696ab701034fde7bd9d944f0c3c3ccc18020ba9
@jaredbeck
jaredbeck / delete_branches_interactively.sh
Last active June 22, 2020 17:57
Loop over git branches, interactively inspecting/deleting them
#!/usr/bin/env bash
set -e
for BRANCH in $(git branch --format '%(refname:short)' | egrep -v '(master|dev)')
do
NEXT_BRANCH=false
until [ "$NEXT_BRANCH" = true ]
do
echo -e "\n$BRANCH"
@jaredbeck
jaredbeck / test.rb
Created May 13, 2020 18:19
Testing Authlogic PR 717
require 'bundler/setup'
require 'minitest'
require 'minitest/autorun'
# AR 6.0.2.2
module AR6022
def save(*args, &block)
{ args: args }
end
end
# 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
@jaredbeck
jaredbeck / sorbet_polymorphism.rb
Last active June 25, 2019 15:25
Three Examples of Polymorphism under the Reign of Sorbet
# typed: true
require 'sorbet-runtime'
# Example 1: Polymorphism by Classical Inheritance
class Fruit; def eat; puts('ate fruit: ' + self.class.name.to_s); end; end
class Apple < Fruit; def eat; puts 'ate apple'; end; end
class Banana < Fruit; end
class Eater
extend T::Sig
@jaredbeck
jaredbeck / symbol_to_proc_test.rb
Created April 15, 2019 19:58
Regression in cancan 3.0.0: ArgumentError using symbol-to-proc
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem "cancancan", "3.0.0"
gem "rails", "5.2.3"
gem "sqlite3"
end

Prompt Structure

By default, the general appearance of the prompt is::

(<branch> <upstream branch> <branch tracking>|<local status>)

The symbols are as follows:

  • Local Status Symbols
@jaredbeck
jaredbeck / gist:2a7a05a268235fbfecf95a46f1886797
Created February 7, 2018 22:26
notes for params discussion
# 512
Authentication .. no longer possible without using Strong Parameters
https://github.com/binarylogic/authlogic/issues/512
Closed by #558, which deprecates passing AC::Parameters to authlogic. Going
forward, perform the necessary permit, and pass a plain Hash to authlogic.
# 558