Skip to content

Instantly share code, notes, and snippets.

View phero's full-sized avatar

kawasaki yasuhiro phero

View GitHub Profile
@phero
phero / bench.py
Created November 6, 2019 06:25
Sample benchmark of map.
import time
def f1():
return sum([int(i) for i in str(pow(2, 1000))])
def f2():
return sum([int(i) for i in str(2 ** 1000)])
@phero
phero / sample.ahk
Created May 13, 2019 14:16
Sample AutoHotKey script.
vk1D & J::Send,{Blind}{Left}
vk1D & K::Send,{Blind}{Down}
vk1D & I::Send,{Blind}{Up}
vk1D & L::Send,{Blind}{Right}
vk1C & 1::Run,"https://www.google.com/"
vk1C & 2::Run,"https://www.bing.com/"
vk1C & 3::Run,"https://www.amazon.co.jp/"
@phero
phero / append_vs_extend.py
Created June 5, 2018 08:59
Simple benchmark list.append vs list.extend
def f1(xs, ys):
for y in ys:
xs.append(y)
def f2(xs, ys):
xs.extend(ys)
if __name__ == '__main__':
@phero
phero / not_good.py
Created October 26, 2017 02:21
あまりよろしくないサンプル
def f(a, b):
if not a:
return False
if b:
return True
return False
def g(a, b):
return a and b
@phero
phero / settings.py
Created October 26, 2016 01:36
DjangoでGmailからメール送信するためのミニマムの設定
# cf. https://docs.djangoproject.com/ja/1.10/ref/settings/
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = '送信元メールアドレス'
EMAIL_HOST_PASSWORD = 'アプリパスワード'
@phero
phero / mailcheck.py
Created October 26, 2016 01:29
メールが送信できることを確認するためのPythonスクリプト。
# -*- coding: utf-8 -*-
from email.mime.text import MIMEText
import smtplib
EMAIL = '送信元メールアドレス'
PASSWORD = 'アプリパスワード'
TO = '送信先メールアドレス'
msg = MIMEText('This is a test')
@phero
phero / translate-bing.ahk
Last active October 5, 2016 00:29
効率的に英和翻訳するためのAutoHotKeyショートカット
; クリップボードの内容(長文テキスト)をBing翻訳で英和翻訳する
vk1Csc079 & T::Run,http://www.bing.com/translator/?from=en&to=ja&text=%CLIPBOARD%
@phero
phero / destroy.py
Last active January 31, 2017 07:21
ファイルを壊すスクリプト
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
"""
Destroy files.
"""
import argparse
import os
@phero
phero / factorial.py
Created August 13, 2016 07:24
階乗計算
def factorial(a, b):
"""
>>> factorial(1, 6)
720
>>> factorial(10, 100) == factorial(1, 100) / factorial(1, 9)
True
"""
ab = a * b
@phero
phero / prefectures.py
Created June 14, 2016 03:53
都道府県コード
# -*- coding: utf-8 -*-
PREFECTURES_I_TO_S = {
1: '北海道', 2: '青森県', 3: '岩手県', 4: '宮城県', 5: '秋田県',
6: '山形県', 7: '福島県', 8: '茨城県', 9: '栃木県', 10: '群馬県',
11: '埼玉県', 12: '千葉県', 13: '東京都', 14: '神奈川県', 15: '新潟県',
16: '富山県', 17: '石川県', 18: '福井県', 19: '山梨県', 20: '長野県',
21: '岐阜県', 22: '静岡県', 23: '愛知県', 24: '三重県', 25: '滋賀県',
26: '京都府', 27: '大阪府', 28: '兵庫県', 29: '奈良県', 30: '和歌山県',
31: '鳥取県', 32: '島根県', 33: '岡山県', 34: '広島県', 35: '山口県',