Skip to content

Instantly share code, notes, and snippets.

View youngsofun's full-sized avatar

Yang Xiufeng youngsofun

View GitHub Profile
@youngsofun
youngsofun / kill_child_processes.py
Created March 16, 2018 03:02 — forked from jizhilong/kill_child_processes.py
how to kill a process's child processes in python
#!/usr/bin/env python
import multiprocessing
import time
import subprocess, os, signal, sys
def test(s):
while True:
print s
time.sleep(1.5)
import multiprocessing
import threading
import time
import os
import psutil
import sys
import errno
def worker():
print('warker start')
import sys
from six.moves import range
import time
import psutil
import resource
import random
M = 1024*1024
p = psutil.Process()
d = {}
import threading
import psutil
import time
N = 1000
S = 0.01
a = list(range(N))
stop = True
@youngsofun
youngsofun / insert_guard.vim
Created May 12, 2018 00:40 — forked from yt-siden/insert_guard.vim
Insert UUID-based include guard macro on VIM
" C/C++ insert UUID based include guard
function! s:insert_include_guard()
let s:uuid=system('uuidgen')
let s:uuid=strpart(s:uuid, 0, strlen(s:uuid)-1)
let s:uuid=substitute(s:uuid, '[a-f]', '\u\0', 'g')
let s:uuid=substitute(s:uuid, '\-', '_', 'g')
let s:uuid='UUID_'.s:uuid
call append(0, '#ifndef '.s:uuid)
call append(1, '#define '.s:uuid)
@youngsofun
youngsofun / Git push deployment in 7 easy steps.md
Created June 25, 2018 04:49 — forked from thomasfr/Git push deployment in 7 easy steps.md
7 easy steps to automated git push deployments. With small and configurable bash only post-receive hook
(py3) yxf-mac ➜ docs git:(master) ✗ sphinx-quickstart
Welcome to the Sphinx 1.7.5 quickstart utility.
Please enter values for the following settings (just press Enter to
accept a default value, if one is given in brackets).
Selected root path: .
You have two options for placing the build directory for Sphinx output.
@youngsofun
youngsofun / custom_iterator.cpp
Created April 2, 2020 06:47 — forked from jeetsukumaran/custom_iterator.cpp
Sample C++/STL custom iterator
// Sample custom iterator.
// By perfectly.insane (http://www.dreamincode.net/forums/index.php?showuser=76558)
// From: http://www.dreamincode.net/forums/index.php?showtopic=58468
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <cassert>
fn write_stream(col: &ColumnRef) {
let mut buf = Vec::with_capacity(1000*1000);
let s = col.data_type().create_serializer();
let mut stream = s.serialize_csv(&col, &FormatSettings::default()).unwrap();
while let Some(field) = stream.next() {
buf.extend_from_slice(field);
buf.push(b',');
}
@youngsofun
youngsofun / bench int32 not null
Last active May 20, 2022 14:26
csv: index vs iterator
[6.0826 us 6.1268 us 6.1724 us] 2^10 write_by_row
[9.5422 us 9.6044 us 9.7021 us] write_iterator
[34.306 us 35.018 us 35.743 us] 2^12
[59.263 us 64.474 us 70.274 us]
[258.79 us 274.87 us 292.75 us] 2^14
[268.50 us 299.75 us 336.83 us]
[1.0222 ms 1.0915 ms 1.1700 ms] 2^16