Skip to content

Instantly share code, notes, and snippets.

View tag1216's full-sized avatar
😇

tag1216 tag1216

😇
View GitHub Profile
@tag1216
tag1216 / test_stream.py
Created October 13, 2016 03:38
Python subprocessのstdoutとstderrの両方をリアルタイムで取得
#!/usr/bin/python3
import sys
import time
print("start")
i = 1
while True:
if i % 5 == 0:
@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 / 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 / 01_thread.py
Created April 2, 2017 12:19
Pythonでconcurrent.futuresを使った並列タスク実行
import time
from concurrent.futures import ThreadPoolExecutor
from logging import StreamHandler, Formatter, INFO, getLogger
def init_logger():
handler = StreamHandler()
handler.setLevel(INFO)
handler.setFormatter(Formatter("[%(asctime)s] [%(threadName)s] %(message)s"))
logger = getLogger()
@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 / 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 / largesort.py
Created May 7, 2017 07:45
巨大ファイルのソート
import heapq
import os
import re
from argparse import ArgumentParser
from contextlib import contextmanager
from operator import itemgetter
from tempfile import TemporaryDirectory, mktemp
import sys
from typing import IO, Callable, List
@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.