Skip to content

Instantly share code, notes, and snippets.

:octocat:
Coding

涵曦 hanxi

:octocat:
Coding
Block or report user

Report or block hanxi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@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
@hanxi
hanxi / lru.lua
Last active Nov 30, 2018
用 Lua 实现 LRU
View lru.lua
local lru = {}
local lru_mt = { __index = lru }
local function addnode(self, node)
local head = self._head
node._next = head
if head then
head._pre = node
end
self._head = node
@hanxi
hanxi / util.py
Last active Sep 13, 2018
Python Dump
View util.py
static void PrintRefCnt(const char *s, PyObject *obj)
{
printf("PrintRefCnt:%s.%ld\n", s, (long)(obj->ob_refcnt));
}
static void DumpPyObject(const char *s, PyObject *obj)
{
PyObject *str = PyObject_Str(obj);
printf("DumpPyObject:%s.%s\n", s, PyString_AsString(obj));
Py_DECREF(str);
You can’t perform that action at this time.