Skip to content

Instantly share code, notes, and snippets.

@patrickward
patrickward / paginated_collection.js
Created December 13, 2011 20:30 — forked from zerowidth/paginated_collection.js
first whack at pagination with backbone.js
// includes bindings for fetching/fetched
PaginatedCollection = Backbone.Collection.extend({
initialize: function() {
_.bindAll(this, 'parse', 'url', 'pageInfo', 'nextPage', 'previousPage');
this.page = 1;
},
fetch: function(options) {
options || (options = {});
this.trigger("fetching");
@patrickward
patrickward / gist:1136892
Created August 10, 2011 14:20 — forked from dhh/gist:1014971
Use concerns to keep your models manageable
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end
@patrickward
patrickward / backbone.rails.js
Created April 29, 2011 11:09 — forked from trydionel/backbone.rails.js
Makes Backbone.js play nicely with default Rails setup
//
// Backbone.Rails.js
//
// Makes Backbone.js play nicely with the default Rails setup, i.e.,
// no need to set
// ActiveRecord::Base.include_root_in_json = false
// and build all of your models directly from `params` rather than
// `params[:model]`.
//
// Load this file after backbone.js and before your application JS.
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
@patrickward
patrickward / textmate-to-vim.markdown
Created November 9, 2010 17:08
A few notes I've found useful as I move from TextMate to Vim

Moving from TextMate to Vim

Word Completion

I got quite used to TextMate's easy word completion, which is triggered with esc, and shift-esc. You can do something similar in Vim by using the ins-completion feature.

While in insert mode, use ctrl-n to search forward for the next matching word or ctrl-p to search backwards for the next matching line.

Checkout :help ins-completion inside Vim for more details.