Skip to content

Instantly share code, notes, and snippets.

View hanxi's full-sized avatar
🎯
Focusing

涵曦 hanxi

🎯
Focusing
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
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
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 January 17, 2019 07:27
mintty color to putty color
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 November 30, 2018 05:31
用 Lua 实现 LRU
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 September 13, 2018 03:35
Python Dump
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);
@hanxi
hanxi / packfloat.c
Created January 29, 2015 08:03
pack and unpack float
#include <stdio.h>
#include <inttypes.h>
static uint64_t pack754(long double f, uint8_t bits, uint8_t expbits)
{
long double fnorm;
int shift;
uint64_t sign;
uint64_t exp;
uint64_t significand;
@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 / vimrc
Last active August 29, 2015 14:10
set nocompatible
filetype off
"{{ 插件安装
"git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim
"PluginInstall
"set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
@hanxi
hanxi / httpd.c
Created November 24, 2014 02:59
tinyhttd
/* J. David's webserver */
/* This is a simple webserver.
* Created November 1999 by J. David Blackstone.
* CSE 4344 (Network concepts), Prof. Zeigler
* University of Texas at Arlington
*/
/* This program compiles for Sparc Solaris 2.6.
* To compile for Linux:
* 1) Comment out the #include <pthread.h> line.
* 2) Comment out the line that defines the variable newthread.