Skip to content

Instantly share code, notes, and snippets.

View ayang's full-sized avatar

ayang ayang

View GitHub Profile
@ayang
ayang / runes.py
Last active August 29, 2015 14:16
Run a elasticsearch query from a json file begin with a headline like that in the "The Definitive Guide"
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
parse a file with a headline and json content like this:
GET /index/type/_search?pretty
{
"query": {
"match": {
@ayang
ayang / fix_fcitx.vim
Last active December 12, 2017 13:45
Auto change fcitx input method status for vim different mode
let w:insert_input_active = 0
function FcitxLeaveInsert()
let s:input_status = system("fcitx-remote")
if s:input_status == 2
let w:insert_input_active = 1
let l:a = system("fcitx-remote -c")
endif
endfunction
function FcitxEnterInsert()
@ayang
ayang / display-cv-image-using-matplot.ipynb
Created September 7, 2013 11:52
display opencv image using matplotlib in ipython notebook
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ayang
ayang / dropbox_proxy.py
Last active March 28, 2017 15:36
Dropbox proxy behind the GFW of China
#!/usr/bin/env python
import re
import tornado.ioloop
import tornado.web
from tornado import httpclient
class MainHandler(tornado.web.RequestHandler):
@tornado.web.asynchronous
@ayang
ayang / app.py
Created February 4, 2012 03:47
Tornado session manager use redis
class Application(tornado.web.Application):
def __init__(self):
tornado.web.Application.__init__(self, handlers, **settings)
self.db_session = db_session
self.redis = redis.StrictRedis()
self.session_store = RedisSessionStore(self.redis)
class BaseHandler(tornado.web.RequestHandler):