Skip to content

Instantly share code, notes, and snippets.

View ChuckO's full-sized avatar

Chuck ChuckO

  • DoubleTiered, Inc
  • Fort Lauderdale, FL
View GitHub Profile
@ChuckO
ChuckO / output
Created June 28, 2012 22:28
Take a BM
r1.9.3 ~/workarea/take_a_bm $ ruby take_a_bm.rb
Thread.current.object_id:70331712734240 0.000000 0.000000 0.000000 ( 1.001500)
Thread.current.object_id:70331712733480 0.000000 0.000000 0.000000 ( 1.001537)
Thread.current.object_id:70331712733240 0.000000 0.000000 0.000000 ( 1.001746)
Thread.current.object_id:70331712732600 0.000000 0.000000 0.000000 ( 1.001865)
Thread.current.object_id:70331712731560 0.000000 0.000000 0.000000 ( 1.002109)
Thread.current.object_id:70331712733660 0.000000 0.000000 0.000000 ( 1.000823)
Thread.current.object_id:70331712733400 0.000000 0.000000 0.000000 ( 1.002661)
Thread.current.object_id:70331712733000 0.000000 0.000000 0.000000 ( 1.002736)
Thread.current.object_id:70331712729480 0.000000 0.000000 0.000000 ( 1.002143)
@ChuckO
ChuckO / cleandups.rb
Created April 5, 2012 20:26
Find and clean duplicate files (Ruby)
#!/usr/bin/env ruby
require 'digest/md5'
# argument processing -- goes through Dir[], so can use '**/*' etc.
ARGV[0] ||= '.'
# build list of filenames, rejecting symlink, dirs & 0 len files
filenames = ARGV.collect{ |dir| Dir[File.directory?(dir) ? "#{dir}/*" : dir] }.flatten
filenames.reject!{ |fn| File.symlink?(fn) || File.directory?(fn) || File.size?(fn).nil? }