際際滷

際際滷Share a Scribd company logo
Triskelion
                                  and
                           Crapshoot
                            Miami Ruby Brigade
                             January 17, 2010




Monday, January 17, 2011
Triskelion and Crapshoot
                           Triskelion - Rails application
                            UI Elements
                           Crapshoot - Dice-rolling library
                            Parsing with Ragel
                            In鍖x and Post鍖x Notation
                            Random numbers

Monday, January 17, 2011
Pen and Paper Games
                           Pens
                           Paper        Talking
                           Dice         Snacks
                           Books
Monday, January 17, 2011
Pen and Paper Games
                           Pens
                           Paper        Talking
                           Dice         Snacks
                           Books
Monday, January 17, 2011
Monday, January 17, 2011
Monday, January 17, 2011
m p
                                 sta
                               e
                           T im




Monday, January 17, 2011
m p        e
                                 sta        am
                               e          N
                           T im




Monday, January 17, 2011
m p        e          d e
                                 sta        am         c o
                               e          N         rip
                           T im                    T




Monday, January 17, 2011
m p        e          d e          n t
                                    sta        am         c o         n te
                                 m e         N        Trip         C o
                           T i




Monday, January 17, 2011
Colored Name
                           Easier to read than text-only nickname
                           Shift the 鍖rst few bytes of hash into LSBs of color

油油def chat_color
油油油油digest = Digest::SHA1.hexdigest(self.tripcode +
                                    self.name)
油油油油r = (digest[0..1].to_i(16) >> 1) + 127
油油油油g = (digest[2..3].to_i(16) >> 1) + 127
油油油油b = (digest[4..5].to_i(16) >> 1) + 127
油油油油"##{r.to_s 16}#{g.to_s 16}#{b.to_s 16}"
油油end
Monday, January 17, 2011
Tripcode
                           Identity without Password or Registration
                           Used on 4chan

油油def tripcode_digest
油油油油[Digest::SHA1.digest(self.tripcode)].
      pack('m').
      tr('+/','-_')[0..7]
油油end


Monday, January 17, 2011
Chat
auto_link chat.content,
 :html=>{:target=>'_blank'}




Monday, January 17, 2011
Chat
auto_link chat.content,
 :html=>{:target=>'_blank'}



                           http://www.鍖ickr.com/photos/lostvegas/2214183472/




Monday, January 17, 2011
Roll

                           4d6v + 40 =57 ((3+5+6+6-3)+40)
    <span class="code">
      <%=h roll.code %></span>
    <span class="result">
      <%=h roll.result %></span>
    <span class="description">
      <%=h roll.description %></span>

Monday, January 17, 2011
Triskelion and Crapshoot
                           Triskelion - Rails application
                            UI Elements
                           Crapshoot - Dice-rolling library
                            Parsing with Ragel
                            In鍖x and Post鍖x Notation
                            Random numbers

Monday, January 17, 2011
Dice Code
                           2d4
                            Two four-sided dice
                           1d100 + 8
                            One hundred-sided die plus eight
                           4d6v
                            Four six-sided dice, minus the lowest


Monday, January 17, 2011
Dice Language

                           A programming language is [] designed to
                           express computations, [] to express
                           algorithms precisely, or as a mode of human
                           communication.
                                           http://en.wikipedia.org/wiki/Programming_language




Monday, January 17, 2011
Triskelion and Crapshoot
                           Triskelion - Rails application
                            UI Elements
                           Crapshoot - Dice-rolling library
                            Parsing with Ragel
                            In鍖x and Post鍖x Notation
                            Random numbers

Monday, January 17, 2011
Regular Language
                   In computer science, a regular language is a formal
                   language [] that satis鍖es the following equivalent
                   properties:
                   it can be accepted by a deterministic 鍖nite state
                           machine
                   it can be generated by a regular grammar
                                              http://en.wikipedia.org/wiki/Regular_language



Monday, January 17, 2011
Dice Language
   4d6v                    + 3d10^    2d6 - 300




Monday, January 17, 2011
Dice Language
   4d6v                    + 3d10^  2d6 - 300
                              Expression



Monday, January 17, 2011
Dice Language
   4d6v                    + 3d10^    2d6 - 300




Monday, January 17, 2011
Dice Language
                           2d6 - 300




Monday, January 17, 2011
Dice Language
                              2d6 - 300
                           BinaryExpression



Monday, January 17, 2011
Dice Language
                           2d6 - 300




Monday, January 17, 2011
Dice Language
                           2d6
                                 -
                                     300
