This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;(function($) { | |
var app = $.sammy(function() { | |
this.location_proxy = new Sammy.DataLocationProxy(this); | |
this.get('#/', function() { | |
$('#main').text(''); | |
}); | |
this.get('#/test', function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;(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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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: | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.sammy(function() { | |
this.helpers({ | |
showModal: function() { | |
$('.modal').show('slow'); | |
}, | |
hideModal: function() { | |
$('.modal').show('slow'); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var data = [1,2,3,4] | |
var template = (<r><![CDATA[ | |
<% for ( var i = 0; i < data.length; i++ ) { %> | |
<% if(data[i] != 2 ){ %> | |
<li><%= data[i] %></li> | |
<% } %> | |
<% } %> | |
]]></r>).toString(); | |
console.log($.srender(template, data)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# mac specific aliases ------------------------------------------ | |
alias o='open . &' | |
alias ff='open -a Firefox' | |
alias m='mate' | |
# other aliases ------------------------------------------ | |
# utility | |
alias c='clear' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In Rails 3, I wanted to include some additional json values in my data for | |
# the jquery ui autocomplete plugin. Overriding to_json() at the model level | |
# seemed to work on a specific model instance, but not for a collection of | |
# model instances. (pretty sure that worked in prior Rails versions) | |
# Here's the working code: | |
class PostsController < ApplicationController | |
def index | |
@posts = Post.all |