Skip to content

Instantly share code, notes, and snippets.

View jejacks0n's full-sized avatar
🕴️
doing things and stuff.

Jeremy Jackson jejacks0n

🕴️
doing things and stuff.
  • Denver, CO
View GitHub Profile
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
Footnotes::Application.initialize!
# Start the websocket server
Footnotes::WebSocketServer.new(10081)
@jejacks0n
jejacks0n / collection_base.js
Created October 21, 2010 18:29
WebSocketCollection inherits from Collection.Base
CollectionBase = Class.create({
resource: null,
resourceName: '',
resourceHandler: null,
collection: null,
initialize: function(resource) {
this.collection = {};
this.resource = resource;
this.resourceName = resource.prototype.resourceName;
// Custom Rails routing/resource handling for ajax requests..
(function() {
var methods = ['get', 'put', 'post', 'delete'],
actions = ['index', 'show', 'new', 'create', 'edit', 'update', 'destroy'];
function parseUrl(url) {
var urlParts = url.match(/^((http[s]?|ftp):\/\/)?(((.+)@)?([^:\/\?#\s]+)(:(\d+))?)?(\/?[^\?#\.]+)?(\.([^\?#]+))?(\?([^#]?))?(#(.*))?$/i) || [];
var pathParts = (urlParts[9]) ? urlParts[9].match(/(\/.*)\/+(\w+)$/i) || [] : [];
module Kernel
def the(a, b)
Exception.new
end
def roof
end
def yo!
end
module FilterableResource
# to test {:filter => {:users => .. }
# {:method => 'any', :terms => ['first', 'second'], :fields => 'all'}
# {:method => 'any', :terms => 'first second', :fields => 'all'}
# {:method => 'any', :terms => 'first', :fields => ['first_name', 'last_name']}
# {:method => 'any', :terms => 'first', :fields => 'first_name last_name'}
# {:method => 'all', :terms => ['first', 'second'], :fields => 'all'}
# {:method => 'all', :terms => 'first second', :fields => 'all'}
# {:method => 'all', :terms => 'first', :fields => 'first_name'}
# {:method => 'all', :terms => 'first', :fields => ['first_name', 'last_name']}
module FilterableResource
def acts_as_filterable(options = {})
cattr_accessor :testing
self.testing = 'testing'
self.named_scope :filtered_from, lambda { |params|
puts('!!![' + self.testing.to_s + ']!!!')
nil
}
end