Skip to content

Instantly share code, notes, and snippets.

@b1naryth1ef
b1naryth1ef / june28hw.py
Created June 28, 2011 22:23
Homework Week of June 27th
#Imports
import math
import csv
x = range(1,500)
#Fib (Using square roots to preserve ram)
def fib(n):
fiby = ((1+math.sqrt(5))**n-(1-math.sqrt(5))**n)/(2**n*math.sqrt(5))
return int(fiby)^2
def fib(n):
if n==0:
return 0
elif n==1:
return 1
else:
return fib(n-2)+fib(n-1)
@b1naryth1ef
b1naryth1ef / NyanCat.html
Created June 29, 2011 03:40
NyanCat.html
<a href="javascript:play_single_sound();"></a>
<audio id="audiotag1" src="<?php bloginfo('template_directory');?>/etc/nyan/Nyan.mp3" preload="auto">
<script type="text/javascript">
function play_single_sound() {
document.getElementById('audiotag1').play();
}
function stop_single_sound() {
document.getElementById('audiotag1').pause();
}
</script>
@b1naryth1ef
b1naryth1ef / rand.py
Created July 8, 2011 03:43
A randomly created random generator.
#Random! Optimized! YAY!
import random
seed = "123456789"
count = 1000000
def generate(seed2,count):
f = open("./random-"+str(count)+".txt", "w")
x = 0
y = None
while x < count:
@b1naryth1ef
b1naryth1ef / hitter.py
Created July 12, 2011 16:34
hitter.py
import urllib2,time
x=0
while x<100000:
urllib2.urlopen("http://thisurl.com/vote/ajax?id=123")
time.sleep(.2)
x+=1
76.***.***.*** - - [12/Jul/2011:10:33:08 -0600] "GET / HTTP/1.1" 200 34300 "-" "Python-urllib/2.6"
76.***.***.*** - - [12/Jul/2011:10:33:09 -0600] "GET / HTTP/1.1" 200 33683 "-" "Python-urllib/2.6"
76.***.***.*** - - [12/Jul/2011:10:33:10 -0600] "GET / HTTP/1.1" 200 33683 "-" "Python-urllib/2.6"
76.***.***.*** - - [12/Jul/2011:10:33:11 -0600] "GET / HTTP/1.1" 200 33683 "-" "Python-urllib/2.6"
76.***.***.*** - - [12/Jul/2011:10:33:11 -0600] "GET / HTTP/1.1" 200 34677 "-" "Python-urllib/2.6"
76.***.***.*** - - [12/Jul/2011:10:33:12 -0600] "GET / HTTP/1.1" 200 34632 "-" "Python-urllib/2.6"
76.***.***.*** - - [12/Jul/2011:10:33:13 -0600] "GET / HTTP/1.1" 200 33683 "-" "Python-urllib/2.6"
76.***.***.*** - - [12/Jul/2011:10:33:14 -0600] "GET / HTTP/1.1" 200 34629 "-" "Python-urllib/2.6"
76.***.***.*** - - [12/Jul/2011:10:33:15 -0600] "GET / HTTP/1.1" 200 34684 "-" "Python-urllib/2.6"
76.***.***.*** - - [12/Jul/2011:10:33:16 -0600] "GET / HTTP/1.1" 200 34509 "-" "Python-urllib/2.6"
@b1naryth1ef
b1naryth1ef / Hashy1.py
Created July 21, 2011 17:12
Original Hashing Method
import hashlib, sys
sys.setrecursionlimit(11000)
def rec(inputy,x):
x += 1
def md5y(iny):
return hashlib.md5(str(iny)).digest()
def sha512y(iny):
@b1naryth1ef
b1naryth1ef / hashy2.py
Created July 21, 2011 17:17
Better Hashing Method
import hashlib
count = 1000
def func(f2):
x = 0
while x < count:
x += 1
f1 = hashlib.md5(str(f2)).digest()
f2 = hashlib.sha512(str(f1)).hexdigest()
print f2
@b1naryth1ef
b1naryth1ef / hashy3.py
Created July 21, 2011 17:36
Hashing/Timing method
import time, hashlib
end = time.time() + 1
f2 = "Hello World"
x = 0
while time.time() < end:
x += 1
f1 = hashlib.md5(str(f2)).digest()
f2 = hashlib.sha512(str(f1)).hexdigest()
print f2,x
@b1naryth1ef
b1naryth1ef / class.py
Created July 26, 2011 05:27
MySQL using classes
import MySQLdb
user = "root"
passwd = ""
db = "test"
host = "localhost"
DB = MySQLdb.connect(user=user, passwd=passwd, host=host, db=db)
C = DB.cursor()