Skip to content

Instantly share code, notes, and snippets.

View tag1216's full-sized avatar
😇

tag1216 tag1216

😇
View GitHub Profile
@tag1216
tag1216 / bytes.ts
Created January 23, 2020 08:44
format bytes
const UNITS = [
"bytes",
"KB",
"MB",
"GB",
"TB",
];
export function formatBytes(bytes: number) {
const index = Math.min(Math.floor(Math.log10(bytes) / 3), UNITS.length - 1);
@tag1216
tag1216 / chunk.ts
Created December 25, 2018 08:24
JavaScript chunk
function *chunk(array: any[], size: number) {
let from = 0;
while (from < array.length) {
const subarray = array.slice(from, from+size);
yield subarray;
from += size;
}
}
@tag1216
tag1216 / sleep.ts
Created December 14, 2018 02:24
Javascript sleep
async function sleep(msec: number) {
return new Promise(resolve => setTimeout(resolve, msec));
}
@tag1216
tag1216 / pipe.py
Last active March 9, 2021 18:06
Python concurrent.futures pipe
import queue
import random
import time
from concurrent.futures import ThreadPoolExecutor, Executor, Future
from contextlib import contextmanager
from threading import Thread
from tqdm import tqdm
@tag1216
tag1216 / app.conf
Created November 12, 2018 04:46
front-backend用nginx設定
server {
listen 8081 default;
server_name localhost 127.0.0.1;
location /api/v1/ {
proxy_pass http://localhost:8082/;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
}
@tag1216
tag1216 / QiitaAdventCalendar2017.ipynb
Created January 13, 2018 02:14
Qiitaアドベントカレンダー2017の分析
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tag1216
tag1216 / calendars.tsv
Created January 11, 2018 11:27
Advent Calendar 2017
We can make this file beautiful and searchable if this error is corrected: It looks like row 10 should actually have 8 columns, instead of 2. in line 9.
year calendar_id title url category participants_count likes_count subscribers_count
2017 haskell5 Haskell (その5) Advent Calendar 2017 https://qiita.com/advent-calendar/2017/haskell5 Programming Langs 5 23 0
2017 vivaldi Vivaldiブラウザー Advent Calendar 2017 https://qiita.com/advent-calendar/2017/vivaldi Web Technologies 1 3 0
2017 yaruki やる気 Advent Calendar 2017 https://qiita.com/advent-calendar/2017/yaruki Miscellaneous 1 0 1
2017 acquisition 買収 Advent Calendar 2017 https://qiita.com/advent-calendar/2017/acquisition Company 5 0 6
2017 power_builder PowerBuilder Advent Calendar 2017 https://qiita.com/advent-calendar/2017/power_builder Programming Langs 1 0 3
2017 enterprise Enterprise Advent Calendar 2017 https://qiita.com/advent-calendar/2017/enterprise Programming Langs 1 0 2
2017 keyboard_mouth キーボードとマウスとコーヒーと Advent Calendar 2017 https://qiita.com/advent-calendar/2017/keyboard_mouth Miscellaneous 7 15 11
2017 bpm bpm Advent Calendar 2017 https://qiita.com/advent-calendar/2017/bpm Services 1 0 1
2017 techscore
@tag1216
tag1216 / a.txt
Last active January 10, 2018 07:05
hoge
@tag1216
tag1216 / deployment.cmd
Created August 12, 2017 03:49
Azure deployment.cmd
@if "%SCM_TRACE_LEVEL%" NEQ "4" @echo off
:: ----------------------
:: KUDU Deployment Script
:: Version: 1.0.15
:: ----------------------
:: Prerequisites
:: -------------
@tag1216
tag1216 / plugin_manager.py
Created July 14, 2017 14:27
ディレクトリ内のPythonモジュールを動的インポート/リロード
import os
import sys
import time
from glob import glob
from importlib import import_module, reload
from watchdog.events import FileSystemEventHandler, FileSystemEvent
from watchdog.observers import Observer
sys.path.append('plugins')