Skip to content

Instantly share code, notes, and snippets.

View chun37's full-sized avatar

chun chun37

View GitHub Profile
@chun37
chun37 / week-of-month.py
Created July 17, 2017 17:55
年月日から何月の第何何曜日か、祝日であれば祝日名をプリント
# -*- coding: utf-8 -*-
import datetime
import sys
try:
g, y, m, d = sys.argv
except:
exit()
try:
t = datetime.date(int(y), int(m), int(d))
try:
@chun37
chun37 / GetFF.py
Last active August 17, 2017 03:37
TwitterのFF内の人のIDをdbにまとめる
# -*- coding: utf-8 -*-
import tweepy
import sqlite3
import os
import time
if __name__ == "__main__":
auth = tweepy.OAuthHandler(CK, CS)
auth.set_access_token(AK, AS)
api = tweepy.API(auth)
path1 = os.path.isfile("followers.db")
@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"ゴミの名前を教えてくれたら、捨て方を案内するよ。粗大ごみの手数料を知りたい場合は、「自転車の手数料」のように話しかけてね。"
@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 / 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}
# -*- coding: utf-8 -*-
import tweepy
import requests
import xmltodict
import HTMLParser
import random
import re
def normalText(tweet):
@chun37
chun37 / getlyrics.py
Last active March 6, 2018 10:21
歌ネットから歌詞取得するプログラム
# -*- coding: utf-8 -*-
import requests
from bs4 import BeautifulSoup
import re
def createurl(url, ep=""):
url += ep; url = url.replace("m//", "m/") if "//" in url else url; return url
songtitle = raw_input(">>>")
@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
@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 / まゆすき.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: