Skip to content

Commit

Permalink
Merge pull request #6 from gsbdarc/day1
Browse files Browse the repository at this point in the history
Wrote Content for Day 1
  • Loading branch information
brad-ross authored Jul 11, 2024
2 parents ee10db4 + b9f03cf commit 7737ecf
Show file tree
Hide file tree
Showing 22 changed files with 549 additions and 47 deletions.
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,12 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

#build stuff
# File system nuisance files
**/.DS_Store

# Jekyll build stuff
/docs/.vendor/
/docs/_site/
/docs/.bundle/
Gemfile.lock
.bundle/


2 changes: 2 additions & 0 deletions docs/Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
source 'https://rubygems.org'
gem 'github-pages', group: :jekyll_plugins
gem "just-the-docs"

gem "webrick", "~> 1.8"
38 changes: 37 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,43 @@ permalink: /:path/
seo:
type: Course
name: RF Coding Bootcamp 2024
updateDate: 2024-06-25
updateDate: 2024-07-10
---

# RF Coding Bootcamp 2024

## "Coding Bootcamp" Goals

- To help you get comfortable working on *large* social science research projects
- Use too-big-for-your-laptop, often proprietary datasets, do computationally intensive analyses
- Tables, figures, and other results generated by thousands of lines of code spread across many files
- Complex enough to require collaboration between >2 people (including past selves)
- To help you learn to use Stanford GSB’s substantial computing resources
- This is not primarily about coding; we’re assuming you’ve done some programming, but talk to us if you haven’t!
- Programming languages you might have used include R, Python, Julia, MATLAB, and/or STATA
- Nor is this a bootcamp; these sessions should be helpful to *you*, so let us know if they aren’t!

## Who are we?

### Brad Ross

- A rising 5th year PhD student in Economics at the GSB
- Research in Urban Economics and Econometrics
- From San Mateo, California, did my undergrad (Applied Math) and masters (Computer Science and Statistics) at Stanford
- Decided to stick around even longer for a PhD
- Outside of research and teaching, I love running, cooking/baking, making music, and watching tennis

### Natalya Rapstine

I'm a research computing specialist in the DARC team at the Research Hub at Stanford GSB. Prior to joining the DARC team in 2020, I worked in government and industry in high performance computing developing parallel scientific code and applications. My expertise is in high performance computing, parallel programming, scientific computing, machine learning, deep learning applications, and statistical methods in Python and R languages. I have a BS degree in earth science from Rice University and an MS degree in statistics from Colorado School of Mines.

My favorite place on the planet is San Diego and my hobbies are video games (League of Legends mostly), music festivals, reading sci-fi, running and yoga (also taking care of my spunky 7-year old but that’s a full time job, not a hobby…)

### Jeff Ott

## The DARC Team:
![](../assets/images/gsbrh_092122_0021.jpg)

### Contact Us
- Join <a href="https://circlerss.slack.com/archives/C01JXJ6U4E5" target="_blank">#gsb-yen-users Slack channel</a> where you can ask and answer GSB Yen related questions and share your Yen usage wisdom with the community - Yen users and the DARC team. We will also use this channel to announce Yen related workshops and poll users about the Yens to improve our services. In case the link does not work, open Slack application, search for <b>#gsb-yen-users</b> channel in Channels and join it.
- Email us at: <a href="mailto:[email protected]">[email protected].</a>
9 changes: 9 additions & 0 deletions docs/day1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: Day 1
layout: page
nav_order: 2
has_children: true
updateDate: 2024-07-03
---

# {{ page.title }}
48 changes: 48 additions & 0 deletions docs/day1/1_the_shell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
title: 1. The Shell
layout: page
nav_order: 1
parent: Day 1
updateDate: 2024-07-10
---

# {{ page.title }}
---

## What is "the shell"?

- Most of us interact with computers day-to-day via **graphical user interfaces**
- Windows with file contents we navigate with a mouse

- To automate common research tasks, interact with computers through __the shell__ (sometimes called the command line)

- The shell allows you to interact with your computer via text commands

- Can write scripts that automate those interactions

## Accessing the shell

- **Mac users:** access the shell through the *Terminal* app

