Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View guoyoujin's full-sized avatar
🍒
I may be slow to respond

TryCatch guoyoujin

🍒
I may be slow to respond
View GitHub Profile
@guoyoujin
guoyoujin / 关于.cap文件过滤IP
Created April 9, 2019 04:34
ruby关于.cap文件过滤IP
str = "21:20:36.678356 IP 190.223.26.38.ldap > 39.108.626.17.64292: UDP, bad length 2903 > 1472
21:20:36.678429 IP 5-198-122-238.static.kc.net.uk.ldap > 39.108.626.17.17604: UDP, bad length 3040 > 1464
21:20:36.678430 IP 190.223.26.38 > 39.108.626.17: udp
21:20:36.678486 IP 13.69.135.13 > 39.108.626.17: udp
21:20:36.678577 IP itt67-1-88-182-62-59.fbx.proxad.net.ntp > 39.108.626.17.47721: NTPv2, Reserved, length 440
21:20:36.678578 IP mail.centromedicomilitar.com.gt.ldap > 39.108.626.17.17604: UDP, bad length 3173 > 1472
21:20:36.678496 IP host-195-33-224-54.reverse.superonline.net.ldap > 39.108.626.17.64292: UDP, bad length 2934 > 1472
21:20:36.678497 IP host-195-33-224-54.reverse.superonline.net > 39.108.626.17: udp"
regex=/^[^I]*IP ([^>]*)>.*$/;
@guoyoujin
guoyoujin / gist:0dfafc3532ebf41e69cf7c064bac08b9
Created March 26, 2019 03:02
图片转换成webp格式
//pip3 install Pillow
import os
from PIL import Image
//
path = "/Users/apple/Desktop/captcha_20190325"
tagerPath = "/Users/apple/Desktop/webcaptcha_20190325/"
files= os.listdir(path)
for file in files:
if not os.path.isdir(file):
@guoyoujin
guoyoujin / gist:e44f36b64024a27e523ff6c609deddef
Created September 13, 2018 07:18
省市身份证编码
110000 北京市
110100 北京市市辖区
110101 北京市东城区
110102 北京市西城区
110103 北京市崇文区
110104 北京市宣武区
110105 北京市朝阳区
110106 北京市丰台区
110107 北京市石景山区
110108 北京市海淀区
切记在rails 使用 migration,rollback的时候需要注意的点
1.删除表之后,执行rollback是无法回滚的
2.删除字段之后,执行rollback是无法回滚的
3.修改字段部分属性之后,执行rollback是无法回滚的
总之删除动作和修改动作回滚比较复杂,乱用,为此付出血的代价
@guoyoujin
guoyoujin / docker-etcd-compose.yml
Created January 8, 2018 08:25
docker-etcd-compose.yml
version: '2'
services:
etcd1:
image: quay.io/coreos/etcd:v3.2.5
restart: always
ports:
- 23791:2379
- 23801:2380
volumes:
@guoyoujin
guoyoujin / docker-compse安装
Created January 5, 2018 10:21
docker-compse安装
https://github.com/docker/compose/releases
curl -L https://github.com/docker/compose/releases/download/1.18.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
@guoyoujin
guoyoujin / install cfssl
Last active March 26, 2024 16:52
linux install cfssl
source:
https://pkg.cfssl.org/
install:
$ curl -s -L -o /bin/cfssl https://pkg.cfssl.org/R1.2/cfssl_linux-amd64
$ curl -s -L -o /bin/cfssljson https://pkg.cfssl.org/R1.2/cfssljson_linux-amd64
$ curl -s -L -o /bin/cfssl-certinfo https://pkg.cfssl.org/R1.2/cfssl-certinfo_linux-amd64
$ chmod +x /bin/cfssl*
@guoyoujin
guoyoujin / 关于物品叠加问题的思维方法
Last active January 5, 2018 09:24
关于物品叠加问题的思维方法
假设有一个九宫格表,格子里面有各种物品,有的格子上是空的,有的格子上的物品是同一种物品,只是数量不一,当你把格子的物品移动到别的格子上的时候,你该怎么做?
下面是代码逻辑的顺序,仅供参考
理想思路算法逻辑
1.如果目标格子上为空,则直接覆盖目标格子,并删除移动格子数据
2.如果种类相同,直接让目标格子数量加上移动格子的数量,并清空移动的格子上的数据
3.如果种类不相同,则互换格子上的数据即可
上面这种情况在正常情况下是完全没有问题,但是当移动格子和目标格子是同一个格子的时候你会发现,他是满足条件2的,这时候奇迹发生了,物品数量翻倍了,老天,假如一直这么移动的话,那不是逆天了。
@guoyoujin
guoyoujin / etcd-client.go
Created December 27, 2017 04:40
rpcx etcd tls
// go run -tags etcd client.go
package main
import (
"context"
"flag"
"log"
"time"
"crypto/tls"
"io/ioutil"
@guoyoujin
guoyoujin / etcd-server.go
Created December 27, 2017 04:38
rpcx etcd tls
// go run -tags etcd server.go
package main
import (
"context"
"flag"
"log"
"time"
"crypto/tls"
metrics "github.com/rcrowley/go-metrics"