Skip to content

Instantly share code, notes, and snippets.

View calebrob6's full-sized avatar

Caleb Robinson calebrob6

View GitHub Profile
@calebrob6
calebrob6 / JSONTicTacToe.html
Created October 11, 2012 20:40
Start of tictactoe gui
<html>
<head>
<title>GUI for Interacting with HTTP Server</title>
<script type="text/javascript">
var userId = -1;
var userAuth = -1;
var gameStarted = false;
@calebrob6
calebrob6 / TkinterPong.py
Created November 6, 2012 04:40
Python Tkinter Poing
import Tkinter
from Tkinter import Frame, BOTH, Canvas
#By Caleb Robinson
class Pong(Frame):
player1 = 0
player2 = 0
ballX=50
ballY=50
@calebrob6
calebrob6 / sudoku_backtrack.py
Created November 8, 2012 04:20
Sudoku Sovler
import os,time
count = 0
def printBoard(b):
print " "
for i in b:
for x in i:
print str(x)+" ",
print " "
print " "
@calebrob6
calebrob6 / post_request.js
Created December 6, 2012 20:53
Sending POST data
http = new XMLHttpRequest();
var params = "lorem=ipsum&name=binny";
http.open("POST", "http://localhost:8080/", true);
//Send the proper header information along with the request
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.setRequestHeader("Content-length", params.length);
http.setRequestHeader("Connection", "close");
http.onreadystatechange = function() {//Call a function when the state changes.
@calebrob6
calebrob6 / xkcd.py
Created April 2, 2013 03:28
xkcd challenge
import skein,itertools
inputNum = 26
target = "5b4da95f5fa08280fc9879df44f418c8f9f12ba424b7757de02bbdfbae0d4c4fdf9317c80cc5fe04c6429073466cf29706b8c25999ddd2f6540d4475cc977b87f4757be023f19b8f4035d7722886b78869826de916a79cf9c94cc79cd4347d24b567aa3e2390a573a373a48a5e676640c79cc70197e1c5e7f902fb53ca1858b6"
targetBin = '0b'+(bin(int(target, 16))[2:]).zfill(1024)
def doWork(a):
return '0b'+(bin(int(skein.skein1024(bytes(a,'utf-8')).hexdigest(), 16))[2:]).zfill(1024)
@calebrob6
calebrob6 / perlin.py
Created April 25, 2013 16:59
Perlin Noise Test Python
from matplotlib import pyplot
X=[]
Y=[]
currentNum = 0
randRange = 7
def getPerlinNum():
global currentNum, randRange
@calebrob6
calebrob6 / thread.py
Created August 5, 2013 19:28
Python threading pattern
from threading import Thread, Lock
from Queue import Queue
from datetime import datetime
import time
import random
class Worker(Thread):
"""This is the main worker - it will process jobs as long as the "job
queue" has jobs available.
f = open("prob3.txt","r")
num = int(f.readline().strip())
def check(board,x,y,n,char):
for i in range(num):
board = []
for j in range(5):
@calebrob6
calebrob6 / ray.py
Last active December 24, 2015 11:09
import cv2
import sys
import numpy as np
import numpy.linalg
import math
import time
class Primitive(object):
def __init__(self):
f=open("3774.txt","r")
try:
while True:
b=[tuple(f.readline().strip().split(",")+[0]) for i in range(int(f.readline().strip()))]
a=reduce(lambda a,b:(b[0],b[1],a[2]+((float(b[0])-float(a[0]))*((float(a[1])+float(b[1]))/2))),b)
print "%.2f to %.2f: %.4f" % (float(b[0][0]),float(a[0]),a[2])
except:
pass