SlideShare a Scribd company logo
1 of 58
Download to read offline
hacker
     101/102
 code4lib 2010 preconference
Asheville, NC, USA 2010-02-21
i. intro

why are we here?
learn to hack?
...not exactly
we work in libraries
    so we can
   help people
we hack
to help ourselves
   help others
what’s a good hacker?
languages?
  standards?
    jargon?
     math?
     logic?
frameworks?
nope!
a good hacker
      knows
when to ask for help
a good hacker
      knows
how to ask for help
a good hacker
     knows how
to help other hackers
a good hacker
knows other hackers
   to ask for help
when to ask
  how to ask
how to answer
 whom to ask
i’m here
   because i want
to be able to ask you
when to ask?
thirty minute rule
for today:
three minute rule
how to ask?
    see “How to ask
questions the smart way”
we’ll get started
    together
basics in Processing
   regexes in JavaScript
glue it together in Python
explore on your own
get comfortable
 asking for help
ii. the basics

Processing
canvas, grid, points
200   300




200

400
lines, rects, ellipses
start




end
syntax, functions, errors
don’t be afraid
to break stuff
variables, loops
test
type “integer”
             initial value               increment




                                    repeating
                                     actions
every lang has loops
• for (a=blah, a<foo, a=a+bar) {...}
• for each (foo in blah) {...}
• for i in range(20): ...
• while (foo != bar) do {...}
• next, continue, break
more variables, loops
even more variables, loops
explore on your own
iii. functions, objects,
      the main loop
why functions?
setup, draw, void
function structure

RETURN_TYPE FUNCTION_NAME ([var a, ...])
            {...statements...}
setup, draw
•   void: returns nothing
    (into the void!)
•   setup: prep stuff
• draw: the “animation
    loop” or “main”
different kinds of “main”
• Processing: draw() is like an
  animation “cell”
• in a GUI: the user feedback loop
• command-line app: parse args,
  then main()
• web app: the user feedback loop
setup, draw, void
we can
write this better
setup, draw, void
see the problem?
setup, draw, void
DRY
Don’t Repeat Yourself
a little
better
more
  task
specific
add
delay
(10);
initialization
  now
try this
               no loop!



               if/else
                  i.e.
            “conditional”
•   draw() is already a loop;
    why another?

•   “i” becomes state

• tightens up draw()
what about objects?
obj
ect
 i
fied
• it says what it is
• it removes a lot of
 repeated noise

•it’s kinda overkill here

• we don’t use rp1 and rp2
 again
no single answer
• design a matter of taste
• sometimes things should
    be called what they mean
•   sometimes an “int i” is
    just an “int i”
•   think about what you’ll
    understand later
explore on your own

More Related Content

Viewers also liked

Bespoke Digital Media - Top 20 Tools for hacking
Bespoke Digital Media - Top 20 Tools for hackingBespoke Digital Media - Top 20 Tools for hacking
Bespoke Digital Media - Top 20 Tools for hackingbespokedigitalmedia
 
Kali Linux, Introduction to Ethical Hacking and Penetration Tools
Kali Linux, Introduction to Ethical Hacking and Penetration ToolsKali Linux, Introduction to Ethical Hacking and Penetration Tools
Kali Linux, Introduction to Ethical Hacking and Penetration ToolsRassoul Ghaznavi Zadeh
 
Hacking with Remote Admin Tools (RAT)
 Hacking with Remote Admin Tools (RAT) Hacking with Remote Admin Tools (RAT)
Hacking with Remote Admin Tools (RAT)Zoltan Balazs
 
How To Be A Hacker
How To Be A HackerHow To Be A Hacker
How To Be A HackerPaul Tarjan
 
Course on Ehtical Hacking - Introduction
Course on Ehtical Hacking - IntroductionCourse on Ehtical Hacking - Introduction
Course on Ehtical Hacking - IntroductionBharat Thakkar
 
How To Become A Successful Hacker In Only 10 Years
How To Become A Successful Hacker In Only 10 YearsHow To Become A Successful Hacker In Only 10 Years
How To Become A Successful Hacker In Only 10 Yearsluke_bkk
 
Introduction To Ethical Hacking
Introduction To Ethical HackingIntroduction To Ethical Hacking
Introduction To Ethical HackingNeel Kamal
 
ethical hacking in the modern times
ethical hacking in the modern timesethical hacking in the modern times
ethical hacking in the modern timesjeshin jose
 

Viewers also liked (11)

