Skip to content

Instantly share code, notes, and snippets.

View ajsharp's full-sized avatar

Alex Sharp ajsharp

View GitHub Profile
def object_report(type = nil)
if type
puts "number of (#{type}) objects in memory = #{ObjectSpace.each_object(type).count}"
else
puts "number of objects in memory = #{ObjectSpace.each_object.count}"
end
end
def full_report
# report
class Person
attr_reader :name
def initialize(name)
@name = name
end
end
Human = Person
alex = Human.new 'alex'
@ajsharp
ajsharp / vcr-response-summary.rb
Last active December 16, 2015 07:48
Outputs a summary of HTTP status codes recorded in your vcr cassettes. Shows file mtime and git status to help determine if bad response were recently recorded.
#!/usr/bin/env ruby
# Usage: ./script/vcr-response-summary
# This script counts all of the response status codes recorded
# in vcr cassettes, prints out a summary, and shows the files that
# have error responses.
output = `grep -rnie 'code: *' spec/fixtures/vcr_cassettes`.chomp
lines = output.split("\n")
[
{
"title": "Some title",
"body": "blah blah",
"slug": "some-title",
"created_at": "2013-04-11T15:46:17-07:00",
"author": {
"name": "Joe Author"
}
"comments": [
require 'forwardable'
module Things
def name
@name
end
end
class Blah
def name
module ActionView::Template::Handlers
class Bldr
# @return [String] the rendered template string
def self.call(template, opts = {})
source = if template.source.empty?
File.read(template.identifier)
else
template.source
end
rescue_from(ActiveRecord::RecordNotFound) do |not_found_exception|
render :json => {status: 404, error_code: "not found", message: not_found_exception.message}, :status => 404
end
@ajsharp
ajsharp / circle-ci-dependency-hack
Last active December 15, 2015 00:39
If you have the dreaded psych / bundler bug, and you run your tests on circle ci, this fix is for you. Paste the gist into the "Dependency Overrides" section of your project's settings in circle. More on the psych issue here: https://github.com/tenderlove/psych/issues/61. Also, you'll probably need to run the "Clear Cache & Retry" option once mo…
rvm use 1.9.3-p125 do gem uninstall -a psych
rvm use 1.9.3-p125 do gem install psych -v=1.3.4
rvm use 1.9.3-p125
bundle install
#!/usr/bin/env ruby
# Usage: ./script/pull-request
#
# Run this script after you've pushed your local branch to origin and you're
# ready to create a PR.
# install hub if not in user's $PATH
if `which hub`.chomp == ''
puts "`hub` not found, installing..."
diff --git a/lib/bldr/node.rb b/lib/bldr/node.rb
index 2d3fa5f..9e19f87 100644
--- a/lib/bldr/node.rb
+++ b/lib/bldr/node.rb
@@ -23,11 +23,22 @@ module Bldr
@parent = opts[:parent]
@views = opts[:views]
@locals = opts[:locals]
+
+ copy_ivars_from_parent(opts[:parent]) if opts[:parent]