Skip to content

Instantly share code, notes, and snippets.

@yuitest
yuitest / memo.markdown
Last active August 29, 2015 14:00
Gist に重いファイル上げすぎて、開けないページができちゃった件

Gist に重いファイル上げすぎて、開けないページができちゃった件

できごと

超巨大な Markdown ファイルをアップロードしたら、 HTML の生成がタイムアウトするらしく、

OH NO!
This page is taking way too long to load.
@yuitest
yuitest / tweet.py
Created April 29, 2014 14:24
キューピー 3 分クッキング的な Twitter Bot。( STDIN から読む)
# coding: utf8
from pit import Pit
from twython import Twython
def pit_config(key='twitter.bot.keys'):
conf = Pit.get(key, {
'require': {
'API_KEY': 'api key',
@yuitest
yuitest / child.py
Last active August 29, 2015 14:00
Twitter のユーザストリームを Redis の pub-sub に流す。
#!/usr/bin/env python
# coding: utf8
from twythonredispubsub import RedisPubSubStreamer
if __name__ == '__main__':
channel = '<channnel name here>'
try:
for tweet in RedisPubSubStreamer.get_tweet_via_redis(channel):
@yuitest
yuitest / unstructure.py
Created May 5, 2014 13:11
Dict と List のネストしたものから、プリミティブなものを取り出す。(例えば JSON とか。)
# coding: utf8
import types
def unstructure(structured, usedictkey=True, usedictvalue=True):
if isinstance(structured, dict):
for keys, values in structured.iteritems():
if usedictkey:
for key in unstructure(keys):
yield key
@yuitest
yuitest / twitterxauth.py
Created May 5, 2014 13:26
Python で Twitter の XAuth するサンプルコード。
# coding: utf8
import oauth2 as oauth
import urllib
import urlparse
def xauth_to_oauth(
consumer_key, consumer_secret, screen_name, password,
API_URL='https://api.twitter.com/oauth/access_token',
):
@yuitest
yuitest / result.txt
Last active August 29, 2015 14:00
タプルから辞書を作るときのパフォーマンス。
('todict1', 2.637644052505493)
('todict2', 2.0221450328826904)
('todict3', 3.7830700874328613)
('todict4', 2.580557107925415)
('todict5', 2.2164390087127686)
('todict6', 2.159787178039551)
@yuitest
yuitest / markdown-to-table.py
Created May 5, 2014 13:37
TSV を Markdown の表に
# coding: utf-8
from __future__ import print_function, unicode_literals
import csv
import sys
def to_md(row):
return '|' + '|'.join(row) + '|'
cr = csv.reader(sys.stdin, delimiter=b'\t')
@yuitest
yuitest / ディレクトリ構成をちょっとだけ考えた.md
Created May 5, 2014 13:47
ディレクトリ構成をちょっとだけ考えた

ディレクトリ構成

ずっと草稿だったうちに、書けなくなっちゃいました。 練れてないですが、ただ消すのも惜しいので、上げておきます。

A. Unix 的なスタイル

/usr/bin/hoge ... バイナリファイル
/etc/hoge/ ... 設定ファイルを保存
@yuitest
yuitest / mlp-card.html
Created May 5, 2014 19:39
MLP CCG のスコア・トークンカウンタを作ってみる。
<html>
<head>
<meta charset="utf-8">
<title>カードのスコア管理的なやつを作ってる</title>
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
<script src="http://code.jquery.com/jquery-latest.js"></script>
<!--
<script src="https://raw.githubusercontent.com/carhartl/jquery-cookie/master/jquery.cookie.js"></script>
-->
<script>
@yuitest
yuitest / difference.txt
Last active August 29, 2015 14:01
一般人には区別がつかない可能性があるもの
ハッカー,クラッカー
ウィルス,細菌
考える,思う
アメリカ,カナダ
インターネット,World Wide Web,Internet Explorer