This file contains hidden or 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
// generate [0..n-1] | |
auto seq = [](size_t n) -> std::vector<size_t> { | |
std::vector<size_t> v(n); | |
for (size_t i=0; i<n; ++i) v[i] = i; | |
return v; | |
}; | |
auto index = seq(n); | |
// n * n distance matrix | |
std::vector<D> dists(n * n); |
This file contains hidden or 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
#include <stdlib.h> | |
#include <string> | |
namespace { | |
const char kBin2Hex[] = { "0123456789ABCDEF" }; | |
char Hex2Bin(char ch) { | |
switch(ch) { | |
case '0': return 0; | |
case '1': return 1; |
This file contains hidden or 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
#!/bin/sh | |
single_instance() { | |
LOCKFILE=$1 | |
[ -f $LOCKFILE ] && echo "Another instance is running." && exit 1 | |
trap "{ rm -f $LOCKFILE; exit 0; }" EXIT SIGTERM SIGINT | |
touch $LOCKFILE | |
} | |
single_instance /tmp/fix_vpn.lck |
This file contains hidden or 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
#!/bin/sh | |
# @(#) sync-to-picasa.sh Time-stamp: <Julian Qian 2013-08-08 00:58:30> | |
# Copyright 2013 Julian Qian | |
# Author: Julian Qian <[email protected]> | |
# Version: $Id: sync-to-picasa.sh,v 0.1 2013-08-07 23:51:13 jqian Exp $ | |
# | |
BACKUP_LIST=( | |
/store1/Downloads/LuluPhotos/百度云同步盘/来自:iPhone | |
/store1/Downloads/LuluPhotos/Backup |
This file contains hidden or 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
#!/usr/bin/env python | |
# -*- coding: utf-8; tab-width: 4; -*- | |
# @(#) gen_route.py Time-stamp: <Julian Qian 2013-06-30 11:32:45> | |
# Copyright 2013 Julian Qian | |
# Author: Julian Qian <[email protected]> | |
# Version: $Id: gen_route.py,v 0.1 2013-06-30 09:50:56 jqian Exp $ | |
# | |
''' | |
这个脚本用来替代chrountes,一是chroutes生成的路由规则太多,二是所有的国外IP全部走VPN还是感觉资源浪费,心理不舒服,所以最理想的方式还是想翻哪个域名就翻哪个域名才是最合理的。不过该脚本很简陋,只是一次性找出当前待翻域名对应的IP,这些大网站为了负载均衡,很可能IP有变化,或者使用CDN,可能导致找不到被墙的IP,不过暂时看来还是凑合能用的。google, twitter没问题,其他的我也不咋上,没有仔细琢磨。如果发觉一段时间后再次被墙,就再运行一次该脚本重新生成路由即可。 |
This file contains hidden or 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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <string.h> | |
#include <netdb.h> | |
#include <ifaddrs.h> | |
#include <arpa/inet.h> | |
#include <sys/socket.h> | |
int main(int argc, char *argv[]) |
This file contains hidden or 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
#include <iostream> | |
#include <map> | |
#include <boost/asio.hpp> | |
#include <boost/date_time/posix_time/posix_time.hpp> | |
#include <boost/shared_ptr.hpp> | |
#include <boost/bind.hpp> | |
enum { N = 10 }; |
This file contains hidden or 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
// -*- mode: c++ -*- | |
// @(#) test_bdb.cpp Time-stamp: <Julian Qian 2013-05-07 11:37:26> | |
// Copyright 2013 Julian Qian | |
// Author: Julian Qian <[email protected]> | |
// Version: $Id: test_bdb.cpp,v 0.1 2013-05-02 20:58:38 jqian Exp $ | |
// | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <time.h> |
This file contains hidden or 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
// -*- mode: c++ -*- | |
// @(#) test_secondary_db.cpp Time-stamp: <Julian Qian 2013-03-23 22:16:12> | |
// Copyright 2013 Julian Qian | |
// Author: Julian Qian <[email protected]> | |
// Version: $Id: test_secondary_db.cpp,v 0.1 2013-03-23 21:31:19 jqian Exp $ | |
// | |
// test multiple secondary index of berkeley db | |
// g++ -o test_secondary_db test_secondary_db.cpp -g -O2 -Wall -Wextra -ldb |
This file contains hidden or 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
/* @(#)test_crc32.cpp | |
* Time-stamp: < 2011-12-26 11:30:17> | |
* Copyright 2011 | |
* Version: $Id: test_crc32.c,v 0.0 2011/12/26 03:25:28 jqian Exp $ | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <zlib.h> |