Skip to content

Instantly share code, notes, and snippets.

View BenEddy's full-sized avatar
💭
🍂

Ben Eddy BenEddy

💭
🍂
  • Seattle
View GitHub Profile
@BenEddy
BenEddy / angular-bootstrap-nav.html
Created February 18, 2016 01:06 — forked from fpv83/angular-bootstrap-nav.html
angular navbar directive for twitter bootstrap with the aid of bootstrap.ui
<!DOCTYPE html>
<html data-ng-app="webapp">
<head>
<title>angular nav</title>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">
<style>
body{
padding-top: 70px;
}
class User < ActiveRecord::Base
has_many :comments
accepts_nested_attributes_for :comments
end
class Comment < ActiveRecord::Base
belongs_to :user
end
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)
# =&gt; "Ben"
@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
# 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
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)
# 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
Dir[File.dirname(__FILE__) + '/support/*.rb'].each {|file| require file }
describe UserSearch do
describe "#results" do
let(:relation) { MockActiveRelation.new(:name_matching, :email_matching) }
def results(options = {})
described_class.new(options).results
end
before { User.stub(scoped: relation) }
class MockActiveRelation < Hash
attr_reader :mocked_scopes
def initialize(*mocked_scopes)
@mocked_scopes = mocked_scopes
super()
end
def scoped?
any?