Skip to content

Instantly share code, notes, and snippets.

@liushapku
liushapku / scantree.py
Created January 10, 2019 01:51
python scan tree
import os
def scantree(*paths):
for path in paths:
if os.path.exists(path):
for entry in sorted(os.scandir(path), key=lambda x: x.name.lower()):
yield entry
if entry.is_dir(follow_symlinks=False):
yield from scantree(entry.path)
else:
searchsorted(arr, x, 'left') returns the position i such that arr[i-1] < x <= arr[i],
so that i is the first one such that x <= arr[i]. Equivalent to lower_bound in c++

searchsorted(arr, x, 'right') returns the position i such that arr[i-1] <= x < arr[i],
so that i is the first one such that x < arr[i]. Equivalent to upper_bound in c++
@liushapku
liushapku / log_vim.patch
Created December 7, 2018 02:06
a patch make vim able to log
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 9040c0d07..e7f040fc2 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -1,3 +1,23 @@
+#include <stdio.h>
+#include <stdarg.h>
+int shouldout = 0;
+int mprintf(char *fmt, ...)
+{
@liushapku
liushapku / execute_test.vim
Created December 6, 2018 14:37
vim: test for execute()
" test 1
function! Test1a()
echo 12345678
let x = execute('echo 1234567890', '')
echon '1234'
endfunction
function! Test1b()
echo 12345678
echo 1234567890
@liushapku
liushapku / gist:ca47de750197f42290e58ad92c46c7e2
Created July 16, 2018 07:03
manually share numpy memmapped arrays to different processes
import numpy as np
from numpy.lib.stride_tricks import as_strided
from distutils.version import LooseVersion
import mmap
import tempfile
import shutil
import os
import uuid
import contextlib
" Plug 'mattn/gist-vim'
Plug 'liushapku/gist-vim'