Monday, January 17, 2011
Dice Language
                           2d6             Series
                                 -
                                     300
Monday, January 17, 2011
Dice Language
                                  2d6             Series
                           Arithmetic   -
                                            300
Monday, January 17, 2011
Dice Language
                                  2d6             Series
                           Arithmetic   -
                             Constant       300
Monday, January 17, 2011
Dice Language
                           2d6
                                 -
                                     300
Monday, January 17, 2011
Dice Language
                                                                 0 % D
                                                                0 IE
                                                               1 F
             Number = digit+;                                      I
                                                                 T AR
                                                                R L
                                                               E U
             Constant = Number;                               C G      G E
                                                                E UA
                                                               R G
             Drop = ('^' | 'v');                                  N
             Series = Number 'd' Number Drop?;                 LA
             Arithmetic = ('+' | '-');

             UnaryExpression = Series | Constant;
             BinaryExpression = UnaryExpression (space* Arithmetic space* UnaryExpression)+;
             Expression = UnaryExpression | BinaryExpression;




Monday, January 17, 2011
Ragel

                           Ragel compiles executable 鍖nite state machines from regular
                           languages. Ragel targets C, C++, Objective-C, D, Java and
                           Ruby.
                                                               http://www.complang.org/ragel/




Monday, January 17, 2011
scan.rl
                   %%{
                油油machine scanner;

                油油action _number { @mark_num = p }




                                                                                                Language Actions
                油油action number { @num_stack.push atos(data[@mark_num..p-1]) }

                油油action constant { @tokens << Tokens::Constant.new(@num_stack.pop) }
                油油action series {
                油油油油drop = @drop_current
                油油油油@drop_current = nil
                油油油油sides = @num_stack.pop
                油油油油count = @num_stack.pop
                油油油油@tokens << Tokens::Series.new(count, sides, drop)
                油油}
                油油action arithmetic { @tokens << Tokens::Arithmetic.new(data[p-1].chr) }

                油油action drop { @drop_current = data[p-1].chr }

                油油Number = digit+ >_number %number;

                油油Constant = Number %constant;

                油油Drop = ('^' | 'v') %drop;
                油油Series = Number 'd' Number Drop? %series;

                油油Arithmetic = ('+' | '-') %arithmetic;

                油油UnaryExpression = Series | Constant;
                油油BinaryExpression = UnaryExpression (space* Arithmetic space* UnaryExpression)+;
                油油Expression = UnaryExpression | BinaryExpression;

                油油main := Expression;
                }%%




Monday, January 17, 2011
Ragel




Monday, January 17, 2011
Ragel
                           scan.rl: 62 lines




Monday, January 17, 2011
Ragel
                           scan.rl: 62 lines
                           scan.rb: 330 lines




Monday, January 17, 2011
Ragel
                           scan.rl: 62 lines
                           scan.rb: 330 lines
                           scan.pdf: priceless




Monday, January 17, 2011
scan.rl
                           Transform constant, series, and arithmetic elements into
                                                Token objects

油油action constant { @tokens << Tokens::Constant.new(@num_stack.pop) }
油油action series {
油油油油drop = @drop_current
油油油油@drop_current = nil
油油油油sides = @num_stack.pop
油油油油count = @num_stack.pop
油油油油@tokens << Tokens::Series.new(count, sides, drop)
油油}
油油action arithmetic { @tokens << Tokens::Arithmetic.new(data[p-1].chr) }




Monday, January 17, 2011
Tokens
                           Token#eval
                            Turn token into result during evaluation

                           Token#independent
                            Determine if token needs the next token during post鍖xing

                           Token#inspect
                            <Crapshoot::Tokens::Series dice=4d6 drop=nothing>




Monday, January 17, 2011
Parsed Dice
  4d6v                     + 3d10^      - 2d6        - 300
  count: 4                  count: 3     count: 2     value: 300
  sides: 6                  sides: 10    sides: 6
  drop: v                 drop: ^    drop: nil




Monday, January 17, 2011
Triskelion and Crapshoot
                           Triskelion - Rails application
                            UI Elements
                           Crapshoot - Dice-rolling library
                            Parsing with Ragel
                            In鍖x and Post鍖x Notation
                            Random numbers

Monday, January 17, 2011
In鍖x & Post鍖x




Monday, January 17, 2011
In鍖x & Post鍖x

                           In鍖x
                           1+2+3+4
                           Used for centuries
                           Hard for computers




