"tracing through weird Japanese code takes less brain than tracing Rails" -- drbrain
September 2007 Archives
My current favorite emacs hack, thanks to SeanO. This extends find-file-at-point (which I have bound to C-x C-p) to automatically look a bit further for a line number and use it if available:
(defadvice find-file-at-point (around goto-line compile activate)
(let ((line (and (looking-at ".*:\\([0-9]+\\)")
(string-to-number (match-string 1)))))
ad-do-it
(and line (goto-line line))))
ParseTree is a C extension (using RubyInline) that extracts the parse tree for an entire class or a specific method and returns it as a s-expression (aka sexp) using ruby's arrays, strings, symbols, and integers.
As an example:
def conditional1(arg1) if arg1 == 0 then return 1 end return 0 end
becomes:
[:defn, :conditional1, [:scope, [:block, [:args, :arg1], [:if, [:call, [:lvar, :arg1], :==, [:array, [:lit, 0]]], [:return, [:lit, 1]], nil], [:return, [:lit, 0]]]]]
- Uses RubyInline, so it just drops in.
- Includes SexpProcessor and CompositeSexpProcessor.
- Allows you to write very clean filters.
- Includes UnifiedRuby, allowing you to automatically rewrite ruby quirks.
- ParseTree#parsetreefor_string lets you parse arbitrary strings of ruby.
- Includes parsetreeshow, which lets you quickly snoop code.
- echo "1+1" | parsetreeshow -f for quick snippet output.
- Includes parsetreeabc, which lets you get abc metrics on code.
- abc metrics = numbers of assignments, branches, and calls.
- whitespace independent metric for method complexity.
- Includes parsetreedeps, which shows you basic class level dependencies.
- Does not work on the core classes, as they are not ruby (yet).
Changes:
2 minor enhancements:
- Deactivated gcc-specific compiler flags unless ENV['ANAL'] or on my domain.
- Minor code cleanup - happier with -pedantic and the like.
1 bug fix:
- FINALLY conquered the splat args bug on certain platforms/versions. Special Thanks to Jonas Pfenniger for debugging this and providing a patch.
Which one is better? You decide...
if true then # 0.75 seconds
require 'active_record'
require 'yaml'
require 'app/models/author'
require 'app/models/project'
config = YAML.load(File.read('config/database.yml'))
ActiveRecord::Base.establish_connection(config["development"])
else # 2.0 seconds
require File.dirname(__FILE__) + '/../config/environment'
end
conn = ActiveRecord::Base.connection
I'm slightly partial to the faster running one (esp. during development)... but it did take me a while to figger it out. Loading config/environment a heavy price to pay just to get a DB connection and automatic requires.
Vlad the Deployer is pragmatic application deployment automation, without mercy. Much like Capistrano, but with 1/10th the complexity. Vlad integrates seamlessly with Rake, and uses familiar and standard tools like ssh and rsync.
Impale your application on the heartless spike of the Deployer.
FEATURES/PROBLEMS:
- Full deployment automation stack.
- Turnkey deployment for mongrel+apache+svn.
- Supports single server deployment with just 3 variables defined.
- Built on rake. Easy. Engine is small.
- Very few dependencies. All simple.
- Uses ssh with your ssh settings already in place.
- Uses rsync for efficient transfers.
- Run remote commands on one or more servers.
- Mix and match local and remote tasks.
- Compatible with all of your tab completion shell script rake-tastic goodness.
- Ships with tests that actually pass in 0.028 seconds!
- Does NOT support Windows right now (we think). Coming soon in 1.2.
Changes:
1.1.0 / 2007-09-12
- 3 major enhancements:
- Vlad.load now takes a hash of recipe overrides, eg: Vlad.load :web => :nginx. See rdoc for defaults.
- Removed vlad_tasks.rb and split into vlad/apache.rb, vlad/mongrel.rb, and vlad/core.rb.
- The flog ratio between capistrano+deps / vlad+deps is pi (or, damn close)!
- 12 minor enhancements:
- Added $TRACE to make it more available and cleaner to read.
- Added :svn_cmd variable.
- Added Rake.clear_tasks *str_or_regexp
- Added debug and mana_from_heaven tasks to Rakefile.
- Added more documentation.
- Added :rsync_cmd and :rsync_flags.
- Added :ssh_cmd and :ssh_flags.
- Added variable expansion to vlad:debug task.
- Removed :scm variable. Now a Vlad.load component/flavor/need-a-word-here.
- Removed :application var. Use it if you want it. We don't require it.
- Renamed :p4cmd to :p4_cmd.
- Renamed :rake var to :rake_cmd.
2 (important) bug fixes:
- HUGE: Fixed sudo hang bug #13072. Fix suggested by Chris Van Pelt.
- HUGE: Vlad.load calls user config last, allowing variable overrides. ACK! Sorry!
- http://rubyforge.org/projects/hitsquad/
I'm not sure yet (still waiting on more responses on the mailing list), but I think that Seattle.rb is batting 1000 for RubyConf2007!!! A big congratulations goes out to:
- Evan Phoenix - talking about Rubinius.
- Eric Hodel - giving a talk about Über-Productivity.
- Phil Hagelberg - giving a talk on tightening the feedback loop.
And, um... my talk... titled:
It should be fun... I hope to see you there!
