Skip to content

Instantly share code, notes, and snippets.

@yin8086
yin8086 / gunicorn.sh
Created November 22, 2012 16:10 — forked from suda/gunicorn
Gunicorn init.d script (debian/ubuntu/centos/redhat)
#!/bin/sh
# chkconfig: 2345 55 45
# description: start or stop gunicorn
# chkconfig –add gunicorn in centos and redhat
# update-rc.d gunicorn defaults in debian and ubuntu
### BEGIN INIT INFO
# Provides: gunicorn
# Required-Start: $all
@yin8086
yin8086 / parseVCard.py
Last active November 18, 2023 04:46
VCard process to get the person who has phone numbers
# -*- coding: utf-8 -*-
import vobject, sys, codecs
from os import path
def hasTel(lineList):
for line in lineList:
if line[:len('TEL;')] == 'TEL;':
return True
return False
@yin8086
yin8086 / datezhcn.py
Created November 27, 2012 07:17
Python 中文日期 格式化
date.today().strftime(u'%Y年%m月%d日'.encode('utf-8')).decode('utf-8')
#输出:2012年11月27日
@yin8086
yin8086 / pandoc.template.zh.tex
Created November 28, 2012 15:54 — forked from farawayboat/pandoc.template.zh.tex
Chinese LaTeX template (using Ctex) for pandoc.
\documentclass[$if(fontsize)$$fontsize$,$endif$$if(lang)$$lang$,$endif$]{$documentclass$}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\usepackage{fixltx2e} % provides \textsubscript
% use microtype if available
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
\IfFileExists{microtype.sty}{\usepackage{microtype}}{}
\usepackage[utf8]{inputenc}
@yin8086
yin8086 / unicode_trans.py
Created January 23, 2013 09:13
encode('unicode-escape'),decode('unicode-escape')可将'\uxxxx\uxxxx'的字符串与unicode进行自由转换
# -*- coding: utf-8 -*-
"""
Created on Wed Jan 23 11:19:33 2013
@author: Stardrad
"""
import sys, os, codecs
if len(sys.argv) < 2:
print u'参数不够'
@yin8086
yin8086 / gbk2utf8.py
Created May 20, 2013 09:29
Recursively translate all the C++ file from gbk codecs to utf-8 codecs
# -*- coding: utf-8 -*-
"""
Created on Mon May 20 16:15:32 2013
@author: Yinxy
"""
import os, fnmatch
for pathName, dirNames, fileNames in os.walk('.'):
print pathName
@yin8086
yin8086 / printHadamard.py
Last active December 17, 2015 16:49
Generate Hadamard transform martrix and Walsh transform martrix. input n is the log2(width) n = 2, H4 n = 3, H8
# -*- coding: utf-8 -*-
"""
Created on Fri May 24 10:29:36 2013
@author: Stardrad Yin
"""
# http://fourier.eng.hmc.edu/e161/lectures/wht/node3.html
import numpy
from Tkinter import Tk
@yin8086
yin8086 / fixPMF.py
Created July 11, 2013 02:28
Use {filename:time} dictionary fix the timestamp in pmf file
# -*- coding: utf-8 -*-
"""
Created on Thu Jul 11 09:50:16 2013
@author: Stardrad Yin
"""
import os, fnmatch, struct
timeDic = {'mv00':89, 'mv04':67, 'mv05':102, 'mv06':29, 'mv07':27,\
'mv08':34, 'mv10':21, 'mv12':21}
@yin8086
yin8086 / pysquish.cpp
Created October 1, 2014 09:59
PySquish
// Squish bindings for python
// http://stackoverflow.com/questions/10972595/dxt-compression-for-python
// modify Stardrad
#include <squish.h>
#include "pysquish.h"
extern "C" {
void CompressMasked(u8 const* rgba, int mask, void* block, int flags) {
@yin8086
yin8086 / mimetypes.py
Created October 15, 2014 02:44
Modify the ipython notebook error in Python
# Python27/Lib/mimetypes.py
# Line 248
# Original Line, comment the following lines
def enum_types(mimedb):
i = 0
while True:
try: