Skip to content

Instantly share code, notes, and snippets.

@hamakn
hamakn / bq.sql
Last active March 21, 2024 00:04
how to deal with FARM_FINGERPRINT between BQ and golang
select
FARM_FINGERPRINT("UserCustomerID + salt"), -- => -3587376224092439943
mod(abs(FARM_FINGERPRINT("UserCustomerID + salt")), 100) -- => 43
package main
import (
"testing"
"time"
)
func BenchmarkTimeDate(b *testing.B) {
now := time.Now()
@startuml family_tree
package "磯野家" {
[磯野波平]
[(石田)フネ]
[磯野カツオ]
[磯野ワカメ]
() " " as m0
[磯野波平] - m0
package main
import (
"errors"
"testing"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
@hamakn
hamakn / hoge.go
Last active May 6, 2020 13:29
multiple errgroup and timeout
package main
import (
"context"
"errors"
"fmt"
"time"
"golang.org/x/sync/errgroup"
)

migrate testify to go-cmp

require "pry"
# http://nabetani.sakura.ne.jp/yokohamarb/103mask/
def solve(mask)
# 0. 入力を、1a(16) => 26(10) => 11010(2) にする
# 1. 11010(2) => [2, 8, 16] にする
# 2. arrの要素数で分岐する、4つ以下 or それ以上
# 2a. 全部のconbinationを取って、数字変換して、終わり
# 2b. 下4つの組み合わせの前13つと、最後2つを取って、終わり
require "pry"
# どう書く 2019-04-06
# http://nabetani.sakura.ne.jp/hena/orde32rects/
#
# 方針
# 1. 各入力矩形で塗ったかどうかを点ごとに記録する
# 2. 全体を舐めてその点がどの図形に属しているかを判定しつつ、面積と縦横別の面積を記録する
# 3. 各図形のうち長方形になっているものを選択して面積を返してソートする
#
require "pry"
# どう書く 2019-04-06
# http://nabetani.sakura.ne.jp/hena/orde32rects/
#
# 方針
# 1. 各入力矩形で塗ったかどうかを点ごとに記録する
# 2. 全体を舐めてその点がどの図形に属しているかを判定しつつ、面積と縦横別の面積を記録する
# 3. 各図形のうち長方形になっているものを選択して面積を返してソートする
#
@hamakn
hamakn / codes.md
Created March 15, 2019 11:00
gRPC Code and HTTP Status Code