Skip to content

Instantly share code, notes, and snippets.

package main
import (
"fmt"
"math/rand"
"strings"
"testing"
"time"
)
package main
import (
"context"
"fmt"
"sync"
"testing"
"time"
"github.com/stretchr/testify/assert"
#!/bin/bash
golangci_lint() {
# $1: パス
# $2: サブパスも展開するか
DIR=$1
if [ -n "$2" ]; then
DIR=./$1/...
fi
echo -e "\n$DIR"
@suzujun
suzujun / comma.go
Last active November 2, 2018 01:17
func comma(v int64) string {
sign := ""
// Min int64 can't be negated to a usable value, so it has to be special cased.
if v == math.MinInt64 {
return "-9,223,372,036,854,775,808"
}
if v < 0 {
sign = "-"
v = 0 - v
@suzujun
suzujun / program_number_type.md
Last active February 27, 2023 12:57
言語間の整数型範囲まとめ

signed: 符号あり

数値範囲 mysql java golang javascript
-128 ~ 127 tinyint byte int8 -
-32768 ~ 32767 smallint short int16 -
-8388608 ~ 8388607 mediumint (int) (int32) -
-2147483648 ~ 2147483647 int int int32 -
-9223372036854775808 ~ 9223372036854775807 bigint long int64

※カッコは補うためのタイプ

@suzujun
suzujun / simple_decimal.js
Created June 29, 2016 13:55
IEEE 754 規格による浮動小数点数の計算時に生じる誤差を補うため四則演算クラス
/**
* javascript Decimal クラス
*
* IEEE 754 規格による浮動小数点数の計算時に生じる誤差を補うために使用します
*
* example:
* - var a = new utils.Decimal(100).multi(0.0476).calc();
* print(a); // 4.760000000000001 => 4.76
*
* data case:
@suzujun
suzujun / gist:e3a6c82b53118b3ed1cf
Created May 26, 2015 02:09
github commit diff
javascript:(function(){var l=location.href;if(!l.match(/^https:\/\/github.com\/([0-9a-z\/-]*)\/commit\//)){alert("This page is error");return;};var a=prompt("比較対象を入力してください","develop");location.href=location.href.replace(/commit/,"compare")+"..."+a;})()