Skip to content

Instantly share code, notes, and snippets.

View timonwong's full-sized avatar
😶

Timon Wong timonwong

😶
View GitHub Profile
@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 / 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: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 / gist:6570051
Created September 15, 2013 11:48
Batch convert to .spx (through ffmpeg)
# -*- coding: utf-8 -*-
import os
import subprocess
import logging
import multiprocessing
import shutil
logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO)
@timonwong
timonwong / naive_mem_pool.cc
Created July 30, 2013 02:06
弱爆的内存池实现
// g++ -std=c++11
#include <cstdio>
#include <new>
#include <vector>
using std::size_t;
using std::vector;
using std::bad_alloc;
// 固定大小内存池, 非常基本的演示
diff -urN --strip-trailing-cr libao-1.1.0-orig/configure libao-1.1.0-gd/configure
--- libao-1.1.0-orig/configure 2011-02-23 00:30:22 +0800
+++ libao-1.1.0-gd/configure 2013-05-12 08:53:47 +0800
@@ -173,6 +173,14 @@
as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1
+
+ test -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || (
+ ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
#!/bin/sh
./configure \
--prefix=$PREFIX \
--build-suffix=-gd \
--enable-memalign-hack \
--enable-runtime-cpudetect \
--enable-shared \
--disable-static \
--disable-debug \
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""
name.txt
O Efeito do Verão.mp3
"""
name = open('name.txt').read().strip()
@timonwong
timonwong / gist:4671209
Created January 30, 2013 06:35
ST2: Missing C# .tmPreferences file for comments
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Comments</string>
<key>scope</key>
<string>source.cs</string>
<key>settings</key>
<dict>
@timonwong
timonwong / novice_killer.user.js
Last active October 13, 2015 09:37 — forked from lyricat/novice_killer.user.js
干掉V2EX上所有使用默认头像用户的发言。
// ==UserScript==
// @name v2ex novice killer
// @namespace http://shellex.info
// @author shellex(5h3ll3x@gmail.com)
// @description 干掉使用默认头像的人的发言
// @include http://www.v2ex.com/go/*
// @include http://v2ex.com/go/*
// @include http://www.v2ex.com/?tab=*
// @include http://v2ex.com/?tab=*
// @include http://www.v2ex.com/