Skip to content

Instantly share code, notes, and snippets.

var pubsub = (function(){
var q = {}, topics = {}, subUid = -1;
q.subscribe = function(topic, func) {
topics[topic] = topics[topic] || [];
var token = (++subUid).toString();
topics[topic].push({
token: token,
func: func
});
return token;
@milesplit
milesplit / gist:1399624
Created November 28, 2011 08:33
really really basic common js
below i'm just mocking up a really simple way to emmulate module/require code similar to commonjs
i just threw this together and it doesnt do any loading at all... have another script i could strap that to
wonder though if this should be async instead of sync, even though commonjs is synchronous with require
<script>
window.__loadedModules = {};
window.define = function(n,f){
var exports = {};
@milesplit
milesplit / testSupport.js
Created November 28, 2011 07:41 — forked from miketaylr/formsuitest.js
testSupport
// testSupport for HTML 5 input types
// By: Jason Byrne of MileSplit, Inc.
//
// Just needed a simple thing to test for support
//
// Adapted from: http://miketaylr.com/code/html5-forms-ui-support.html
var testSupport = function(t){
var f = ':(';
@milesplit
milesplit / colorGrid.js
Created November 28, 2011 06:06
colorGrid - Works with jQuery to turn inputs into color dropdowns
var colorGrid = (function() {
var Me=this,colors = ["#FBEFEF","#FBF2EF","#FBF5EF","#FBF8EF","#FBFBEF","#F8FBEF","#F5FBEF","#F2FBEF","#EFFBEF","#EFFBF2","#EFFBF5","#EFFBF8","#EFFBFB","#EFF8FB","#EFF5FB","#EFF2FB","#EFEFFB","#F2EFFB","#F5EFFB","#F8EFFB","#FBEFFB","#FBEFF8","#FBEFF5","#FBEFF2","#FFFFFF","#F8E0E0","#F8E6E0","#F8ECE0","#F7F2E0","#F7F8E0","#F1F8E0","#ECF8E0","#E6F8E0","#E0F8E0","#E0F8E6","#E0F8EC","#E0F8F1","#E0F8F7","#E0F2F7","#E0ECF8","#E0E6F8","#E0E0F8","#E6E0F8","#ECE0F8","#F2E0F7","#F8E0F7","#F8E0F1","#F8E0EC","#F8E0E6","#FAFAFA","#F6CECE","#F6D8CE","#F6E3CE","#F5ECCE","#F5F6CE","#ECF6CE","#E3F6CE","#D8F6CE","#CEF6CE","#CEF6D8","#CEF6E3","#CEF6EC","#CEF6F5","#CEECF5","#CEE3F6","#CED8F6","#CECEF6","#D8CEF6","#E3CEF6","#ECCEF5","#F6CEF5","#F6CEEC","#F6CEE3","#F6CED8","#F2F2F2","#F5A9A9","#F5BCA9","#F5D0A9","#F3E2A9","#F2F5A9","#E1F5A9","#D0F5A9","#BCF5A9","#A9F5A9","#A9F5BC","#A9F5D0","#A9F5E1","#A9F5F2","#A9E2F3","#A9D0F5","#A9BCF5","#A9A9F5","#BCA9F5","#D0A9F5","#E2A9F3","#F5A9F2","#F5A9E1","
@milesplit
milesplit / zepto.template.js
Created November 15, 2011 07:31
Zepto Simple Template Plugin
// Template
// (c) 2011 Jason Byrne, MileSplit
// May be freely distributed under the MIT license, with attribution.
//
// ** Usage **
//
// HTML:
// <script type="text/html" id="tmplArticle"><h1>${Title}</h1></script>
//
// JavaScript:
@milesplit
milesplit / zepto.pubsub.js
Created November 12, 2011 06:39
PubSub with zepto... few fancy features like priorities and owner modules
(function($) {
var Subscription = function(t, c, o, p) {
this.topic = t;
this.callback = c;
this.owner = o;
this.priority = p || 10;
this.signature = function(){