Skip to content

Instantly share code, notes, and snippets.

@uzimith
uzimith / insert_test.sql
Last active July 6, 2020 19:30
mysql 5.6.45以上で挿入できない
#! /bin/sh
docker run --name tmp-mysql -d --rm \
-p 13306:3306 \
-e MYSQL_ALLOW_EMPTY_PASSWORD=yes -e MYSQL_DATABASE=tmp -v $(pwd):/fixture mysql:5.6.45 \
mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --sql-mode=TRADITIONAL,NO_AUTO_VALUE_ON_ZERO,ONLY_FULL_GROUP_BY --secure-file-priv=""
while ! mysqladmin ping -s -u root -P 13306 -h 0.0.0.0; do
printf .
sleep 1
done
echo ""
@uzimith
uzimith / alacritty.yml
Created July 3, 2020 10:01
alacritty.yml
font:
normal:
family: Ricty for Powerline
style: Regular
bold:
family: Ricty for Powerline
style: Bold
italic:
family: Ricty for Powerline
style: Italic
@uzimith
uzimith / 15_upsert_all.go.tpl
Created April 27, 2020 07:03
SQLboiler bulk update
{{- $alias := .Aliases.Table .Table.Name -}}
{{- $schemaTable := .Table.Name | .SchemaTable}}
// UpsertAll upserts all rows with the specified column values, using an executor.
func (o {{$alias.UpSingular}}Slice) UpsertAll({{if .NoContext}}exec boil.Executor{{else}}ctx context.Context, exec boil.ContextExecutor{{end}}, columns boil.Columns) error {
ln := int64(len(o))
if ln == 0 {
return nil
}
var sql string
@uzimith
uzimith / bench.scala
Last active December 11, 2018 00:55
shapeless vs circe vs refrection
package bench
import org.openjdk.jmh.annotations._
import impl.Impl._
@BenchmarkMode(Array(Mode.Throughput))
@Warmup(iterations = 40, time = 3)
@Measurement(iterations = 40, time = 3)
@Fork(1)
class Bench {
@uzimith
uzimith / build.sbt
Last active December 3, 2018 16:12
how to use msgpack4z
lazy val root = (project in file(".")).
settings(
libraryDependencies ++= Seq(
"com.github.xuwei-k" %% "msgpack4z-core" % "0.3.9",
"com.github.xuwei-k" %% "msgpack4z-native" % "0.3.5"
)
)
@uzimith
uzimith / cloudSettings
Last active August 1, 2019 06:58
Visual Studio Code Settings Sync Gist
{"lastUpload":"2019-08-01T06:58:24.465Z","extensionVersion":"v3.2.9"}
fn main() {
let user_dao = UserMockDao {};
let post_dao = PostMockDao {};
let app = App { user_dao, post_dao };
println!("{:?}", app.get_user_by_id(2));
app.show_by_id(1);
app.show_by_id(2)
}
pub type Result<T> = std::result::Result<T, Box<std::error::Error>>;
@uzimith
uzimith / .babelrc
Last active December 21, 2017 02:04
stream API / async iteration
{
"presets": ["env"],
"plugins": ["transform-runtime", "transform-async-generator-functions"]
}
@uzimith
uzimith / inject.go
Last active December 13, 2017 03:02
package main
import (
"fmt"
"os"
"ghe.ca-tools.org/leicester/auction.git/rdb"
"github.com/facebookgo/inject"
_ "github.com/go-sql-driver/mysql"
"github.com/go-xorm/xorm"
@uzimith
uzimith / flow.js
Created October 12, 2017 03:04
Object.assignエラー
/* @flow */
type Article = {
id: string
}
type State = {
articles: Article[]
}
const state: State = {