Skip to content

Instantly share code, notes, and snippets.

# -*- 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
import System.Net
import System.Text
import System.IO
url as string = 'https://www.google.co.jp/'
enc as Encoding = Encoding.GetEncoding('UTF-8')
req as WebRequest = WebRequest.Create(url)
res as WebResponse = req.GetResponse()
st as Stream = res.GetResponseStream()
sr as StreamReader = StreamReader(st, enc)
@utgwkk
utgwkk / lifegame.py
Last active August 29, 2015 13:57
A Lifegame for Python (requires Pygame)
import pygame, sys, random
from copy import deepcopy
pygame.init()
size = (800,450)
white = (255, 255, 255)
color = (30, 30, 180)
fps = 30
screen = pygame.display.set_mode(size)
pygame.display.set_caption('lifegame')
# coding: utf-8
import os
import hashlib
from glob import glob
flist = []
fmd5 = []
dl = []
dirname = './images/'
import tempfile
import sqlite3
import webbrowser
if __name__ == '__main__':
conn = sqlite3.connect('hoge.db')
c = conn.cursor()
tmp = tempfile.mkstemp(prefix='pythontemp_', suffix='.htm')
f = open(tmp[1], 'wt')
b = ''
# coding: utf-8
import os
from PIL import Image
from glob import glob
flist = []
fhist = []
dl = []
dirname = './images/'
import pygame, sys, random
from copy import deepcopy
pygame.init()
size = (800,450)
white = (255, 255, 255)
color = (30, 30, 180)
fps = 30
screen = pygame.display.set_mode(size)
pygame.display.set_caption('lifegame')
@utgwkk
utgwkk / ray-ban-detector.py
Last active August 29, 2015 14:25
レイバン検出するやつ
# -*- coding: utf-8 -*-
# NOTE: use Python 3.
import tweepy
import re
import sys
CONSUMER_KEY = ''
CONSUMER_SECRET = ''
me = 'YOUR_SCREEN_NAME'