Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

MISAWA Yoshihiro PyYoshi

🏠
Working from home
View GitHub Profile
View Twiter OAUTHのWebクライアント形式で認証サンプル (Python)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Twiter-OAUTHのWebクライアント形式で認証サンプル
#
# 設定ファイルの書式 (ConfigParser)
# [TOKENS]
# ACCESS_TOKEN=HOGE
# ACCESS_SECRET_TOKEN=FUGA
# "#"や";"が最初につく行はスキップ
#
View PythonでUserstreamなアレ
#!/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
View 自鯖のグローバルIPをGmail宛に送るやつ。
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2
from email.MIMEText import MIMEText
from email.Utils import formatdate
import smtplib
import datetime
#LOGファイル
View gist:982298
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
繰り返し系制御文の使用を禁止されているので再帰呼び出しによる実装を行った。
View ES用の課題(設問 3-A)
#!/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
arm-eabi-objdump
View gist:986100
#!/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
Androidのboot.imgナイにあるlogo.rleをpngに変換するツール
View gist:986104
/*
* 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
multipart form-dataで画像ファイルをアップするとき。
View 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'
View tumblrのアレ
# -*- 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 Jun 8, 2011
python-webmで実際に変換してみる。PIL、python-webmそれとlibwebp.soが必要。いまのところpython-webmはWinには対応してない。 ちょっといじればできそうだけども^^;
View gist:1013712
#!/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)
You can’t perform that action at this time.