Skip to content

Instantly share code, notes, and snippets.

@jasonl99
jasonl99 / calcs.md
Created March 29, 2018 22:03
XBRL Calcs

I gotta go eat dinner, but I have calculations verifying as a ruby class with each period and concept. Here’s a dump of data that shows it. It’s really hard to show this way, more tomorrow when we’re in the office, but major progress!

j.periods  # Show the periods that are defined in the `facts` json column used by this role
=> {"9d7fc963515289af9d036110666da3a05f965b9f"=>{"months"=>12, "end_date"=>Sat, 30 Sep 2017, "start_date"=>Sun, 25 Sep 2016, "fiscal_year"=>"2017", "fiscal_period"=>"FY"},
 "6bfcb1582b287c9a1a4b06c9e663b5ef32d4caff"=>{"months"=>12, "end_date"=>Sat, 24 Sep 2016, "start_date"=>Sun, 27 Sep 2015, "fiscal_year"=>nil, "fiscal_period"=>nil},
 "e8c1b42bd81892ebbb9ad903f69ffbd1d683e209"=>{"months"=>12, "end_date"=>Sat, 26 Sep 2015, "start_date"=>Sun, 28 Sep 2014, "fiscal_year"=>nil, "fiscal_period"=>nil}}

# There are three periods.  For ease of use, I assigned them a, b, and c to each id 
# so a is "9d7fc9735...", b is "6bfcb15..", c is "e8c1b42..."
@jasonl99
jasonl99 / demo.rb
Last active March 13, 2018 02:36
Random Sample in Ruby
class Demo
EXAMPLE = { "75%" => 0.75, "15%" => 0.15, "9%" => 0.09, "1%" => 0.01 }
def self.sample(choices = EXAMPLE)
choices.max_by { |_, weight| rand ** (1.0 / weight) }.first
end
def self.show(samples: 10000)
items = samples.times.map {sample}
items.each_with_object(Hash.new(0)) do |item, counts|

Keybase proof

I hereby claim:

  • I am jasonl99 on github.
  • I am jasonl99 (https://keybase.io/jasonl99) on keybase.
  • I have a public key ASB8mJ7INichm7J9WmDXGVCSimWA-ReRGAe6hvaH8yG6swo

To claim this, I am signing this object: