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
@hanxi
hanxi / buffertest.c
Created February 16, 2023 23:55
lua buffer test
#define LUA_LIB
#include <lua.h>
#include <lauxlib.h>
#include <string.h>
static void
dump_stack(lua_State *L, const char * name) {
int top = lua_gettop(L);
for (int i=1; i<=top; i++) {
@hanxi
hanxi / hanzi.html
Last active March 8, 2022 05:52
汉字打印
<head>
<script src="https://cdn.jsdelivr.net/npm/hanzi-writer@3.0/dist/hanzi-writer.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<style>
.box {
border: 1px solid rgb(235, 235, 235);
width: 60px;
margin-right: 5px;
margin-top: 15px;
display: inline-flex;
@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;
@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 / 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 / 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()
#
# 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 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.")
@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 = {}
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