Skip to content

Instantly share code, notes, and snippets.

@jedy
jedy / read_mylogin.py
Created Jun 5, 2020
read mylogin.cnf
View read_mylogin.py
import struct
from Crypto.Cipher import AES
LOGIN_KEY_LEN = 20
MY_LOGIN_HEADER_LEN = 24
MAX_CIPHER_STORE_LEN = 4
f = open(".mylogin.cnf", "rb")
f.seek(4)
b = f.read(LOGIN_KEY_LEN)
@jedy
jedy / unzip.py
Created Apr 7, 2020
decompress ZIP file with encoding
View unzip.py
import zipfile
import pathlib
import chardet
def unzip(file, path):
z = zipfile.ZipFile(file)
detector = chardet.UniversalDetector()
for i in z.infolist():
if i.flag_bits & 0x800 == 0:
detector.feed(i.filename.encode("cp437"))
View mysql 8.md
  • 读写混合性能相比5.7有很大提升

  • 高竞争场景的性能有很大提升

  • 不支持query cache了

  • 只有innodb支持分区(PARTITION)

  • expire_logs_days废弃了,使用binlog_expire_logs_seconds

@jedy
jedy / main.go
Created Jul 10, 2017
自动获得let's encrypt的证书
View main.go
package main
// https://blog.kowalczyk.info/article/Jl3G/https-for-free-in-go.html
// To run:
// go run main.go
// Command-line options:
// -production : enables HTTPS on port 443
// -redirect-to-https : redirect HTTP to HTTTPS
import (
@jedy
jedy / mail.go
Last active Mar 15, 2017
sendmail with tls
View mail.go
package main
import (
"crypto/tls"
"errors"
"log"
"net"
"net/smtp"
)
@jedy
jedy / 词性标记.md
Created Apr 15, 2016 — forked from luw2007/词性标记.md
词性标记: 包含 ICTPOS3.0词性标记集、ICTCLAS 汉语词性标注集、jieba 字典中出现的词性、simhash 中可以忽略的部分词性
View 词性标记.md

词的分类

  • 实词:名词、动词、形容词、状态词、区别词、数词、量词、代词
  • 虚词:副词、介词、连词、助词、拟声词、叹词。

ICTPOS3.0词性标记集

n 名词
	nr 人名
View gray.go
func BinaryToGray(num uint) uint {
return (num >> 1) ^ num
}
func GrayToBinary(num uint) uint {
for mask := num >> 1; mask != 0; mask = mask >> 1 {
num = num ^ mask
}
return num
}
@jedy
jedy / copy_to_clipboard.py
Created Apr 10, 2015
copy figure to windows clipboard
View copy_to_clipboard.py
import matplotlib.pyplot as plt
from cStringIO import StringIO
import win32clipboard
from PIL import Image
def send_to_clipboard(clip_type, data):
win32clipboard.OpenClipboard()
win32clipboard.EmptyClipboard()
win32clipboard.SetClipboardData(clip_type, data)
@jedy
jedy / lua_mem_usage.c
Last active Oct 14, 2015 — forked from AndrewTsao/lua_mem_usage.c
lua memory usage
View lua_mem_usage.c
#include <stdio.h>
#include <stdlib.h>
#include "lua5.1/lua.h"
#include "lua5.1/lauxlib.h"
#include "lua5.1/lualib.h"
// Measuring lua vm memory usage.
// build: gcc main.c -llua5.1 -lm -ldl -fPIC
static size_t mem_used = 0;
@jedy
jedy / compare_version.c
Last active Aug 29, 2015
compare version
View compare_version.c
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
int compareVersion(const char *v1, const char *v2)
{
char *f1, *f2, *s1, *s2;
int n1, n2, r;
f1 = s1 = strdup(v1);
f2 = s2 = strdup(v2);
You can’t perform that action at this time.