Skip to content

Instantly share code, notes, and snippets.

@fwindpeak
fwindpeak / uuid.lua
Created May 23, 2017 03:42
lua gen uuid
-- fork from https://gist.github.com/jrus/3197011
local random = math.random
local _M = {}
function _M.uuid()
math.randomseed(tonumber(tostring(os.clock()):reverse():sub(1,6)))
local template ='xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
return string.gsub(template, '[xy]', function (c)
local v = (c == 'x') and random(0, 0xf) or random(8, 0xb)
return string.format('%x', v)
@fwindpeak
fwindpeak / getopttest.py
Created June 27, 2017 03:05
getopt example
#!/usr/bin/env python
import sys,getopt
opts,args = getopt.getopt(sys.argv[1:],"s:e:h",["start_time","end_time","help"])
start_time=''
end_time=''
for op,value in opts:
#!/bin/bash
git filter-branch -f --env-filter '
if test "$GIT_AUTHOR_EMAIL" = "name@name.com"
then
GIT_AUTHOR_EMAIL=fwindpeak@gmail.com
export GIT_AUTHOR_EMAIL
fi
if test "$GIT_AUTHOR_NAME" = "name"
then
@fwindpeak
fwindpeak / jd_autobuy.js
Last active December 11, 2020 12:55
userscript for auto buy jd.com item
// ==UserScript==
// @name jd_autobuy
// @namespace http://fwindpeak.github.com
// @version 0.0.1
// @description autobuy jd item
// @author fwindpeak
// @match *://item.jd.com/*.html*
// @match *://marathon.jd.com/seckill/seckill.action*
// @match *://marathon.jd.com/koFail.html*
// @match *://cart.jd.com/addToCart.html*
var express = require('express')
var proxy = require('http-proxy-middleware')
var app = express()
app.use('/api', proxy({ target: 'http://xxxx:8090', pathRewrite: {
'^/api': ''
}, changeOrigin: true }))
app.use('/', proxy({ target: 'http://xxxx:3002', changeOrigin: true }))
app.listen(3001)
@fwindpeak
fwindpeak / ps1.sh
Last active September 21, 2018 02:49 — forked from Flushot/ps1.sh
PS1
__git_ps1 ()
{
local b="$(git symbolic-ref HEAD 2>/dev/null)";
if [ -n "$b" ]; then
printf " (%s)" "${b##refs/heads/}";
fi
}
export PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\033[0;36m\]$(__git_ps1)\[\033[0m\]\n\$ '
@fwindpeak
fwindpeak / ssh_socks5.sh
Created September 29, 2018 05:03
通过ssh建立socks5代理
ssh -qTfnN -D 1234 user@myvps
@fwindpeak
fwindpeak / vimrc.sh
Last active November 5, 2019 06:25
simple vimrc
set nu sts=4 ts=4 sw=4 et si ai
set ruler
set hlsearch
syntax on
filetype plugin on
nmap <esc><esc> :silent! noh<cr>
@fwindpeak
fwindpeak / ocr-server.py
Created December 24, 2019 06:06
websocket ocr server
#!/usr/bin/python
# coding:utf-8
from websocket_server import WebsocketServer
import pytesseract
import io
import requests
from PIL import Image
def get_ocr_result(img_url):