Skip to content

Instantly share code, notes, and snippets.

View timonwong's full-sized avatar
😶

Timon Wong timonwong

😶
View GitHub Profile
@timonwong
timonwong / gist:11129685
Last active August 29, 2015 14:00
Create python2.7 rpm by fpm
NAME=python27
MAJOR_VERSION=2.7
VERSION=2.7.6
PYTHON_SOURCE=Python-$(VERSION)
INSTALL_DIR=/opt/python$(MAJOR_VERSION)
INTERMEDIATE_INSTALL_DIR=/tmp/installdir-$(NAME)-$(VERSION)
.PHONY: all clean package
@timonwong
timonwong / provision-centos6.sh
Last active August 29, 2015 14:00
CentOS provision (EPEL, Gem chinese mirror, ansible, toolchain)
#!/usr/bin/env bash
# Change yum mirror
sed -i.backup 's/^enabled=1/enabled=0/' /etc/yum/pluginconf.d/fastestmirror.conf
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base-163.repo http://mirrors.163.com/.help/CentOS6-Base-163.repo
yum makecache
yum update
# Install ruby dependencies
@timonwong
timonwong / gist:11130336
Last active August 29, 2015 14:00
Create Python libs rpm by fpm (setuptools, virtualenv, pip)
PYTHON_PACKAGE_PREFIX=python27
PYTHON_INSTALL_DIR=/opt/python2.7
SETUPTOOLS_VER=2.2
SETUPTOOLS_TARBALL=setuptools-$(SETUPTOOLS_VER).tar.gz
VIRTUALENV_VER=1.11.4
VIRTUALENV_TARBALL=virtualenv-$(VIRTUALENV_VER).tar.gz
PYPI_SOURCE_MIRROR=http://pypi.douban.com/packages/source
@timonwong
timonwong / 1consumer_1producer_then_exhaust_connections.py
Last active August 29, 2015 14:01
Demonstrate that RabbitMQ consumer will get blocked after all connections exhausted
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import logging
import threading
import time
import kombu.common
import kombu.pools
#!/bin/bash
# !!path to the pip binary!!
PIP_BIN=/opt/python2.7/bin/pip
WHEEL_DIR=wheelhouse
DOWNLOAD_CACHE_DIR=cache
PIP_WHELL_REQUIREMENT="$@"
@timonwong
timonwong / go_stacktrace.go
Created July 21, 2014 06:28
Go stack trace
package main
import (
"fmt"
"runtime"
)
func StackTrace(all bool) string {
// Reserve 10K buffer at first
buf := make([]byte, 10240)
@timonwong
timonwong / stringinfo.py
Last active August 29, 2015 14:05
A very simple System.Globalization.StringInfo class, ported from .net world
import unicodedata
import sys
__all__ = ['UnicodeCategory', 'StringInfo']
PY3K = sys.version_info[0] >= 3
if PY3K:
unicode_type = str
else:
@timonwong
timonwong / gist:748f73b7686be0cc8190
Created May 14, 2015 06:18
Shutdown all containers
sudo docker ps -a | awk '{print $1}' | grep -v "CONTAINER" | xargs --no-run-if-empty sudo docker rm
http://stackoverflow.com/questions/22717428/vagrant-error-failed-to-mount-folders-in-linux-guest
@timonwong
timonwong / github.css
Created October 10, 2012 02:10 — forked from KOBA789/github.css
Github Markdown CSS - for Markdown Editor Preview
body {
font-family: Helvetica, arial, sans-serif;
font-size: 14px;
line-height: 1.6;
padding-top: 10px;
padding-bottom: 10px;
background-color: white;
padding: 30px; }
body > *:first-child {