Skip to content

Instantly share code, notes, and snippets.

@harmy
harmy / gist:4256774
Last active October 13, 2015 21:08
转换tga文件为dds
texconv -m 1 -if NONE -f dxt1 test.tga
说明:miplevels设为1,否则转出来的文件会保存多级纹理,浪费了空间。
@harmy
harmy / vpn-setup.sh
Created October 15, 2012 07:19
Ubuntu VPN for poor Chinese (on AWS EC2)
#!/bin/bash -x
## original author: Oliver Nassar <[email protected]>
## credit: harmy <[email protected]>
## Ubuntu VPN for poor Chinese (you know de)
## Sample Usage:
##
## wget https://gist.github.com/raw/3891178/ff1702fac175eb21c513b93f51f39948be693aba/vpn-setup.sh
## chmod +x vpn-setup.sh
## sudo ./vpn-setup.sh <username> <password>
@harmy
harmy / gist:3652993
Created September 6, 2012 08:23
mysql创建用户总结

用root账户登录mysql,敲入并执行下列指令可以创建一个新的数据库并赋予myuser用户从任何主机任意操作该数据库

create database mydb;

CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'mypassword';
CREATE USER 'myuser'@'%' IDENTIFIED BY 'mypassword';

GRANT ALL PRIVILEGES ON mydb.* TO 'myuser'@'localhost';
GRANT ALL PRIVILEGES ON mydb.* TO 'myuser'@'%';
@harmy
harmy / 12factor.md
Created August 23, 2012 14:30
12factor

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

简介

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

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