Skip to content

Instantly share code, notes, and snippets.

View BenEddy's full-sized avatar
💭
🍂

Ben Eddy BenEddy

💭
🍂
  • Seattle
View GitHub Profile
# in config/initializers/navigatrix.rb
Navigatrix.register_item_renderer(:my_item) do
def link
link_to(name, path, class: "my-class")
end
def unlinked_content
content_tag(:span, name)
end
class ContextMatters.CompositeRouter extends Backbone.Router
constructor: ->
@route("*path", "extractComponents")
super
extractComponents: (path) ->
@changes ||= {}
for namespace, payload of @_decode(path)
unless _.isEqual(@changes[namespace], payload)
# initializers/navigatrix.rb
Navigatrix.register_list_renderer(:table_list) do |renderer|
renderer.wrapper do |items, html_attributes|
content_tag(:div, html_attributes.merge_attribute(:class, "navigation")) do
content_tag(:table, items, class: "nav-table")
end
end
end
@BenEddy
BenEddy / gist:8e17d4de673789c59019
Last active August 29, 2015 14:05
grep for NewRelic availability agent
grep '50.31.164.139\|50.112.95.211\|54.247.188.179\|54.248.250.232\|54.251.34.67\|184.73.237.85\|50.18.57.7\|54.214.255.205\|54.228.244.177\|54.232.123.139\|54.241.22.142\|54.248.225.67\|54.251.109.246\|54.252.114.169\|54.252.114.170\|177.71.245.207\|200' log/production.log
1. write_attribute is private, but read_attribute, []= and [] are public.
user = User.new

user.first_name = "Ben"
user[:first_name] = "Ben"

user.read_attribute(:first_name)
# => "Ben"
class User < ActiveRecord::Base
has_many :comments
accepts_nested_attributes_for :comments
end
class Comment < ActiveRecord::Base
belongs_to :user
end
@BenEddy
BenEddy / gist:1127814
Created August 5, 2011 15:48
Test Gist
More Codez
@BenEddy
BenEddy / eleven
Created August 5, 2011 15:56
Scrrrrrript.
activty stream
@BenEddy
BenEddy / encode-test
Created November 4, 2012 21:01 — forked from reagent/encode-test
Test harness for David's encode.c program
#!/usr/bin/env ruby
# Usage: ./encode-test /path/to/encode.c
require 'fileutils'
def directory(path)
path = File.expand_path(path)
if File.directory?(path)
path
class User < ActiveRecord::Base
has_many :tasks
def self.with_flagged_comments
includes(:task).merge(Task.with_flagged_comments)
end
end
class Task < ActiveRecord::Base
belongs_to :user