Skip to content

Instantly share code, notes, and snippets.

View brentvatne's full-sized avatar
😴
☕️⚛️🏃‍♂️🐶🎸

Brent Vatne brentvatne

😴
☕️⚛️🏃‍♂️🐶🎸
View GitHub Profile
@brentvatne
brentvatne / gist:899167
Created April 2, 2011 02:11
error messages partial not accepting locals argument?
#this is the view for Users#new
<h1>Sign up</h1>
<%= form_for(@user) do |f| %>
<%= render 'shared/error_messages', :object => f.object %>
<%= render 'fields', :f => f %>
<div class="actions">
<%= f.submit "Sign up" %>
</div>
# edit
<h1>Edit user</h1>
<%= form_for(@user) do |f| %>
<%= render :partial => "shared/error_messages", :locals => { :object => f.object } %>
<%= render 'fields', :f => f %>
<div class="actions">
<%= f.submit "Update" %>
</div>
#if I comment out the render below, then it works. if not, I get the 'undefined local variable or method `object' ' error
#see below for code that actually executes and will read the object local in error_messages helper
# for Users#new
<h1>Sign up</h1>
<%= form_for(@user) do |f| %>
<%= render :partial => "shared/error_messages", :locals => { :object => "hi"} %>
<%#= render 'fields', :f => f %>
@brentvatne
brentvatne / gist:1213048
Created September 13, 2011 03:06
lazy load
/*
* Lazy Load - jQuery plugin for lazy loading images
*
* Copyright (c) 2007-2009 Mika Tuupola
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
*
* Project home:
* http://www.appelsiini.net/projects/lazyload
@brentvatne
brentvatne / gist:1218364
Created September 15, 2011 02:26
cross-browser inline-block sass mixin
//using the technique from: http://colinaarts.com/articles/inline-block-and-you/
@mixin cross-browser-inline-block {
display: inline-block; /* For normal, healthy browsers */
* html & { /* for IE6 */
display: inline;
}
*+html & { /* for IE7 */
@brentvatne
brentvatne / gist:1239440
Created September 24, 2011 15:15
octopi error
/Library/Ruby/Gems/1.8/gems/twitter-stream-0.1.14/lib/twitter/json_stream.rb:121:in `<<': Could not parse data entirely (HTTP::Parser::Error)
from /Library/Ruby/Gems/1.8/gems/twitter-stream-0.1.14/lib/twitter/json_stream.rb:121:in `receive_data'
from /Library/Ruby/Gems/1.8/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run_machine'
from /Library/Ruby/Gems/1.8/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run'
from /Library/Ruby/Gems/1.8/gems/tinder-1.6.0/lib/tinder/room.rb:148:in `listen'
from ./bin/../lib/moneypenny/connections/campfire.rb:37:in `listen'
from ./bin/../lib/moneypenny/moneypenny.rb:24:in `listen!'
from bin/moneypenny:25
@brentvatne
brentvatne / gist:1390110
Created November 23, 2011 22:24
useful short script for firing events when an image is loaded
function when_loaded($img, callback) {
if ($img.attr("complete") || $img.attr("readyState") === 4) {
callback.call();
} else {
$img.load(callback);
}
}
function load_image(img_url) {
return $('<img/>').attr('src', img_url);
@brentvatne
brentvatne / 0_README.md
Created November 28, 2011 20:12 — forked from netzpirat/0_README.md
Continuous CoffeeScript testing with Guard and Jasmine

Continuous CoffeeScript testing with Guard and Jasmine

This Gist shows how to set up a Rails project to practice BDD with CoffeeScript, Guard and Jasmine. You can see this setup in action on Vimeo

  • Install Gems with Bundler with bundle install
  • Define your guards with mate Guardfile
  • Initialize Jasmine with bundle exec jasmine init
  • Configure Jasmine with mate spec/support/yasmine.yml
  • Start Guard with bundle exec guard
@brentvatne
brentvatne / mail_server.rb
Created January 31, 2012 22:04 — forked from practicingruby/mail_server.rb
my ideal api
class MailingLst < PostalService::App
config.some_config_var = ".."
filter(:unsubscribed_users) do
!list_members.include?(incoming.from)
end
filter(:subscribed_users) do
list_members.include?(incoming.from)
end
@brentvatne
brentvatne / hack.sh
Created March 31, 2012 23:02 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#