Skip to content

Instantly share code, notes, and snippets.

View PyYoshi's full-sized avatar
🌍
Working from The World

MISAWA Yoshihiro PyYoshi

🌍
Working from The World
View GitHub Profile
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Twiter-OAUTHのWebクライアント形式で認証サンプル
#
# 設定ファイルの書式 (ConfigParser)
# [TOKENS]
# ACCESS_TOKEN=HOGE
# ACCESS_SECRET_TOKEN=FUGA
# "#"や";"が最初につく行はスキップ
#
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from tweepy import OAuthHandler, Stream, StreamListener, TweepError, API
import urllib
from wsgiref.simple_server import make_server
import threading
import ConfigParser
import webbrowser
import os
import sys
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2
from email.MIMEText import MIMEText
from email.Utils import formatdate
import smtplib
import datetime
#LOGファイル
def import_simplejson():
try:
import simplejson as json
except ImportError:
try:
import json # Python 2.6+
except ImportError:
try:
from django.utils import simplejson as json # Google App Engine
except ImportError:
@PyYoshi
PyYoshi / ES用の課題(設問 3-A)
Created May 21, 2011 09:23
繰り返し系制御文の使用を禁止されているので再帰呼び出しによる実装を行った。
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'Yoshihiro Misawa'
def recursion(int_list, cnt=0):
try:
xlen = len(int_list) -1
if int_list[cnt] > 0:
@PyYoshi
PyYoshi / gist:986100
Created May 23, 2011 02:00
arm-eabi-objdump
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from os import system, name as osname, getcwd, chdir
from sys import path
from commands import getoutput
from popen2 import popen3
cdir = getcwd()
@PyYoshi
PyYoshi / gist:986104
Created May 23, 2011 02:03
Androidのboot.imgナイにあるlogo.rleをpngに変換するツール
/*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@PyYoshi
PyYoshi / multipart form-data用の出力関数
Created May 23, 2011 13:47
multipart form-dataで画像ファイルをアップするとき。
def _enc_image(filename, max_size):
try:
if os.path.getsize(filename) > (max_size * 1024):
print 'File is too big, must be less than %d' % (max_size * 1024)
except os.errno, e:
print 'Unable to access file, %s' % e
file_type = mimetypes.guess_type(filename)
if file_type is None:
print 'Could not datermine file type'
@PyYoshi
PyYoshi / tumblrのアレ
Created May 24, 2011 08:03
アレです
# -*- coding: utf-8 -*-
from __future__ import generators
__author__ = "Yoshihiro Misawa (remu.biz)"
__version__ = "0.0.1"
__copyright__ = "Copyright (c) 2011 Yoshihiro Misawa"
__license__ = ""
import urllib2
@PyYoshi
PyYoshi / gist:1013712
Created June 8, 2011 03:25
python-webmで実際に変換してみる。PIL、python-webmそれとlibwebp.soが必要。いまのところpython-webmはWinには対応してない。 ちょっといじればできそうだけども^^;
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from webm.encode import WebPEncoder
from webm.handlers import BitmapHandler
import Image
import os
fpath = os.path.join( os.path.dirname( __file__ ), "test.jpg" )
im = Image.open(fpath)