+ - 0:00:00
Notes for current slide
Notes for next slide

Hacking for Historians

Session 2 - Breaking Down Code

Matthias Bannert** (@whatsgoodio) and Ina Serif++

ETH Zurich**, Uni Basel++

2019-09-25

1 / 11

Take Aways from Session I

Why Code When You Can Click?

2 / 11

Reproducibility

reproducibility

3 / 11

Visualization

4 / 11

Code as a Communication Channel

5 / 11

Automation & Scaling

6 / 11

Or in Other Words ...

7 / 11

Breaking Down Code: General Advice

  1. 'Eat Cake First', i.e., run the code see what it does (unless you work in security)
  2. Read line by line
  3. Read lines from the inside out
  4. Understand scoping
8 / 11

Breaking Down Code: A Minimal API Wrapper

  1. Go to github.com/mbannert/dh-2019/.... to see what we will be working on
  2. Copy & Paste the code from the raw version to a new R file (to create a new file press CMD+Shift+N on a Mac / Ctrl+Shift+N on Win & Linux)

  3. Select all the code in the new file and run the selection (Cmd+Enter on a Mac / Ctrl+Enter on Win & Linux)

  4. What happens? Do you get errors? Can you make sense of the error messages?

Let's understand what we do here and break down the code.

9 / 11

Task 1: Write Your Own Wrapper

This is the URL for the METs search endpoint: https://collectionapi.metmuseum.org/public/collection/v1/search?q=

Write an own wrapper function called search_MET that

  • a search character string as its only argument
  • returns a vector of object ids as results

BONUS: Find / explain what the function should return in case there are no results found.

10 / 11
11 / 11

Take Aways from Session I

Why Code When You Can Click?

2 / 11
Paused

Help

Keyboard shortcuts

, , Pg Up, k Go to previous slide
, , Pg Dn, Space, j Go to next slide
Home Go to first slide
End Go to last slide
Number + Return Go to specific slide
b / m / f Toggle blackout / mirrored / fullscreen mode
c Clone slideshow
p Toggle presenter mode
t Restart the presentation timer
?, h Toggle this help
Esc Back to slideshow