Bespoke Digital Media - Top 20 Tools for hacking
Bespoke Digital Media - Top 20 Tools for hackingBespoke Digital Media - Top 20 Tools for hacking
Bespoke Digital Media - Top 20 Tools for hacking
 
Kali Linux, Introduction to Ethical Hacking and Penetration Tools
Kali Linux, Introduction to Ethical Hacking and Penetration ToolsKali Linux, Introduction to Ethical Hacking and Penetration Tools
Kali Linux, Introduction to Ethical Hacking and Penetration Tools
 
Hacking with Remote Admin Tools (RAT)
 Hacking with Remote Admin Tools (RAT) Hacking with Remote Admin Tools (RAT)
Hacking with Remote Admin Tools (RAT)
 
How To Be A Hacker
How To Be A HackerHow To Be A Hacker
How To Be A Hacker
 
Windows hacking 1
Windows hacking 1Windows hacking 1
Windows hacking 1
 
Ethical hacking with Python tools
Ethical hacking with Python toolsEthical hacking with Python tools
Ethical hacking with Python tools
 
Black hat hackers
Black hat hackersBlack hat hackers
Black hat hackers
 
Course on Ehtical Hacking - Introduction
Course on Ehtical Hacking - IntroductionCourse on Ehtical Hacking - Introduction
Course on Ehtical Hacking - Introduction
 
How To Become A Successful Hacker In Only 10 Years
How To Become A Successful Hacker In Only 10 YearsHow To Become A Successful Hacker In Only 10 Years
How To Become A Successful Hacker In Only 10 Years
 
Introduction To Ethical Hacking
Introduction To Ethical HackingIntroduction To Ethical Hacking
Introduction To Ethical Hacking
 
ethical hacking in the modern times
ethical hacking in the modern timesethical hacking in the modern times
ethical hacking in the modern times
 

Similar to Hacker 101/102 - Introduction to Programming w/Processing

Test First Teaching
Test First TeachingTest First Teaching
Test First TeachingSarah Allen
 
Code Like Pythonista
Code Like PythonistaCode Like Pythonista
Code Like PythonistaChiyoung Song
 
Functions, List and String methods
Functions, List and String methodsFunctions, List and String methods
Functions, List and String methodsPranavSB
 
Java Building Blocks
Java Building BlocksJava Building Blocks
Java Building BlocksCate Huston
 
Boost Maintainability
Boost MaintainabilityBoost Maintainability
Boost MaintainabilityMosky Liu
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />tutorialsruby
 
&lt;b>PHP&lt;/b> Reference: Beginner to Intermediate &lt;b>PHP5&lt;/b>
&lt;b>PHP&lt;/b> Reference: Beginner to Intermediate &lt;b>PHP5&lt;/b>&lt;b>PHP&lt;/b> Reference: Beginner to Intermediate &lt;b>PHP5&lt;/b>
&lt;b>PHP&lt;/b> Reference: Beginner to Intermediate &lt;b>PHP5&lt;/b>tutorialsruby
 
Drupal 8: A story of growing up and getting off the island
Drupal 8: A story of growing up and getting off the islandDrupal 8: A story of growing up and getting off the island
Drupal 8: A story of growing up and getting off the islandAngela Byron
 
Python教程 / Python tutorial
Python教程 / Python tutorialPython教程 / Python tutorial
Python教程 / Python tutorialee0703
 
Mastering Python lesson 3a
Mastering Python lesson 3aMastering Python lesson 3a
Mastering Python lesson 3aRuth Marvin
 
Python Novice to Ninja
Python Novice to NinjaPython Novice to Ninja
Python Novice to NinjaAl Sayed Gamal
 
Functional Programming for Busy Object Oriented Programmers
Functional Programming for Busy Object Oriented ProgrammersFunctional Programming for Busy Object Oriented Programmers
Functional Programming for Busy Object Oriented ProgrammersDiego Freniche Brito
 
JS Fest 2018. Douglas Crockford. The Better Parts
JS Fest 2018. Douglas Crockford. The Better PartsJS Fest 2018. Douglas Crockford. The Better Parts
JS Fest 2018. Douglas Crockford. The Better PartsJSFestUA
 
