This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// cf. https://maximorlov.com/parallel-tasks-with-pure-javascript/ | |
import { setTimeout } from 'node:timers/promises'; | |
async function doWork(iterator, i) { | |
for await (const value of iterator) { | |
await setTimeout(1000); | |
console.log(`worker ${i}: ${value}`); | |
} | |
console.log(`worker ${i} finish`) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/base64" | |
"fmt" | |
"github.com/tuneinsight/lattigo/v4/ckks" | |
"github.com/tuneinsight/lattigo/v4/rlwe" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import winston from "winston"; | |
type LogLevel = keyof typeof winston.config.npm.levels; | |
const levels = Object.keys(winston.config.npm.levels); | |
const DEFAULT_LABEL = "-"; | |
const formatAddLocation = winston.format((info) => { | |
const getLocation = () => { | |
const limitBak = Error.stackTraceLimit; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function elapsed_millisec() { | |
BEFORE=$(date +%s%3N) | |
eval "${@}" | |
AFTER=$(date +%s%3N) | |
awk -v OFMT="%.3f" -v before=${BEFORE} -v after=${AFTER} 'BEGIN { print (after - before) / 1000 }' | |
} | |
elapsed_millisec sleep 1.234 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mergeHeader: | |
[ | |
"scheme", | |
"user", | |
"password", | |
"domain", | |
"path", | |
"querystring", | |
"fragment" | |
] as $header |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name = "generic" | |
version = "0.1.0" | |
edition = "2021" | |
[dependencies] | |
serde = { version = "1.0", features = ["derive"] } | |
serde_json = "1.0" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import reduce | |
def f_add(x): | |
def __add(y): | |
return x + y | |
return __add | |
def f_mul(x): | |
def __mul(y): | |
return x * y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TODAY := $(shell date --iso-8601="seconds") | |
N := 7 | |
from = $(shell date +'%Y-%m-%d %H:00:00' -d '${TODAY} $1 day ago 1 day ago') | |
to = $(shell date +'%Y-%m-%d %H:00:00' -d '${TODAY} $1 day ago') | |
define bt | |
@ echo "BETWEEN '${from}' AND '${to}'" | |
endef |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# サンプルはこちらにある json | |
# https://docs.aws.amazon.com/ja_jp/step-functions/latest/dg/sample-map-state.html | |
run: | |
@ cat sample.asl.json | jq -f a.jq |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cf. https://ichirin2501.hatenablog.com/entry/2015/12/24/164916 | |
export MYSQL_PWD := db_pass | |
CLI := mysql -h 127.0.0.1 -P 3306 -u root -D hoge | |
Q1 := INSERT INTO player (name) VALUES \ | |
("a"), ("b"), ("c"), ("d"), ("e"), ("f"), ("g"), ("h"), ("i"), ("j"), ("k"), ("l"), ("m"), ("n"), ("o"), ("p"), ("q"), ("r"), ("s"), ("t"), ("u"), ("v"), ("w"), ("x"), ("y"), ("z") | |
Q2 := INSERT INTO player (name) VALUES \ | |
("z"), ("y"), ("x"), ("w"), ("v"), ("u"), ("t"), ("s"), ("r"), ("q"), ("p"), ("o"), ("n"), ("m"), ("l"), ("k"), ("j"), ("i"), ("h"), ("g"), ("f"), ("e"), ("d"), ("c"), ("b"), ("a") |
NewerOlder