autocmd BufWritePre * :%s/\s\+$//e
(add-hook 'before-save-hook 'delete-trailing-whitespace)
| /** | |
| * @description DropDownAnything, drop down menu based on prototype | |
| * @author Leandro N. Camargo; leandro-at-gmail-dot-com | |
| * @version 0.1 | |
| * @date 08/09/2008 | |
| * @requires prototype.js 1.6 | |
| */ | |
| var DDropDown = function(menu, targets, opt) { | |
| var null_fn = function() {}, _this = this, ie = Prototype.Browser.IE, select_callback = false, menu_caller; |
| module RIndexer | |
| RE_TAG = %r!<([a-z\d_-]+)\s*.*?>!im | |
| def fetch_tags(doc_stream) | |
| tags = Hash.new(0) | |
| doc_stream.scan(RE_TAG).each do |e| | |
| tags[e] += 1 | |
| end | |
| tags | |
| end |
| module RIndexer | |
| RE_TAG = %r!<([a-z\d_-]+)\s*.*?>!im | |
| def fetch_tags(doc_stream) | |
| tags = Hash.new(0) | |
| doc_stream.scan(RE_TAG).each do |e| | |
| tags[e] += 1 | |
| end | |
| tags | |
| end |
| class String | |
| def /(separator) | |
| split separator | |
| end | |
| end |
| class Object | |
| # with this method you can call stuffs like this Comment.nested_send(:creator, :login) | |
| # it's the same of Comment.creator.login without the need of checking the absense of creator like: | |
| # Comment.creator && Comment.creator.login | |
| def nested_send(*methods) | |
| obj = self | |
| methods.each do |e| | |
| case e | |
| when Array |
| class Object | |
| # with this method you can call stuffs like this Comment.nested_send(:creator, :login) | |
| # it's the same of Comment.creator.login without the need of checking the absense of creator like: | |
| # Comment.creator && Comment.creator.login | |
| def nested_send(*methods) | |
| obj = self | |
| methods.each do |e| | |
| case e | |
| when Array |
| require 'matrix' | |
| module FixnumExt | |
| def square? | |
| sqrt = self ** (1.0/2) | |
| (sqrt - sqrt.to_i).zero? | |
| end | |
| end | |
| module MatrixDeterminant |
| # Matrix#det2 does what Matrix#det doesn't do: calculate correctly a matrix determinant | |
| require 'matrix' | |
| module FixnumExt | |
| def square? | |
| sqrt = self ** (1.0/2) | |
| (sqrt - sqrt.to_i).zero? | |
| end | |
| end |
| # collect information about a running process | |
| # ruby debug.rb <pid> | |
| begin | |
| raise ArgumentError unless pid = ARGV[0] | |
| pid = pid.to_i | |
| Process.kill(0,pid) | |
| rescue TypeError, ArgumentError | |
| raise 'pid required' | |
| rescue Errno::ESRCH |