Skip to content

Instantly share code, notes, and snippets.

View CodeOfficer's full-sized avatar

Russell Jones CodeOfficer

View GitHub Profile
@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:

@strangeminds
strangeminds / hackintosh
Created October 17, 2011 03:32
Hackintosh Build October 2011
Hackintosh Build October 2011
Component list:
ASUS P8P67 PRO (REV 3.0) LGA 1155
http://www.newegg.com/Product/Product.aspx?Item=N82E16813131703
Intel Core i7-2600K
http://www.newegg.com/Product/Product.aspx?Item=N82E16819115070
@lucasfais
lucasfais / gist:1207002
Created September 9, 2011 18:46
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@rx
rx / gist:1118201
Created August 1, 2011 14:18 — forked from cmorss/gist:1076315
Jammit Handlebar Template funciton
Handlebars.template = function(templateString) {
return function () {
if (arguments.length < 1) {
// With no arguments, return the raw template -- useful for rendering
// partials.
return templateString;
} else {
Handlebars.templates = Handlebars.templates || {}
Handlebars.templates[templateString] = Handlebars.templates[templateString] || Handlebars.compile(templateString);
return Handlebars.templates[templateString](arguments[0], arguments[1]);
namespace.views.MyWizard = Backbone.Views.extend({
initialize: function() {
_.bindAll(this, 'render', 'wizardMethod');
}
render: function() {
this.wizardMethod();
return this;
},
@rwc9u
rwc9u / address.rb
Created June 21, 2011 20:11
:accepts_nested_attributes_for with custom autosave
class Address < ActiveRecord::Base
has_many :phonings, :as => :phonable
has_many :phone_numbers, :through => :phonings
accepts_nested_attributes_for :phonings, :allow_destroy => true
end
@seven1m
seven1m / templates.js.coffee.erb
Created May 24, 2011 22:24
Render ERB JS templates with Underscore.js and Sprockets and Tilt in Rails 3.1
# creates a global JST object containing all the templates
# 1. install Tilt in your Gemspec
# 2. Paste this in a file at app/assets/javascripts/templates.js.coffee.erb
# 3. `require` the templates file from your main js include file.
# 4. Put your templates at app/views/whatever/my_template.html.jst
window.JST =
<% Dir[Rails.root.join('app/views/**/*.jst')].each do |path| %>
<%= path.match(%r{/([^/]+)\.html\.jst$})[1] %>: _.template(<%= File.read(path).inspect.gsub(/\r?\n/, '') %>)
<% end %>
@danreedy
danreedy / autgen.sh
Created April 8, 2011 16:05
Scripting the automation of an interactive script to generate a self-signed certificate for POW usage
# Generate our local key
openssl genrsa 2048 > local.key
# Create the self-signed certificate for all *.dev addresses
openssl req -new -x509 -nodes -sha1 -days 3650 -key local.key << ANSWERS > local.cert
US
IL
Chicago
Myself
Me
@ernie
ernie / javascripts.rake
Created March 9, 2011 19:07
Rake task for minifying javascripts using YUI Compressor
namespace :javascripts do
desc 'minify the javascript files residing in app/javascripts to public/javascripts'
task :minify do
RakeFileUtils.verbose false do
Dir["app/javascripts/*.js"].each do |filename|
outfile = filename.sub(/^app/, 'public').sub(/\.js$/, '.min.js')
puts "#{filename} -> #{outfile}"
sh(
'java',
'-jar',
@io41
io41 / paginated_collection.js
Created February 22, 2011 10:10 — forked from zerowidth/paginated_collection.js
Pagination with Backbone.js
// includes bindings for fetching/fetched
var PaginatedCollection = Backbone.Collection.extend({
initialize: function() {
_.bindAll(this, 'parse', 'url', 'pageInfo', 'nextPage', 'previousPage');
typeof(options) != 'undefined' || (options = {});
this.page = 1;
typeof(this.perPage) != 'undefined' || (this.perPage = 10);
},
fetch: function(options) {