Skip to content

Instantly share code, notes, and snippets.

@ikbear
ikbear / uptoken.md
Created February 10, 2014 08:58
UpToken

uptoken

uptoken 是由PutPolicy经过编码加密得到的,语义如下

PutPolicy

字段 类型 语义
scope string 指定为bucket:key这样的形式,bucket必须
deadline int token失效的unix时间戳(单位:秒),必须
@matthew-brett
matthew-brett / rename_wheels.py
Created May 20, 2014 04:19
Script to rename wheel files built with MacPython, to express compatibility with 10.9 system python and homebrew.
#!/usr/bin/env python
""" Rename MacPython wheels for system python and homebrew """
from __future__ import print_function
import os
from os.path import expanduser, splitext
import sys
from wheel.install import WheelFile
POP_PLAT_TAG = 'macosx_10_6_intel'
@sidupadhyay
sidupadhyay / sample.config
Created June 7, 2011 05:27
Sample HA Proxy Config for Tornado/Socket.io Backends
global
maxconn 10000 # Total Max Connections. This is dependent on ulimit
nbproc 2
defaults
mode http
option redispatch
maxconn 2000
contimeout 5000
clitimeout 50000
@qzaidi
qzaidi / nginx-multibackend.conf
Created March 11, 2012 01:35
nginx a/b test config
upstream rrbackend {
server 127.0.0.1:8080 weight=3;
server 127.0.0.1:8888;
}
map $cookie_backend $backend {
default rrbackend;
experimental 127.0.0.1:8888;
}
@mayli
mayli / zipdb.py
Created April 5, 2012 13:58
Use a zipfile store a dict like k-v database
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# zipdb.py
# Use a zipfile store a dict like k-v database.
# Known bug: duplicate key(filenames) allowed
#
# Copyright 2012 mayli <mayli.he@gmail.com>
#
@tiye
tiye / paint,js
Created July 12, 2012 12:11
几行代码网页变成画布
document.body.innerHTML = "<canvas id='cvs' width='1200px' height='600px'></canvas>";
cvs = document.getElementById('cvs');
ctx = cvs.getContext('2d');
cvs.onmousedown = function(){
cvs.onmousemove = function(e){ctx.fillRect(e.offsetX,e.offsetY,2,2);console.log(e.clientX);}
};
cvs.onmouseup = function(){ cvs.onmousemove =function(e){}};
// oldj:设 A = $("#id a"),B = $("#id .c a"),求 A - B。要求:
// 1、不能用 jQuery 等框架;
// 2、兼容 IE6 在内的各大浏览器;
// 3、尽可能高效;
// 4、尽可能简短。
function getWanted() {
var root = document.getElementById('id')
var all = root.getElementsByTagName('*')
- (void)testTwitter
{
// Step 0: Check that the user has local Twitter accounts
BOOL isTwitterAvailable = [SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter];
NSLog(@"isTwitterAvailable:%d", isTwitterAvailable);
if (isTwitterAvailable) {
// Step 1: Obtain access to the user's Twitter accounts
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
@shunfan
shunfan / slugify.py
Last active June 25, 2017 20:18
Slugify Chinese
# coding=utf-8
"""
Slugify for Chinese
没有优化多音字
优化多音字的项目有:
https://github.com/jiedan/chinese_pinyin
"""
import re
import unidecode
@zvving
zvving / CLLocation+Sino.h
Last active January 9, 2019 02:39
火星坐标系转换扩展。Earth(国外 WGS84), mars(国内 GCJ-02), bearPaw(百度 BD-09) 坐标系间相互转换
//
// CLLocation+Sino.h
//
// Created by i0xbean@gmail.com on 13-4-26.
// 火星坐标系转换扩展
//
// earth(国外 WGS84), mars(国内 GCJ-02), bearPaw(百度 BD-09) 坐标系间相互转换
// 未包含 mars2earth. 需要这个可参考 http://xcodev.com/131.html
#import <CoreLocation/CoreLocation.h>