Monday, January 17, 2011
In鍖x & Post鍖x

                           In鍖x                 Post鍖x
                           1+2+3+4              12+3+4+
                           Used for centuries   Easy for computers
                           Hard for computers   Convertible from in鍖x




Monday, January 17, 2011
Parsed Dice
  4d6v                     + 3d10^      - 2d6        - 300
  count: 4                  count: 3     count: 2     value: 300
  sides: 6                  sides: 10    sides: 6
  drop: v                 drop: ^    drop: nil




Monday, January 17, 2011
Post鍖xed Dice
  4d6v                     3d10^       + 2d6        - 300         -
  count: 4                 count: 3     count: 2     value: 300
  sides: 6                 sides: 10    sides: 6
  drop: v                drop: ^    drop: nil




Monday, January 17, 2011
Post鍖x Evaluation




Monday, January 17, 2011
Post鍖x Evaluation

                           Series




Monday, January 17, 2011
Post鍖x Evaluation

                           Series
                            Roll dice




Monday, January 17, 2011
Post鍖x Evaluation

                           Series
                            Roll dice
                            Do drop




Monday, January 17, 2011
Post鍖x Evaluation

                           Series
                            Roll dice
                            Do drop
                            Push result to stack


Monday, January 17, 2011
Post鍖x Evaluation

                                                    Constant
                           Series
                            Roll dice
                            Do drop
                            Push result to stack


Monday, January 17, 2011
Post鍖x Evaluation

                                                    Constant
                           Series
                                                     Push value to stack
                            Roll dice
                            Do drop
                            Push result to stack


Monday, January 17, 2011
Post鍖x Evaluation

                                                    Constant
                           Series
                                                     Push value to stack
                            Roll dice
                                                    Arithmetic
                            Do drop
                            Push result to stack


Monday, January 17, 2011
Post鍖x Evaluation

                                                    Constant
                           Series
                                                     Push value to stack
                            Roll dice
                                                    Arithmetic
                            Do drop
                                                     Pop twice
                            Push result to stack


Monday, January 17, 2011
Post鍖x Evaluation

                                                    Constant
                           Series
                                                     Push value to stack
                            Roll dice
                                                    Arithmetic
                            Do drop
                                                     Pop twice
                            Push result to stack
                                                     Push result


Monday, January 17, 2011
Post鍖x Evaluation
  4d6v                     3d10^       + 2d6        - 300         -
  count: 4                 count: 3     count: 2     value: 300
  sides: 6                 sides: 10    sides: 6
  drop: v                drop: ^    drop: nil


   Stack



Monday, January 17, 2011
Post鍖x Evaluation
   15                      3d10^       + 2d6        - 300         -
                           count: 3     count: 2     value: 300
                           sides: 10    sides: 6
                           drop: ^    drop: nil


   Stack



Monday, January 17, 2011
Post鍖x Evaluation
                           3d10^       + 2d6        - 300         -
                           count: 3     count: 2     value: 300
                           sides: 10    sides: 6
                           drop: ^    drop: nil


   Stack

  15
Monday, January 17, 2011
Post鍖x Evaluation
                           5         + 2d6          - 300         -
                                        count: 2     value: 300
                                        sides: 6
                                        drop: nil


   Stack

  15
Monday, January 17, 2011
Post鍖x Evaluation
                                  + 2d6         - 300         -
                                    count: 2     value: 300
                                    sides: 6
                                    drop: nil


   Stack

  15 5
Monday, January 17, 2011
Post鍖x Evaluation
                                    2d6         - 300         -
                                    count: 2     value: 300
                                    sides: 6
                                    drop: nil


   Stack

  15 + 5
Monday, January 17, 2011
Post鍖x Evaluation
                                    2d6         - 300         -
                                    count: 2     value: 300
                                    sides: 6
                                    drop: nil


   Stack

  20
Monday, January 17, 2011
Post鍖x Evaluation
                                    9     - 300         -
                                           value: 300




   Stack

  20
Monday, January 17, 2011
Post鍖x Evaluation
                                          - 300         -
                                           value: 300




   Stack

  20 9
Monday, January 17, 2011
Post鍖x Evaluation
                                           300          -
                                           value: 300




   Stack

  20 - 9
Monday, January 17, 2011
Post鍖x Evaluation
                                           300          -
                                           value: 300




   Stack

  11
Monday, January 17, 2011
Post鍖x Evaluation
                                           300   -


   Stack

  11
Monday, January 17, 2011
Post鍖x Evaluation
                                               -


   Stack

  11 300
Monday, January 17, 2011
Post鍖x Evaluation




   Stack

  11 - 300
