Skip to content

Instantly share code, notes, and snippets.

Avatar

Felix021 felix021

View GitHub Profile
View ucloud-chinajoy-2016
import urllib
print len(urllib.urlopen('http://106.75.28.160/UCloud.txt#rd?n').read().split('UCanUup')) - 1 #728
@felix021
felix021 / multiprocess.py
Last active Apr 12, 2016
Python多进程库multiprocessing的封装
View multiprocess.py
#!/usr/bin/python
#coding: utf-8
"""
Usage:
import multiprocess
slices = multiprocess.split_list(filelist, 8) #分成8份
processes = map(lambda slice: multiprocess.spawn(file_processor, slice), slices)
@felix021
felix021 / basic permutation
Created Jun 3, 2015
递归回溯法生成数字排列。
View basic permutation
#include <stdio.h>
int visit[1024] = {0};
void perm_rec(int *a, int n, int i)
{
int j;
if (i == n) {
for (j = 0; j < n; j++)
printf("%d ", a[j]);
@felix021
felix021 / pyinterpreter.py
Created Oct 28, 2014
扔这里存档吧,侵入式的调试工具:D 用法:pyinterpreter.thread_interpreter(globals(), locals())
View pyinterpreter.py
#!/usr/bin/env python
#coding:utf-8
import sys
import compiler
import thread
def thread_interpreter(globals_dict, locals_dict):
thread.start_new_thread(interpreter, (globals_dict, locals_dict))
View README.md

替换上你的Email,密码,域名ID,记录ID等参数,就可以运行了。 会在后台一直运行,每隔30秒检查一遍IP,如果修改了就更新IP。

获得domain_id可以用curl curl -k https://dnsapi.cn/Domain.List -d "login_email=xxx&login_password=xxx"

获得record_id类似 curl -k https://dnsapi.cn/Record.List -d "login_email=xxx&login_password=xxx&domain_id=xxx"

@felix021
felix021 / switch_pic
Created Sep 14, 2014
交换图片的左右两半
View switch_pic
#!/usr/bin/python
#coding:utf-8
import sys
import PIL
from PIL import Image
if len(sys.argv) < 2:
raise Exception("bad parameter")
@felix021
felix021 / sudoku.py
Last active Aug 29, 2015
Sudoku:解数独
View sudoku.py
#!/usr/bin/python
import copy
def grid_id(x, y):
return ((x - 1) / 3 * 3) + (y - 1) / 3 + 1
class Position:
def __init__(self, x, y):
self.x = x
self.y = y
@felix021
felix021 / 4x4 puzzle
Created Jan 25, 2014
一个简单的BFS问题的答案,题面在这里:https://www.v2ex.com/t/98224
View 4x4 puzzle
#!/usr/bin/env python
#coding:utf-8
#problem description: https://www.v2ex.com/t/98224
start_node = dict(state='2011001100110011', row=0, col=0, prev=None);
target_state = '2101101001011010'
def swap(state, r1, c1, r2, c2):
m, n = list(sorted([r1 * 4 + c1, r2 * 4 + c2]))
return state[:m] + state[n] + state[m+1:n] + state[m] + state[n+1:]
@felix021
felix021 / PortForwarder.py
Last active Aug 1, 2016
Bind a local tcp port, and forward requests to a remote port directly.绑定本地tcp端口,并把请求直接转发到远程端口。
View PortForwarder.py
#!/usr/bin/python
# simplified from msocks5.py @ https://github.com/felix021/ssocks5
import sys
import signal
try:
import gevent
@felix021
felix021 / toy_midi.py
Last active Jan 1, 2016
一个2B小玩意……缅怀当年高中电脑课上用QBasic的Play函数调用扬声器发声的2B时光。
View toy_midi.py
#!/usr/bin/env python
#coding=utf-8
# WINDOWS ONLY #
import winsound
import time
freq_map = {
"C<" : 262,
You can’t perform that action at this time.