Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
hackin'

Benjamin E. Coe bcoe

💭
hackin'
View GitHub Profile
View PlaneTetris.js
// 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;
View amqp-thread.py
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):
View comet-server.py
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)
View cherrypy-server.py
@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)
View orbited.js
/**
* HackWars 2
*
* The main JavaScript entry-point.
*/
var HackWars = Class.extend({
/**
*
*/
init: function() {
View schedgy.js
/**
* 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.
View data.js
this.$user.click(function() {
var userObject = $(this).data('class');
userObject.handleClick(this);
});
View tight-coupling.html
<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>
View template.html
<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>
View spec.js
describe 'CouchConnector'
describe 'loadDocument with mocked connection'
before
lastURL = ''
c = new connector.connector({
port: 5984,
host: 'localhost',