Skip to content

Instantly share code, notes, and snippets.

#include <condition_variable>
#include <fstream>
#include <mutex>
#include <queue>
#include <streambuf>
#include <string>
#include <thread>
#include <vector>
struct async_buf
@jemyzhang
jemyzhang / spacemacs.mirror
Last active March 23, 2018 01:45
[Mirror of emacs in China] mirror site of china to install spacemacs #emacs
(defun dotspacemacs/init ()
(setq configuration-layer--elpa-archives
'(("gnu" . "https://mirrors.tuna.tsinghua.edu.cn/elpa/gnu/")
("melpa" . "https://mirrors.tuna.tsinghua.edu.cn/elpa/melpa/")
("melpa-stable" . "https://mirrors.tuna.tsinghua.edu.cn/elpa/melpa-stable/")
("org" . "https://mirrors.tuna.tsinghua.edu.cn/elpa/org/")
("marmalade" . "https://mirrors.tuna.tsinghua.edu.cn/elpa/marmalade/")))
@jemyzhang
jemyzhang / install_makemkv.sh
Last active February 12, 2019 01:26 — forked from knugie/install_makemkv.sh
Ubuntu - Install MakeMKV 1.10.2
sudo apt-get install build-essential pkg-config libc6-dev libssl-dev libexpat1-dev libavcodec-dev libgl1-mesa-dev qt5-default
wget http://www.makemkv.com/download/makemkv-oss-1.10.2.tar.gz
wget http://www.makemkv.com/download/makemkv-bin-1.10.2.tar.gz
tar -xvf makemkv-oss-1.10.2.tar.gz
tar -xvf makemkv-bin-1.10.2.tar.gz
cd makemkv-oss-1.10.2/
./configure
make
sudo make install
@jemyzhang
jemyzhang / randomstring.sh
Created July 8, 2016 09:03
generate random string in shell script
random-string()
{
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w ${1:-32} | head -n 1
}
git clone https://github.com/ym/anti-hijack-list.git
#replace default server address to local
sed -i 's/155.254.49.43/127.0.0.1/g' dnsmasq/hijack.conf
sudo ln -s `pwd`/dnsmasq/hijack.conf /etc/dnsmasq.d/
sudo ln -s `pwd`/htdocs /var/www/anti-hijack
sudo apt-get install nginx
sudo ln -s `pwd`/nginx/hijack.conf /etc/nginx/
sudo vi /etc/NetworkManager/NetworkManager.conf
# add dns=dnsmasq at section [main]
@jemyzhang
jemyzhang / build_ss_qt5.sh
Created January 28, 2016 06:39
build shadowsocks-qt5 from repo
git clone https://github.com/shadowsocks/libQtShadowsocks.git
sudo apt-get install qt5-qmake qtbase5-dev libqrencode-dev libappindicator-dev libzbar-dev libbotan1.10-dev build-essential autoconf libtool libssl-dev gawk debhelper dh-systemd init-system-helpers pkg-config
cd libQtShadowsocks
dpkg-buildpackage -us -uc -b
#install libqtshadowsocks-dev before build shadowsocks-qt5
#sudo dpkg -i libqtshadowsocks-dev_1.8.4-1_amd64.deb
sudo dpkg -i libqtshadowsocks-dev_*.deb
git clone https://github.com/shadowsocks/shadowsocks-qt5.git
@jemyzhang
jemyzhang / v2ex_checkin.py
Created September 18, 2015 14:30
v2ex签到脚本
# -*- coding: utf-8 -*-
from bs4 import BeautifulSoup
import requests
username = '' ###账号###
password = '' ###密码###
login_url = 'http://v2ex.com/signin' ###如V2EX设置了使用 SSL,必须改 https###
index_url = 'http://v2ex.com' ###同上###
mission_url = 'http://www.v2ex.com/mission/daily' ###同上###
UA = "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) \
@jemyzhang
jemyzhang / rsync_ssh.sh
Created September 18, 2015 03:25
rsync through ssh protocol
rsync -avz -e "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" --progress /root/bigfile.txt 198.211.117.129:/root/
@jemyzhang
jemyzhang / Qt.QTextEdit.rmOldBlocks.cpp
Last active December 26, 2015 09:29
remove top old blocks from QTextEdit
QTextBlock block = document()->begin();
while(block.isValid()) {
if(document()->blockCount() > m_maxlines)
{
QTextCursor cursor(block);
block = block.next();
cursor.select(QTextCursor::BlockUnderCursor);
//move forward one character to select the return-char,
//in order to avoid the empty line after the selected text is removed.
cursor.movePosition(QTextCursor::NextCharacter,QTextCursor::KeepAnchor);
@jemyzhang
jemyzhang / get_current_rss.c
Last active April 1, 2024 11:38
common functions
/**
* Returns the current resident set size (physical memory use) measured
* in bytes, or zero if the value cannot be determined on this OS.
*/
size_t getCurrentRSS( )
{
long rss = 0L;
FILE* fp = NULL;
if ( (fp = fopen( "/proc/self/statm", "r" )) == NULL )
return (size_t)0L; /* Can't open? */