Skip to content

Instantly share code, notes, and snippets.

View CodeOfficer's full-sized avatar

Russell Jones CodeOfficer

View GitHub Profile
var Comment = Model("comment",
// Class methods
{
persistence: Model.RestPersistence("/posts/:post_id/comments"),
findAllRemote: function(context, callback) {
$.getJSON("/posts/" + context.post_id() + "/comments.json", function(json) {
$.each(json, function(i, comment) {
Comment.add(new Comment($.extend(comment, {post_id: context.post_id()})));
var CommentsController = $.sammy(function() {
// CONFIG ---------------------------------------------------------------
this.debug = true;
this.use(Sammy.EJS);
this.use(Sammy.NestedParams);
this.element_selector = "#comments_app";
// this.location_proxy = new Sammy.DataLocationProxy(this);
this.resources_loaded = false;
(function($){
$.each(["live", "die"], function( i, name ) {
var method = $.fn[ name ];
$.fn[ name ] = function( types, data, fn, origSelector ) {
if ( typeof types === "object" && !types.preventDefault ) {
for ( var key in types ) {
method.call( this, key, data, types[key], origSelector );
}
/**
* An implementation of the K Combinator.
* http://wiki.tcl.tk/1923
*
* Copied from Mikael Brockman's code in Ruby on Rails' ActiveSupport library.
* http://weblog.jamisbuck.org/2006/10/27/mining-activesupport-object-returning
*/
function returning(value, block, context) {
block.call(context || null, value);
return value;
;(function($) {
var app = $.sammy(function() {
this.location_proxy = new Sammy.DataLocationProxy(this);
this.get('#/', function() {
$('#main').text('');
});
this.get('#/test', function() {
This is an example of using RVM's Project .rvmrc file
to have it automatically bootstrap your environment, including bundler.
This could be further expanded to do anything you require :)
The important thing to remember is that the purpose of these files is
to allow you to very easily have your 'project context' (aka 'environment')
loaded automatically for you when you enter the project in the shell (cd).
You can generate the .rvmrc file below by running:
(function ($) {
$.event.special.textchange = {
setup: function (data, namespaces) {
$(this).bind('keyup', $.event.special.textchange.handler);
$(this).bind('cut paste input', $.event.special.textchange.delayedHandler);
},
teardown: function (namespaces) {
;(function($) {
$(function() {
$('body').bind('confirm', function(event) {
console.log('confirm', event);
});
$('body').bind('ajax:before', function(event) {
console.log('ajax:before', event);
// return false; works here to cancel the chain
file 'Gemfile', <<-GEMS
source 'http://gemcutter.org'
gem "rails", "3.0.0.beta3"
gem "bson_ext"
gem "mongoid", "2.0.0.beta4"
gem "haml", "3.0.0.rc.2"
gem "compass", "0.10.0.rc4"
gem "inherited_resources"
group :test do
#!/usr/bin/env ruby
# Usage: gemspec [-s] GEMNAME
#
# Prints a basic gemspec for GEMNAME based on your git-config info.
# If -s is passed, saves it as a GEMNAME.gemspec in the current
# directory. Otherwise prints to standard output.
#
# Once you check this gemspec into your project, releasing a new gem
# is dead simple:
#