Monday, January 17, 2011
Post鍖x Evaluation




   Stack

  -289
Monday, January 17, 2011
Result


                           -289



Monday, January 17, 2011
Triskelion and Crapshoot
                           Triskelion - Rails application
                            UI Elements
                           Crapshoot - Dice-rolling library
                            Parsing with Ragel
                            In鍖x and Post鍖x Notation
                            Random numbers

Monday, January 17, 2011
Randomness

                           Computers are deterministic
                           Gather and store entropy where
                           possible
                           Use secure hashes to disburse entropy


Monday, January 17, 2011
Randomness

                           Just use
                           OpenSSL
Monday, January 17, 2011
SecureRandom

                           Ruby 1.9 and ActiveSupport
                                random_number
                                 random_bytes
                                      hex


Monday, January 17, 2011
Triskelion and Crapshoot
                           Triskelion - Rails application
                            UI Elements
                           Crapshoot - Dice-rolling library
                            Parsing with Ragel
                            In鍖x and Post鍖x Notation
                            Random numbers

Monday, January 17, 2011
Ad

Recommended

GDI Ruby Class 3: Sinatra!
GDI Ruby Class 3: Sinatra!
Emma Persky
GDI Ruby on Rails Class 2
GDI Ruby on Rails Class 2
Emma Persky
GDI Ruby Class 3: Sinatra
GDI Ruby Class 3: Sinatra
Emma Persky
Content Analysis is King
Content Analysis is King
Emma Persky
Emma's Guide to Great BarCamping
Emma's Guide to Great BarCamping
Emma Persky
How To: Uncricket
How To: Uncricket
Emma Persky
Tienda y abarrotes el gordo
TIENDAELGORDO
Gesture Recognition
Gesture Recognition
Emma Persky
Uma vis達o do mundo rails campus party 2011 - fabio akita
Uma vis達o do mundo rails campus party 2011 - fabio akita
Campus Party Brasil
Ferramentas do mundo Rails - Campus Party 2011
Ferramentas do mundo Rails - Campus Party 2011
Fabio Akita
Seriously Playful
Seriously Playful
Daniel Burka
The Digital Toolbox - a discussion -Science Online '11
The Digital Toolbox - a discussion -Science Online '11
Kaitlin Thaney
User interface design for thumbs and fingers
User interface design for thumbs and fingers
Gregory Raiz
MILOFest 2010
MILOFest 2010
Larry Staton
Digital changes everything
Digital changes everything
Sara Silfverberg
Nachos3T
Nachos3T
garciacgabriela
Ruby can haz Everyone
Ruby can haz Everyone
RubyX
Blackhat Workshop
Blackhat Workshop
wremes
Read the Docs: A completely open source Django project
Read the Docs: A completely open source Django project
ericholscher
HTML5 with Play Scala, CoffeeScript and Jade - Jfokus 2012
HTML5 with Play Scala, CoffeeScript and Jade - Jfokus 2012
Matt Raible
Information Security Response Team Nepal_npCERT_Vice_President_Sudan_Jha.pdf
Information Security Response Team Nepal_npCERT_Vice_President_Sudan_Jha.pdf
ICT Frame Magazine Pvt. Ltd.
"Database isolation: how we deal with hundreds of direct connections to the d...
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
Cyber Defense Matrix Workshop - RSA Conference
Cyber Defense Matrix Workshop - RSA Conference
Priyanka Aash
AI VIDEO MAGAZINE - June 2025 - r/aivideo
AI VIDEO MAGAZINE - June 2025 - r/aivideo
1pcity Studios, Inc
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
OWASP Barcelona 2025 Threat Model Library
OWASP Barcelona 2025 Threat Model Library
PetraVukmirovic
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Safe Software
Securing AI - There Is No Try, Only Do!.pdf
Securing AI - There Is No Try, Only Do!.pdf
Priyanka Aash
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha

More Related Content

Similar to Triskelion and Crapshoot (12)

