Skip to content

Instantly share code, notes, and snippets.

View dmiyakawa's full-sized avatar
🤠
Vacation in Raccoon City

Daisuke Miyakawa dmiyakawa

🤠
Vacation in Raccoon City
View GitHub Profile
@dmiyakawa
dmiyakawa / shell
Created March 29, 2020 11:23
pip install mysqlclient に失敗したときは
$ LDFLAGS=-L/usr/local/opt/openssl/lib pip install mysqlclient
@dmiyakawa
dmiyakawa / README.md
Created March 28, 2020 13:19
『OAuth徹底入門』 (OAuth in Action) の3サーバを立てるスクリプト

本ではそれぞれ別のターミナルで起動してくださいという趣旨の説明があるんですが面倒なんで。

@dmiyakawa
dmiyakawa / entrypoint.sh
Created October 13, 2018 08:39
mysql:5.6 on Docker Hub
#!/bin/bash
set -eo pipefail
shopt -s nullglob
# if command starts with an option, prepend mysqld
if [ "${1:0:1}" = '-' ]; then
set -- mysqld "$@"
fi
# skip setup if they want an option that stops mysqld
@dmiyakawa
dmiyakawa / docker-compose.yml
Created May 4, 2018 04:11
WordPress on Docker Compose
wordpress:
image: wordpress:latest
links:
- db:mysql
ports:
- '127.0.0.1:8080:80'
db:
image: mariadb:latest
environment:
MYSQL_ROOT_PASSWORD: password123
@dmiyakawa
dmiyakawa / signal_exp_01.py
Created April 24, 2018 05:44
Investigate signals and threads/processes
#!/usr/bin/env python3
#
# In this code we investigate how to "gracefully" exit all child processes
# and threads. "Gracefully" implies "each thread/process gets through the
# whole release work before exitting, minimizing the lisk of resource leaks or
# other unexpected behaviors"
#
# In the real world, it may be OK just to use thread.daemon = True or
# process.daemon = True, especially if you do not care of long term stability.
# Container technology may allow that kind of rough edges in your codes.
@dmiyakawa
dmiyakawa / flags_asyncio.py
Last active March 22, 2018 09:11
asyncio example on "Fluent Python", modified
#
# c.f. "Fluent Python" (Ja) p577
#
import asyncio
import aiohttp
import sys
import time
POP20_CC = ['CN', 'IN', 'US', 'ID', 'BR', 'PK', 'NG', 'BD', 'RU', 'JP',
'MX', 'PH', 'VN', 'ET', 'EG', 'DE', 'IR', 'TR', 'CD', 'FR']
@dmiyakawa
dmiyakawa / shell
Created March 3, 2018 08:12
異字体セレクタの使われ方がなんかおかしい?
$ hexdump -C <(curl -sS https://twitter.com/________Kee/status/969785495424180225) | grep -A 3 'e3 83 88 20'
00001350 30 3b e3 83 86 e3 82 b9 e3 83 88 20 e7 a4 be ef |0;......... ....|
00001360 b8 80 ef b8 80 e2 80 a6 20 26 71 75 6f 74 3b 3c |........ &quot;<|
00001370 2f 74 69 74 6c 65 3e 0a 20 20 20 20 20 20 3c 6d |/title>. <m|
00001380 65 74 61 20 6e 61 6d 65 3d 22 72 6f 62 6f 74 73 |eta name="robots|
--
00002cc0 e3 83 88 20 e7 a4 be ef b8 80 ef b8 80 e2 80 a6 |... ............|
00002cd0 20 26 71 75 6f 74 3b 22 3e 0a 0a 0a 20 20 3c 6c | &quot;">... <l|
00002ce0 69 6e 6b 20 72 65 6c 3d 22 61 6c 74 65 72 6e 61 |ink rel="alterna|
00002cf0 74 65 22 20 6d 65 64 69 61 3d 22 68 61 6e 64 68 |te" media="handh|
@dmiyakawa
dmiyakawa / proof_of_work_parallel.go
Created December 27, 2017 07:00
Proof of Work? with Goroutine
package main
import (
"crypto/sha256"
"fmt"
"math/rand"
"time"
"runtime"
)
@dmiyakawa
dmiyakawa / stairs_2.py
Created November 28, 2017 08:41
n段飛び
#!/usr/bin/env python
import functools
# メモ化を行うデコレータ
# 戻り値をキャッシュするのでprint()は使わないように
@functools.lru_cache()
def stairs(n):
if n < 0:
return None
@dmiyakawa
dmiyakawa / qlearn.py
Created November 1, 2017 05:08
carpole + Q学習
#!/usr/bin/env python3
#
# http://neuro-educator.com/rl1/
#
import gym # 倒立振子(cartpole)の実行環境
import numpy as np
import time
# カート位置 -2.4~2.4
# カート速度 -3.0~3.0