- YAML 使用 2 空格+.yml后缀
- Jinja 变量前后需要使用空格 {{ var }}
- YAML 中引用变量时需要用双引号
- 环境变量全大写,其他变量全小写
- 所有变量前需要加上 role name 作为前缀,比如 nginx_xxx
- role 命名使用短横线
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import click | |
@click.command() | |
@click.option("--age", type=int, default=24, help="你当前的年龄") | |
@click.option("--asset", type=float, default=0, help="上一年年末总资产") | |
@click.option("--salary", type=float, default=200000, help="预计今年年工作收入") | |
@click.option("--salary-rate", type=float, default=0.1, help="预计工作收入年增长率") | |
@click.option("--invest", type=float, default=10000, help="预计今年投资收入") | |
@click.option("--invest-rate", type=float, default=0.1, help="预计投资收入年增长率") | |
@click.option("--expense", type=float, default=90000, help="预计今年支出") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Instructions for making hybrid GPT/MBR boot USB thumb drive. | |
# The Slackware Linux installer will be added to the image as an example, | |
# however the syslinux configuration can be modified to include any desired | |
# image. | |
# | |
# A USB thumb drive formatted with these instructions was able to | |
# boot the Slackware Installer on a: | |
# | |
# Dell Latitude E6430 in Legacy BIOS mode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Proxy] | |
TestTLS = https, 192.168.20.6, 443, client-cert=item | |
[Keystore] | |
item = password=123456, base64=MIILqQIBAzCCC28GCSqGSIb3DQEHAaCCC2AEggtcMIILWDCCBg8GCSqGSIb3DQEHBqCCBgAwggX8AgEAMIIF9QYJKoZIhvcNAQcBMBwGCiqGSIb3DQEMAQYwDgQIh4LPGCPkcqkCAggAgIIFyDOP/a/YB66H0jctVC5/D3ZF98es9Xtf60hqDokaekMp7VlKhr7EEvf1GrmxOY9XqO1dSR0F2C17yefazR7lZVDwfmNvU8eEpIPrBAnqSnCFyMZGXjcu9aoEySkwRlSclqg9lbFhp9XZG4F4qRuo94mlTPDy47dvdzyiPAQPBIq2DOE/qbRVHqrbnZMkUZi1lxihRRcQv7YJAfLEP2VHffjZTYzlBMi/ldKyD4ZQdpM7mdBtHXFa21ZV9j4oqM2PWWToHwIxkeiS6J2SgfEg501QEy4kbihlp+pSK4OMrj33DrVFP9rOMDnkJtQ+EP0LXXQBaF+7rRp+dekcH+sYBQF0cDMhNEkHEBL8LoQ96hZxIDxE3YQ6fq9KGi4TV8Ktkgb2l0G5DoavN8dhCKS5Gx0nexDT8vj91Js94Xt4tFThSyoc4ZmZvN+b2ugqVvYsnWaKqS8UeAjIAFsZCiLgj4OG6frrAxI+V3c8kL9FrwfFQcL9eWoqVfhBv8SKzMYObTv9FwyJn/fyGdtoT19OpyWiP1+nU+WY7e5KjcJNsKeYolgpgHDXdOSYCakQfesENeeKqvzMA6Quj7g7gZl/AB/GjRybyAXfkxyYBLk5cz7MuDcM1nk6DR47IuHBHyrwOATXyejWYrlK0QUVUsFEmM2vjl38jU8+qxjVWDTFu3gQkFBERncJp1XnKSTueDEPkdeq1BzV1SZ1m1KHNPNI4h2lPa+IKvpYbnDure9n1VV7fk2ySJrBFT5pYonXdpyaCTAvTEFk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let bytes = input.as_bytes(); | |
let mut raw = Vec::<u8>::with_capacity(input.len()); | |
for (offset, codepoint) in input.char_indices() { | |
let c = codepoint as u32; | |
if (c > 0x40 && c < 0x5b) || (c > 0x60 && c < 0x7b) || | |
(c > 0x29 && c < 0x3a) || c == 0x2b || c == 0x2f { | |
raw.push(bytes[offset]); | |
} else if codepoint.is_whitespace() || c == 0x3d { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn ignore-trailing-slash | |
"Modifies the request uri before calling the handler. | |
Removes a single trailing slash from the end of the uri if present. | |
Useful for handling optional trailing slashes until Compojure's route matching syntax supports regex. | |
Adapted from http://stackoverflow.com/questions/8380468/compojure-regex-for-matching-a-trailing-slash" | |
[handler] | |
(fn [request] | |
(let [uri (:uri request)] | |
(handler (assoc request :uri (if (and (not (= "/" uri)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Weisi Dai <[email protected]> | |
# | |
# Usage: bash dns_ttl.sh 8.8.8.8 | |
# | |
# Dependencies: mtr dig iptables bc | |
DOMAIN=twitter.com | |
DNS=$1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this forces dpkg not to call sync() after package extraction and speeds up install | |
RUN echo "force-unsafe-io" > /etc/dpkg/dpkg.cfg.d/02apt-speedup | |
# we don't need and apt cache in a container | |
RUN echo "Acquire::http {No-Cache=True;};" > /etc/apt/apt.conf.d/no-cache |
Create an empty directory, download the code and run it:
$ mkdir /tmp/lj
$ cd /tmp/lj
$ wget https://gist.github.com/benbjohnson/5622779/raw/e53d227ebdbea8d513b62ad076feb3f6ac1c1594/luajit.go
$ go run luajit.go
And you should see:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def quicksel(l,k): | |
if len(l) <k: | |
raise ValueError | |
else: | |
pivot=l.pop() | |
lg=filter(lambda x:x>pivot,l) | |
ll=filter(lambda x:x<=pivot,l) | |
if len(lg)>=k: | |
return quicksel(lg,k) | |
elif len(lg)+1==k: |
NewerOlder