├── Gemfile ├── misc ├── README.md ├── class_attributes.rb └── echler.py ├── Gemfile.lock ├── Rakefile ├── .gitignore ├── README.md └── implicit_attr_accessor.rb /Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | gem 'rake' 4 | -------------------------------------------------------------------------------- /misc/README.md: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | 3 | A collection of whatnot for exploration ideas. 4 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | 5 | PLATFORMS 6 | ruby 7 | 8 | DEPENDENCIES 9 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | task :rb_file, [:file_name] => :bundle do |t, args| 2 | sh "ruby #{args.file_name}" 3 | end 4 | 5 | desc "Bundle gems" 6 | task :bundle do 7 | sh "bundle install" 8 | end 9 | -------------------------------------------------------------------------------- /misc/class_attributes.rb: -------------------------------------------------------------------------------- 1 | class MyClass 2 | class << self 3 | attr_accessor :my_attribute 4 | end 5 | end 6 | 7 | MyClass.my_attribute = "foo!" 8 | 9 | puts MyClass.my_attribute 10 | 11 | 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | *.rbc 3 | .bundle 4 | .config 5 | coverage 6 | InstalledFiles 7 | lib/bundler/man 8 | pkg 9 | rdoc 10 | spec/reports 11 | test/tmp 12 | test/version_tmp 13 | tmp 14 | 15 | # YARD artifacts 16 | .yardoc 17 | _yardoc 18 | doc/ 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | sandbox 2 | ======= 3 | 4 | Notes, ideas, and doodles from a software engineer. This repository is a 5 | collection of spikes that I work on when attempting to solve other 6 | problems. 7 | 8 | Please see the [wiki](https://github.com/jschairb/sandbox/wiki) for further 9 | notes. 10 | -------------------------------------------------------------------------------- /implicit_attr_accessor.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | class AttrdObject 4 | def method_missing(name, *args) 5 | if /\w+=/.match(name) 6 | self.class.send(:attr_accessor, name.to_s.gsub('=', '')) 7 | send(name, *args) 8 | else 9 | super 10 | end 11 | end 12 | end 13 | 14 | attrd_object = AttrdObject.new 15 | 16 | attrd_object.foo # NoMethodError 17 | 18 | attrd_object.foo = "bar" # bar 19 | 20 | attrd_object.foo # bar 21 | -------------------------------------------------------------------------------- /misc/echler.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, jsonify, request 2 | 3 | app = Flask(__name__) 4 | 5 | @app.route('/', methods=['DELETE', 'GET', 'POST', 'PUT']) 6 | def root_url(): 7 | return jsonify(diagnostics()) 8 | 9 | def diagnostics(): 10 | body = { 11 | 'data': request.data, 12 | 'headers': dict(request.headers), 13 | 'method': request.method, 14 | 'path': request.path, 15 | 'query_string': request.query_string, 16 | 'referrer': request.referrer, 17 | 'request': dir(request), 18 | 'url': request.url 19 | } 20 | return body 21 | 22 | if __name__ == "__main__": 23 | app.run(debug=True, 24 | host='0.0.0.0') 25 | --------------------------------------------------------------------------------