- **Windows users:** have to install third-party software to use the “right” shell
- We recommend using an app called [MobaXterm](https://mobaxterm.mobatek.net/) (click the link and follow instructions to install)

- **Linux users:** depending on your specific OS, should be an app called “Shell” or something similar

*Take 3 minutes to (install and) be sure you can open a terminal*

## The command line and working directory

- When you first open the terminal, you should see something like this:

```bash
machine_name:~$
```

- The command line prompt above contains the following components:
- `machine_name` is the name of the computer you're using
- `~` is your current *working directory*
- the blank space after the `$` is the command prompt

- For now, focus on **working directory:** where programs you run through the shell will "operate from"
- Like opening a file browser window to a particular folder, but also a reference point for programs that read and/or manipulate files
116 changes: 116 additions & 0 deletions docs/day1/2_directories_and_paths.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
---
title: 2. Directories and File System Paths
layout: page
nav_order: 2
parent: Day 1
updateDate: 2024-07-10
---

# {{ page.title }}
---

## Making and changing directories

- `ls` is the name of a built in **program** that lists the contents of the current directory
- To run it, type `ls` in the command line and press enter:

```bash
machine_name:~$ ls
```

- The program `mkdir` accepts one **argument:** a new directory name, and creates a new directory with that name *in the current working directory:*

```bash
machine_name:~$ mkdir test_dir
```

- *Note:* a shell program's potentially multiple arguments are separated by spaces, not specified as a comma-separated list enclosed by parentheses

- To change your current working directory, pass the name of a new directory to the program `cd` as an argument (note that multiple arguments):

```bash
machine_name:~$ cd test_dir
```

- After running the command line above, the new command line prompt should list `~/test_dir` as the new working directory:

```bash
machine_name:~/test_dir$
```

## File system paths

- The working directory `~/test_dir` above is an example of a file system **path**, a string that maps to a particular location in the file system
- Paths are strings of directory names separated by `/`

- Try making another directory inside `~/test_dir` called `test2`, confirm you created the new directory inside `test_dir` with `ls`, and then change directories to `~/test_dir/test2`:

```bash
machine_name:~/test_dir$ mkdir test2
machine_name:~/test_dir$ ls
machine_name:~/test_dir$ cd test2
```

- After running the last command above, your command line prompt should now look like so:

```bash
machine_name:~/test_dir/test2$
```

- *Note:* if we don't put `~` at the beginning of the path to the new directory that we pass to `cd`, the `cd` program looks for the new directory *relative to the current working directory.*

### Aside: escaping characters

- Suppose instead we had run the following commands:

```bash
machine_name:~/test_dir$ mkdir test 2
machine_name:~/test_dir$ ls
```

- We'd see that there are two directories named `test` and `2`!
- Remember, arguments are separated by spaces in shell programming, so `mkdir` makes as many directories as there are arguments

- To make a directory called `test 2` (DON'T!), you have to *escape* special characters by prefacing them with a `/` or by enclosing the whole argument in single (`'`) or double (`"`) quotes:

```bash
machine_name:~/test_dir$ mkdir test\ 2
machine_name:~/test_dir$ mkdir 'test 2'
machine_name:~/test_dir$ mkdir "test 2"
```

- *Escaping* characters means telling the shell to interpret that character literally, rather than as something with programmatic meaning

## Relative vs. absolute file system paths

- Why doesn’t `cd` work relative to the working directory for the path starting w/ `~`? Because `~` is actually an alias for another path; use `pwd` to see full current working directory:

```bash
machine_name:~/test_dir/test2$ pwd
```

- *Note:* the output of `pwd` is a path that starts with a `/`, so it’s an **absolute path**
- The path `/` points to the `top` of the file system, i.e. the directory that contains all others (called the "root")
- `/` is not the "home" directory for a user because files related to the operating system live in `/` that users shouldn’t (usually) touch

- Paths that don’t start with `/` are **relative paths**; wherever they’re used (directly in the shell or in code), they start from the current working directory, not `/`
- The shell assumes paths that don’t start with `/` are meant to be relative to the current working directory

- The following file system diagram illustrates an example directory structure as a tree:

![](../assets/images/home-dir-local-machine.png)

- The directories highlighted in orange form the absolute path `/Users/nrapstine`, which is typically aliased by `~`

## Relative path helpers

- If you use the special directory name `..` somewhere in the path, it will replace the path up to the `..` with the "parent" directory of the directory before the `..`
- E.g. the path `/this/is/a/path/..` is equivalent to the path `/this/is/a`

- You can also use `ls` to list the contents of any directory (not just the current one) by passing it a path as an argument; try passing it the path `..`:

```bash
machine_name:~/test_dir/test2$ ls ..
```

- *Note:* since `..` doesn’t start with `/`, the shell assumes the path is relative to the current directory, so the output should be the contents of `~/test_dir` (i.e. the directory `test2`)
47 changes: 47 additions & 0 deletions docs/day1/3_deleting_files_and_directories.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
title: 3. Deleting Files and Directories
layout: page
nav_order: 3
parent: Day 1
updateDate: 2024-07-10
---

# {{ page.title }}
---

## Deleting files

- When passed paths to non-existent files in an existing directory as arguments, the command `touch` creates a empty files w/ those names there; try it:

```bash
machine_name:~/test_dir/test2$ touch a b
```

- file, pass a path to that file to the program `rm` as an argument; try deleting the file `a` you just created from outside the directory it’s in like so:

```bash
machine_name:~/test_dir/test2$ cd ..
machine_name:~/test_dir$ rm test2/a
machine_name:~/test_dir$ ls test2
```

## Deleting directories

- To delete a directory and its contents (if any), have to pass the `-r` flag to the `rm` program:

```bash
machine_name:~/test_dir$ cd ..
machine_name:~$ rm -r test_dir
```

- *Note:* if you run `rm test_dir` without the `-r` flag, the shell will complain since `test_dir` is a directory, not a file

## Shell program flags

- More generally, an **option** (often called a **flag**) is another way to change the behavior of a program besides an argument

- A shell program knows which argument is which from the order of them, while options have names (e.g. `-r`) that the program can recognize

## More resources

We'll only have time to scratch the surface of interacting with computers via the shell today and tomorrow; See lessons [1](https://missing.csail.mit.edu/2020/course-shell/) and [3](https://missing.csail.mit.edu/2020/shell-tools/) of [the Missing Semester](https://missing.csail.mit.edu) open-source MIT course on miscellaneous software engineering skills for more in-depth information and tips about making the most of the shell.
Loading

0 comments on commit 7737ecf

Please sign in to comment.