Skip to content

Instantly share code, notes, and snippets.

View evalphobia's full-sized avatar

evalphobia

View GitHub Profile
@evalphobia
evalphobia / README.md
Last active February 22, 2024 18:28
Golang Benchmark: gob vs json

tl;dr

  • JSON is faster for small size data
    • map (key size < 50 and Unmarshalling intensive workload)
    • single struct
  • gob is faster for big size data
    • map (key size > 50 or Marshalling intensive workload)
    • slice

(old) about

@evalphobia
evalphobia / osx_setup.sh
Created February 15, 2014 05:21
initial configuration for OSX 10.9
#!/bin/bash
OS_KEY_REPEAT=2
OS_REPEAT_START=15
# keyboard
defaults write NSGlobalDomain KeyRepeat -int $OS_KEY_REPEAT # キーリピート速度
defaults write NSGlobalDomain InitialKeyRepeat -int $OS_REPEAT_START # キーリピート開始までの時間
defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false # キー代用入力を無効にする

6 Concurrency 並行処理

  • ゴルーチンを使ったコード
  • レースコンディションの検知と修正
  • チャネルによるデータ共有

・スケジューラーがどのゴルーチンがどのプロセッサで動いているか管理している
・CSP message passing model(共有データをロックするのではなくチャネルでの受け渡し)

@evalphobia
evalphobia / atoi_test.go
Last active February 13, 2023 16:12
golang benchmark: String and Int conversions
package bench
import (
"strconv"
"testing"
)
var smallStr = "35"
var bigStr = "999999999999999"
@evalphobia
evalphobia / list.txt
Created December 19, 2022 12:34
Check PayPal payment data from Transaction ID
1122334455667788A
AABBCCDDEEFFGGHH1
@evalphobia
evalphobia / README.md
Last active December 19, 2022 04:15
Golang Benchmark: uuid(v4) vs cuid vs nanoid

Golang Benchmark: uuid(v4) vs cuid vs nanoid

Comparing these libraries

  • github.com/google/uuid
  • github.com/lucsky/cuid
  • github.com/matoous/go-nanoid

result

@evalphobia
evalphobia / The_Site_Reliability_Workbook.ch01.md
Last active August 24, 2022 14:21
The Site Reliability Workbook: Chapter 1

Ch.1の前に、この本の簡単な説明。

SRE本が教科書/参考書とするとワークブックは問題集。 SRE本は主に原則や哲学を説明していたが、ワークブックはその原則をどのように適用していくかについて説明。 SRE本はGoogle内でのSREの実践例の話だったが、ワークブックはその他の企業(GCPユーザー)での話もあり。

  • Evernote, Home Depot, NY Times, Spotify

1. SREはDevOpsにどのように関わっていくのか

@evalphobia
evalphobia / The Three Go Landmines.ja.markdown
Last active July 27, 2022 10:48 — forked from lavalamp/The Three Go Landmines.markdown
Go言語の地雷(原題: Golang landmines)

Goでよくやってしまうミスが3つあります。
私はそのミスを、分かりやすいように簡略した書き方ではなく、巷でよく見かける書き方のままここで説明します。
3つのミスの全てが、私の知る限り少なくとも1回づつ、Kubernetesの過去のコードレビューにありました。

1: ループ変数がループ外のスコープになっている

この各行はいったい何を行っているのでしょうか。想像してから下へスクロールしてください。

@evalphobia
evalphobia / resize_jpg.go
Created March 19, 2020 10:11
Resizing Image (Jpeg) for golang
package library
import (
"bytes"
"image"
"image/jpeg"
"io"
"github.com/disintegration/imaging"
)
@evalphobia
evalphobia / action.js
Created July 5, 2018 08:14
To fetch Google Calendar event. (Running on Firebase Functions for Dialogflow)
class Action {
constructor(req, res){
this.request = req;
this.response = res;
this.requestSource = (req.body.originalRequest) ? req.body.originalRequest.source : undefined;
this.app = new DialogflowApp({req, res});
console.log('api-v2')
}