Uma vis達o do mundo rails campus party 2011 - fabio akita
Uma vis達o do mundo rails campus party 2011 - fabio akita
Campus Party Brasil
Ferramentas do mundo Rails - Campus Party 2011
Ferramentas do mundo Rails - Campus Party 2011
Fabio Akita
Seriously Playful
Seriously Playful
Daniel Burka
The Digital Toolbox - a discussion -Science Online '11
The Digital Toolbox - a discussion -Science Online '11
Kaitlin Thaney
User interface design for thumbs and fingers
User interface design for thumbs and fingers
Gregory Raiz
MILOFest 2010
MILOFest 2010
Larry Staton
Digital changes everything
Digital changes everything
Sara Silfverberg
Nachos3T
Nachos3T
garciacgabriela
Ruby can haz Everyone
Ruby can haz Everyone
RubyX
Blackhat Workshop
Blackhat Workshop
wremes
Read the Docs: A completely open source Django project
Read the Docs: A completely open source Django project
ericholscher
HTML5 with Play Scala, CoffeeScript and Jade - Jfokus 2012
HTML5 with Play Scala, CoffeeScript and Jade - Jfokus 2012
Matt Raible
Uma vis達o do mundo rails campus party 2011 - fabio akita
Uma vis達o do mundo rails campus party 2011 - fabio akita
Campus Party Brasil
Ferramentas do mundo Rails - Campus Party 2011
Ferramentas do mundo Rails - Campus Party 2011
Fabio Akita
Seriously Playful
Seriously Playful
Daniel Burka
The Digital Toolbox - a discussion -Science Online '11
The Digital Toolbox - a discussion -Science Online '11
Kaitlin Thaney
User interface design for thumbs and fingers
User interface design for thumbs and fingers
Gregory Raiz
Digital changes everything
Digital changes everything
Sara Silfverberg
Ruby can haz Everyone
Ruby can haz Everyone
RubyX
Blackhat Workshop
Blackhat Workshop
wremes
Read the Docs: A completely open source Django project
Read the Docs: A completely open source Django project
ericholscher
HTML5 with Play Scala, CoffeeScript and Jade - Jfokus 2012
HTML5 with Play Scala, CoffeeScript and Jade - Jfokus 2012
Matt Raible

Recently uploaded (20)

Information Security Response Team Nepal_npCERT_Vice_President_Sudan_Jha.pdf
Information Security Response Team Nepal_npCERT_Vice_President_Sudan_Jha.pdf
ICT Frame Magazine Pvt. Ltd.
"Database isolation: how we deal with hundreds of direct connections to the d...
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
Cyber Defense Matrix Workshop - RSA Conference
Cyber Defense Matrix Workshop - RSA Conference
Priyanka Aash
AI VIDEO MAGAZINE - June 2025 - r/aivideo
AI VIDEO MAGAZINE - June 2025 - r/aivideo
1pcity Studios, Inc
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
OWASP Barcelona 2025 Threat Model Library
OWASP Barcelona 2025 Threat Model Library
PetraVukmirovic
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Safe Software
Securing AI - There Is No Try, Only Do!.pdf
Securing AI - There Is No Try, Only Do!.pdf
Priyanka Aash
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
2025_06_18 - OpenMetadata Community Meeting.pdf
2025_06_18 - OpenMetadata Community Meeting.pdf
OpenMetadata
The Future of Data, AI, and AR: Innovation Inspired by You.pdf
The Future of Data, AI, and AR: Innovation Inspired by You.pdf
Safe Software
OpenPOWER Foundation & Open-Source Core Innovations
OpenPOWER Foundation & Open-Source Core Innovations
IBM
AI vs Human Writing: Can You Tell the Difference?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
From Manual to Auto Searching- FME in the Driver's Seat
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance
10 Key Challenges for AI within the EU Data Protection Framework.pdf
10 Key Challenges for AI within the EU Data Protection Framework.pdf
Priyanka Aash
Securing Account Lifecycles in the Age of Deepfakes.pptx
Securing Account Lifecycles in the Age of Deepfakes.pptx
FIDO Alliance
Information Security Response Team Nepal_npCERT_Vice_President_Sudan_Jha.pdf
Information Security Response Team Nepal_npCERT_Vice_President_Sudan_Jha.pdf
ICT Frame Magazine Pvt. Ltd.
"Database isolation: how we deal with hundreds of direct connections to the d...
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
Cyber Defense Matrix Workshop - RSA Conference
Cyber Defense Matrix Workshop - RSA Conference
Priyanka Aash
AI VIDEO MAGAZINE - June 2025 - r/aivideo
AI VIDEO MAGAZINE - June 2025 - r/aivideo
1pcity Studios, Inc
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
OWASP Barcelona 2025 Threat Model Library
OWASP Barcelona 2025 Threat Model Library
PetraVukmirovic
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Safe Software
Securing AI - There Is No Try, Only Do!.pdf
Securing AI - There Is No Try, Only Do!.pdf
Priyanka Aash
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
2025_06_18 - OpenMetadata Community Meeting.pdf
2025_06_18 - OpenMetadata Community Meeting.pdf
OpenMetadata
The Future of Data, AI, and AR: Innovation Inspired by You.pdf
The Future of Data, AI, and AR: Innovation Inspired by You.pdf
Safe Software
OpenPOWER Foundation & Open-Source Core Innovations
OpenPOWER Foundation & Open-Source Core Innovations
IBM
AI vs Human Writing: Can You Tell the Difference?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
From Manual to Auto Searching- FME in the Driver's Seat
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance
10 Key Challenges for AI within the EU Data Protection Framework.pdf
10 Key Challenges for AI within the EU Data Protection Framework.pdf
Priyanka Aash
Securing Account Lifecycles in the Age of Deepfakes.pptx
Securing Account Lifecycles in the Age of Deepfakes.pptx
FIDO Alliance
Ad

