Skip to content

Instantly share code, notes, and snippets.

View yuroyoro's full-sized avatar
🍣
🍣

しいたけ yuroyoro

🍣
🍣
View GitHub Profile
@yuroyoro
yuroyoro / grpc_vcr.rb
Created July 17, 2020 03:07
gRPCのレスポンスをファイルに記録してrspecで再生できるようにしたやつ
require "grpc"
module GRPC::VCR
GRPC_VCR_FiXTURE_PATH = SPEC_PATH.join("fixtures/grpc_vcr")
def grpc_interceptor(example)
cassette = example.metadata[:grpc_vcr]
return unless cassette&.is_a? GRPC::VCR::Cassette
cassette.exist? ?

噛み癖を治すために

  • 噛みたいという欲求を解消する必要がある
  • ケージから出して、引っ張り合いをして遊んであげる
    • おもちゃの種類をふやす 10種類くらい用意して飽きさせないように
    • 紐や人形などで引っ張り合いをする
      • 引っ張りで噛む力を発散させる
    • 大きく振り回すと歯を炒めるので、小刻みに引っ張る
  • あそぶときに手をかんだらやめる
@yuroyoro
yuroyoro / evil_promise_usage.js
Created May 23, 2019 05:08
async/awaitとpromise使えばモナド糖衣構文っぽいの書けそうだよねって思って書いてみたけど、async () => {} でwrapしないといけないしまぁそんなにきれいに書けなかったって話。でもこういう邪悪なことやる関数型厨いそうですよね?(オマエだよ)
// Optional container like maybe monad
class Option {
constructor(value){
this.value = value
}
async promise() {
return new Promise((resolve, reject) => {
if (this.value) {
resolve(this.value);
@yuroyoro
yuroyoro / calculate_asset_path.rb
Created August 17, 2018 13:35
Congrats toward to HTML5
#!/usr/bin/env ruby
arr = {
resource: [6657, 5699, 3371, 8909, 7719, 6229, 5449, 8561, 2987, 5501, 3127, 9319, 4365, 9811, 9927, 2423, 3439, 1865, 5925, 4409, 5509, 1517, 9695, 9255, 5325, 3691, 5519, 6949, 5607, 9539, 4133, 7795, 5465, 2659, 6381, 6875, 4019, 9195, 5645, 2887, 1213, 1815, 8671, 3015, 3147, 2991, 7977, 7045, 1619, 7909, 4451, 6573, 4545, 8251, 5983, 2849, 7249, 7449, 9477, 5963, 2711, 9019, 7375, 2201, 5631, 4893, 7653, 3719, 8819, 5839, 1853, 9843, 9119, 7023, 5681, 2345, 9873, 6349, 9315, 3795, 9737, 4633, 4173, 7549, 7171, 6147, 4723, 5039, 2723, 7815, 6201, 5999, 5339, 4431, 2911, 4435, 3611, 4423, 9517, 3243],
voice: [2475, 6547, 1471, 8691, 7847, 3595, 1767, 3311, 2507, 9651, 5321, 4473, 7117, 5947, 9489, 2669, 8741, 6149, 1301, 7297, 2975, 6413, 8391, 9705, 2243, 2091, 4231, 3107, 9499, 4205, 6013, 3393, 6401, 6985, 3683, 9447, 3287, 5181, 7587, 9353, 2135, 4947, 5405, 5223, 9457, 5767, 9265, 8191, 3927, 3061, 2805, 3273, 7331]
}
def createKey(s)
s.codepoints.
@yuroyoro
yuroyoro / mith_proxy_in_go.md
Last active February 15, 2018 04:18
GoでhttpsをMiTMするProxyの作り方メモ

GoでhttpsをMiTMするProxyの作り方

  1. CONNECTメソッドのリクエストから、http.Hijackerを使って生のTCPコネクションを取り出す
  2. クライアントには200 okを返す
  3. 接続先ホストの証明書を、予め用意してあるroot証明書でサインして生成する
  4. 生成した証明書でクライアントとtls接続を確立する (root証明書が登録されていないとブラウザで警告が出る)
  5. goroutine起こして、クライアントとのtls接続からhttp requestを読み込む
  6. 受けたhttp requestをそのまま接続先hostに送信する
  7. 接続先hostからのhttp responseを、クライアントtls接続に書き込む
  8. EOFが来るまで 5-7繰り返し
@yuroyoro
yuroyoro / README.md
Last active November 30, 2017 08:21
Sentryをdocker-composeで。
  1. docker run --rm sentry config generate-secret-key でSECRET_KEYを生成する
  2. SECRET_KEYを環境変数にいれる export SENTRY_SECRET_KEY="your generated secret key"
  3. docker-compose up -d でサービスあげる。
  4. docker-compose run -rm sentry sentry upgrade で初期設定する
  5. docker-compmse restart で再起動
  6. Go http://localhost:9000 and get sentry!
Received: by 10.170.200.130 with SMTP id r124csp566647yke;
Mon, 26 Jan 2015 17:40:13 -0800 (PST)
X-Received: by 10.236.7.39 with SMTP id 27mr10135662yho.16.1422322813088;
Mon, 26 Jan 2015 17:40:13 -0800 (PST)
Authentication-Results: mx.google.com;
spf=none (google.com: [email protected] does not designate permitted sender hosts) [email protected];
dkim=pass [email protected]
Received-SPF: none (google.com: [email protected] does not designate permitted sender hosts) client-ip=210.224.168.166;
Received: by 10.170.124.9 with POP3 id q9mf1527070ykb.31;
Mon, 26 Jan 2015 17:40:12 -0800 (PST)
Delivered-To: [email protected]
Received: by 10.129.121.20 with SMTP id u20csp861396ywc;
Mon, 19 Sep 2016 01:14:24 -0700 (PDT)
X-Received: by 10.13.204.87 with SMTP id o84mr24656150ywd.299.1474272863926;
Mon, 19 Sep 2016 01:14:23 -0700 (PDT)
Authentication-Results: mx.google.com;
spf=neutral (google.com: 133.242.250.102 is neither permitted nor denied by best guess record for domain of [email protected]) [email protected];
dkim=pass [email protected]
Received-SPF: neutral (google.com: 133.242.250.102 is neither permitted nor denied by best guess record for domain of [email protected]) client-ip=133.242.250.102;
Received: by 10.129.42.135 with POP3 id q129mf23827744ywq.2;
Received: by 10.202.106.74 with SMTP id f71csp251115oic;
Tue, 4 Jul 2017 19:42:52 -0700 (PDT)
X-Received: by 10.202.85.212 with SMTP id j203mr27110703oib.174.1499222571214;
Tue, 04 Jul 2017 19:42:51 -0700 (PDT)
Authentication-Results: mx.google.com;
spf=neutral (google.com: 133.242.250.104 is neither permitted nor denied by best guess record for domain of [email protected]) [email protected];
dkim=neutral (body hash did not verify) [email protected] header.b=MZougrB6
Received-SPF: neutral (google.com: 133.242.250.104 is neither permitted nor denied by best guess record for domain of [email protected]) client-ip=133.242.250.104;
Received: by 10.202.86.195 with POP3 id k186mf60078182oib.1;
Tue, 04 Jul 2017 19:42:51 -0700 (PDT)
import java.util.*;
import java.util.function.*;
public class Fold {
// 自作fold関数
// 引数に List<T> と、2引数の演算を行うBiFunction<T, T, T>をとって、
// listを順番にfで畳み込む
public static <T> T fold(List<T> list, BiFunction<T, T, T> f) {
T res = list.get(0);