Skip to content

Instantly share code, notes, and snippets.

@terryfinn
terryfinn / keybase.md
Last active June 4, 2016 20:11
keybase.md

Keybase proof

I hereby claim:

  • I am terryfinn on github.
  • I am terryfinn (https://keybase.io/terryfinn) on keybase.
  • I have a public key whose fingerprint is 1CE6 FC73 6E62 0712 DB68 0371 739D 3E98 F455 3FDD

To claim this, I am signing this object:

Ring ID: 883d28b76116889cfe39c314fdd298a8efa200ae

@terryfinn
terryfinn / ruby_source_data_store-data_store.rb
Last active December 14, 2015 21:28
Read and write data in a ruby script after __END__. Reading data from the DATA constant is easy, but writing to it isn't as simple. The trick is to ask DATA for its position in the file with DATA.pos. Whatever DATA.pos returns needs to be save to a variable and used to seek back to this position when writing to the file. RubySourceDataStore::Dat…
module RubySourceDataStore
class DataStore
DEFAULT_OPTIONS = {
auto_save: true,
serializer_name: :YAML
}
def initialize(data_file_handler, options = {})
@data = data_file_handler
@data_pos = data_file_handler.pos