Skip to content

Instantly share code, notes, and snippets.

@hitode909
Created December 28, 2011 08:40
Show Gist options
  • Select an option

  • Save hitode909/1527130 to your computer and use it in GitHub Desktop.

Select an option

Save hitode909/1527130 to your computer and use it in GitHub Desktop.
counter
#! /usr/bin/env ruby
puts 0
source = open($0).read
open($0, "w").write source.sub(/puts (\d+)/) {
"puts #{$1.to_i+1}"
}
#! /usr/bin/env ruby
file = open($0, "r+")
puts file.read.length
file.write("1")
111111
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment