Skip to content

Instantly share code, notes, and snippets.

View jwo's full-sized avatar

Jesse Wolgamott jwo

View GitHub Profile
@jwo
jwo / burrito_delicious_policy.rb
Created October 12, 2011 12:13
Fast Rails Burro Test -- Modules
class BurritoDeliciousPolicy
def delicious?(burrito)
burrito.guacamole?
end
end
@jwo
jwo / registrations_controller.rb
Created September 30, 2011 23:11
API JSON authentication with Devise
class Api::RegistrationsController < Api::BaseController
respond_to :json
def create
user = User.new(params[:user])
if user.save
render :json=> user.as_json(:auth_token=>user.authentication_token, :email=>user.email), :status=>201
return
else
@jwo
jwo / application.html
Created July 15, 2011 15:47
Dynamically load javascript source files
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js" type="text/javascript"></script>
<script>
//<![CDATA[
window.jQuery || document.write("<script src='/javascripts/jquery.min.js'>\x3C/script>")
//]]>
</script>
@jwo
jwo / gist:1067444
Created July 6, 2011 15:00
MacVim - Find in files
:vimgrep regex path
#example to find all ruby files using "belongs"to
:vimgrep /belongs_to/ **/*.rb
:cnext
:cprevious
@jwo
jwo / _flash.sass
Created July 5, 2011 19:39
Drop Down and Fade out Flash Messages
/* flash-messages
#flash
left: 0
margin: 0 auto
position: absolute
text-align: center
top: 0
width: 100%
z-index: 1000
# Condition Builder for ActiveRecord
#
# (c) 2005-2006 Ezra Zygmuntovic, Jens-Christian Fischer and Duane Johnson
# distributed under the same license as Ruby On Rails
#
# Version 1.1
#
# Jan 4, 2007: Added "AND" and "OR" using 'and' and 'or'. Also added ability to use sub-conditions
# e.g.
# Condition.block { |c|