Skip to content

Instantly share code, notes, and snippets.

@quad
Created October 5, 2011 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quad/1264899 to your computer and use it in GitHub Desktop.
Save quad/1264899 to your computer and use it in GitHub Desktop.
Inspired by _why c1-5
#!/usr/bin/env ruby
class String
def shuffle
chars.to_a.shuffle.join
end
end
me = File.basename __FILE__
where_am_i = File.dirname __FILE__
10.times do
to_go = Dir.open where_am_i
places = to_go.map { |n| File.join to_go.path, n }.select { |d| File.directory? d }
whence = places.shuffle.first
begin
File.rename File.join(where_am_i, me), File.join(whence, me)
rescue Errno::EACCES
next
else
where_am_i = whence
end
end
puts where_am_i.shuffle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment