Skip to content

Instantly share code, notes, and snippets.

var a = 'SOCKS5 127.0.0.1:1080;SOCKS 127.0.0.1:1080;DIRECT';
function FindProxyForURL(url, host) {
var b = a;
a = 'DIRECT';
return b;
}
curl --socks5-hostname 127.0.0.1:1080 -v http://www.google.com/ 2>&1 | python test_latency.py
@clowwindy
clowwindy / aes.c
Created November 11, 2014 16:07
PolarSSL aes-256-cfb minimal
#if !defined(POLARSSL_CONFIG_FILE)
#include "polarssl/config.h"
#else
#include POLARSSL_CONFIG_FILE
#endif
#if defined(POLARSSL_AES_C)
#include "polarssl/aes.h"
$ g++ -g LRU.cpp
In file included from LRU.cpp:2:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ext/hash_map:212:5: warning:
Use of the header <ext/hash_map> is deprecated. Migrate to <unordered_map> [-W#warnings]
# warning Use of the header <ext/hash_map> is deprecated. Migrate to <unordered_map>
^
1 warning generated
$ lldb ./a.out
(lldb) target create "./a.out"
Current executable set to './a.out' (x86_64).
errf("opening");
FILE *f = fopen("test", "rb");
fread(ctx->udp_buf + SHADOWVPN_PACKET_OFFSET, 1, 1024, f);
if (-1 == crypto_decrypt(ctx->tun_buf, ctx->udp_buf, 1000)) {
errf("failure");
} else {
errf("success");
}
@clowwindy
clowwindy / gist:1699170
Created January 29, 2012 14:58
json to Python object
input_str = "{'a':[{'b':'1','d':'3',},{'b':'2','d'='a'},{'b':'3','d':'4'}],'c':'1'}"
import json
class storage(object):
def __init__(self, dct):
self.__dict__ = dct
result = json.loads(input_str.replace("'",'"').replace("=", ":").replace(",}","}"), object_hook=storage)
<a href="#" title="blue">blue</a>
<a href="#" title="red">red</a>
<script>
function bgc() {
var links = document.getElementsByTagName('a');
for (var i = 0; i < links.length; ++i) {
links[i].onclick = (function() {
var color = links[i].title;
return function() {
document.body.style.backgroundColor = color;
import os
import sys
import getpass
import subprocess
password = getpass.getpass('input password:')
for line in open('server_list.txt'):
line = line.strip()
print line
os.system('scp init_directory.sh %s:~/' % line)
s = subprocess.Popen(['ssh', line, "sudo", "-S", "bash", "init_directory.sh"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
@clowwindy
clowwindy / print_current_frame.py
Created August 3, 2012 07:45
print current frame
#!/usr/bin/python
import inspect
LINES_TO_PRINT = 5
# blarblarblar
# foobar
frame = inspect.currentframe()
@clowwindy
clowwindy / print_current_frame.py
Created August 3, 2012 07:46
print current frame
#!/usr/bin/python
import inspect
LINES_TO_PRINT = 5
# blahblahblah
# foobar
frame = inspect.currentframe()