Triskelion and Crapshoot

  • 1. Triskelion and Crapshoot Miami Ruby Brigade January 17, 2010 Monday, January 17, 2011
  • 2. Triskelion and Crapshoot Triskelion - Rails application UI Elements Crapshoot - Dice-rolling library Parsing with Ragel In鍖x and Post鍖x Notation Random numbers Monday, January 17, 2011
  • 3. Pen and Paper Games Pens Paper Talking Dice Snacks Books Monday, January 17, 2011
  • 4. Pen and Paper Games Pens Paper Talking Dice Snacks Books Monday, January 17, 2011
  • 7. m p sta e T im Monday, January 17, 2011
  • 8. m p e sta am e N T im Monday, January 17, 2011
  • 9. m p e d e sta am c o e N rip T im T Monday, January 17, 2011
  • 10. m p e d e n t sta am c o n te m e N Trip C o T i Monday, January 17, 2011
  • 11. Colored Name Easier to read than text-only nickname Shift the 鍖rst few bytes of hash into LSBs of color 油油def chat_color 油油油油digest = Digest::SHA1.hexdigest(self.tripcode + self.name) 油油油油r = (digest[0..1].to_i(16) >> 1) + 127 油油油油g = (digest[2..3].to_i(16) >> 1) + 127 油油油油b = (digest[4..5].to_i(16) >> 1) + 127 油油油油"##{r.to_s 16}#{g.to_s 16}#{b.to_s 16}" 油油end Monday, January 17, 2011
  • 12. Tripcode Identity without Password or Registration Used on 4chan 油油def tripcode_digest 油油油油[Digest::SHA1.digest(self.tripcode)]. pack('m'). tr('+/','-_')[0..7] 油油end Monday, January 17, 2011
  • 14. Chat auto_link chat.content, :html=>{:target=>'_blank'} http://www.鍖ickr.com/photos/lostvegas/2214183472/ Monday, January 17, 2011
  • 15. Roll 4d6v + 40 =57 ((3+5+6+6-3)+40) <span class="code"> <%=h roll.code %></span> <span class="result"> <%=h roll.result %></span> <span class="description"> <%=h roll.description %></span> Monday, January 17, 2011
  • 16. Triskelion and Crapshoot Triskelion - Rails application UI Elements Crapshoot - Dice-rolling library Parsing with Ragel In鍖x and Post鍖x Notation Random numbers Monday, January 17, 2011
  • 17. Dice Code 2d4 Two four-sided dice 1d100 + 8 One hundred-sided die plus eight 4d6v Four six-sided dice, minus the lowest Monday, January 17, 2011
  • 18. Dice Language A programming language is [] designed to express computations, [] to express algorithms precisely, or as a mode of human communication. http://en.wikipedia.org/wiki/Programming_language Monday, January 17, 2011
  • 19. Triskelion and Crapshoot Triskelion - Rails application UI Elements Crapshoot - Dice-rolling library Parsing with Ragel In鍖x and Post鍖x Notation Random numbers Monday, January 17, 2011
  • 20. Regular Language In computer science, a regular language is a formal language [] that satis鍖es the following equivalent properties: it can be accepted by a deterministic 鍖nite state machine it can be generated by a regular grammar http://en.wikipedia.org/wiki/Regular_language Monday, January 17, 2011
  • 21. Dice Language 4d6v + 3d10^ 2d6 - 300 Monday, January 17, 2011
  • 22. Dice Language 4d6v + 3d10^ 2d6 - 300 Expression Monday, January 17, 2011
  • 23. Dice Language 4d6v + 3d10^ 2d6 - 300 Monday, January 17, 2011
  • 24. Dice Language 2d6 - 300 Monday, January 17, 2011
  • 25. Dice Language 2d6 - 300 BinaryExpression Monday, January 17, 2011
  • 26. Dice Language 2d6 - 300 Monday, January 17, 2011
  • 27. Dice Language 2d6 - 300 Monday, January 17, 2011
  • 28. Dice Language 2d6 Series - 300 Monday, January 17, 2011
  • 29. Dice Language 2d6 Series Arithmetic - 300 Monday, January 17, 2011
  • 30. Dice Language 2d6 Series Arithmetic - Constant 300 Monday, January 17, 2011
  • 31. Dice Language 2d6 - 300 Monday, January 17, 2011
  • 32. Dice Language 0 % D 0 IE 1 F Number = digit+; I T AR R L E U Constant = Number; C G G E E UA R G Drop = ('^' | 'v'); N Series = Number 'd' Number Drop?; LA Arithmetic = ('+' | '-'); UnaryExpression = Series | Constant; BinaryExpression = UnaryExpression (space* Arithmetic space* UnaryExpression)+; Expression = UnaryExpression | BinaryExpression; Monday, January 17, 2011
  • 33. Ragel Ragel compiles executable 鍖nite state machines from regular languages. Ragel targets C, C++, Objective-C, D, Java and Ruby. http://www.complang.org/ragel/ Monday, January 17, 2011
  • 34. scan.rl %%{ 油油machine scanner; 油油action _number { @mark_num = p } Language Actions 油油action number { @num_stack.push atos(data[@mark_num..p-1]) } 油油action constant { @tokens << Tokens::Constant.new(@num_stack.pop) } 油油action series { 油油油油drop = @drop_current 油油油油@drop_current = nil 油油油油sides = @num_stack.pop 油油油油count = @num_stack.pop 油油油油@tokens << Tokens::Series.new(count, sides, drop) 油油} 油油action arithmetic { @tokens << Tokens::Arithmetic.new(data[p-1].chr) } 油油action drop { @drop_current = data[p-1].chr } 油油Number = digit+ >_number %number; 油油Constant = Number %constant; 油油Drop = ('^' | 'v') %drop; 油油Series = Number 'd' Number Drop? %series; 油油Arithmetic = ('+' | '-') %arithmetic; 油油UnaryExpression = Series | Constant; 油油BinaryExpression = UnaryExpression (space* Arithmetic space* UnaryExpression)+; 油油Expression = UnaryExpression | BinaryExpression; 油油main := Expression; }%% Monday, January 17, 2011
  • 36. Ragel scan.rl: 62 lines Monday, January 17, 2011
  • 37. Ragel scan.rl: 62 lines scan.rb: 330 lines Monday, January 17, 2011
  • 38. Ragel scan.rl: 62 lines scan.rb: 330 lines scan.pdf: priceless Monday, January 17, 2011
  • 39. scan.rl Transform constant, series, and arithmetic elements into Token objects 油油action constant { @tokens << Tokens::Constant.new(@num_stack.pop) } 油油action series { 油油油油drop = @drop_current 油油油油@drop_current = nil 油油油油sides = @num_stack.pop 油油油油count = @num_stack.pop 油油油油@tokens << Tokens::Series.new(count, sides, drop) 油油} 油油action arithmetic { @tokens << Tokens::Arithmetic.new(data[p-1].chr) } Monday, January 17, 2011
  • 40. Tokens Token#eval Turn token into result during evaluation Token#independent Determine if token needs the next token during post鍖xing Token#inspect <Crapshoot::Tokens::Series dice=4d6 drop=nothing> Monday, January 17, 2011
  • 41. Parsed Dice 4d6v + 3d10^ - 2d6 - 300 count: 4 count: 3 count: 2 value: 300 sides: 6 sides: 10 sides: 6 drop: v drop: ^ drop: nil Monday, January 17, 2011
  • 42. Triskelion and Crapshoot Triskelion - Rails application UI Elements Crapshoot - Dice-rolling library Parsing with Ragel In鍖x and Post鍖x Notation Random numbers Monday, January 17, 2011
  • 43. In鍖x & Post鍖x Monday, January 17, 2011
  • 44. In鍖x & Post鍖x In鍖x 1+2+3+4 Used for centuries Hard for computers Monday, January 17, 2011
  • 45. In鍖x & Post鍖x In鍖x Post鍖x 1+2+3+4 12+3+4+ Used for centuries Easy for computers Hard for computers Convertible from in鍖x Monday, January 17, 2011
  • 46. Parsed Dice 4d6v + 3d10^ - 2d6 - 300 count: 4 count: 3 count: 2 value: 300 sides: 6 sides: 10 sides: 6 drop: v drop: ^ drop: nil Monday, January 17, 2011
  • 47. Post鍖xed Dice 4d6v 3d10^ + 2d6 - 300 - count: 4 count: 3 count: 2 value: 300 sides: 6 sides: 10 sides: 6 drop: v drop: ^ drop: nil Monday, January 17, 2011
  • 49. Post鍖x Evaluation Series Monday, January 17, 2011
  • 50. Post鍖x Evaluation Series Roll dice Monday, January 17, 2011
  • 51. Post鍖x Evaluation Series Roll dice Do drop Monday, January 17, 2011
  • 52. Post鍖x Evaluation Series Roll dice Do drop Push result to stack Monday, January 17, 2011
  • 53. Post鍖x Evaluation Constant Series Roll dice Do drop Push result to stack Monday, January 17, 2011
  • 54. Post鍖x Evaluation Constant Series Push value to stack Roll dice Do drop Push result to stack Monday, January 17, 2011
  • 55. Post鍖x Evaluation Constant Series Push value to stack Roll dice Arithmetic Do drop Push result to stack Monday, January 17, 2011
  • 56. Post鍖x Evaluation Constant Series Push value to stack Roll dice Arithmetic Do drop Pop twice Push result to stack Monday, January 17, 2011
  • 57. Post鍖x Evaluation Constant Series Push value to stack Roll dice Arithmetic Do drop Pop twice Push result to stack Push result Monday, January 17, 2011
  • 58. Post鍖x Evaluation 4d6v 3d10^ + 2d6 - 300 - count: 4 count: 3 count: 2 value: 300 sides: 6 sides: 10 sides: 6 drop: v drop: ^ drop: nil Stack Monday, January 17, 2011
  • 59. Post鍖x Evaluation 15 3d10^ + 2d6 - 300 - count: 3 count: 2 value: 300 sides: 10 sides: 6 drop: ^ drop: nil Stack Monday, January 17, 2011
  • 60. Post鍖x Evaluation 3d10^ + 2d6 - 300 - count: 3 count: 2 value: 300 sides: 10 sides: 6 drop: ^ drop: nil Stack 15 Monday, January 17, 2011
  • 61. Post鍖x Evaluation 5 + 2d6 - 300 - count: 2 value: 300 sides: 6 drop: nil Stack 15 Monday, January 17, 2011
  • 62. Post鍖x Evaluation + 2d6 - 300 - count: 2 value: 300 sides: 6 drop: nil Stack 15 5 Monday, January 17, 2011
  • 63. Post鍖x Evaluation 2d6 - 300 - count: 2 value: 300 sides: 6 drop: nil Stack 15 + 5 Monday, January 17, 2011
  • 64. Post鍖x Evaluation 2d6 - 300 - count: 2 value: 300 sides: 6 drop: nil Stack 20 Monday, January 17, 2011
  • 65. Post鍖x Evaluation 9 - 300 - value: 300 Stack 20 Monday, January 17, 2011
  • 66. Post鍖x Evaluation - 300 - value: 300 Stack 20 9 Monday, January 17, 2011
  • 67. Post鍖x Evaluation 300 - value: 300 Stack 20 - 9 Monday, January 17, 2011
  • 68. Post鍖x Evaluation 300 - value: 300 Stack 11 Monday, January 17, 2011
  • 69. Post鍖x Evaluation 300 - Stack 11 Monday, January 17, 2011
  • 70. Post鍖x Evaluation - Stack 11 300 Monday, January 17, 2011
  • 71. Post鍖x Evaluation Stack 11 - 300 Monday, January 17, 2011
  • 72. Post鍖x Evaluation Stack -289 Monday, January 17, 2011
  • 73. Result -289 Monday, January 17, 2011
  • 74. Triskelion and Crapshoot Triskelion - Rails application UI Elements Crapshoot - Dice-rolling library Parsing with Ragel In鍖x and Post鍖x Notation Random numbers Monday, January 17, 2011
  • 75. Randomness Computers are deterministic Gather and store entropy where possible Use secure hashes to disburse entropy Monday, January 17, 2011
  • 76. Randomness Just use OpenSSL Monday, January 17, 2011
  • 77. SecureRandom Ruby 1.9 and ActiveSupport random_number random_bytes hex Monday, January 17, 2011
  • 78. Triskelion and Crapshoot Triskelion - Rails application UI Elements Crapshoot - Dice-rolling library Parsing with Ragel In鍖x and Post鍖x Notation Random numbers Monday, January 17, 2011