Skip to content

Instantly share code, notes, and snippets.

View bcoe's full-sized avatar
💭
hackin'

Benjamin E. Coe bcoe

💭
hackin'
View GitHub Profile
// All the Tetris blocks are instances of this Block class.
Block = Class.extend({
init: function(game, grid, color) {
this.color = color;
this.grid = grid;
this.game = game;
this.x = 64;
this.y = -128;
this.rotation = 0;
from multiprocessing import Process, Queue
from amqplib import client_0_8 as amqp
from hackwars import SETTINGS
import simplejson as json
import threading
CONNECTION_LOOKUP = {}
def handle_message(message):
import thread, time
import socket
from hackwars.orbited_server.comet import handle_request
from orbited import start
def listen():
try:
comet_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
comet_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
@cherrypy.expose
def publish(self, access_token="", ip="", payload=""):
"""
"""
# Make sure the access token matches the IP.
user_check = hackwars.get_cache().get(ip)
if user_check == access_token:
conn = amqp.Connection(host=SETTINGS['rabbit_host'] + ":5672", userid="guest", password="guest", virtual_host="/", insist=False)
/**
* HackWars 2
*
* The main JavaScript entry-point.
*/
var HackWars = Class.extend({
/**
*
*/
init: function() {
/**
* The calendar widget.
*
* @param {jQuery object} $element an element to attach the calendar object to.
* @param {Date} dateObject the date of the first of the month.
* @param {Schedgy object} a reference to the parent schedgy object.
* @retrun calendar is initialized and attached to the element provided.
*/
var Calendar = Class.extend({
days: {}, // Lookup a day in the calendar based on a key representing year/month/day.
@bcoe
bcoe / data.js
Created November 11, 2010 19:34
this.$user.click(function() {
var userObject = $(this).data('class');
userObject.handleClick(this);
});
<script type="text/javascript">
$(document).ready(function() {
var value = $('#div-i-care-about').find('.value').text();
});
</script>
<div id="div-i-care-about">
<span class="value">30.5</span>
</div>
<script type="text" id="template-user-side">
<li>
<a>
<img src="http://www.gravatar.com/avatar/{md5}" width="24" height="24" />{first_name} {last_name} {days_assigned}
</a>
</li>
</script>
@bcoe
bcoe / spec.js
Created November 15, 2010 16:26
describe 'CouchConnector'
describe 'loadDocument with mocked connection'
before
lastURL = ''
c = new connector.connector({
port: 5984,
host: 'localhost',