Skip to content

Instantly share code, notes, and snippets.

# 在末尾加上,显示当前在第几个窗口。
caption always "%{= kw}%-w%{= kG}%{+b}[%n %t]%{-b}%{= kw}%+w %=%d %M %0c %{g}%H%{-}"
@aqzlpm11
aqzlpm11 / string_enum.cpp
Last active July 11, 2017 11:55
C++: string enum
/////////// self defined ENUM_STR, have a string val
#define ENUM_STR_BEGIN(type_name) \
class type_name { \
std::string v; \
public: \
static std::set<std::string>* vals() { static std::set<std::string> s; return &s; }\
type_name(const std::string& a): v(a){} \
std::string toString() { return v; } \
bool isValid() { return vals()->find(v) != vals()->end(); }
@aqzlpm11
aqzlpm11 / python_like.h
Created July 16, 2017 07:56
c++: python_like code in c++. 在C++中以python的方式写部分代码
#ifndef __PYTHON_LIKE__
#define __PYTHON_LIKE__
#include <stdio.h>
#include <string>
#include <fstream>
#include <streambuf>
#include <vector>
#include <iostream>
#include <stdarg.h>
@aqzlpm11
aqzlpm11 / cooledit2_labelling_helper.py
Created July 9, 2017 06:43
python: cooledit2_labelling_helper. 把所有的wav合成一个,做好标记后,再分开。
import librosa
import wave
from pathlib import Path
import numpy as np
import os
all_in_one_wav = "@all_in_one.wav"
all_in_one_wav_info = "@all_in_one.txt"
all_in_one_label = "@all_in_one_vad.txt"
label_file = "@label.txt"
@aqzlpm11
aqzlpm11 / performance_analyse.py
Last active July 16, 2017 08:01
python: performance analysing example.
#encoding=utf-8
import cProfile
import pstats
def fun():
return sum([i for i in range(10000000)])
if __name__ == "__main__":
cProfile.run('fun()', "result")
@aqzlpm11
aqzlpm11 / lcs.py
Created June 28, 2017 09:33
python: Longest common subsequence (LCS) algorithm
from functools import lru_cache
@lru_cache(maxsize=2**20)
def LCS(a, b):
""" Longest common subsequence """
if len(a) == 0 or len(b) == 0:
return 0
res = max(
@aqzlpm11
aqzlpm11 / ping_all.py
Last active July 26, 2017 13:12
python: explore available ips in the LAN
# coding=utf-8
import os
from multiprocessing.dummy import Pool
def can_ping(ip):
ret = os.system('ping -n 1 -w 1 %s > nul' % ip)
can_ping = True if ret == 0 else False
return can_ping, ip
@aqzlpm11
aqzlpm11 / tuna-source.list
Created September 25, 2017 15:12
ubuntu 16.04 tuna
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main multiverse restricted universe
@aqzlpm11
aqzlpm11 / install-docker-at-ubuntu-16.04-.sh
Last active October 11, 2017 03:09
Install docker at ubuntu 16.04
#!/bin/sh
# Warning: This script is untested. (copy from command history)
# Install
curl -fsSL get.docker.com -o get-docker.sh | exit -1
sudo sh get-docker.sh | exit -1
# Add user to docker group (sudoless)
sudo gpasswd -a ${USER} docker | exit -1
@aqzlpm11
aqzlpm11 / 1.cpp
Last active December 18, 2017 06:55
ACM 开栈黑魔法
// Reference:
// https://www.cnblogs.com/HarryGuo2012/p/4722784.html
// http://blog.csdn.net/fcxxzux/article/details/40053937
#include <cstring>
#include <cstdio>
#include <cstdlib>
int dfs(int i) {
int a[100];