Skip to content

Instantly share code, notes, and snippets.

@killagu
killagu / worker.js
Created July 11, 2018 15:15
thread cluster
const { Worker, isMainThread, parentPort, threadId } = require('worker_threads');
const os = require('os');
const http = require('http');
const fs = require('fs');
if (isMainThread) {
const workers = [];
const workerCount = os.cpus().length;
for (let i = 0; i < workerCount; ++i) {
workers.push(new Worker(__filename, {}));
@killagu
killagu / auto_str.py
Created September 26, 2017 08:34
python auto generate __str__
from enum import Enum
from functools import reduce
from collections import Iterable
def auto_str(cls):
def build_key_value_str(key, value, intent):
return build_intent(intent) + key + ': ' + value + '\n'
def is_enum(obj):