Skip to content

Instantly share code, notes, and snippets.

@ZhanruiLiang
ZhanruiLiang / genNtest.py
Created January 13, 2012 04:40
A script for the poor men who failed to finish all the problems in algorithm exam.
#! /usr/bin/python2
# Author: Ray
# Date: Fir Jan 13, 13:00
#
from subprocess import Popen, PIPE
import sys
from time import time as tick
inFile = 'in3'
@ZhanruiLiang
ZhanruiLiang / fkgfw.py
Created January 19, 2012 05:59
A util to FXXK the GFW
#! /usr/bin/python2
import pexpect
import os
log = {'addr':'srv6.unssh.com', 'user':'xxxxxx', 'port':'443', 'passwd':'xxxxxx'}
log['config_path'] = os.path.expanduser('~/.fkgfw_ssh_config')
if not os.path.exists(log['config_path']):
open(log['config_path'], 'w').write('# fkgfw - fuck the great firewall\n')
cmd = 'ssh -TfnN -D 7070 %(user)s@%(addr)s -p %(port)s -F %(config_path)s' % log
@ZhanruiLiang
ZhanruiLiang / balls.py
Created March 21, 2012 06:27
Balls simulation
from pymunk import Body, Circle, Vec2d, Segment, Poly, Space
import pymunk
import pygame
import random
from select import select
def vint(v):
return int(v[0]), int(v[1])
def randarea(x0, y0, w, h):
@ZhanruiLiang
ZhanruiLiang / wifilogon.py
Created March 29, 2012 15:30
SYSU wifi autologon
import urllib2
from time import sleep
import os
import subprocess as sb
import re
User = 'your_netid'
Passwd = 'xxxxxxxxxx'
class AutoLogon:
import urllib2
import re
oo = 9000
# userPageAddr = 'http://soj.me/user.php?id=8750'
userPageAddr = raw_input('Please input your user page address on Sicily(http://soj.me/user.php?id=8750, for example): ')
userId = re.findall('id=(\d+)', userPageAddr)[0]
s = urllib2.urlopen(userPageAddr).read()
problems = re.findall(r'show_problem\.php\?pid=(\d+)', s, re.M)
problems.sort()
@ZhanruiLiang
ZhanruiLiang / yyan.py
Created May 6, 2012 05:40
Balls hitting
import pygame as pg
R = 10
M = 1
FPS = 30
Margin = 10
ScreenW, ScreenH = 400, 400
@ZhanruiLiang
ZhanruiLiang / gdebugpoj1070.py
Created May 20, 2012 06:57
A set of python scripts to show the animation of the problem POJ1070: Deformed Wheel.
import pygame as pg
import sys
from pygame.locals import *
import subprocess as sb
W, H = 800, 600
x0, y0 = 400, 400
BgColor = (0xff, 0xff, 0xff, 0xff)
LineColor = (0, 0, 0, 0xff)
SCROLL_UP, SCROLL_DOWN = 4, 5
@ZhanruiLiang
ZhanruiLiang / in
Created May 21, 2012 07:44
soj1111
2
Infernus 280
Cheetah 285
PCJ600 250
Stallion 180
HotRingRacer 300
Mansion Infernus
CarShowRoom HotRingRacer
VicePort Cheetah
@ZhanruiLiang
ZhanruiLiang / minesweeper.py
Created June 3, 2012 06:05
hjkl mine sweeper
#!/usr/bin/env python
import pygame as pg
from collections import deque
import random
W, H = 1200, 1000
BarW = 100
gw, gh = 30, 20
gs = min((W - BarW)/gw, H/gh)
sep = 1
@ZhanruiLiang
ZhanruiLiang / imhere.py
Created June 24, 2012 18:40
Where are you & im here
"i'm here"
import socket
import getpass
from time import sleep
Port = 8789
User = getpass.getuser()
Delta = 3.0
dest = ('<broadcast>' , Port)
s = socket.socket(socket.AF_INET , socket.SOCK_DGRAM)