SlideShare ist ein Scribd-Unternehmen logo
1 von 44
Downloaden Sie, um offline zu lesen
Too
    Busy
Sharpening
 the
       Saw
I
AM
A
LIAR
!
Move upwards to
the unimportant
Try faking it
The most
important thing is
  the thing most
 easily forgotten
Be extravagant
Bridges - build -
     burn
Consider different
 fading systems
Courage!
# states                                                                                                                     def count_lines(code):
init     = 0                                                                                                                   current_line_is_code = False
code      = 1                                                                                                                  line_count = 0
slash     = 2                                                                                                                  current_state = init
slash_star = 3                                                                                                                 for c in code + 'n':
slash_slash = 4                                                                                                                   input = translate_input(c)
star     = 5                                                                                                                      current_state, contains_code = state_table[current_state][input]
string    = 6                                                                                                                     if contains_code:
bs_string = 7                                                                                                                         current_line_is_code = True
                                                                                                                                  if input == input_n and current_line_is_code:
# inputs                                                                                                                              line_count += 1
input_w = 0                                                                                                                           current_line_is_code = False
input_n = 1                                                                                                                    return line_count
input_l = 2
input_slash = 3                                                                                                              ### debug output ###
input_star = 4
input_quote = 5                                                                                                              state_str = ['init', 'code', '/','/*', '//', '*', '"', '']
input_bs = 6
                                                                                                                             def input_str(input):
def translate_input(input):                                                                                                    if input in ' t':
  if input == '*':                                                                                                                 return '<space>'
      return input_star                                                                                                        elif input in 'nr':
  elif input == '/':                                                                                                               return '<NL>'
      return input_slash                                                                                                       else:
  elif input == '"':                                                                                                               return '<' + input + '>'
      return input_quote
  elif input == ''':                                                                                                        def count_lines_with_debug_output(code):
      return input_bs                                                                                                          current_line_is_code = False
  elif input in ' t':                                                                                                         i=0
      return input_w                                                                                                           line_count = 0
  elif input in 'nr':                                                                                                        current_state = init
      return input_n                                                                                                           for c in code + 'n':
  else:                                                                                                                           print "n================="
      return input_l                                                                                                              print code[:i+1] + '$n'
                                                                                                                                  print state_str[current_state], 't', input_str(c), 't', '=>',
T = True
f = False                                                                                                                          current_state, contains_code = state_table[current_state][translate_input(c)]
                                                                                                                                   if contains_code:
# state_table[current_state][input] == (next_state, contains_code?)                                                                    current_line_is_code = True
state_table = [                                                                                                                   if translate_input(c) == input_n and current_line_is_code:
    [(init,    f), (init,     f), (code,      T), (slash,    f), (code,       T), (string,        T), (code,        T)],              line_count += 1
    [(code,       T), (init,     f), (code,      T), (slash,    f), (code,       T), (string,        T), (code,                        current_line_is_code = False
T)], 
    [(code,       T), (init,     T), (code,      T), (slash_slash,f), (slash_star, f), (string,           T), (code,               print state_str[current_state], ('(%s)' % line_count)
T)],                                                                                                                              i+=1
    [(slash_star, f), (slash_star, f), (slash_star, f), (slash_star, f), (star,         f), (slash_star, f),                    return line_count
(slash_star, f)], 
    [(slash_slash, f), (init,      f), (slash_slash,f), (slash_slash,f), (slash_slash,f), (slash_slash, f),                  import sys
(slash_slash, f)],                                                                                                          if __name__ == '__main__':
    [(slash_star, f), (slash_star, f), (slash_star, f), (init,     f), (star,      f), (string,       T), (slash_star,          code = sys.stdin.read()
f)],                                                                                                                           print count_lines_with_debug_output(code)

   [(string,    T),   (string,   T),   (string,    T),   (string,   T),   (string,   T), (init,      T), (bs_string,
T)], 
   [(string,    T),   (string,   T),   (string,    T),   (string,   T),   (string,   T), (string,     T), (string,
T)] 
]
# states                                                                                                                     def count_lines(code):
init     = 0                                                                                                                   current_line_is_code = False
code      = 1                                                                                                                  line_count = 0
slash     = 2                                                                                                                  current_state = init
slash_star = 3                                                                                                                 for c in code + 'n':
slash_slash = 4                                                                                                                   input = translate_input(c)
star     = 5                                                                                                                      current_state, contains_code = state_table[current_state][input]
string    = 6                                                                                                                     if contains_code:
bs_string = 7                                                                                                                         current_line_is_code = True
                                                                                                                                  if input == input_n and current_line_is_code:
# inputs                                                                                                                              line_count += 1
input_w = 0                                                                                                                           current_line_is_code = False
input_n = 1                                                                                                                    return line_count
input_l = 2
input_slash = 3                                                                                                              ### debug output ###
input_star = 4
input_quote = 5                                                                                                              state_str = ['init', 'code', '/','/*', '//', '*', '"', '']
input_bs = 6
                                                                                                                             def input_str(input):
def translate_input(input):                                                                                                    if input in ' t':
  if input == '*':                                                                                                                 return '<space>'
      return input_star                                                                                                        elif input in 'nr':


  puts gets.
  elif input == '/':                                                                                                               return '<NL>'
      return input_slash                                                                                                       else:
  elif input == '"':                                                                                                               return '<' + input + '>'
      return input_quote

       gsub(/(/*([^*]|[rn]|(*+([^*/]|[rn])))**+/)|(//.*)/,'').
  elif input == ''':
      return input_bs
  elif input in ' t':
                                                                                                                             def count_lines_with_debug_output(code):
                                                                                                                               current_line_is_code = False
                                                                                                                               i=0


       gsub(/^s*$/,'').gsub(/n+/,"n").split(/n/).length-1
      return input_w                                                                                                           line_count = 0
  elif input in 'nr':                                                                                                        current_state = init
      return input_n                                                                                                           for c in code + 'n':
  else:                                                                                                                           print "n================="
      return input_l                                                                                                              print code[:i+1] + '$n'
                                                                                                                                  print state_str[current_state], 't', input_str(c), 't', '=>',
