Skip to content

Instantly share code, notes, and snippets.

View Qquanwei's full-sized avatar
💭
Busyman

李权威 Qquanwei

💭
Busyman
View GitHub Profile
function getMaxPrefixAndSuffix(P) {
let i = 0;
let len = 0;
for (let i = P.length - 1; i >= 0; --i) {
if (P.slice(0, i) === P.slice(-i)) {
return i;
}
}
@Qquanwei
Qquanwei / install-mod.sh
Created November 29, 2019 03:55
install mod
modprobe br_netfilter
modprobe ip6_udp_tunnel
modprobe ip_set
modprobe ip_set_hash_ip
modprobe ip_set_hash_net
modprobe iptable_filter
modprobe iptable_nat
modprobe iptable_mangle
modprobe iptable_raw
modprobe nf_conntrack_netlink
@Qquanwei
Qquanwei / review.yaml
Last active September 24, 2019 08:10
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: reviews
spec:
hosts:
- reviews
http:
- route:
- destination:
set -xeo pipefail
apt-get update -y
apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
docker rm -f $(sudo docker ps -aq);
docker volume rm $(sudo docker volume ls -q);
rm -rf /etc/ceph \
/etc/cni \
/etc/kubernetes \
/opt/cni \
/opt/rke \
/run/secrets/kubernetes.io \
/run/calico \
@Qquanwei
Qquanwei / install_container_service.sh
Last active August 26, 2019 07:46 — forked from carlosedp/install_container_service.sh
Install Container services (Docker/Kubernetes) on Debian/Ubuntu
#!/bin/bash
echo "Container Linux installation script"
echo "This will install:"
echo " - Docker Community Edition"
echo " - Docker Compose"
echo " - Kubernetes: kubeadm, kubelet and kubectl"
echo ""
set -xeo pipefail
const shouldSizeMatch = compact(
itShouldProp('width', large(20), always('width should large 20')),
itShouldProp('height', large(20), always('height should large 20'))
);
of({ width: 10, height: 30})
.map(shouldSizeMatch)
.validate((success, reason) => {
// reuse rules
})
function imageMatch(file) {
return readImageAsPromise(file).then(image => {
return of(image).map(itShouldProp('width', large(10), always('image width should large 10, now is ' + image.width)))
})
}
of({ filename: 'c:/fakepath/file.txt'})
.map(itShould(imageMatch, always('image not exists')))
.validate(( success, reason) => {
// async validation just fun
import { of, always } from 'OverAssert';
function asyncCheckValidate(value) {
return new Promise((resolve, reject) => {
setTimeout(() => {
if (value > 10) {
resolve();
} else {
reject();
}
import { of, itShouldPath, itShouldProp, equals, allPass, large, less, always } from 'OverAssert';
const data = {
user: {
name: 'Alice',
id: 200
},
expireTime: 200,