This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Thanks: https://stackoverflow.com/a/53894298/665869 | |
use std::collections::HashMap; | |
use std::sync::{Arc, Mutex}; | |
use std::thread; | |
type Map = HashMap<String, String>; | |
fn handle_n_times(count: i32, arc_map: Arc<Mutex<Map>>) { | |
for i in 0..count { | |
let clone_arc = arc_map.clone(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
xonsh history backend with couchdb. | |
Copy this file to "~/.xonsh/history_couchdb.py" and put the following | |
into your "~/.xonshrc" file. | |
import os.path | |
import sys | |
xonsh_ext_dir = os.path.expanduser('~/.xonsh') | |
if os.path.isdir(xonsh_ext_dir): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from xonsh.history.json import JsonHistory | |
from xonsh.history.sqlite import SqliteHistory | |
hist_json = JsonHistory(gc=False) | |
# if you want to have a check first | |
print('have {} json items'.format(len(list(hist_json.all_items())))) # may very slow here | |
hist_db = SqliteHistory(gc=False) | |
for item in hist_json.all_items(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// via: http://c.learncodethehardway.org/book/ex20.html | |
#ifndef __dbg_h__ | |
#define __dbg_h__ | |
#include <stdio.h> | |
#include <errno.h> | |
#include <string.h> | |
#include <time.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Simplify Dict.cn | |
// @namespace http://mitnk.com | |
// @version 0.1 | |
// @description Simplify dict cn 的生词本 | |
// @match http://scb.dict.cn/card.php* | |
// @copyright 2014+, mitnk | |
// for tampermonkey on Chrome. | |
// ==/UserScript== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
path=`ps ax | grep -i 'postmaster' | grep -o '\-D\(/Library/Post.*\)' | awk -F D '{print $NF}'` | |
log_dir="${path}/pg_log" | |
log_name=`sudo ls -1t ${log_dir} | head -n1` | |
log_file="${log_dir}/${log_name}" | |
echo "" | |
echo "=========== $log_file ==========" | |
echo "" | |
sudo tail -f "$log_file" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir -p tmp_dir_to_install_grep | |
cd tmp_dir_to_install_grep | |
wget https://ftp.gnu.org/gnu/grep/grep-2.18.tar.xz | |
tar xf grep-2.18.tar.xz | |
cd grep-2.18/ | |
./configure && make && sudo make install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from urllib2 import urlopen | |
from subprocess import Popen, PIPE | |
from bs4 import BeautifulSoup | |
page = urlopen('http://pyvideo.org/category/33/pycon-us-2013') | |
soup = BeautifulSoup(page) | |
video_url_list = [] | |
count = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
yum remove -y pptpd ppp | |
iptables --flush POSTROUTING --table nat | |
iptables --flush FORWARD | |
rm -rf /etc/pptpd.conf | |
rm -rf /etc/ppp | |
wget http://poptop.sourceforge.net/yum/stable/packages/dkms-2.0.17.5-1.noarch.rpm | |
wget http://poptop.sourceforge.net/yum/stable/packages/kernel_ppp_mppe-1.0.2-3dkms.noarch.rpm | |
wget ftp://ftp.muug.mb.ca/mirror/centos/6.3/os/x86_64/Packages/ppp-2.4.5-5.el6.x86_64.rpm | |
wget http://poptop.sourceforge.net/yum/stable/packages/pptpd-1.3.4-2.el6.x86_64.rpm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#encoding=utf8 | |
""" | |
有豹子,老虎,狮子,都一大一小,三个大的和小老虎都会划船,其他两个 | |
不会划,每次只能过两个,大吃小(没有大的在保护就被吃掉). | |
这2个动物怎样才能过河? | |
""" | |
from itertools import combinations | |
def is_bad(L): |
NewerOlder