Skip to content

Instantly share code, notes, and snippets.

web: start_nginx.sh
wrk.method = "POST"
wrk.body = [[ ["\u4ed6\u662f\u4e2a\u50bb\u903c", "\u7f8e\u597d\u7684\u4e16\u754c"] ]]
wrk.headers["Content-Type"] = "Content-Type: application/json"

0726 技术分享

daapi项目(Dashboard 2.0的JSON API)为实例,介绍用到的一些Python第三方库、一些用Python做web项目的best practice,以及如何使用Ansible来做自动部署。

暖场

可以直接在命令行运行Python的package或者module,类似这样:python -m module_name

python -m this

@mrluanma
mrluanma / base62.py
Created July 15, 2013 14:34
新浪微博mid转id Python代码。
import sys
ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
def rsplit(s, count):
f = lambda x: x > 0 and x or 0
return [s[f(i - count):i] for i in range(len(s), 0, -count)]
-- pbpaste (Mac OS X) program for Windows
-- to run: luajit clip.lua
-- it should print the clipboard (textual content)
local ffi = require( "ffi" )
ffi.cdef[[
enum { CF_TEXT = 1 };
int OpenClipboard(void*);
void* GetClipboardData(unsigned);
int CloseClipboard();
"\e[A": history-search-backward
"\e[B": history-search-forward
set show-all-if-ambiguous on
set completion-ignore-case on
@mrluanma
mrluanma / bitbucket_wiki_rocks.md
Created April 18, 2013 16:32
Bitbucket的Wiki真的特别赞

Bitbucket的Wiki真的特别赞

这两天我一直在找可以方便的多人共同编辑Markdown文件的这么一个服务。因为项目合作方那边的API文档是用Markdown写的,之前一直导出成PDF email给我们,PDF文件无法编辑,我这边实现接口的时候有什么调整无法反馈到文档中。现在他们直接发Markdown文件过来,我这边可以编辑,可是多个版本共同编辑手动同步肯定是个噩梦。

我们一直用Bitbucket的private仓库,非常好用。没想到Bitbucket的Wiki也是特别的赞,完全能满足我的上述需求。每个Bitbucket project都可以有一个Wiki,并且private的仓库也可以有public的Wiki。每个Wiki就是一个git仓库,git clone到本地就可以非常方便的用自己顺手的编辑器来写Markdown文件,push到Bitbucket就能看到Markdown转换成HTML之后的页面。小改动也可以直接用Bitbucket Wiki的web editor。

@mrluanma
mrluanma / .astylerc
Created April 15, 2013 14:32
.astylerc
indent-classes
convert-tabs
delete-empty-lines
brackets=break
indent=spaces=4
suffix=none
indent-col1-comments
break-blocks
preserve-date
align-pointer=name
@mrluanma
mrluanma / luajit_ffi_exe.c
Created April 13, 2013 17:00
Embedding LUA to an Executable using LuaJIT/FFI via: http://forums.4fips.com/viewtopic.php?f=3&t=589
/*
(c) 2012 +++ Filip Stoklas, aka FipS, http://www.4FipS.com +++
THIS CODE IS FREE - LICENSED UNDER THE MIT LICENSE
ARTICLE URL: http://forums.4fips.com/viewtopic.php?f=3&t=589
*/
extern "C" {
#include <lua.h>
#include <lualib.h>