Skip to content

Instantly share code, notes, and snippets.

View iwinux's full-sized avatar
👽

Limbo Peng iwinux

👽
View GitHub Profile
@Linusp
Linusp / finance.py
Last active January 10, 2021 07:32
计算达到资产目标需要多少年
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="预计今年支出")
#
# 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
@Blankwonder
Blankwonder / gist:cd9fa1987e41cf1a1f1df50583ba1d9c
Created November 14, 2017 04:48
client-side SSL/TLS certificate validation
[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
@humiaozuzu
humiaozuzu / convention.md
Last active May 29, 2019 05:13
Ansible best practice

Ansible best practice

通用规则

  • YAML 使用 2 空格+.yml后缀
  • Jinja 变量前后需要使用空格 {{ var }}
  • YAML 中引用变量时需要用双引号
  • 环境变量全大写,其他变量全小写
  • 所有变量前需要加上 role name 作为前缀,比如 nginx_xxx
  • role 命名使用短横线
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 {
@dannypurcell
dannypurcell / trailing-slash-middleware
Created January 2, 2014 05:30
Ring middleware fn. Removes a trailing slash from the uri before calling the handler.
(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))
@weisi
weisi / dns_ttl.sh
Last active July 25, 2020 06:42
尝试利用 IP.TTL 确定 DNS 污染发生的位置
#!/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
@jpetazzo
jpetazzo / gist:6127116
Created July 31, 2013 23:21
Debian/Ubuntu containers protips, thanks to @spahl
# 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
@benbjohnson
benbjohnson / README.md
Last active February 11, 2019 12:10
LuaJIT + Go Integration Test

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:

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: