Public Gists by jeremy

gist: 163744 Track object allocations in...
Gravatar
Thu Aug 06 22:35:18 -0700 2009
1
2
3
<table width="100%">
<tr><td width="50%">
{% compare_with_last_week_chart metric:'Custom/Objects/Allocated' title:'Object Allocations' value:total_value %}
Gravatar
Wed Jul 15 13:50:18 -0700 2009
1
2
3
  # Configure generators to use sequel, haml, and shoulda.
  config.generators do |g|
    g.orm :sequel
Gravatar
Thu Jul 02 14:12:13 -0700 2009
1
2
3
# Round expiry to encourage HTTP caching.
# 5-minute expiry at 6:03 would round up from 6:08 to 6:10.
module QuantizedExpiry
Gravatar
Sat Jun 06 17:11:32 -0700 2009
1
2
3
# Including a module included in a superclass is ignored
>> module Foo; end
=> nil
Gravatar
Fri Jun 05 18:16:37 -0700 2009
1
2
3
# Users: JSON.encode(whatever)
#
# Implementors: override dump_json(options) returning a Hash, Array, etc
Gravatar
Thu Jun 04 21:29:25 -0700 2009
1
2
3
# $/ is the ruby line separator, defaults to \n
$/ = '~'
File.open('some_file') do |file|
Gravatar
Thu May 14 14:01:28 -0700 2009
1
2
3
module AfterTransaction
  def self.included(base)
    base.extend(ClassMethods)
Gravatar
Tue May 05 20:05:23 -0700 2009
1
2
3
# encoding: utf-8
= Class.new { def ; puts "⎆" end }
.new.
Gravatar
Wed Apr 22 14:52:08 -0700 2009
1
2
3
jeremy@foo rails (master) $ /usr/local/ruby/1.8.6-ree/bin/ruby -v
ruby 1.8.6 (2008-08-08 patchlevel 286) [i686-darwin9.5.0]
jeremy@foo rails (master) $ /usr/local/ruby/1.8.6-ree/bin/ruby profile_requires.rb active_support
Gravatar
Wed Apr 22 01:39:39 -0700 2009
1
2
3
jeremy@foo rails (master) $ ruby -v
ruby 1.8.8dev (2009-03-19 revision 23009) [i386-darwin9.6.2]
jeremy@foo rails (master) $ ./profile_requires.rb active_support
Gravatar
Wed Apr 22 01:29:37 -0700 2009
1
2
3
#!/usr/bin/env ruby
# Run from toplevel rails checkout to profile a component's requires:
# $ ./profile_requires.rb active_support
Gravatar
Sun Mar 29 00:22:09 -0700 2009
1
2
3
$ irb
>> String.instance_method(:to_s).name
=> "to_s"
Gravatar
Mon Mar 23 01:32:44 -0700 2009
1
2
3
#!/usr/bin/env ruby
class FooArray < Array; end
a = FooArray.new(1000000){'a'}
Gravatar
Fri Mar 20 15:21:37 -0700 2009
1
2
3
$ ruby-1.9 -e "module A; B = 1 end; class C; include A end; puts C.constants(false).inspect"
[]
$ jruby --1.9 -e "module A; B = 1 end; class C; include A end; puts C.constants(false).inspect"
Gravatar
Fri Mar 20 15:19:13 -0700 2009
1
2
3
$ ruby-1.9 -e 'puts __ENCODING__'
UTF-8
$ jruby --1.9 -e 'puts __ENCODING__'
Gravatar
Thu Mar 19 00:57:58 -0700 2009
1
2
3
From 273f56bd6c23bea5ca910af689aa44d4ca56cb7b Mon Sep 17 00:00:00 2001
From: Jeremy Kemper <jeremy@bitsweat.net>
Date: Fri, 27 Feb 2009 14:13:32 -0800
Gravatar
Mon Feb 23 13:34:16 -0800 2009
1
2
3
# ruby-1.8.6-ree profile_startup.rb process_time|allocations|memory
# kcachegrind profile_startup.memory.tree
require 'rubygems'
Gravatar
Mon Feb 23 13:31:38 -0800 2009
1
2
3
# ruby-1.8.6-ree profile_requires.rb config/environment
GC.enable_stats
 
Gravatar
Mon Feb 02 22:19:21 -0800 2009
1
2
3
$ irb
>> module M; protected; attr_reader :foo end
=> nil
Gravatar
Mon Feb 02 21:11:03 -0800 2009
1
2
3
$ irb
>> class Foo; def to_yaml(options); 'abc'.to_yaml(options) end end
=> nil