Skip to content

Instantly share code, notes, and snippets.


Chris Mears chrisjm

View GitHub Profile
addyosmani /
Created Oct 28, 2011
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

##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:

stuliston / artists_releases_spec.rb
Created Sep 10, 2011
Testing HABTM with rspec and factory girl
View artists_releases_spec.rb
require 'spec_helper'
describe "Artists to releases relationship" do
before(:all) do
@kanye = FactoryGirl.create(:artist, :name => 'Kanye West')
@jz = FactoryGirl.create(:artist, :name => 'Jay Z')
@watch_the_throne = FactoryGirl.create(:release, :name => 'Watch the Throne')
@dropout = FactoryGirl.create(:release, :name => 'The College Dropout')
rodneyrehm / urlify.php
Created Apr 8, 2011
Reduce (UTF-8) strings to alphanumeric
View urlify.php
consider decomposing the characters to "capture" more "obscure" characters such as ṩ
* Normalize a string to only contain alphanumeric characters and dashes.
jystewart / jangomail-sync.php
Created Jun 9, 2010
A slightly saner interface for JangoMail Sync than the one they supply
View jangomail-sync.php
* A slightly saner interface for JangoMail Sync than the one they supply
* This is a demonstration of how to produce a more security-aware interface for JangoMail's
* web database synchronisation system. It is not guaranteed in any way and is not meant
* to be seen as an example of best practice on any level. It does, however, demonstrate how
* the flaws in that system can be worked around to build a reasonable JSON-based interface
* when working with recent versions of PHP.
View CSS for <sup> and <sub>
sub, sup {
/* Specified in % so that the sup/sup is the
right size relative to the surrounding text */
font-size: 75%;
/* Zero out the line-height so that it doesn't
interfere with the positioning that follows */
line-height: 0;
/* Where the magic happens: makes all browsers position
mxcl / rsync+watcher.rb
Created Jul 18, 2009
rsync whenever the directory the script is in changes using the OS X FSEvents API
View rsync+watcher.rb
require 'osx/foundation'
OSX.require_framework '/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework'
include OSX
$d=File.basename Dir.pwd
Dir.chdir '..'
fsevents_cb = proc do |stream, ctx, numEvents, paths, marks, eventIDs|
system "rsync --delete -rt --rsh=ssh '#{$d}' ''"