#!/usr/bin/env bash
this_dir="${BASH_SOURCE%/*}"
# Recursively iterates over directories looking for .sh files sourcing them if they exist
for executable in $(find "$this_dir" -regex ".*\.sh"); do
[ -f "$executable" ] && source "$executable"
done
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 Levenshtein | |
class << self | |
def call(a, b) | |
return cache["#{a}-#{b}"] if cache["#{a}-#{b}"] | |
cache["#{a}-#{b}"] = cache["#{b}-#{a}"] = -> { | |
return a.length if b.length.zero? | |
return b.length if a.length.zero? | |
a_head, a_tail = a.chars.then { |head, *tail| [head, tail.join] } |
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 Search | |
class << self | |
def search(options = {}, &process_node) | |
process_node ||= proc {} | |
stop = options.fetch(:stop, nil) | |
queue = options.fetch(:queue) { raise QueueRequiredError } | |
until queue.empty? | |
current_node = queue.dequeue |
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
import\s*\{[\n\s]*(\w+\s*,\s*)*\bUploadSnackbar\b(\s*,\s*\w+\s*,*\s*|\s*,*)*[\n\s]*\}\s*from\s*('|")\s*.*\bMyComponent\b.*\s*('|") |
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
// https://stackoverflow.com/questions/57683303/how-can-i-see-the-full-expanded-contract-of-a-typescript-type | |
// expands object types one level deep | |
type Expand<T> = T extends infer O ? { [K in keyof O]: O[K] } : never; | |
// expands object types recursively | |
type ExpandRecursively<T> = T extends object | |
? T extends infer O ? { [K in keyof O]: ExpandRecursively<O[K]> } : never | |
: T; |
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
type Indexable = string | symbol | number; | |
type PickByKeyName<Type, Name extends Indexable> = { | |
[Key in keyof Type as Key extends Name ? Key : never]: Type[Key]; | |
}; | |
type PickByKeyType<Type, KeyType> = Pick<Type, { | |
[Key in keyof Type]: Type[Key] extends KeyType ? Key : never | |
}[keyof Type]>; |
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
# https://www.ascii-code.com/ | |
# https://fontstruct.com/fontstructions/show/847768/5x7_dot_matrix | |
' | |
1 2 3 4 5 6 7 8 9 0 | |
a b c d e f g h i j k l m n o p q r s t u v w x y z | |
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z | |
' | |
# 00 01 02 03 04 | |
# 05 06 07 08 09 |
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
# https://www.ascii-code.com/ | |
# https://fontstruct.com/fontstructions/show/847768/5x7_dot_matrix | |
' | |
1 2 3 4 5 6 7 8 9 0 | |
a b c d e f g h i j k l m n o p q r s t u v w x y z | |
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z | |
' | |
# 00 01 02 03 04 | |
# 05 06 07 08 09 |
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 | |
module Middleware | |
class Entry | |
attr_reader :klass, :args, :kwargs, :block | |
def initialize(klass, *args, **kwargs, &block) | |
@klass = klass | |
@args = args | |
@kwargs = kwargs |
NewerOlder