Skip to content

Instantly share code, notes, and snippets.

View lxyu's full-sized avatar

Lixin Yu lxyu

View GitHub Profile
@lxyu
lxyu / init.py
Last active August 29, 2015 14:02
Dynamic generate function with ordered default kwargs in python
import types
def init_generator(spec):
"""Generate `__init__` function based on spec
"""
varnames, defaults = zip(*spec)
varnames = ('self', ) + varnames
def init(self):
@lxyu
lxyu / PKGBUILD
Created June 26, 2014 02:42
haproxy-1.5.1 AUR for vps
pkgname=haproxy
pkgver=1.5.1
pkgrel=1
pkgdesc="The Reliable, High Performance TCP/HTTP Load Balancer"
arch=('i686' 'x86_64')
url="http://haproxy.1wt.eu"
license=('GPL')
depends=('pcre' 'openssl' 'zlib')
makedepends=('gcc' 'linux-headers')
backup=('etc/haproxy/haproxy.cfg')
@lxyu
lxyu / t1.md
Last active August 29, 2015 14:10
pymysql + gevent + sqlalchemy connection error log
$ pip freeze
gevent==1.0.1
PyMySQL==0.6.2
SQLAlchemy==0.9.8
..........................................X.................................................................X..................................................................................X........................................................................X.....................................................................................ERROR:sqlalchemy.pool.QueuePool:Exception during reset or similar
Traceback (most recent call last):
@lxyu
lxyu / mini.css
Created May 9, 2015 02:50
Firefox Mini
@namespace url(http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul);
:root {
/* TAB VARIABLES */
--bg-light: #17181A; --bg-dark: #222326;
--fg-light: #EBECEE; --fg-dark: #AAABAD;
--tab-height: 24px; --tab-icon-size: 16px; --tab-strip-margin: -12px; --tab-overlap: -5px;
--tab-fonts: "terminus", "Dejavu Sans"; --tab-font-size: 13px;
--tab-triangle: block; /* block |
@lxyu
lxyu / pip-install.md
Created July 15, 2015 07:41
Gevent install log on archlinux
$ sudo pip install gevent==1.1a2
Collecting gevent==1.1a2
  Using cached gevent-1.1a2.tar.gz
Requirement already satisfied (use --upgrade to upgrade): greenlet>=0.4.7 in /usr/lib/python3.4/site-packages (from gevent==1.1a2)
Building wheels for collected packages: gevent
  Running setup.py bdist_wheel for gevent
  Complete output from command /usr/bin/python -c "import setuptools;__file__='/tmp/pip-build-lfmpuicl/gevent/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmp5n4kq__mpip-wheel-:
  running bdist_wheel
  running build
@lxyu
lxyu / php.log
Created September 19, 2011 03:12
brew install -v php --with-mysql --with-intl --with-fpm > php.log
==> Downloading http://www.php.net/get/php-5.3.8.tar.gz/from/this/mirror
File already downloaded in /Users/lxyu/Library/Caches/Homebrew
/usr/bin/tar xf /Users/lxyu/Library/Caches/Homebrew/php-5.3.8
==> Patching
/usr/bin/patch -f -p1 -i 001-homebrew.diff
patching file ext/tidy/tidy.c
==> ./configure --prefix=/usr/local/Cellar/php/5.3.8 --disable-debug --with-config-file-path=/usr/local/etc --with-config-file-scan-dir=/usr/local/etc/php5/conf.d --with-iconv-dir=/usr --enable-dba --enable-ndbm=/usr --enable-exif --enable-soap --enable-sqlite-utf8 --enable-wddx --enable-ftp --enable-sockets --enable-zip --enable-pcntl --enable-shmop --enable-sysvsem --enable-sysvshm --enable-sysvmsg --enable-mbstring --enable-mbregex --enable-zend-multibyte --enable-bcmath --enable-calendar --with-openssl=/usr --with-zlib=/usr --with-bz2=/usr --with-ldap --with-ldap-sasl=/usr --with-xmlrpc --with-iodbc --with-kerberos=/usr --with-libxml-dir=/usr/local/Cellar/libxml2/2.7.8 --with-xsl=/usr --with-curl=/usr --with-gd --enable-gd-nat
@lxyu
lxyu / README.md
Created November 22, 2012 09:00
Python serialization benchmark
$ python benchmark.py
msgpack benchmark
7.78079032898
9.00101661682

ujson benchmark
12.1378898621
14.5480632782
@lxyu
lxyu / firefoxmini.css
Created December 14, 2015 16:13
Firefox Mini
@namespace url(http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul);
:root {
/* TAB VARIABLES */
--bg-light: #17181A; --bg-dark: #222326;
--fg-light: #EBECEE; --fg-dark: #AAABAD;
--tab-height: 24px; --tab-icon-size: 16px; --tab-strip-margin: -12px; --tab-overlap: -5px;
--tab-fonts: "terminus", "Dejavu Sans"; --tab-font-size: 13px;
--tab-triangle: block; /* block |
@lxyu
lxyu / get_or_create_multi.py
Created June 5, 2013 10:13
get or create multi for dogpile.cache based on @zzzeek's 33.patch
def get_or_create_multi(self, keys, creator, expiration_time=None,
should_cache_fn=None):
def get_value():
value = values.get(key, NO_VALUE)
if value is NO_VALUE or \
value.metadata['v'] != value_version or \
(self._invalidated and
value.metadata["ct"] < self._invalidated):
invalidated.append(key)
@lxyu
lxyu / unicode.patch
Last active December 18, 2015 21:39
diff --git a/compiler/cpp/src/generate/t_py_generator.cc b/compiler/cpp/src/generate/t_py_generator.cc
index 08f2e68..42c4b33 100644
--- a/compiler/cpp/src/generate/t_py_generator.cc
+++ b/compiler/cpp/src/generate/t_py_generator.cc
@@ -838,8 +838,13 @@ void t_py_generator::generate_py_struct_reader(ofstream& out,
"and fastbinary is not None:" << endl;
indent_up();
- indent(out) <<
- "fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))" << endl;