Skip to content

Instantly share code, notes, and snippets.

@harmy
harmy / generate_guild_sql.py
Created December 19, 2011 05:28
将行会数据从文本导入mysql
# -*- coding: gbk -*-
__author__ = 'harmy'
import glob
def main():
guild_master = {}
guild_member_count = {}
with open("update_guild.sql", "w+") as f:
#插入tbl_guild_member表
for txt_file in glob.glob("*.txt"):
@harmy
harmy / putin.py
Created December 19, 2011 06:01
在当前目录下建立所有tga文件的同名文件夹,并把tga文件移动到各自文件夹内
import os, shutil, glob
[os.mkdir(file[:-4]) for file in glob.glob("*.tga")]
[shutil.move(file, file[:-4]) for file in glob.glob("*.tga")]
@harmy
harmy / unzipgbk.py
Created December 30, 2011 10:42
Linux解压缩zip文件中文乱码问题的pathon解决方案
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import zipfile
print "Processing File " + sys.argv[1]
file=zipfile.ZipFile(sys.argv[1],"r");
@harmy
harmy / 2012.py
Created December 31, 2011 16:56
2012写的第一个程序
while datetime.today() <= "2012-12-21":
work_hard()
play_hard()
sleep()
if(life is not None):
print "hello world!"
@harmy
harmy / hequ.py
Created January 13, 2012 12:48
合区脚本
#encoding=gbk
import datetime
__author__ = 'harmy'
import os, sys, shutil, csv, shelve, multiprocessing
from multiprocessing import Process
if len(sys.argv) != 4:
print "用法: hequ.py 老区1数据路径 老区2数据路径 新区区id"
exit(1)
@harmy
harmy / CropMap.py
Created March 16, 2012 08:34
地图切图脚本
import os, shutil, glob
for file in glob.glob("*.jpg"):
print "processing %s..." % file
try:
shutil.rmtree(file[:-4])
except:
pass
os.mkdir(file[:-4])
os.system("convert.exe -crop 512x512 -quality 75%% -scene 1 %s %s\%%d.jpg" % (file, file[:-4]))
@harmy
harmy / jsonrpc2.0.py
Created May 15, 2012 16:09
a jsonrpc2.0 lib base on twisted
# CC-BY-NC-3.0
import json
from twisted.protocols.basic import LineReceiver
from twisted.internet import defer
class Request(object):
def __init__(self, protocol, method):
self.protocol = protocol
self.method = method
@harmy
harmy / client.c
Created August 4, 2012 20:36
jsonrpc client in c
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <jansson.h>
@harmy
harmy / brubeck_installer.sh
Created August 5, 2012 06:10 — forked from j2labs/brubeck_installer.sh
Brubeck Installer for Ubuntu
#!/bin/sh
###
### Settings
###
ZMQ_VERSION="zeromq-2.2.0"
MONGREL2_VERSION="mongrel2-1.7.5"
PREV_DIR=$PWD
SRC_DIR=$HOME/src
@harmy
harmy / 12factor.md
Created August 23, 2012 14:30
12factor

中文翻译:梁山 英文原文:Adam Wiggins

简介

如今,软件通常会作为一种服务来交付,它们被称为网络应用程序,或“软件即服务”(SaaS)。“十二要素应用程序”(12-Factor App)为构建如下的SaaS应用提供了方法论:

  • 使用标准化流程自动配置,从而使新的开发者花费最少的学习成本加入这个项目;
  • 和操作系统之间尽可能的划清界限,在各个系统中提供最大的可移植性
  • 适合部署在现代的云计算平台,从而在服务器和系统管理方面节省资源;