Skip to content

Instantly share code, notes, and snippets.

View buzzedword's full-sized avatar
:octocat:
Live and in stereo

Danny Garcia buzzedword

:octocat:
Live and in stereo
View GitHub Profile
@buzzedword
buzzedword / AsyncBlocks.js
Created January 11, 2011 21:52
Simple async building blocks for threading
var queueExecutionInterval = 200,
debug = function (call) {
if ("console" in window) {
console.log.apply(call);
}
},
QUEUE = [],
SECONDARY = [],
functionContainer, primaryThread = setInterval(function () { // QUEUE.push( function ) to register item for queue processing.
if (QUEUE.length > 1) {
var obj1index = obj1.length;
for (var obj2index in obj2){
obj1[obj1index] = obj2[obj2index];
obj1index++;
}
@buzzedword
buzzedword / protobull.js
Created March 18, 2011 17:02
Recommended alternative to mutable __proto__ from mozilla
Object.create2 = function(a, b) {
var res = Object.create(a);
for (var x in b) { if (b.hasOwnProperty(x)) res[x] = b[x]; }
return res;
}
var o = Object.create2(foo, { f:0, g:1, ... });
@buzzedword
buzzedword / js.rb
Created March 21, 2011 20:19
Javascript routing file using CoffeeScript in Monk
class Main
get "/js/:application.js" do
content_type "text/javascript", :charset => "UTF-8"
CoffeeScript.compile File.read("app/views/js/#{params[:application]}.coffee")
end
end
@buzzedword
buzzedword / comments.json
Created March 22, 2011 17:51
Proof of concept for encapsulating comments in a JSON string, then cleaning it out on the client side.
jsonp123(
{
"//" : "Here comes the callback",
"callback": {
"//": "This has the first item",
"item": {
"title": "Databases",
"content": {
"item": {
"//": "Here's where the content is",
@buzzedword
buzzedword / jquery.1.5.1.min.js
Created April 1, 2011 16:14
IIFE with named anonymous parameters
/*!
* jQuery JavaScript Library v1.5.1
* http://jquery.com/
*
* Copyright 2011, John Resig
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* Includes Sizzle.js
* http://sizzlejs.com/
@buzzedword
buzzedword / jQuery.storage.cache.js
Created May 20, 2011 17:21
Globalized storage for jQuery using a document fragment instead of $(element).data();
/*
* Notes: Optimized for "set" operations
* Performance test URL: http://jsperf.com/global-storage-vs-jquery
*/
(function($, unknown) {
// Usage: Instead of $(elem).data('key'), you use $.storage.get('key') for retrieval.
// Usage: Instead of $(elem).data('key', 'value'), you use $.storage.set('key', 'value') for set.
$.storage = {
get: function(key) {
if (typeof $.storage.db == 'undefined') {
@buzzedword
buzzedword / gs.js
Created May 24, 2011 22:40
Grooveshark Chrome Extension
chrome.extension.onRequest.addListener(
function(request, sender, sendResponse) {
switch (request.message.action){
case "addSong" :
Grooveshark.addSongsByID(request.message.ID, true);
break;
case "getSong" :
var song = GrooveShark.getCurrentSongStatus().song;
sendResponse({"songTitle": song});
break;
@buzzedword
buzzedword / console.js
Created June 8, 2011 22:33
Console tic tac toe.
var grid;
function Grid() {
var grid, quadrant, dash, stilt, breaks;
dash = '-------------------------';
stilt = '| | | |';
breaks = '\n\r';
quadrant = {
@buzzedword
buzzedword / loadjs.js
Created June 15, 2011 17:31 — forked from qwertypants/loadjs.js
Super tiny JS loader
// {String} f File name
// {Boolean} c Condition
// {undefined} [l,j,s] Shortcut for var.
var loadjs = function(f,c,l,j,s,a) {
a = ((typeof f == 'object')? f : []);
f = ((typeof f == 'undefined') ? '' :
((typeof f == 'object') ?
((typeof f[0] !== 'undefined')? f[0] : '')
: f));
l = f.length;