Skip to content

Instantly share code, notes, and snippets.

@yoppi
yoppi / caching_bundle_install.md
Last active December 16, 2021 02:10
GitHub Actions上でのbundle installのキャッシュ

モチベーション

毎回bundle installするのはコストがかかるため、Gemfileに変更がない場合はキャッシュしたい。

参考 https://blog.freks.jp/github-action-cache/

+      - name: cache bundle directory
+        uses: actions/cache@v1
+ with:
@yoppi
yoppi / readfile.go
Created August 18, 2018 05:18
Fileを読み込むやつ
$ ./file_read [~/d/src/go]
ReadFile:148545 elapsed:167.706µs
ReadLine:144946 elapsed:209.144µs
Scanner:144946 elapsed:553.246µs
@yoppi
yoppi / map.go
Created April 4, 2018 06:03
Goのmapは値渡しではない
$ ./map
map[1:hoge]
&map[1:hoge]
map[1:hogehoge]
&map[1:hogehoge]
@yoppi
yoppi / regexp.go
Last active October 20, 2017 09:37
キャプチャするしない
package regexp
import (
"regexp"
"testing"
)
func BenchmarkRegexp1(b *testing.B) {
re := regexp.MustCompile(`(iTunes)/(\d+)\.(\d+)`)
for i := 0; i < b.N; i++ {
@yoppi
yoppi / reading_dep.md
Last active April 5, 2017 04:17
depのコードリーディング

depのコードを読んで面白いとか思った所

genericsないから案件

https://github.com/golang/dep/blob/4105d3a/context.go#L200-208 こういった任意の型のコンテナの探索はGenericsだ!と息巻く人もいると思うけど、stringしか扱わないならベタで書いたほうが僕は読みやすくていいと思う。

@yoppi
yoppi / git_fileters.md
Last active March 27, 2017 05:20
gitのfilterで指定できるatom一覧
@yoppi
yoppi / uuid.sh
Created March 15, 2017 07:49
Gen uuid in command line
uuidgen | tr '[:upper:]' '[:lower:]' # Mac OS(darwin) generate default uppercase
@yoppi
yoppi / tcpdos.go
Last active May 12, 2017 04:17
DoS for TCP
package main
import (
"bytes"
"flag"
"fmt"
"net"
"runtime"
"strconv"
"sync"
@yoppi
yoppi / each_vs_compact_map_uniq_bench.rb
Created February 7, 2017 02:08
each君 vs enumerable君
require 'benchmark'
N = 5
TRY = 1_000_000
campaign = Struct.new("Campagin", :id)
campaings = []
N.times { |i| campaings << campaign.new(i+1) }
def each(ary)
@yoppi
yoppi / unicorn_vs_puma.md
Last active February 12, 2017 08:36
Unicorn vs Puma

Unicorn

 < ab -n 10000 -c 100 'http://127.0.0.1:8080/loadtest'
This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 1000 requests