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
#!/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
#!/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
#!/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
#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
// 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
import io | |
import avro.schema | |
import avro.io | |
import lipsum | |
import random | |
from kafka.client import KafkaClient | |
from kafka.producer import SimpleProducer, KeyedProducer | |
g = lipsum.Generator() |
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
worker_processes 2; | |
error_log /var/log/nginx/error.log; | |
pid /var/run/nginx.pid; | |
events { | |
worker_connections 1024; | |
use epoll; | |
} |
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
[unix_http_server] | |
file=/tmp/supervisor.sock ; path to your socket file | |
[supervisord] | |
logfile=/var/log/supervisord/supervisord.log ; supervisord log file | |
logfile_maxbytes=50MB ; maximum size of logfile before rotation | |
logfile_backups=10 ; number of backed up logfiles | |
loglevel=error ; info, debug, warn, trace | |
pidfile=/var/run/supervisord.pid ; pidfile location | |
nodaemon=false ; run supervisord as a daemon |
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
<?php | |
require_once('../lib/avro.php'); | |
function create_record() { | |
$rec = array('member_id' => 1392, 'member_id2' => 999); | |
for ($i = 0; $i < 20; $i++) { | |
$rec['field' . $i] = 'test_value' . $i; | |
} | |
return $rec; |