I hereby claim:
- I am apeiros on github.
- I am apeiros (https://keybase.io/apeiros) on keybase.
- I have a public key whose fingerprint is 8069 6F42 1FD4 35A8 F0FD 23B6 97C0 D061 072D 0718
To claim this, I am signing this object:
# encoding: utf-8 | |
require 'spreadsheet' | |
require 'stringio' | |
class Spreadsheet::Workbook |
class Namespace | |
def initialize(current=[], &block) | |
@current = current | |
instance_eval(&block) | |
end | |
def namespace(name, &block) | |
Namespace.new(@current+[name], &block) | |
end |
module MyApp | |
class Link | |
def self.json(json_string) | |
new(JSON.parse(json_string)) # could add a json-schema validation here, fitting Link | |
end | |
attr_accessor :rel, :href | |
def initialize(rel: nil, href: nil) | |
@rel = rel |
def invoke(verb, path, expected_code, additional_params=nil) | |
if additional_params | |
response = RestClient.public_send(verb, restclient_uri(path), additional_params.to_json, core_params(verb)) | |
else | |
response = RestClient.public_send(verb, restclient_uri(path), core_params(verb)) | |
end | |
rescue RestClient::Exception => e | |
e | |
rescue | |
response |
def ==(other) | |
other.data == @data | |
rescue NoMethodError | |
false | |
end |
class String | |
def match_all(regex) | |
if block_given? | |
scan(regex) { yield $~ } | |
else | |
enum_for(:scan, regex).map { $~ } | |
end | |
end | |
end |
class Hash | |
def map_keys | |
map_pairs { |key, value| [yield(key), value] } | |
end | |
def map_keys! | |
map_pairs! { |key, value| [yield(key), value] } | |
end | |
def map_values |
I hereby claim:
To claim this, I am signing this object:
# encoding: utf-8 | |
#p(/\xff/.encoding) # -> raises SyntaxError, "invalid multibyte escape: /\xff/" | |
p(/\xff/n.encoding) | |
#p(/\xff/u.encoding) # -> raises SyntaxError, "invalid multibyte escape: /\xff/" | |
p(/x/.encoding) | |
p(/x/n.encoding) | |
p(/x/u.encoding) |
#!/usr/bin/ruby -w | |
# grab the input, convert it, sum it, and spit out the answer | |
$stdin.each_line do |line| | |
puts line.scan(/\d+/).map(&:to_i).reduce(:+) | |
end |