Skip to content

Instantly share code, notes, and snippets.

View bulatie's full-sized avatar
🏴‍☠️

Michael bulatie

🏴‍☠️
View GitHub Profile
@bulatie
bulatie / circleClickHandler.js
Created March 25, 2020 09:34
circleClickHandler
circleClickHandler() {
let level = this.curExpendLevel
if (level < 2 && (level > this.lastExpendLevel || level === 0)) {
level++
} else {
level--
}
this.lastExpendLevel = this.curExpendLevel
this.curExpendLevel = level
}
@bulatie
bulatie / ExportNetEaseMusicSongList.js
Last active November 28, 2019 06:43 — forked from XueshiQiao/ExportNetEaseMusicSongList.js
导出网易云音乐歌单到 AppleMusic / Spotify 等平台
/**
* 使用方法:
* 1. 用 Chrome 打开歌单的 web 页面(可以通过分享拿到链接,链接类似这样:http://music.163.com/playlist?id=xxx&userid=yyy)
* 2. 然后右键“检查”(如果有左上角有 device 选项,需要选择 Laptop 开头的,可以在 Edit/编辑 里添加)
* 3. 在 console 里输入下面脚本,即可输出 “歌曲名 - 歌手名” 格式的内容:
Springsteen - Eric Church
Chattahoochee - Alan Jackson
Baby Now That I Found You - Alison Krauss
Check Yes or No - George Strait
@bulatie
bulatie / server.js
Last active October 31, 2019 03:11
koa upload file
const fs = require('fs')
const path = require('path')
const os = require('os')
const Koa = require('koa')
const koaBody = require('koa-body');
const app = new Koa()
@bulatie
bulatie / regex.js
Last active July 11, 2019 08:19
regex
var fileOrPath = /^((((?:\.\/|\.\.\/|\/)?(?:[.\w-_]+\/)*)([.\w-_]+)*),?)+$/
var email = /^[a-z0-9]+([._\\-]*[a-z0-9])*@(?:(?!qq|gmail|163|sina|live|126|yeah|sohu|hotmail|outlook|263|googlemail|yahoo|sogou|21cn|189|aliyun|foxmail|139|10086)[a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/
var phone = /^1\d{10}$|^(0\d{2,3}-?|\(0\d{2,3}\))?[1-9]\d{4,7}(-\d{1,8})?$/
var hexstring = /\b[0-9a-fA-F]+\b/
@bulatie
bulatie / binary_hex_list.py
Created May 14, 2019 07:56
convert binary string to hex list in python2
# https://stackoverflow.com/questions/14678132/python-hexadecimal
iv = '\xf3\xc2\xafw:\r}k'
res = ''
for i in iv:
res = res + "{:#04x}".format(ord(i)) + ", "
print res
@bulatie
bulatie / generate_token.sh
Created May 14, 2019 07:43
a decent way to generate a secret key
python -c "import os; print(repr(os.urandom(24)))"
@bulatie
bulatie / decode.py
Created May 14, 2019 03:22
encode from go, decode in python by using aes cfb
SEGMENT_SIZE=128
BLOCK_SIZE = 16
cipher = AES.new(KEY, AES.MODE_CFB, IV, segment_size=SEGMENT_SIZE)
dc = dynamic_token.decode("hex")
pt = cipher.decrypt(dc)
print pt
@bulatie
bulatie / aes_cfb_eg.py
Created May 13, 2019 07:59
aes cfb mode py2
import json
from base64 import b64encode
from Crypto.Cipher import AES
from Crypto.Random import get_random_bytes
data = "secret"
print(data)
key = get_random_bytes(16)
iv = get_random_bytes(16)
cipher = AES.new(key, AES.MODE_CFB, iv)
@bulatie
bulatie / cfb_aes_eg.py
Created May 13, 2019 07:56
aes cfb mode py3
import json
from base64 import b64encode
from Crypto.Cipher import AES
from Crypto.Random import get_random_bytes
data = b"secret"
print(data)
key = get_random_bytes(16)
iv = get_random_bytes(16)
cipher = AES.new(key, AES.MODE_CFB, iv)
@bulatie
bulatie / run_command.py
Created May 13, 2019 06:30
run_command
(subprocess.check_output("echo xxx", shell=True).strip()).decode()