Skip to content

Instantly share code, notes, and snippets.

View jasondavis's full-sized avatar

Jason Davis jasondavis

View GitHub Profile
@jwage
jwage / SplClassLoader.php
Last active April 9, 2024 21:04
Add MIT license.
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// my little html string builder
buildHTML = function(tag, html, attrs) {
// you can skip html param
if (typeof(html) != 'string') {
attrs = html;
html = null;
}
var h = '<' + tag;
for (attr in attrs) {
if(attrs[attr] === false) continue;
@iansym
iansym / jquery.pubsub.js
Created July 28, 2010 16:06
PubSub functionality
/**
* Package: jQuery PubSub
* a lightweight and fast jQuery Publish/Subscribe system
* based on the jQuery plugin by Peter Higgins (dante@dojotoolkit.org)
* http://higginsforpresident.net/js/jq.pubsub.js
*/
(function(window) {
var subscriptions = {},
cache = {},
we,
@cowboy
cowboy / HEY-YOU.md
Last active April 9, 2024 15:54
jQuery Tiny Pub/Sub: A really, really, REALLY tiny pub/sub implementation for jQuery.
@amedeo
amedeo / gist:820412
Created February 10, 2011 12:00
CouchDB and multiple tags

CouchDB and multiple tags

The problem

Given a set of documents, each associated with multiple tags, how can I retrieve the documents tagged with an arbitrary set of tags?

My solution

@MarijnKoesen
MarijnKoesen / StateDebugger.php
Created April 6, 2011 07:13
A statedebugger handy for debugging (AJAX) requests
<?php
/**
* Debug helper function for logging and restoring requests. Do not use in
* production environments.
*
* - Logs the URL and all request data (_POST, _GET, _SESSION, _COOKIE etc).
* - With __STATE_DEBUGGER__ parameter in the URL it displays a listing
* of logged requests.
* - Clicking an item in that listing, re-creates that request.
@necolas
necolas / snippet.js
Created June 14, 2011 20:36
Optimised async loading of cross-domain scripts
/*
* Updated to use the function-based method described in http://www.phpied.com/social-button-bffs/
* Better handling of scripts without supplied ids.
*
* N.B. Be sure to include Google Analytics's _gaq and Facebook's fbAsyncInit prior to this function.
*/
(function(doc, script) {
var js,
fjs = doc.getElementsByTagName(script)[0],
@gnarf
gnarf / jQuery.ajaxQueue.min.js
Created June 21, 2011 23:52
jQuery.ajaxQueue - A queue for ajax requests
/*
* jQuery.ajaxQueue - A queue for ajax requests
*
* (c) 2011 Corey Frang
* Dual licensed under the MIT and GPL licenses.
*
* Requires jQuery 1.5+
*/
(function(a){var b=a({});a.ajaxQueue=function(c){function g(b){d=a.ajax(c).done(e.resolve).fail(e.reject).then(b,b)}var d,e=a.Deferred(),f=e.promise();b.queue(g),f.abort=function(h){if(d)return d.abort(h);var i=b.queue(),j=a.inArray(g,i);j>-1&&i.splice(j,1),e.rejectWith(c.context||c,[f,h,""]);return f};return f}})(jQuery)
@tbranyen
tbranyen / breakfast.js
Created September 8, 2011 03:04
basic module function
(function(self) {
self.Model = Backbone.Model.extend({
defaults: {
beverage: 'Orange Soda',
yogurt: false,
fruits: ['Apple', 'Plum', 'Watermelon']
}
});
@mathewbyrne
mathewbyrne / slugify.js
Created October 12, 2011 04:34
Javascript Slugify
function slugify(text)
{
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}