This file contains hidden or 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 'set' | |
Yamanote = %w[とうきょう ゆうらくちょう しんばし はままつちょう たまち しながわ おおさき ごたんだ めぐろ えびす しぶや はらじゅく よよぎ しんじゅく しんおおくぼ たかだのばば めじろ いけぶくろ おおつか すがも こまごめ たばた にしにっぽり にっぽり うぐいすだに うえの おかちまち あきはばら かんだ] | |
Station = Struct.new(:name, :val) | |
class Loop | |
def initialize(array) | |
@array = array.map do |a| | |
if a.is_a? Station |
This file contains hidden or 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 HttpUtil | |
class PathSegment < String | |
MATCHER = Regexp.new("\\A#{URI::RFC3986_Parser::SEG_NC}+\\Z") | |
def self.encode_from(str, allow_slash: false) | |
return str if str.is_a?(PathSegment) | |
raise 'should not include / in element or use allow_slash option to encode' if !allow_slash && str.include?('/') | |
new(URI.encode_uri_component(str.unicode_normalize(:nfkc))) | |
end | |
def initialize(str) | |
raise "invalid char: #{str}" unless MATCHER.match?(str) |
This file contains hidden or 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
RSpec.configure do |config| | |
config.before(:suite) { Coverage.start(oneshot_lines: true) } | |
config.after :suite do | |
coverage_data = Coverage.result(stop: true, clear: true) | |
uncovered_lines(coverage_data) | |
end | |
end | |
def parse_git_diff(base_branch) | |
diff_output, _stderr, _status = Open3.capture3("git diff #{base_branch} --unified=0") |
This file contains hidden or 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 | |
run "heroku create #{@app_name}" | |
gem "pg" | |
file "config/database.yml", <<~CODE | |
development: &psql | |
adapter: postgresql | |
database: #{@app_name} | |
pool: 5 |
This file contains hidden or 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
# A template to run ubuntu using vmType: vz instead of qemu (Default) | |
# This template requires Lima v0.14.0 or later and macOS 13. | |
vmType: "vz" | |
rosetta: | |
# Enable Rosetta for Linux. | |
# Hint: try `softwareupdate --install-rosetta` if Lima gets stuck at `Installing rosetta...` | |
enabled: true | |
# Register rosetta to /proc/sys/fs/binfmt_misc | |
binfmt: true |
This file contains hidden or 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 'benchmark' | |
require 'json' | |
require 'active_support/notifications' | |
require 'active_support/cache' | |
array = (1..1000).map { rand } | |
TIMES = 1000 | |
Benchmark.bmbm do |x| | |
cache = ActiveSupport::Cache::FileStore.new("./tmp/cache") |
This file contains hidden or 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
function dive | |
set repo $argv[1] | |
if test -z (echo $repo | cut -d '/' -f3) | |
set repo github.com/$repo | |
end | |
set path ~/repos/$repo | |
if test -d $path | |
cd $path | |
echo "Moved to existing directory $path" |
This file contains hidden or 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
=LET(LX, LAMBDA(X, A, BITXOR(X, BITLSHIFT(BITAND(X, 2^(32-A)-1), A))), RX, LAMBDA(X, A, BITXOR(X, BITRSHIFT(X, A))), LX(RX(LX(input, 13), 17), 5)) |
This file contains hidden or 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
RewriteEngine On | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteRule ^(.*)$ dispatch.cgi/$1 [QSA,L] |
This file contains hidden or 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
[package] | |
name = "chacha" | |
version = "0.1.0" | |
edition = "2021" | |
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | |
[dependencies] | |
"chacha20poly1305" = "0.10.1" |
NewerOlder