Skip to content

Instantly share code, notes, and snippets.

View mopemope's full-sized avatar
🏠
Working from home

Yutaka Matsubara mopemope

🏠
Working from home
View GitHub Profile
@mopemope
mopemope / tw,py
Created April 6, 2011 04:39
twitter search plugin
from plugpy.ext.skype import SimpleSkypePlugin
import urllib2
from urllib import quote_plus
from pyquery import PyQuery as pq
base_url = "http://search.twitter.com/search?q=%s&rpp=5&maxId=null&locale=ja"
def search(*args):
q = []
word = " ".join(args)
@mopemope
mopemope / pink.py
Created April 6, 2011 09:19
ピンク速報 skype bot
# -*- coding: utf-8 -*-
from plugpy.ext.skype import SimpleSkypePlugin
import itertools
import mimetools
import mimetypes
from cStringIO import StringIO
import urllib2
import os
import feedparser
from pyquery import PyQuery as pq
@mopemope
mopemope / this.py
Created April 11, 2011 03:44
Zen of Python
s = """Gur Mra bs Clguba, ol Gvz Crgref
Ornhgvshy vf orggre guna htyl.
Rkcyvpvg vf orggre guna vzcyvpvg.
Fvzcyr vf orggre guna pbzcyrk.
Pbzcyrk vf orggre guna pbzcyvpngrq.
Syng vf orggre guna arfgrq.
Fcnefr vf orggre guna qrafr.
Ernqnovyvgl pbhagf.
Fcrpvny pnfrf nera'g fcrpvny rabhtu gb oernx gur ehyrf.
@mopemope
mopemope / meinheld_autoreloader.py
Created April 19, 2011 14:47
auto reloader for meinheld
from plugpy import *
from plugpy.ext.filewatcher import FileWatchPlugin
from plugpy.ext.autoreloader import AutoReloadPlugin
from meinheld import server
def hello_world(environ, start_response):
status = '200 OK'
res = "Hello world!"
response_headers = [('Content-type','text/plain')]
start_response(status, response_headers)
# -*- coding: utf-8 -*-
nums = [1, 1, 7, 7]
from operator import add, sub, mul, div
ops = {"*": mul, "+": add, "-": sub, "/": div}
def split(nums):
N = len(nums)
@mopemope
mopemope / gist:933755
Created April 21, 2011 05:12
bjoern and meinheld hello_world benchmark
ab -c 100 -n 10000 http://192.168.2.11:8000/
bjoern 1.1.1
This is ApacheBench, Version 2.0.41-dev <$Revision: 1.141 $> apache-2.0
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 2006 The Apache Software Foundation, http://www.apache.org/
Benchmarking 192.168.2.11 (be patient)
Completed 1000 requests
@mopemope
mopemope / test.c
Created May 5, 2011 02:36
bucho show
PyObject *
bucho_show(PyObject *self, PyObject *args)
{
return PyString_FromString("show");
}
static PyMethodDef BuchoMethods[] = {
{"show", bucho_show, METH_NOARGS, ""},
{NULL, NULL, 0, NULL} /* Sentinel */
@mopemope
mopemope / irclog.py
Created May 11, 2011 14:26
irc logger
from twisted.internet import reactor, protocol
from twisted.words.protocols import irc
import time
name = 'logger'
channels = ['#coderepos-en', '#1986', '#subtech',
'#django-dev', '#pocoo']
logfiles = {}
@mopemope
mopemope / async_dns.c
Created May 26, 2011 08:35
c-ares example
#include <ares.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netdb.h>
#include <stdarg.h>
#include <string.h>
#include <ctype.h>
@mopemope
mopemope / test_server.py
Created May 30, 2011 02:14
tobikko example
from tobikko import get_hub
from tobikko.api import *
from tobikko.server import StreamServer
from tobikko import socket
def test_accept():
s = StreamServer()
def _handle(sock, addr):
while True: