Skip to content

Instantly share code, notes, and snippets.

# -*- 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 December 29, 2015 03:48
tweets.csv を基にNGワードを含む過去ツイート(RT)を削除してすっきりトゥイッターライフを送ろう(for Python, requires tweepy)
#!/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'
@utgwkk
utgwkk / fizzbuzz.py
Created November 26, 2013 07:00
fizzbuzz
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 December 31, 2015 22:18
GMail の受信ボックスのスター付きメールの件名を抽出して、Excel Book に保存する http://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q11118070576
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Email を扱うために必要なモジュール
import imaplib, email
# http://www.python-excel.org/ でダウンロード・インストールしておくこと
import xlwt
# 保存するファイル名
savename = 'list.xlsx'
#!/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 December 6, 2022 12:27
Making m3u playlist automatically
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 January 19, 2014 10:53
Generate "Ulam spiral (prime spiral)"
# -*- 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)])
# -*- 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 February 23, 2014 08:26
Calculate Egyptian fraction
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):
#!/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