Skip to content

Instantly share code, notes, and snippets.

@utgwkk
utgwkk / nippo.py
Last active January 14, 2019 07:41
日報を書くように促してくれるSlack incoming webhook氏
#!/usr/bin/python3
import subprocess
import json
import urllib.parse
from datetime import date
PROJECT_NAME = 'your-project-name'
WEBHOOK_URL = 'SLACK_INCOMING_WEBHOOK_URL'
def to_ja_week(week_num: int) -> str:
#!/usr/bin/env python3
import itertools
import sys
users = [x.rstrip() for x in sys.stdin.readlines()]
result = "(" + " OR ".join(map(lambda x: "from:" + x, users)) + " exclude:replies) OR "
pairs = []
@utgwkk
utgwkk / rorotoro.py
Created September 23, 2018 03:47
H_na_rorotoroガチャ
import random
import itertools
def rorotoro():
for ro in range(1, 5):
to = 4 - ro
for rorotoro in itertools.permutations((['ro'] * ro) + (['to'] * to)):
yield ''.join(rorotoro)
def h_na_rorotoro(num_min_underscores=1, num_max_underscores=30):
@utgwkk
utgwkk / closure.py
Created July 11, 2018 05:41
Calculating closure of functional dependencies
fds = {
('A', 'B'),
('A', 'G'),
('B', 'C'),
('C', 'D'),
('BC', 'E'),
('CG', 'A'),
}
start = 'B'
@utgwkk
utgwkk / emoji.mysql
Created March 21, 2018 07:53
MySQL 5.7
-- MySQL dump 10.13 Distrib 5.7.21, for Linux (x86_64)
--
-- Host: localhost Database: sandbox
-- ------------------------------------------------------
-- Server version 5.7.21
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
@utgwkk
utgwkk / fib.c
Created February 12, 2018 02:03
fib(38) を求めるCプログラム
#include <stdio.h>
#include <stdlib.h>
extern void start_timer();
extern void stop_timer();
typedef union MLType {
int value;
union MLType (*func)(union MLType, union MLType);
union MLType *tuple;
} _t;
@utgwkk
utgwkk / conv.py
Created February 10, 2018 04:03
カレントディレクトリのMP3のファイル名を,ID3をもとに変更するスクリプト
"""
You have to `pip install mutagen` before executing this script
"""
import os
from glob import glob
from mutagen.easyid3 import EasyID3
for idx, path in enumerate(glob('*.mp3')):
tags = EasyID3(path)
new_path = '%02d - %s.mp3' % (idx + 1, tags['title'][0])
@utgwkk
utgwkk / fib.c
Created January 17, 2018 06:30
10! を求めるCプログラム
#include <stdio.h>
#include <stdlib.h>
union MLType {
int value;
union MLType (*func)(union MLType, union MLType);
union MLType *tuple;
};
typedef union MLType _t;

Keybase proof

I hereby claim:

  • I am utgwkk on github.
  • I am utgwkk (https://keybase.io/utgwkk) on keybase.
  • I have a public key whose fingerprint is 246F 563A 4426 4BC1 E635 80BD F1E6 21A1 51D6 1491

To claim this, I am signing this object:

@utgwkk
utgwkk / mysql-accumlate.md
Last active May 30, 2023 09:34
詳説 MySQLで累積和を求める方法

MySQL で累積和を求める方法

SELECT
    t1.accum_date
 , t1.count