Skip to content

Instantly share code, notes, and snippets.

View boyxuper's full-sized avatar

Weizheng Xu boyxuper

  • SOHU mobile
  • Beijing, China
View GitHub Profile
@boyxuper
boyxuper / solar_terms_1.py
Last active December 18, 2015 06:08
solar terms algorithm which didn't pass the test
# -*- coding: utf-8 -*-
__author__ = 'johnx'
__date__ = '6/8/13 2:47 PM'
#see [Y*D+C]-L
#@see http://bbs.csdn.net/topics/340009030
D = .2422
C_21th = {
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'johnx'
__date__ = '2/27/13 3:36 PM'
import socket
import ssl
import struct
import json
@boyxuper
boyxuper / .keyed_bash.sh
Created September 24, 2014 03:29
keyed_bash
export HISTFILESIZE=9999999
export HISTSIZE=9999999
PUB_KEY='sed -ne "/sshd.$PPID.:.*matching .SA key/{s/^.* //g;h};\${x;p}" /var/log/secure'
SSH_KEY=`eval $PUB_KEY`
SSH_IP=${SSH_CLIENT%% *}
function match_key(){
# default result
@boyxuper
boyxuper / client.py
Created January 26, 2016 12:07
urllib3==1.14 AttributeError: 'bool' object has no attribute 'close'
#!/usr/bin/env python
import urllib3.poolmanager
pool = urllib3.poolmanager.HTTPConnectionPool('127.0.0.1', 9900)
resp = pool.urlopen('GET', '/', timeout=1)
print resp.data
@boyxuper
boyxuper / h2_tornado.py
Last active August 14, 2016 14:55
WIP: hyper-h2 + tornado 4.1
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import io
import ssl
import sys
import copy
import base64
import socket
import httplib
@boyxuper
boyxuper / resolve_A.py
Created August 22, 2017 06:02
recursive DNS resolver
# -*- coding: utf8 -*-
"""
@author: boyxuper
@date: 2017/8/21 16:07
"""
import random
import socket
from collections import defaultdict
from itertools import chain