diff --git a/data/schedule/lectures.yml b/data/schedule/lectures.yml index b8d107bc882a6c360116702097411de38f9e810c..fc01a71133942e0d1ac38a07998b3d707988eaf2 100644 --- a/data/schedule/lectures.yml +++ b/data/schedule/lectures.yml @@ -112,37 +112,36 @@ schedule: url: https://youtu.be/bZpiwIUdty8 duration: "8:34" in-class: - gslides: null + gslides: https://docs.google.com/presentation/d/1Gx_mp2kkqf-8H_3RJGcuvGfGA9fQZy8mVxdMZxR_0qA/edit?usp=sharing recording: null - title: "Version control (<code>git</code>)" - resources: - pre-class: null - in-class: null - resources: null - # TODO: uncomment and fill out in-class to release # resources: - # pre-class: - # videos: - # - name: Introduction to Git - # url: https://www.youtube.com/watch?v=jeXPdZr12_A - # duration: "14:55" - # - name: Four Phases of Git - # url: https://youtu.be/_FYjufUV39o - # duration: "17:55" - # - name: Git Branching and Merging - # url: https://www.youtube.com/watch?v=j2lYr0ziUGQ - # duration: "18:44" - # in-class: - # gslides: null - # recording: null - # resources: - # commands: "/lectures/{num}/lec_{num}_commands.txt" - # "Discussion Questions": "/lectures/{num}/questions.md" - # "Lecture Notes": "/lectures/lecture_notes.md/#week{num}" - # "Extra Resources": - # "How to Write a Git Commit Message": https://cbea.ms/git-commit/ - # "Git Branching Game": https://learngitbranching.js.org/ - # "Branching Tutorial": https://www.atlassian.com/git/tutorials/using-branches + # pre-class: null + # in-class: null + # resources: null + resources: + pre-class: + videos: + - name: Introduction to Git + url: https://www.youtube.com/watch?v=jeXPdZr12_A + duration: "14:55" + - name: Four Phases of Git + url: https://youtu.be/_FYjufUV39o + duration: "17:55" + - name: Git Branching and Merging + url: https://www.youtube.com/watch?v=j2lYr0ziUGQ + duration: "18:44" + in-class: + gslides: null + recording: null + resources: + commands: "/lectures/{num}/lec_{num}_commands.txt" + "Discussion Questions": "/lectures/{num}/questions.md" + "Lecture Notes": "/lectures/lecture_notes.md/#week{num}" + "Extra Resources": + "How to Write a Git Commit Message": https://cbea.ms/git-commit/ + "Git Branching Game": https://learngitbranching.js.org/ + "Branching Tutorial": https://www.atlassian.com/git/tutorials/using-branches - title: "More Version Control (<code>git</code>)" resources: pre-class: null diff --git a/src/lectures/3/questions.md b/src/lectures/3/questions.md index ed72d933e73d2f4a3d2d65075e3353531628a7bb..976558167284b6e1bb4fcf61efd129719dfbee6d 100644 --- a/src/lectures/3/questions.md +++ b/src/lectures/3/questions.md @@ -53,19 +53,51 @@ extra_css: ["discussion.scss", "discussion_hide_solutions.scss"] tail -n+2 intro_survey.csv | cut -d, -f1 | sort -f | uniq -i | wc -l ``` -6. Write a command that would delete all directories, recursively, starting from the current directory. **Be careful about where you run this command!!** Don't run it from your home directory! +6. Suppose we have the intro survey data below. + Let's try to print the column "Cats or Dogs?" from this data. + First, come up with a `cut` command you might use to do this. + Second, predict whether or not this will work for the data below. + Third, run the `cut` command on the data below. + Did it work? Why or why not? + + ``` + What's your favorite candy?,What is your favorite dinner?,Cats or Dogs?,Are you currently enrolled in CSE 351? + Peanut M&Ms,Sandwich,Either,No + Snickers,rice, pork, and cabbage,Dogs,No + Sour skittles,thai,Dogs,No + sour patch, starburst,Dumplings,Cats,No + ``` + +??? Solutions + Assuming the data is in short_intro_survey.csv: + + ``` + cut -d, -f3 short_intro_survey.csv + ``` + + This will not work for the above data, because some of the responses + contain commas. `cut` cannot detect which comma is "supposed" to be the + column separator, so it uses any commas in a line as delimiters. + + For example, the line `sour patch, starburst,Dumplings,Cats,No` + will interpret `sour patch` as the first field, ` starburst` as the second + field, and `Dumplings` as the third field. + + This is an important limitation of using `cut` to parse CSVs! + +7. Write a command that would delete all directories, recursively, starting from the current directory. **Be careful about where you run this command!!** Don't run it from your home directory! ??? Solutions ``` find -type d | xargs rm ``` -7. Suppose we know that `Compile.java` compiles with no errors. If we were to run `javac Compile.java || java Compile` what would be the result? Would the program compile? Would it run? +8. Suppose we know that `Compile.java` compiles with no errors. If we were to run `javac Compile.java || java Compile` what would be the result? Would the program compile? Would it run? ??? Solutions When we use the `||` operator, if the first statement is true, then we know the entire line is true, thus we wouldn't run the second statement. In other words, `Compile.java` will compile, but it won't run. -8. What would be some security issues with running some of the commands you learned from lecture (think of some of the practical implications of `rm`, `find`, and `xargs` in regards to malicious code injection)? +9. What would be some security issues with running some of the commands you learned from lecture (think of some of the practical implications of `rm`, `find`, and `xargs` in regards to malicious code injection)? ??? Solutions An example of a security issue would be loss of data by running the command `find -name *.java | xargs rm` which deletes all java files.