Skip to content

Instantly share code, notes, and snippets.

View hlian's full-sized avatar
🦫
beaver

Hao Lian hlian

🦫
beaver
View GitHub Profile
#!/usr/bin/env python
import random
import sys
print(1000)
def randfloat(a, b):
return random.random() * (b - a) + a
@hlian
hlian / echoservermultsocketserver.py
Created March 1, 2011 18:56
echoservermult.py implemented with SocketServer
#!/usr/bin/env python
from sys import argv, exit
import threading
import SocketServer
HOST = 'localhost'
#-----------------------------------------------------------------------
[0x004000a4] 0x00165821 addu $11, $0, $22 ; 43: move $t3, $s6 # $t3 := $s6
(spim)
[0x004000a8] 0x00176021 addu $12, $0, $23 ; 44: move $t4, $s7 # $t4 := $s7
(spim)
[0x004000ac] 0x00041021 addu $2, $0, $4 ; 45: move $v0, $a0 # $v0 := $a0
(spim)
[0x004000b0] 0x34020005 ori $2, $0, 5 ; 46: li $v0, 5 # $v0 := 5
(spim)
[0x004000b4] 0x34040003 ori $4, $0, 3 ; 47: li $a0, 3 # $a0 := 3
(spim)
.data
NL: .asciiz "\n"
.text
main:
addi $sp, $sp, -4 # $sp := $sp+-4
sw $ra, 0($sp) # [$sp+0] := $ra
li $a0, 32000 # $a0 := 32000
li $v0, 9 # $v0 := 9
syscall
sw $v0, 0($gp) # [$gp+0] := $v0
@hlian
hlian / gist:961634
Created May 8, 2011 19:43
cos 426 video game profile report from shark
# Report 3 - Session 2 - Time Profile of game
SharkProfileViewer
# Generated from the visible portion of the outline view
+ 98.4%, start, game
| + 98.4%, main, game
| | + 91.9%, GLUTMainLoop(), game
| | | + 91.9%, glutMainLoop, GLUT
| | | | + 91.9%, -[GLUTApplication run], GLUT
| | | | | + 91.1%, __glutProcessWorkEvents, GLUT
| | | | | | + 91.1%, processWindowWorkList, GLUT
@hlian
hlian / gist:963973
Created May 10, 2011 05:56
regular play
# Report 3 - Session 3 - Time Profile of game
SharkProfileViewer
# Generated from the visible portion of the outline view
+ 96.9%, start, game
| + 96.9%, main, game
| | + 88.0%, GLUTMainLoop(), game
| | | + 88.0%, glutMainLoop, GLUT
| | | | + 88.0%, -[GLUTApplication run], GLUT
| | | | | + 87.1%, __glutProcessWorkEvents, GLUT
| | | | | | + 87.1%, processWindowWorkList, GLUT
@hlian
hlian / gist:963981
Created May 10, 2011 06:01
playerless
# Report 5 - Session 4 - Time Profile of game
SharkProfileViewer
# Generated from the visible portion of the outline view
+ 98.5%, start, game
| + 98.5%, main, game
| | + 90.0%, GLUTMainLoop(), game
| | | + 90.0%, glutMainLoop, GLUT
| | | | + 90.0%, -[GLUTApplication run], GLUT
| | | | | + 89.8%, __glutProcessWorkEvents, GLUT
| | | | | | + 89.8%, processWindowWorkList, GLUT
@hlian
hlian / gist:964009
Created May 10, 2011 06:41
playerless: post-hao
# Report 7 - Session 5 - Time Profile of game
SharkProfileViewer
# Generated from the visible portion of the outline view
+ 97.9%, start, game
| + 97.9%, main, game
| | + 86.5%, GLUTMainLoop(), game
| | | + 86.5%, glutMainLoop, GLUT
| | | | + 86.5%, -[GLUTApplication run], GLUT
| | | | | + 86.3%, __glutProcessWorkEvents, GLUT
| | | | | | + 86.3%, processWindowWorkList, GLUT
@hlian
hlian / philosophy.py
Created May 26, 2011 16:00
EVERY WIKIPEDIA ARTICLE CONVERGES TO PHILOSOPHY
#!/usr/bin/env python
import gzip
import urllib2
from cStringIO import StringIO
from lxml import etree, html
from lxml.cssselect import CSSSelector
opener = urllib2.build_opener()
opener.addheaders = [('User-agent', 'Mozilla/5.0')]
bad friends
-----------
chris
good friends
------------
everybody else