T = True
f = False                                                                                                                          current_state, contains_code = state_table[current_state][translate_input(c)]
                                                                                                                                   if contains_code:
# state_table[current_state][input] == (next_state, contains_code?)                                                                    current_line_is_code = True
state_table = [                                                                                                                   if translate_input(c) == input_n and current_line_is_code:
    [(init,    f), (init,     f), (code,      T), (slash,    f), (code,       T), (string,        T), (code,        T)],              line_count += 1
    [(code,       T), (init,     f), (code,      T), (slash,    f), (code,       T), (string,        T), (code,                        current_line_is_code = False
T)], 
    [(code,       T), (init,     T), (code,      T), (slash_slash,f), (slash_star, f), (string,           T), (code,               print state_str[current_state], ('(%s)' % line_count)
T)],                                                                                                                              i+=1
    [(slash_star, f), (slash_star, f), (slash_star, f), (slash_star, f), (star,         f), (slash_star, f),                    return line_count
(slash_star, f)], 
    [(slash_slash, f), (init,      f), (slash_slash,f), (slash_slash,f), (slash_slash,f), (slash_slash, f),                  import sys
(slash_slash, f)],                                                                                                          if __name__ == '__main__':
    [(slash_star, f), (slash_star, f), (slash_star, f), (init,     f), (star,      f), (string,       T), (slash_star,          code = sys.stdin.read()
f)],                                                                                                                           print count_lines_with_debug_output(code)

   [(string,    T),   (string,   T),   (string,    T),   (string,   T),   (string,   T), (init,      T), (bs_string,
T)], 
   [(string,    T),   (string,   T),   (string,    T),   (string,   T),   (string,   T), (string,     T), (string,
T)] 
]
# states                                                                                                                     def count_lines(code):
init     = 0                                                                                                                   current_line_is_code = False
code      = 1                                                                                                                  line_count = 0
slash     = 2                                                                                                                  current_state = init
slash_star = 3                                                                                                                 for c in code + 'n':
slash_slash = 4                                                                                                                   input = translate_input(c)
star     = 5                                                                                                                      current_state, contains_code = state_table[current_state][input]
string    = 6                                                                                                                     if contains_code:
bs_string = 7                                                                                                                         current_line_is_code = True
                                                                                                                                  if input == input_n and current_line_is_code:
