Skip to content

Instantly share code, notes, and snippets.

// Subsriber and publisher pattern via https://api.jquery.com/jQuery.Callbacks/
var topics = {};
jQuery.Topic = function( id ) {
var callbacks, method,
topic = id && topics[ id ];
if ( !topic ) {
callbacks = jQuery.Callbacks();
topic = {
publish: callbacks.fire,
@veryphatic
veryphatic / deferralsPromises
Last active December 30, 2015 02:18
A very simple example showing deferrals and promises using jQuery
// Setup a global scopped timer variable
var timer;
// Create a named function expression
var yourPromise = getBeer();
// Execute this code when the promise is done
yourPromise.done(function(message) {
console.log('done. ' + message);
});
@veryphatic
veryphatic / programmablechandelier.java
Created September 10, 2012 00:53
Programmable chandelier circuit
// Chandelier workshop program (Non-interactive version)
// Created by Nathen Street 24 March 2012
// Program choice determined by switch on circuit board
// Option 1: Chase
// Option 2: Always on
int lightsOne = 0; // light group 1
int lightsTwo = 1; // light group 2
int lightsThree = 2; // light group 3
@veryphatic
veryphatic / markov.java
Created July 27, 2012 23:11
Simple Markov chain text generator
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Hashtable;
import java.util.Random;
import java.util.Vector;
public class Markov {