Skip to content

Instantly share code, notes, and snippets.

View sjwilliams's full-sized avatar

Josh Williams sjwilliams

View GitHub Profile
@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.
@danott
danott / modernizr-tests.js
Created March 4, 2011 16:55
Custom Modernizr tests that are useful.
/* modernizr-test.js
* Daniel Ott
* 3 March 2011
* Custom Tests using Modernizr's addTest API
*/
/* iOS
* There may be times when we need a quick way to reference whether iOS is in play or not.
* While a primative means, will be helpful for that.
*/
@JamieMason
JamieMason / encapsulate.js
Created April 4, 2011 14:01
Encapsulates an object and exposes each of it's properties with their own getter and setter, which maintains the original data type. Methods can be overridden to validate properties more strictly if needed.
var encapsulate = (function()
{
var rGetFirstChar = /^([a-z])/;
function isNumber (value)
{
return !isNaN(parseFloat(value)) && typeof value !== 'string';
}
@max-mapper
max-mapper / awesome.html
Created May 12, 2011 15:37
node-serialport + arduino + popcorn.js DIY video scrubber
<html>
<head>
<script src="http://code.jquery.com/jquery-1.5.2.min.js"></script>
<script src="http://burritopizza.local/socket.io/socket.io.js"></script>
<script src="https://gist.github.com/raw/952547/f298c7e30d0978da0c78df0ff79436e883efbad2/gistfile1.txt"></script>
<script src="http://popcornjs.org/code/players/youtube/popcorn.youtube.js"></script>
<style type='text/css'>
body {
}
@fwielstra
fwielstra / api.js
Created June 14, 2011 14:46
An example NodeJS / Mongoose / Express application based on their respective tutorials
/* The API controller
Exports 3 methods:
* post - Creates a new thread
* list - Returns a list of threads
* show - Displays a thread and its posts
*/
var Thread = require('../models/thread.js');
var Post = require('../models/post.js');
@JamieMason
JamieMason / average.js
Created July 28, 2011 09:29
Using underscore.js, return the average value from an array of Numbers.
function average (arr)
{
return _.reduce(arr, function(memo, num)
{
return memo + num;
}, 0) / arr.length;
}
@mxcl
mxcl / uninstall_homebrew.sh
Created August 26, 2011 11:25
Uninstall Homebrew
#!/bin/sh
# Just copy and paste the lines below (all at once, it won't work line by line!)
# MAKE SURE YOU ARE HAPPY WITH WHAT IT DOES FIRST! THERE IS NO WARRANTY!
function abort {
echo "$1"
exit 1
}
set -e
@lucasallan
lucasallan / install_postgis_osx.sh
Created September 6, 2011 21:03 — forked from klebervirgilio/install_postgis_osx.sh
Installing PostGIS on Mac OS X and Ubuntu
# Some good references are:
# http://russbrooks.com/2010/11/25/install-postgresql-9-on-os-x
# http://www.paolocorti.net/2008/01/30/installing-postgis-on-ubuntu/
# http://postgis.refractions.net/documentation/manual-1.5/ch02.html#id2630392
#1. Install PostgreSQL postgis and postgres
brew install postgis
initdb /usr/local/var/postgres
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
@nuxlli
nuxlli / sublime_text_2_useful_shortcuts.md
Created September 9, 2011 18:51 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 - Useful Shortcuts

Tested in Mac OS X: super == command

Open/Goto


  • super+t: go to file
  • super+ctrl+p: go to project
  • super+r: go to methods
@addyosmani
addyosmani / pubsub.md
Created October 28, 2011 06:49
Four ways to do Pub/Sub with jQuery 1.7 and jQuery UI (in the future)

#Four Ways To Do Pub/Sub With jQuery and jQuery UI (in the future)

Between jQuery 1.7 and some of work going into future versions of jQuery UI, there are a ton of hot new ways for you to get your publish/subscribe on. Here are just four of them, three of which are new.

(PS: If you're unfamiliar with pub/sub, read the guide to it that Julian Aubourg and I wrote here http://msdn.microsoft.com/en-us/scriptjunkie/hh201955.aspx)

##Option 1: Using jQuery 1.7's $.Callbacks() feature:

$.Callbacks are a multi-purpose callbacks list object which can be used as a base layer to build new functionality including simple publish/subscribe systems. We haven't yet released the API documentation for this feature just yet, but for more information on it (including lots of examples), see my post on $.Callbacks() here: