Skip to content

Instantly share code, notes, and snippets.

Avatar
🆒
Happy Coding!!!

涵曦 hanxi

🆒
Happy Coding!!!
View GitHub Profile
View skiplist.c
// fork from https://github.com/xjdrew/lua-zset
// skiplist similar with the version in redis
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "skiplist.h"
@hanxi
hanxi / chk_net_redail.sh
Last active Dec 17, 2020
检查网络并重连 wan 口,检测多个 url
View chk_net_redail.sh
#!/bin/sh
# filename: /root/chk_net_redail.sh
# 4=network error/refused/timeout/dns err/
# need "opkg install wget ca-bundle"
log()
{
#echo $*
logger -t redail $*
}
@hanxi
hanxi / drop.js
Created Jul 26, 2019
H5 拖拽上传文件
View drop.js
// 获得拖拽文件的回调函数
function getDropFileCallBack (dropFiles) {
//console.log(dropFiles, dropFiles.length)
upload_parse(dropFiles)
}
var dropZone = document.querySelector("#dropZone")
dropZone.addEventListener("dragenter", function (e) {
e.preventDefault()
e.stopPropagation()
View k2.config
#
# Automatically generated file; DO NOT EDIT.
# OpenWrt Configuration
#
CONFIG_MODULES=y
CONFIG_HAVE_DOT_CONFIG=y
# CONFIG_TARGET_sunxi is not set
# CONFIG_TARGET_apm821xx is not set
# CONFIG_TARGET_ath25 is not set
# CONFIG_TARGET_ar71xx is not set
@hanxi
hanxi / calculate.lua
Created May 24, 2019
Skynet 动态控制无状态服务的数量
View calculate.lua
-- calculate.lua
local skynet = require "skynet"
local CMD = {}
function CMD.calculate(a, b)
return a^b
end
function CMD.exit()
skynet.error("slave exit.")
@hanxi
hanxi / reload.lua
Last active Feb 19, 2019
Lua hotfix
View reload.lua
-- fork from https://github.com/cloudwu/luareload/blob/3dbd54ddfda5848623e9b93576d16dfe4c6b4169/reload.lua
-- changes:
-- 1. local a = { xx = 100} -- this will use merge new data
-- 2. local a = 100 -- this will use new data
-- 3. local a = "abcd" -- this will use new data
-- 4. local a = MEMORY_VAR("a", 0) -- this will use old data
-- 5. local a = RESET_VAR("a", 0) -- this will use new data
local reload = {}
local sandbox = {}
View close_plugin_window.vim
function! ClosePluginWindow()
" Close quickfix
cclose
" Close Leaderf Buffer
redir => message
silent execute "ls!"
redir END
let l:buflist = split(message, '\n')
for l:one in l:buflist
View gen_tags_find.vim
function! s:gen_tags_find(cmd, keyword) abort
" Mark this position
execute "normal! mY"
" Close any open quickfix windows
cclose
" Clear existing quickfix list
cal setqflist([])
let l:cur_buf=@%
let l:cmd = 'cs find ' . a:cmd . ' ' . a:keyword
View search_root.vim
function! SearchRoot()
let l:scm_list = ['.root', '.svn', '.git']
for l:item in l:scm_list
let l:dirs = finddir(l:item, '.;', -1)
if !empty(l:dirs)
return fnamemodify(l:dirs[-1].'/../', ':p:h')
endif
endfor
return getcwd()
endfunction
@hanxi
hanxi / dracula.minttyrc
Created Jan 17, 2019
mintty color to putty color
View dracula.minttyrc
ForegroundColour=248,248,242
BackgroundColour=40,42,54
Black=0,0,0
BoldBlack=104,104,104
Red=255,85,85
BoldRed=255,110,103
Green=80,250,123
BoldGreen=90,247,142
Yellow=241,250,140
BoldYellow=244,249,157