Skip to content

Instantly share code, notes, and snippets.

View hanxi's full-sized avatar
:octocat:
Happy Coding!!!

涵曦 hanxi

:octocat:
Happy Coding!!!
View GitHub Profile
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
@hanxi
hanxi / reload.lua
Last active February 19, 2019 06:04
Lua hotfix
-- 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 = {}
@hanxi
hanxi / calculate.lua
Created May 24, 2019 10:35
Skynet 动态控制无状态服务的数量
-- calculate.lua
local skynet = require "skynet"
local CMD = {}
function CMD.calculate(a, b)
return a^b
end
function CMD.exit()
skynet.error("slave exit.")
#
# 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 / drop.js
Created July 26, 2019 10:38
H5 拖拽上传文件
// 获得拖拽文件的回调函数
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()
@hanxi
hanxi / makefile
Created November 22, 2014 09:35
交叉编译luasocket
#Hellomake
#Magnum, 2014-10-19
# 指令编译器和选项
NDK_HOME=/Users/hrj/Documents/android/android-ndk
TOOLCHAINS_ROOT=$(NDK_HOME)/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64/
TOOLCHAINS_PREFIX=$(TOOLCHAINS_ROOT)/bin/arm-linux-androideabi
TOOLCHAINS_INCLUDE=$(TOOLCHAINS_ROOT)/lib/gcc/arm-linux-androideabi/4.8/include-fixed
PLATFORM_ROOT=$(NDK_HOME)/platforms/android-19/arch-arm
NDKINC=$(PLATFORM_ROOT)/usr/include
@hanxi
hanxi / chk_net_redail.sh
Last active December 17, 2020 01:50
检查网络并重连 wan 口,检测多个 url
#!/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 / skiplist.c
Created December 24, 2020 04:55
skiplist
// 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 / lmd.lua
Created December 16, 2014 08:14
使用LPeg将markdown转成html
local lpeg = require 'lpeg'
local P,S,C,Cs,Cg = lpeg.P,lpeg.S,lpeg.C,lpeg.Cs,lpeg.Cg
local test = [[
A title
---
BTitle
--
CTitle
@hanxi
hanxi / philosopher.c
Last active November 24, 2021 06:05
哲学家进餐问题
// gcc -std=c99 -g philosopher.c -o philosopher
#include <pthread.h>
#include <unistd.h>
#include <stdio.h>
#include <stdbool.h>
struct philosopher {
int id;
int think_count;
bool eating;