Skip to content

Instantly share code, notes, and snippets.

View felix021's full-sized avatar

Felix021 felix021

View GitHub Profile
@felix021
felix021 / README.md
Last active August 29, 2015 14:07 — forked from chuangbo/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 September 14, 2014 15:29
交换图片的左右两半
#!/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 August 29, 2015 13:59
Sudoku:解数独
#!/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 January 25, 2014 09:50
一个简单的BFS问题的答案,题面在这里:https://www.v2ex.com/t/98224
#!/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 August 1, 2016 15:22
Bind a local tcp port, and forward requests to a remote port directly.绑定本地tcp端口,并把请求直接转发到远程端口。
#!/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 January 1, 2016 10:49
一个2B小玩意……缅怀当年高中电脑课上用QBasic的Play函数调用扬声器发声的2B时光。
#!/usr/bin/env python
#coding=utf-8
# WINDOWS ONLY #
import winsound
import time
freq_map = {
"C<" : 262,
@felix021
felix021 / magicpython
Last active December 31, 2015 17:38
一个看起来好像没什么用的Python脚本。
#!/usr/bin/env python
import os
import sys
import compiler
fsrc = open(sys.argv[1])
code = fsrc.read()
lines = code.split('\n')
fsrc.close()