Speaking 'Development Language' (Or, how to get your hands dirty with technic...
Speaking 'Development Language' (Or, how to get your hands dirty with technic...Speaking 'Development Language' (Or, how to get your hands dirty with technic...
Speaking 'Development Language' (Or, how to get your hands dirty with technic...Julie Meloni
 
Password Storage Sucks!
Password Storage Sucks!Password Storage Sucks!
Password Storage Sucks!nerdybeardo
 

Similar to Hacker 101/102 - Introduction to Programming w/Processing (20)

Test First Teaching
Test First TeachingTest First Teaching
Test First Teaching
 
Code Like Pythonista
Code Like PythonistaCode Like Pythonista
Code Like Pythonista
 
Functions, List and String methods
Functions, List and String methodsFunctions, List and String methods
Functions, List and String methods
 
Python: The Dynamic!
Python: The Dynamic!Python: The Dynamic!
Python: The Dynamic!
 
Java Building Blocks
Java Building BlocksJava Building Blocks
Java Building Blocks
 
Boost Maintainability
Boost MaintainabilityBoost Maintainability
Boost Maintainability
 
Fancy talk
Fancy talkFancy talk
Fancy talk
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
 
&lt;b>PHP&lt;/b> Reference: Beginner to Intermediate &lt;b>PHP5&lt;/b>
&lt;b>PHP&lt;/b> Reference: Beginner to Intermediate &lt;b>PHP5&lt;/b>&lt;b>PHP&lt;/b> Reference: Beginner to Intermediate &lt;b>PHP5&lt;/b>
&lt;b>PHP&lt;/b> Reference: Beginner to Intermediate &lt;b>PHP5&lt;/b>
 
Python in 90 minutes
Python in 90 minutesPython in 90 minutes
Python in 90 minutes
 
Drupal 8: A story of growing up and getting off the island
Drupal 8: A story of growing up and getting off the islandDrupal 8: A story of growing up and getting off the island
Drupal 8: A story of growing up and getting off the island
 
Python教程 / Python tutorial
Python教程 / Python tutorialPython教程 / Python tutorial
Python教程 / Python tutorial
 
Mastering Python lesson 3a
Mastering Python lesson 3aMastering Python lesson 3a
Mastering Python lesson 3a
 
Python Novice to Ninja
Python Novice to NinjaPython Novice to Ninja
Python Novice to Ninja
 
Functional Programming for Busy Object Oriented Programmers
Functional Programming for Busy Object Oriented ProgrammersFunctional Programming for Busy Object Oriented Programmers
Functional Programming for Busy Object Oriented Programmers
 
JS Fest 2018. Douglas Crockford. The Better Parts
JS Fest 2018. Douglas Crockford. The Better PartsJS Fest 2018. Douglas Crockford. The Better Parts
JS Fest 2018. Douglas Crockford. The Better Parts
 
Speaking 'Development Language' (Or, how to get your hands dirty with technic...
Speaking 'Development Language' (Or, how to get your hands dirty with technic...Speaking 'Development Language' (Or, how to get your hands dirty with technic...
Speaking 'Development Language' (Or, how to get your hands dirty with technic...
 
Lua pitfalls
Lua pitfallsLua pitfalls
Lua pitfalls
 
Password Storage Sucks!
Password Storage Sucks!Password Storage Sucks!
Password Storage Sucks!
 
Conf orm - explain
Conf orm - explainConf orm - explain
Conf orm - explain
 

More from Dan Chudnov

Overview of Adaptive Blocking for DDL Research Lab
Overview of Adaptive Blocking for DDL Research LabOverview of Adaptive Blocking for DDL Research Lab
Overview of Adaptive Blocking for DDL Research LabDan Chudnov
 
stuff i'm learning in data school
stuff i'm learning in data schoolstuff i'm learning in data school
stuff i'm learning in data schoolDan Chudnov
 
Capturing the Ephemeral: Collecting Social Media with Social Feed Manager
Capturing the Ephemeral: Collecting Social Media with Social Feed ManagerCapturing the Ephemeral: Collecting Social Media with Social Feed Manager
Capturing the Ephemeral: Collecting Social Media with Social Feed ManagerDan Chudnov
 
think locally, code globally - dchud's code4lib japan 2013 talk
think locally, code globally - dchud's code4lib japan 2013 talkthink locally, code globally - dchud's code4lib japan 2013 talk
think locally, code globally - dchud's code4lib japan 2013 talkDan Chudnov
 
what i want from linked data
what i want from linked datawhat i want from linked data
what i want from linked dataDan Chudnov
 
collecting twitter data w/social feed manager
collecting twitter data w/social feed managercollecting twitter data w/social feed manager
collecting twitter data w/social feed managerDan Chudnov
 
web archiving tools and technologies
web archiving tools and technologiesweb archiving tools and technologies
web archiving tools and technologiesDan Chudnov
 
20121018 Access "social feed manager"
20121018 Access "social feed manager"20121018 Access "social feed manager"
20121018 Access "social feed manager"Dan Chudnov
 
WWIC - Library Linked Data as a Customer Service Medium
WWIC - Library Linked Data as a Customer Service MediumWWIC - Library Linked Data as a Customer Service Medium
WWIC - Library Linked Data as a Customer Service MediumDan Chudnov
 
introduction to Django in five slides
introduction to Django in five slides introduction to Django in five slides
introduction to Django in five slides Dan Chudnov
 
Linking Library Data on the Web
Linking Library Data on the WebLinking Library Data on the Web
Linking Library Data on the WebDan Chudnov
 
CTS at LC - Access 2010
CTS at LC - Access 2010CTS at LC - Access 2010
CTS at LC - Access 2010Dan Chudnov
 
Repository Development at LC - Access 2009
Repository Development at LC - Access 2009Repository Development at LC - Access 2009
Repository Development at LC - Access 2009Dan Chudnov
 
Hacker 102 - regexes w/Javascript, Python
Hacker 102 - regexes w/Javascript, PythonHacker 102 - regexes w/Javascript, Python
Hacker 102 - regexes w/Javascript, PythonDan Chudnov
 
Hacker102 - RegExes w/JavaScript and Python
Hacker102 - RegExes w/JavaScript and PythonHacker102 - RegExes w/JavaScript and Python
Hacker102 - RegExes w/JavaScript and PythonDan Chudnov
 
TCDL 2009 keynote: Better living through linking
TCDL 2009 keynote: Better living through linkingTCDL 2009 keynote: Better living through linking
TCDL 2009 keynote: Better living through linkingDan Chudnov
 

More from Dan Chudnov (16)

Overview of Adaptive Blocking for DDL Research Lab
Overview of Adaptive Blocking for DDL Research LabOverview of Adaptive Blocking for DDL Research Lab
Overview of Adaptive Blocking for DDL Research Lab
 
stuff i'm learning in data school
stuff i'm learning in data schoolstuff i'm learning in data school
stuff i'm learning in data school
 
Capturing the Ephemeral: Collecting Social Media with Social Feed Manager
Capturing the Ephemeral: Collecting Social Media with Social Feed ManagerCapturing the Ephemeral: Collecting Social Media with Social Feed Manager
Capturing the Ephemeral: Collecting Social Media with Social Feed Manager
 
think locally, code globally - dchud's code4lib japan 2013 talk
think locally, code globally - dchud's code4lib japan 2013 talkthink locally, code globally - dchud's code4lib japan 2013 talk
think locally, code globally - dchud's code4lib japan 2013 talk
 
what i want from linked data
what i want from linked datawhat i want from linked data
what i want from linked data
 
collecting twitter data w/social feed manager
collecting twitter data w/social feed managercollecting twitter data w/social feed manager
collecting twitter data w/social feed manager
 
web archiving tools and technologies
web archiving tools and technologiesweb archiving tools and technologies
web archiving tools and technologies
 
20121018 Access "social feed manager"
20121018 Access "social feed manager"20121018 Access "social feed manager"
20121018 Access "social feed manager"
 
WWIC - Library Linked Data as a Customer Service Medium
WWIC - Library Linked Data as a Customer Service MediumWWIC - Library Linked Data as a Customer Service Medium
WWIC - Library Linked Data as a Customer Service Medium
 
introduction to Django in five slides
introduction to Django in five slides introduction to Django in five slides
introduction to Django in five slides
 
Linking Library Data on the Web
Linking Library Data on the WebLinking Library Data on the Web
Linking Library Data on the Web
 
CTS at LC - Access 2010
CTS at LC - Access 2010CTS at LC - Access 2010
CTS at LC - Access 2010
 
Repository Development at LC - Access 2009
Repository Development at LC - Access 2009Repository Development at LC - Access 2009
Repository Development at LC - Access 2009
 
Hacker 102 - regexes w/Javascript, Python
Hacker 102 - regexes w/Javascript, PythonHacker 102 - regexes w/Javascript, Python
Hacker 102 - regexes w/Javascript, Python
 
Hacker102 - RegExes w/JavaScript and Python
Hacker102 - RegExes w/JavaScript and PythonHacker102 - RegExes w/JavaScript and Python
Hacker102 - RegExes w/JavaScript and Python
 
TCDL 2009 keynote: Better living through linking
TCDL 2009 keynote: Better living through linkingTCDL 2009 keynote: Better living through linking
TCDL 2009 keynote: Better living through linking
 

Hacker 101/102 - Introduction to Programming w/Processing