Skip to content

Instantly share code, notes, and snippets.

Avatar

utagawa kiki utgwkk

View GitHub Profile
View wiin_eject.rb
# -*- coding: utf-8 -*-
Plugin.create :wiin_eject do
on_appear do |ms|
ms.each do |m|
if m.message.to_s =~ /ウ(イ|ィ)ーン|[Ee]ject/
system("eject")
end
end
end
end
@utgwkk
utgwkk / delete_black_history.py
Last active Dec 29, 2015
tweets.csv を基にNGワードを含む過去ツイート(RT)を削除してすっきりトゥイッターライフを送ろう(for Python, requires tweepy)
View delete_black_history.py
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
import csv
import tweepy
CONSUMER_KEY = 'CONSUMER_KEY'
CONSUMER_SECRET = 'CONSUMER_SECRET'
ACCESS_KEY = 'ACCESS_TOKEN'
ACCESS_SECRET = 'ACCESS TOKEN SECRET'
View fizzbuzz.py
for i in range(1,101): print [0,'Fizz','Buzz','FizzBuzz'][(i%3<1)+2*(i%5<1)] or i
@utgwkk
utgwkk / get_subject_and_save_in_excel.py
Last active Dec 31, 2015
GMail の受信ボックスのスター付きメールの件名を抽出して、Excel Book に保存する http://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q11118070576
View get_subject_and_save_in_excel.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Email を扱うために必要なモジュール
import imaplib, email
# http://www.python-excel.org/ でダウンロード・インストールしておくこと
import xlwt
# 保存するファイル名
savename = 'list.xlsx'
View get_subject_and_save_in_excel_2.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Email を扱うために必要なモジュール
import imaplib, email
# http://www.python-excel.org/ でダウンロード・インストールしておくこと
import xlwt
# 正規表現を扱うためのモジュール
import re
@utgwkk
utgwkk / mkm3u.bat
Last active Jul 11, 2019
Making m3u playlist automatically
View mkm3u.bat
rem Execute it in the directory which includes music files
rem It requires one argument which will become created m3u playlist file's name
for %%i in (*.mp3,*.mp4,*.m4a,*.wma,*.wav) do echo %cd%\%%i >> %1.m3u
@utgwkk
utgwkk / ulam_spiral.py
Created Jan 19, 2014
Generate "Ulam spiral (prime spiral)"
View ulam_spiral.py
# -*- encoding: utf-8 -*-
from PIL import Image
from math import sqrt
Max = 333
pix = 3
filename = 'output.png'
f1 = lambda x,y: sorted(range(x-(y-1)*2+1-y, x-(y-1)*2+1),reverse=True)
isprime = lambda x: x != 1 and (x == 2 or not 0 in [x%y for y in range(2,int(sqrt(x))+1)])
View update_name.py
# -*- coding: utf-8 -*-
import tweepy
import re
CONSUMER_KEY = ''
CONSUMER_SECRET = ''
me = 'YOUR_SCREEN_NAME'
class Listener(tweepy.StreamListener):
def on_status(self,s):
@utgwkk
utgwkk / egypt_frac.py
Created Feb 23, 2014
Calculate Egyptian fraction
View egypt_frac.py
def getdiv(n):
l = []
for k in xrange(1,n):
if n%k==0: l.append(k)
return l
def go(l,n,m):
l = [[x,0] for x in l if x/m <= 0.5]
f = [0 for x in xrange(len(l))]
for i in xrange(2**len(f)-1):
View _img2square.py
#!/usr/bin/env python
# coding: utf-8
from google.appengine.api import images
from google.appengine.ext.webapp import template
import webapp2 as webapp
import os
from StringIO import StringIO
try: from PIL import Image
except ImportError: import Image