This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# From PragDave: | |
# http://pragdave.blogs.pragprog.com/pragdave/2008/04/babydoc.html | |
require 'ripper' | |
# This class handles parser events, extracting | |
# comments and attaching them to class definitions | |
class BabyRDoc < Ripper::Filter | |
def initialize(*) | |
super |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/ruby -ws | |
# Quick Hack to show which methods are not explicitly called within a class. | |
# This is only with regard to the class itself. | |
require 'pp' | |
begin require 'rubygems' rescue LoadError end | |
require 'parse_tree' | |
require 'sexp_processor' | |
require 'set' | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'jruby' | |
import org.jruby.ast.Node | |
import org.jruby.ast.DefnNode | |
import org.jruby.ast.ClassNode | |
# Quick test of the JRuby AST, actually much easier to work with than | |
# ParseTree | |
code = <<-END | |
class Feline::Cat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CmdUtils.CreateCommand({ | |
name: "bus-schedule", | |
takes: {"route": noun_arb_text}, | |
icon: "http://transit.metrokc.gov/favicon.ico", | |
homepage: "http://endofline.wordpress.com", | |
author: {name: "Adam Sanderson", email: "[email protected]"}, | |
license: "MPL", | |
description: "Look up King County Metro bus route", | |
help: "Select a bus route", | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Quick and dirty dot file for ActiveRecord models | |
namespace :dot do | |
task :load_models => :environment do | |
Dir.glob("#{RAILS_ROOT}/app/models/**/*rb").each{|p| require p} | |
end | |
desc 'Generates a dot file of the models' | |
task :models => :load_models do | |
models = Object.subclasses_of ActiveRecord::Base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env jruby | |
include Java | |
import java.lang.System | |
import javax.swing.JFrame | |
import javax.swing.JLabel | |
import javax.swing.JTextField | |
import javax.swing.event.DocumentListener | |
import java.awt.GridLayout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# throw catch test | |
class Thingy | |
def loop | |
value = catch(:cake) do | |
(0..7).each do |i| | |
puts "Looking at #{i}" | |
throw(:cake, i) if i == 3 | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
around_filter do |controller, action| | |
delta = Hash.new{|h,k| h[k] = 0} | |
ObjectSpace.each_object{|o| delta[o.class] -= 1} | |
action.call | |
GC.start | |
ObjectSpace.each_object{|o| delta[o.class] += 1} | |
delta.sort_by{|cls, count| -count}[0...25].each do |cls, count| | |
logger.info("%6d: %s\n" % [count,cls.to_s]) | |
end | |
true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Track down where requirements are coming from. | |
# ruby -r require_inspector.rb <file> | |
def require path | |
puts "require: (#{path}) #{caller[0]}" | |
super | |
end | |
def gem(*args) | |
puts "gem: #{args.inspect} #{caller[0]}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# Be lazy and restart your node.js app when you change things. | |
# Screenshot: http://img.skitch.com/20100606-mbi52g6knk3n83b6m3eqxr4pa4.png | |
# INSTALL: | |
# $ gem install watchr | |
# $ wget http://gist.github.com/raw/427720/2aae1f3b43a256f5ca07a603025d455aa92560e1/node_run | |
# $ cd YOUR_NODE_APP | |
# $ watchr node_runner.rb | |
# | |
# NOTES: |
OlderNewer