From 8cf2288d2e15d43c1bc04d189d7ee2b97a7ad98c Mon Sep 17 00:00:00 2001 From: muflax Date: Mon, 30 Apr 2012 00:42:19 +0200 Subject: [PATCH] range_math post --- content/references/personal.mkd | 5 +++ content/references/references.mkd | 2 ++ content/references/videos.mkd | 1 + content_blog/software/index.mkd | 6 ++++ content_blog/software/range_math.mkd | 46 ++++++++++++++++++++++++++++ 5 files changed, 60 insertions(+) create mode 100644 content_blog/software/index.mkd create mode 100644 content_blog/software/range_math.mkd diff --git a/content/references/personal.mkd b/content/references/personal.mkd index 9c0ce04..6d165e7 100644 --- a/content/references/personal.mkd +++ b/content/references/personal.mkd @@ -17,6 +17,9 @@ [Twitter pali]: https://twitter.com/#!/muflax/status/66635052242567168 + +[comment Church]: http://blog.muflax.com/jesus/self-baptism/#comment-513169408 + [Config]: https://github.com/muflax/config [Github]: https://github.com/muflax/ @@ -29,3 +32,5 @@ [fume]: https://github.com/muflax/fume [fumetrap]: https://github.com/muflax/fumetrap [github web history]: https://github.com/muflax/scripts/blob/master/google_web_history.rb +[range_math]: https://github.com/muflax/range_math +[avg_dmg]: https://github.com/muflax/scripts/blob/master/average_damage.rb diff --git a/content/references/references.mkd b/content/references/references.mkd index cb86a29..2da75e1 100644 --- a/content/references/references.mkd +++ b/content/references/references.mkd @@ -77,6 +77,8 @@ [Ingram flame]: http://www.dharmaoverground.org/web/guest/discussion/-/message_boards/message/2880527 [Rhetological Fallacies]: http://www.informationisbeautiful.net/visualizations/rhetological-fallacies/ [Logical Fallacies Poster]: http://yourlogicalfallacyis.com/ +[SMBC skull-king]: http://www.smbc-comics.com/index.php?db=comics&id=2244#comic +[Up and Down the Ladder of Abstraction]: http://worrydream.com/LadderOfAbstraction/ [LW bipolar]: http://lesswrong.com/lw/6nb/ego_syntonic_thoughts_and_values/4igy diff --git a/content/references/videos.mkd b/content/references/videos.mkd index 5410307..e73300b 100644 --- a/content/references/videos.mkd +++ b/content/references/videos.mkd @@ -42,3 +42,4 @@ [Stanford Metaethics]: http://www.youtube.com/watch?v=kBdfcR-8hEY [Schopenhauer Lecture]: http://www.youtube.com/watch?feature=player_detailpage&v=aK4pR1Uatqw#t=1084s [Batmobile]: https://www.youtube.com/watch?v=BmjFni_WLrA +[Lecher Bitch]: https://www.youtube.com/watch?v=H3_sBoCUlOo diff --git a/content_blog/software/index.mkd b/content_blog/software/index.mkd new file mode 100644 index 0000000..01a183d --- /dev/null +++ b/content_blog/software/index.mkd @@ -0,0 +1,6 @@ +--- +title: Software +is_category: true +--- + +<%= category :software %> diff --git a/content_blog/software/range_math.mkd b/content_blog/software/range_math.mkd new file mode 100644 index 0000000..b270637 --- /dev/null +++ b/content_blog/software/range_math.mkd @@ -0,0 +1,46 @@ +--- +title: Ruby Math with Ranges +date: 2012-04-30 +techne: :done +episteme: :believed +--- + +You're playing some D&D game, like you always do, and you find two weapons, the Sword of Burnination, 1d8+3 and 1d6 fire damage, and the [Axe of Castigation][Lecher Bitch], 2d6+3. And you're tired of doing this math in your head. + +So you write a Ruby gem to do it for you. + +First, you write a [simple gem][range_math] to do math with ranges. You wanted this since you read [Up and Down the Ladder of Abstraction][]. Now this works: + +~~~ +#!ruby +(1..6) * 3 # => (3..18) +(-5..3) + 7 # => (2..10) +(1..3) + (2..4) # => (3..7) +(4..12) / 2 # => (2.0..6.0) +~~~ + +You can do quick math in your irb sessions with ranges instead of numbers now. You're happy. + +You do a `gem install range_math` on any system, and put this in your `.zshrc`: + +~~~ +#!sh +alias i="irb -rrange_math" +~~~ + +Then you write a [simple script][avg_dmg] to convert dice rolls into ranges, put it in your PATH and alias it like this: + +~~~ +#!sh +alias avg="noglob average_damage.rb" +~~~ + +Now this works: + +~~~ +#!sh +$ avg 1d8+3 + 1d6 +range: 5..17, average: 11.0 +~~~ + +Suffering ends.