Skip to content

Instantly share code, notes, and snippets.

View chun37's full-sized avatar

chun chun37

View GitHub Profile
#!/usr/bin/env python3
import shutil
import subprocess
import sys
revive_path = shutil.which("revive")
if revive_path == "":
print("revive をインストールしてください")
print("`go install github.com/mgechev/revive@latest`")
@chun37
chun37 / masume_image.py
Created September 6, 2020 04:22
いい感じにマス目の画像を作れるやーつ
from PIL import Image
def create_cell(
size: int, border_size: int, inside_color: str, border_color: str
) -> Image.Image:
inside_size = size - border_size * 2
inside_cell_img = Image.new("RGB", (inside_size, inside_size), inside_color)
cell_img = Image.new("RGB", (size, size), border_color)
cell_img.paste(inside_cell_img, (border_size, border_size))
### Keybase proof
I hereby claim:
* I am chun37 on github.
* I am chun37 (https://keybase.io/chun37) on keybase.
* I have a public key ASCCW9xK8G8AjsKPGrrC4KEwVq34btu-cM_nS3cfqo_EiAo
To claim this, I am signing this object:
@chun37
chun37 / まゆすき.py
Created November 14, 2018 13:49
まゆすき.py
# -*- coding: utf-8 -*-
import itertools
base = range(10)
data = list(itertools.permutations(base, 6))
data = list(map(lambda x: None if x[5] % 2 != 0 or x[0] == 0 else x, data))
data = list(filter(None, data))
for き, く, さ, す, ま, ゆ in data:
まゆすき = int(f'{ま}{ゆ}{す}{き}')
さくままゆ = int(f'{さ}{く}{ま}{ま}{ゆ}')
if まゆすき < 1000 or さくままゆ < 10000:
@chun37
chun37 / ImageEffect.py
Created July 30, 2018 03:21
画像をネガポジ反転・シンメトリー(左右2種)した画像を保存
# -*- coding: utf-8 -*-
from PIL import Image, ImageOps
import numpy as np
import os
file = "" # ここに読み込む画像ファイル名を入力
img = Image.open(file)
filename = file.split("/")[-1].split(".")[0]
if not os.exist("changedImage"):
os.mkdir("changedImage")
@chun37
chun37 / NowPlaying.py
Created June 21, 2018 21:16
NowPlaying.py
# -*- coding: utf-8 -*-
# !python3
from PIL import Image
import appex
import ui
from objc_util import NSBundle, ObjCClass, uiimage_to_png, CGSize
import tweepy
import io
import os
# -*- coding: utf-8 -*-
import tweepy
import requests
import xmltodict
import HTMLParser
import random
import re
def normalText(tweet):
@chun37
chun37 / tweet-thread.py
Created December 13, 2017 03:46
Twitterのスレッド機能をPythonで。
# -*- coding: utf-8 -*-
from requests_oauthlib import OAuth1Session
def tweet(status, batch_mode, in_reply_to_status_id=None):
global tweet_id
if batch_mode:
params = {"status": status, "batch_mode": "first", "weighted_character_count": True}
else:
params = {"status": status, "in_reply_to_status_id": in_reply_to_status_id, "batch_mode": "subsequent", "weighted_character_count": True}
@chun37
chun37 / sql2list.py
Created September 28, 2017 22:38
SQLのcolumnをlist型にする
# -*- coding: utf-8 -*-
import sqlite3
con = sqlite3.connect("") # dbname
conn = con.cursor()
conn.row_factory = sqlite3.Row
ret = conn.execute("select * from # order by #") # 1つ目の#: tablename, 2つ目の#: columnname
result = [i[0] for i in conn.fetchall()] # <type 'list'>
print result
@chun37
chun37 / yokohama_gomi.py
Last active August 17, 2017 03:37
横浜市資源循環局のイーオくんとお話できるよ
# -*- coding: utf-8 -*-
import requests
import json
import re
import sys
print u"このプログラムは横浜市資源循環局のイーオくんとお話できるプログラムだよ"
print u"終了したいときは[Ctrl+C]を押すか[/exit]と送ってね"
print u"---" * 20
print u"イーオだよ。こんにちは。"
print u"ゴミの名前を教えてくれたら、捨て方を案内するよ。粗大ごみの手数料を知りたい場合は、「自転車の手数料」のように話しかけてね。"