# inputs                                                                                                                              line_count += 1
input_w = 0                                                                                                                           current_line_is_code = False
input_n = 1                                                                                                                    return line_count
input_l = 2
input_slash = 3                                                                                                              ### debug output ###
input_star = 4
input_quote = 5                                                                                                              state_str = ['init', 'code', '/','/*', '//', '*', '"', '']
input_bs = 6
  What’s Happening?
def translate_input(input):
                                                                                                                             def input_str(input):
                                                                                                                               if input in ' t':
  if input == '*':                                                                                                                 return '<space>'
      return input_star                                                                                                        elif input in 'nr':


  puts gets.
  elif input == '/':                                                                                                               return '<NL>'
      return input_slash                                                                                                       else:
  elif input == '"':                                                                                                               return '<' + input + '>'
      return input_quote

       gsub(/(/*([^*]|[rn]|(*+([^*/]|[rn])))**+/)|(//.*)/,'').
  elif input == ''':
      return input_bs
  elif input in ' t':
                                                                                                                             def count_lines_with_debug_output(code):
                                                                                                                               current_line_is_code = False
                                                                                                                               i=0


       gsub(/^s*$/,'').gsub(/n+/,"n").split(/n/).length-1
      return input_w                                                                                                           line_count = 0
  elif input in 'nr':                                                                                                        current_state = init
      return input_n                                                                                                           for c in code + 'n':
  else:                                                                                                                           print "n================="
      return input_l                                                                                                              print code[:i+1] + '$n'
                                                                                                                                  print state_str[current_state], 't', input_str(c), 't', '=>',
T = True
f = False                                                                                                                          current_state, contains_code = state_table[current_state][translate_input(c)]
                                                                                                                                   if contains_code:
# state_table[current_state][input] == (next_state, contains_code?)                                                                    current_line_is_code = True
state_table = [ 
    [(init,
    [(code,
               f), (init,
                  T), (init,
                              f), (code,
                                 f), (code,
                                              T), (slash,
                                                 T), (slash,
                                                             f), (code,
                                                                f), (code,
                                                                              T), (string,
                                                                                 T), (string,
                                                                                                  T), (code,
                                                                                                     T), (code,
                                                                                                                    T)], 
                                                                                                                                   if translate_input(c) == input_n and current_line_is_code:
                                                                                                                                       line_count += 1
                                                                                                                                       current_line_is_code = False
                                                                                                                                                                                               10       Tweet
T)], 
    [(code,       T), (init,     T), (code,      T), (slash_slash,f), (slash_star, f), (string,           T), (code,               print state_str[current_state], ('(%s)' % line_count)
T)],                                                                                                                              i+=1
    [(slash_star, f), (slash_star, f), (slash_star, f), (slash_star, f), (star,         f), (slash_star, f),                    return line_count
(slash_star, f)], 
    [(slash_slash, f), (init,      f), (slash_slash,f), (slash_slash,f), (slash_slash,f), (slash_slash, f),                  import sys
(slash_slash, f)],                                                                                                          if __name__ == '__main__':
    [(slash_star, f), (slash_star, f), (slash_star, f), (init,     f), (star,      f), (string,       T), (slash_star,          code = sys.stdin.read()
f)],                                                                                                                           print count_lines_with_debug_output(code)

   [(string,    T),   (string,   T),   (string,    T),   (string,   T),   (string,   T), (init,      T), (bs_string,
T)], 
   [(string,    T),   (string,   T),   (string,    T),   (string,   T),   (string,   T), (string,     T), (string,
T)] 
]
andersnorås
  i t ’s o n l y c o d e , m o m
@anoras

mail@andersnoras.com

andersnoras.com

Weitere ähnliche Inhalte

Was ist angesagt?

FP 201 - Unit 6
FP 201 - Unit 6FP 201 - Unit 6
FP 201 - Unit 6rohassanie
 
C tech questions
C tech questionsC tech questions
C tech questionsvijay00791
 
C Programming Language Part 8
C Programming Language Part 8C Programming Language Part 8
C Programming Language Part 8Rumman Ansari
 
Mesics lecture 5 input – output in ‘c’
Mesics lecture 5   input – output in ‘c’Mesics lecture 5   input – output in ‘c’
Mesics lecture 5 input – output in ‘c’eShikshak
 
FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2rohassanie
 
CBSE Class XI Programming in C++
CBSE Class XI Programming in C++CBSE Class XI Programming in C++
CBSE Class XI Programming in C++Pranav Ghildiyal
 
P H P Part I, By Kian
P H P  Part  I,  By  KianP H P  Part  I,  By  Kian
P H P Part I, By Kianphelios
 
C Programming Language Part 9
C Programming Language Part 9C Programming Language Part 9
C Programming Language Part 9Rumman Ansari
 
46630497 fun-pointer-1
46630497 fun-pointer-146630497 fun-pointer-1
46630497 fun-pointer-1AmIt Prasad
 
Programming with GUTs
Programming with GUTsProgramming with GUTs
Programming with GUTsKevlin Henney
 
C Programming Language Step by Step Part 5
C Programming Language Step by Step Part 5C Programming Language Step by Step Part 5
C Programming Language Step by Step Part 5Rumman Ansari
 
Programming with GUTs
Programming with GUTsProgramming with GUTs
Programming with GUTsKevlin Henney
 
2.overview of c++ ________lecture2
2.overview of c++  ________lecture22.overview of c++  ________lecture2
2.overview of c++ ________lecture2Warui Maina
 
4 operators, expressions &amp; statements
4  operators, expressions &amp; statements4  operators, expressions &amp; statements
4 operators, expressions &amp; statementsMomenMostafa
 

Was ist angesagt? (20)

FP 201 - Unit 6
FP 201 - Unit 6FP 201 - Unit 6
FP 201 - Unit 6
 
Php basics
Php basicsPhp basics
Php basics
 
C tech questions
C tech questionsC tech questions
C tech questions
 
Fp201 unit4
Fp201 unit4Fp201 unit4
Fp201 unit4
 
C Programming Language Part 8
C Programming Language Part 8C Programming Language Part 8
C Programming Language Part 8
 
Mesics lecture 5 input – output in ‘c’
Mesics lecture 5   input – output in ‘c’Mesics lecture 5   input – output in ‘c’
Mesics lecture 5 input – output in ‘c’
 
FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2
 
Fp201 unit5 1
Fp201 unit5 1Fp201 unit5 1
Fp201 unit5 1
 
Basics of c
Basics of cBasics of c
Basics of c
 
CBSE Class XI Programming in C++
CBSE Class XI Programming in C++CBSE Class XI Programming in C++
CBSE Class XI Programming in C++
 
P H P Part I, By Kian
P H P  Part  I,  By  KianP H P  Part  I,  By  Kian
P H P Part I, By Kian
 
C Programming Language Part 9
C Programming Language Part 9C Programming Language Part 9
C Programming Language Part 9
 
46630497 fun-pointer-1
46630497 fun-pointer-146630497 fun-pointer-1
46630497 fun-pointer-1
 
Lecture20
Lecture20Lecture20
Lecture20
 
Ch 4
Ch 4Ch 4
Ch 4
 
Programming with GUTs
Programming with GUTsProgramming with GUTs
Programming with GUTs
 
C Programming Language Step by Step Part 5
C Programming Language Step by Step Part 5C Programming Language Step by Step Part 5
C Programming Language Step by Step Part 5
 
Programming with GUTs
Programming with GUTsProgramming with GUTs
Programming with GUTs
 
2.overview of c++ ________lecture2
2.overview of c++  ________lecture22.overview of c++  ________lecture2
2.overview of c++ ________lecture2
 
4 operators, expressions &amp; statements
4  operators, expressions &amp; statements4  operators, expressions &amp; statements
4 operators, expressions &amp; statements
 

Kürzlich hochgeladen

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 

Kürzlich hochgeladen (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

Too busy sharpening the saw

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6. Too Busy Sharpening the Saw
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12. I
  • 13. AM
  • 14. A
  • 15. LIAR
  • 16. !
  • 17.
  • 18.
  • 19. Move upwards to the unimportant
  • 20.
  • 22.
  • 23. The most important thing is the thing most easily forgotten
  • 24.
  • 26.
  • 27. Bridges - build - burn
  • 28.
  • 30.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39. # states def count_lines(code): init = 0 current_line_is_code = False code = 1 line_count = 0 slash = 2 current_state = init slash_star = 3 for c in code + 'n': slash_slash = 4 input = translate_input(c) star = 5 current_state, contains_code = state_table[current_state][input] string = 6 if contains_code: bs_string = 7 current_line_is_code = True if input == input_n and current_line_is_code: # inputs line_count += 1 input_w = 0 current_line_is_code = False input_n = 1 return line_count input_l = 2 input_slash = 3 ### debug output ### input_star = 4 input_quote = 5 state_str = ['init', 'code', '/','/*', '//', '*', '"', ''] input_bs = 6 def input_str(input): def translate_input(input): if input in ' t': if input == '*': return '<space>' return input_star elif input in 'nr': elif input == '/': return '<NL>' return input_slash else: elif input == '"': return '<' + input + '>' return input_quote elif input == ''': def count_lines_with_debug_output(code): return input_bs current_line_is_code = False elif input in ' t': i=0 return input_w line_count = 0 elif input in 'nr': current_state = init return input_n for c in code + 'n': else: print "n=================" return input_l print code[:i+1] + '$n' print state_str[current_state], 't', input_str(c), 't', '=>', T = True f = False current_state, contains_code = state_table[current_state][translate_input(c)] if contains_code: # state_table[current_state][input] == (next_state, contains_code?) current_line_is_code = True state_table = [ if translate_input(c) == input_n and current_line_is_code: [(init, f), (init, f), (code, T), (slash, f), (code, T), (string, T), (code, T)], line_count += 1 [(code, T), (init, f), (code, T), (slash, f), (code, T), (string, T), (code, current_line_is_code = False T)], [(code, T), (init, T), (code, T), (slash_slash,f), (slash_star, f), (string, T), (code, print state_str[current_state], ('(%s)' % line_count) T)], i+=1 [(slash_star, f), (slash_star, f), (slash_star, f), (slash_star, f), (star, f), (slash_star, f), return line_count (slash_star, f)], [(slash_slash, f), (init, f), (slash_slash,f), (slash_slash,f), (slash_slash,f), (slash_slash, f), import sys (slash_slash, f)], if __name__ == '__main__': [(slash_star, f), (slash_star, f), (slash_star, f), (init, f), (star, f), (string, T), (slash_star, code = sys.stdin.read() f)], print count_lines_with_debug_output(code) [(string, T), (string, T), (string, T), (string, T), (string, T), (init, T), (bs_string, T)], [(string, T), (string, T), (string, T), (string, T), (string, T), (string, T), (string, T)] ]
  • 40. # states def count_lines(code): init = 0 current_line_is_code = False code = 1 line_count = 0 slash = 2 current_state = init slash_star = 3 for c in code + 'n': slash_slash = 4 input = translate_input(c) star = 5 current_state, contains_code = state_table[current_state][input] string = 6 if contains_code: bs_string = 7 current_line_is_code = True if input == input_n and current_line_is_code: # inputs line_count += 1 input_w = 0 current_line_is_code = False input_n = 1 return line_count input_l = 2 input_slash = 3 ### debug output ### input_star = 4 input_quote = 5 state_str = ['init', 'code', '/','/*', '//', '*', '"', ''] input_bs = 6 def input_str(input): def translate_input(input): if input in ' t': if input == '*': return '<space>' return input_star elif input in 'nr': puts gets. elif input == '/': return '<NL>' return input_slash else: elif input == '"': return '<' + input + '>' return input_quote gsub(/(/*([^*]|[rn]|(*+([^*/]|[rn])))**+/)|(//.*)/,''). elif input == ''': return input_bs elif input in ' t': def count_lines_with_debug_output(code): current_line_is_code = False i=0 gsub(/^s*$/,'').gsub(/n+/,"n").split(/n/).length-1 return input_w line_count = 0 elif input in 'nr': current_state = init return input_n for c in code + 'n': else: print "n=================" return input_l print code[:i+1] + '$n' print state_str[current_state], 't', input_str(c), 't', '=>', T = True f = False current_state, contains_code = state_table[current_state][translate_input(c)] if contains_code: # state_table[current_state][input] == (next_state, contains_code?) current_line_is_code = True state_table = [ if translate_input(c) == input_n and current_line_is_code: [(init, f), (init, f), (code, T), (slash, f), (code, T), (string, T), (code, T)], line_count += 1 [(code, T), (init, f), (code, T), (slash, f), (code, T), (string, T), (code, current_line_is_code = False T)], [(code, T), (init, T), (code, T), (slash_slash,f), (slash_star, f), (string, T), (code, print state_str[current_state], ('(%s)' % line_count) T)], i+=1 [(slash_star, f), (slash_star, f), (slash_star, f), (slash_star, f), (star, f), (slash_star, f), return line_count (slash_star, f)], [(slash_slash, f), (init, f), (slash_slash,f), (slash_slash,f), (slash_slash,f), (slash_slash, f), import sys (slash_slash, f)], if __name__ == '__main__': [(slash_star, f), (slash_star, f), (slash_star, f), (init, f), (star, f), (string, T), (slash_star, code = sys.stdin.read() f)], print count_lines_with_debug_output(code) [(string, T), (string, T), (string, T), (string, T), (string, T), (init, T), (bs_string, T)], [(string, T), (string, T), (string, T), (string, T), (string, T), (string, T), (string, T)] ]
  • 41. # states def count_lines(code): init = 0 current_line_is_code = False code = 1 line_count = 0 slash = 2 current_state = init slash_star = 3 for c in code + 'n': slash_slash = 4 input = translate_input(c) star = 5 current_state, contains_code = state_table[current_state][input] string = 6 if contains_code: bs_string = 7 current_line_is_code = True if input == input_n and current_line_is_code: # inputs line_count += 1 input_w = 0 current_line_is_code = False input_n = 1 return line_count input_l = 2 input_slash = 3 ### debug output ### input_star = 4 input_quote = 5 state_str = ['init', 'code', '/','/*', '//', '*', '"', ''] input_bs = 6 What’s Happening? def translate_input(input): def input_str(input): if input in ' t': if input == '*': return '<space>' return input_star elif input in 'nr': puts gets. elif input == '/': return '<NL>' return input_slash else: elif input == '"': return '<' + input + '>' return input_quote gsub(/(/*([^*]|[rn]|(*+([^*/]|[rn])))**+/)|(//.*)/,''). elif input == ''': return input_bs elif input in ' t': def count_lines_with_debug_output(code): current_line_is_code = False i=0 gsub(/^s*$/,'').gsub(/n+/,"n").split(/n/).length-1 return input_w line_count = 0 elif input in 'nr': current_state = init return input_n for c in code + 'n': else: print "n=================" return input_l print code[:i+1] + '$n' print state_str[current_state], 't', input_str(c), 't', '=>', T = True f = False current_state, contains_code = state_table[current_state][translate_input(c)] if contains_code: # state_table[current_state][input] == (next_state, contains_code?) current_line_is_code = True state_table = [ [(init, [(code, f), (init, T), (init, f), (code, f), (code, T), (slash, T), (slash, f), (code, f), (code, T), (string, T), (string, T), (code, T), (code, T)], if translate_input(c) == input_n and current_line_is_code: line_count += 1 current_line_is_code = False 10 Tweet T)], [(code, T), (init, T), (code, T), (slash_slash,f), (slash_star, f), (string, T), (code, print state_str[current_state], ('(%s)' % line_count) T)], i+=1 [(slash_star, f), (slash_star, f), (slash_star, f), (slash_star, f), (star, f), (slash_star, f), return line_count (slash_star, f)], [(slash_slash, f), (init, f), (slash_slash,f), (slash_slash,f), (slash_slash,f), (slash_slash, f), import sys (slash_slash, f)], if __name__ == '__main__': [(slash_star, f), (slash_star, f), (slash_star, f), (init, f), (star, f), (string, T), (slash_star, code = sys.stdin.read() f)], print count_lines_with_debug_output(code) [(string, T), (string, T), (string, T), (string, T), (string, T), (init, T), (bs_string, T)], [(string, T), (string, T), (string, T), (string, T), (string, T), (string, T), (string, T)] ]
  • 42.
  • 43. andersnorås i t ’s o n l y c o d e , m o m