Skip to content

Instantly share code, notes, and snippets.

View gist:223119951f6520ab4a21
// 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 Dec 30, 2015
A very simple example showing deferrals and promises using jQuery
View deferralsPromises
// 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 Sep 10, 2012
Programmable chandelier circuit
View programmablechandelier.java
// 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 Jul 27, 2012
Simple Markov chain text generator
View markov.java
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 {
You can’t perform that action at this time.