4 Commits
0.0.2 ... 0.0.5

Author SHA1 Message Date
ducoterra
09b4bc8f5b day 2 2020-11-09 21:12:58 -05:00
ducoterra
f2b35db671 add git tag pager info to README 2020-11-05 14:50:27 -05:00
ducoterra
8014742933 add code fence support and fix a ton of lint issues 2020-11-05 14:47:29 -05:00
ducoterra
360bd07a44 Finish Day 1 2020-11-01 19:29:23 -05:00
43 changed files with 596 additions and 81 deletions

1
.gitignore vendored
View File

@@ -1,2 +1,3 @@
venv/
site/
videos/

View File

@@ -2,4 +2,10 @@
```bash
ffmpeg -i in.mov -filter:v "setpts=0.5*PTS" out.gif
ffmpeg -i in.mkv out.mov
```
```bash
git config --global pager.branch false
git config --global pager.tag false
```

22
converter.py Normal file
View File

@@ -0,0 +1,22 @@
import subprocess
import os
import time
done_files = []
while True:
# get a list of all .mov or .gif files
movs = list(filter(lambda item: item.endswith(".mov"), os.listdir()))
print(f"Found {len(movs)} .mov files.")
gifs = list(filter(lambda item: item.endswith(".gif"), os.listdir()))
print(f"Found {len(gifs)} .gif files.")
# find files that are not already gifs and aren't default
not_done = list(filter(lambda mov: mov.replace(".mov",".gif") not in gifs and not mov.startswith("Screen Recording"), movs))
print(f"Found {len(not_done)} to convert.")
for mov in not_done:
print(f"converting {mov}. Ctrl + C to stop...")
subprocess.run(['/usr/local/bin/ffmpeg', '-i', mov, '-filter:v', 'setpts=0.5*PTS', mov.replace(".mov",".gif")], capture_output=True)
time.sleep(1)

View File

@@ -8,9 +8,9 @@ Fortunately we can do some things to make your life easier. We can install an ID
(or skip to [I have a Mac](#i-have-a-mac))
### Install Git
### Install Git (windows)
Git is a version control program, but you can think of it as your best friend in the cold, dark world of data loss. Git will make sure you don't lose progress. It lets you save your code at various stages and
Git is a version control program, but you can think of it as your best friend in the cold, dark world of data loss. Git will make sure you don't lose progress. It lets you save your code at various stages and revert back to previous saves if you need to.
1. Head to <https://git-scm.com/>
@@ -20,7 +20,7 @@ Git is a version control program, but you can think of it as your best friend in
3. Run through the default install process
### Install Python
### Install Python (windows)
1. Head to <https://www.python.org/>
@@ -32,83 +32,83 @@ Git is a version control program, but you can think of it as your best friend in
![python_windows_install](img/day0/install_for_windows.gif)
### Install VSCode
### Install VSCode (windows)
Your most important tool as a programmer is a proper editor. It should offer you a wide selection of tools but get out of your way when you don't need it. VSCode is a great option in 2020. It has tons of extensions and support for almost every language you can throw at it.
1. Head to <https://code.visualstudio.com/>
1. Click on the download link
2. Click on the download link
![vscode_download](img/day0/code_download.png)
1. Run through the installer, select default options
3. Run through the installer, select default options
1. Open VSCode
4. Open VSCode
![vscode_open](img/day0/vscode_open.png)
1. Uncheck "Show welcome page on startup"
5. Uncheck "Show welcome page on startup"
![vscode_uncheck](img/day0/vscode_uncheck.gif)
1. Close out of the welcome page
6. Close out of the welcome page
![close_welcome](img/day0/close_welcome.gif)
1. Open the terinal with <kbd>ctrl</kbd>+<kbd>~</kbd>
7. Open the terinal with ++ctrl++ + ~
1. Click the dropdown that says `1: powershell` and click `Select Default Shell`
8. Click the dropdown that says `1: powershell` and click `Select Default Shell`
![select_default_shell_windows](img/day0/select_default_shell_windows.png)
1. Select Command Prompt
9. Select Command Prompt
![select_cmd_prompt](img/day0/select_cmd_prompt.png)
1. Kill the terminal by clicking the trash can icon
10. Kill the terminal by clicking the trash can icon
![kill_terminal](img/day0/kill_terminal.png)
1. Click the "extensions" button on the left to open the extensions page
11. Click the "extensions" button on the left to open the extensions page
![extension](img/day0/extension.png)
1. Search for "python"
12. Search for "python"
![search_python](img/day0/search_python.png)
1. Click on the first Python extension and click "install"
13. Click on the first Python extension and click "install"
![install_python](img/day0/install_python.png)
1. When the extension has finished installing, close out of the welcome window
14. When the extension has finished installing, close out of the welcome window
![close_welcome](img/day0/close_welcome.png)
1. Close out of the extension window
15. Close out of the extension window
![close_extension](img/day0/close_extension.png)
1. Reopen your document view by clicking the "documents" icon
16. Reopen your document view by clicking the "documents" icon
![select_docs](img/day0/select_docs.png)
### Create a "Projects" folder
### Create a "Projects" folder (windows)
I keep all my projects in a folder called "Projects" in my home directory. On Windows this is at `C:\Users\<your username>\Projects`. Create this folder now. Bookmark it, put it in your favorites, don't lose it.
1. In your `Projects` folder create another folder called `my_website`
2. Switch to VSCode You can use <kbd>alt</kbd>+<kbd>tab</kbd> to quickly switch between windows. Press <kbd>ctrl</kbd>+<kbd>k</kbd>+<kbd>o</kbd> and select the projects/my_website folder
2. Switch to VSCode You can use ++alt+tab++ to quickly switch between windows. Press ++ctrl++ + K + O and select the projects/my_website folder
![ctrl_ko](img/day0/ctrl_ko_windows.gif)
### Create a virtual environment
### Create a virtual environment (windows)
A python virtual environment is a folder that will hold your python installation for the project you're working on. You'll have a virtual environment for every project you create.
1. With your "my_website" folder open in VSCode open the terminal with <kbd>ctrl</kbd>+<kbd>~</kbd>
1. With your "my_website" folder open in VSCode open the terminal with ++ctrl++ + ~
![open_terminal_windows](img/day0/open_terminal_windows.gif)
@@ -126,7 +126,7 @@ A python virtual environment is a folder that will hold your python installation
![source_venv_windows](img/day0/source_venv_windows.gif)
### Install Django
### Install Django (windows)
Django is a pip package. Pip packages are other people's python code that you can download for free. In much the same way you downloaded VSCode and Python itself with your browser, we can download pip packages with "pip". Pip comes preinstalled with Python.
@@ -134,33 +134,33 @@ Django is a pip package. Pip packages are other people's python code that you ca
![pip_django](img/day0/pip_django.gif)
1. If you have a warning like above you can ignore it for now. Type `django-admin startproject config .`
2. If you have a warning like above you can ignore it for now. Type `django-admin startproject config .`
![startproject](img/day0/startproject.gif)
1. Click on `manage.py`. You should see VSCode activate python extensions in the bottom left and select an interpretor. ('venv': venv) should be selected. You can ignore the message that says "linter pylint is not installed" - just close out of it.
3. Click on `manage.py`. You should see VSCode activate python extensions in the bottom left and select an interpretor. ('venv': venv) should be selected. You can ignore the message that says "linter pylint is not installed" - just close out of it.
![open_manage](img/day0/open_manage.gif)
1. Close out of manage.py by clicking the 'x' at the top.
4. Close out of manage.py by clicking the 'x' at the top.
1. Type `python manage.py runserver`
5. Type `python manage.py runserver`
![runserver](img/day0/runserver.gif)
1. Open a browser and navigate to <http://localhost:8000>
6. Open a browser and navigate to <http://localhost:8000>
![localhost8000](img/day0/localhost8000.gif)
1. You should see an install success page. If so, congratulations! You have successfully installed Django.
7. You should see an install success page. If so, congratulations! You have successfully installed Django.
1. Stop running server by clicking in the terminal and typing <kbd>ctrl</kbd>+<kbd>C</kbd>. You have successfully completed Day 0!
8. Stop running server by clicking in the terminal and typing ++ctrl++ + C. You have successfully completed Day 0!
## I have a Mac
### Install Git
### Install Git (mac)
Git is a version control program, but you can think of it as your best friend in the cold, dark world of data loss. Git will make sure you don't lose progress. It lets you save your code at various stages and
Git is a version control program, but you can think of it as your best friend in the cold, dark world of data loss. Git will make sure you don't lose progress. It lets you save your code at various stages and revert back to previous saves if you need to.
1. Head to <https://git-scm.com/>
@@ -170,7 +170,7 @@ Git is a version control program, but you can think of it as your best friend in
3. Run through the default install process
### Install Python
### Install Python (mac)
1. Head to <https://www.python.org/>
@@ -182,87 +182,87 @@ Git is a version control program, but you can think of it as your best friend in
![install_for_mac](img/day0/install_for_mac.gif)
### Install VSCode
### Install VSCode (mac)
Your most important tool as a programmer is a proper editor. It should offer you a wide selection of tools but get out of your way when you don't need it. VSCode is a great option in 2020. It has tons of extensions and support for almost every language you can throw at it.
1. Head to <https://code.visualstudio.com/>
1. Click on the download link
2. Click on the download link
![vscode_download](img/day0/code_download.png)
1. Run through the installer, select default options
3. Run through the installer, select default options
1. Open VSCode
4. Open VSCode
![vscode_open](img/day0/vscode_open.png)
1. Uncheck "Show welcome page on startup"
5. Uncheck "Show welcome page on startup"
![vscode_uncheck](img/day0/vscode_uncheck.gif)
1. Close out of the welcome page
6. Close out of the welcome page
![close_welcome](img/day0/close_welcome.gif)
1. Click the "extensions" button on the left to open the extensions page
7. Click the "extensions" button on the left to open the extensions page
![extension](img/day0/extension.png)
1. Search for "python"
8. Search for "python"
![search_python](img/day0/search_python.png)
1. Click on the first Python extension and click "install"
9. Click on the first Python extension and click "install"
![install_python](img/day0/install_python.png)
1. When the extension has finished installing, close out of the welcome window
10. When the extension has finished installing, close out of the welcome window
![close_welcome](img/day0/close_welcome.png)
1. Close out of the extension window
11. Close out of the extension window
![close_extension](img/day0/close_extension.png)
1. Reopen your document view by clicking the "documents" icon
12. Reopen your document view by clicking the "documents" icon
![select_docs](img/day0/select_docs.png)
### Create a "Projects" folder
### Create a "Projects" folder (mac)
I keep all my projects in a folder called "Projects" in my home directory. On MacOS this is at `/Users/<your username>/Projects`. Create this folder now. Bookmark it, put it in your favorites, don't lose it.
1. In your `Projects` folder create another folder called `my_website`
1. Switch to VSCode You can use <kbd>cmd</kbd>+<kbd>tab</kbd> to quickly switch between windows. Press <kbd>ctrl</kbd>+<kbd>o</kbd> and select the projects/my_website folder
2. Switch to VSCode You can use ++cmd+tab++ to quickly switch between windows. Press ++ctrl++ + O and select the projects/my_website folder
![ctrl_ko](img/day0/ctrl_o_mac.gif)
### Create a virtual environment
### Create a virtual environment (mac)
A python virtual environment is a folder that will hold your python installation for the project you're working on. You'll have a virtual environment for every project you create.
1. With your "my_website" folder open in VSCode open the terminal with <kbd>ctrl</kbd>+<kbd>~</kbd>
1. With your "my_website" folder open in VSCode open the terminal with ++ctrl++ + ~
![open_terminal](img/day0/open_terminal.gif)
1. Type `python3 --version`
2. Type `python3 --version`
![python_version](img/day0/python_version.gif)
1. If you see `Python 3.9.#` you have the correct version, if you see another version try typing `python3.9 --version`. If that doesn't work you'll need to reinstall python 3.9.
3. If you see `Python 3.9.#` you have the correct version, if you see another version try typing `python3.9 --version`. If that doesn't work you'll need to reinstall python 3.9.
1. Type `python3 -m venv venv`. You'll see a folder appear on the left side of VSCode.
4. Type `python3 -m venv venv`. You'll see a folder appear on the left side of VSCode.
![venv_mac](img/day0/venv_mac.gif)
1. Source your venv: type `source venv/bin/activate`. You'll see a (venv) appear next to your terminal cursor.
5. Source your venv: type `source venv/bin/activate`. You'll see a (venv) appear next to your terminal cursor.
![source_venv_mac](img/day0/source_venv_mac.gif)
### Install Django
### Install Django (mac)
Django is a pip package. Pip packages are other people's python code that you can download for free. In much the same way you downloaded VSCode and Python itself with your browser, we can download pip packages with "pip". Pip comes preinstalled with Python.
@@ -270,24 +270,24 @@ Django is a pip package. Pip packages are other people's python code that you ca
![pip_django](img/day0/pip_django.gif)
1. If you have a warning like above you can ignore it for now. Type `django-admin startproject config .`
2. If you have a warning like above you can ignore it for now. Type `django-admin startproject config .`
![startproject](img/day0/startproject.gif)
1. Click on `manage.py`. You should see VSCode activate python extensions in the bottom left and select an interpretor. ('venv': venv) should be selected. You can ignore the message that says "linter pylint is not installed" - just close out of it.
3. Click on `manage.py`. You should see VSCode activate python extensions in the bottom left and select an interpretor. ('venv': venv) should be selected. You can ignore the message that says "linter pylint is not installed" - just close out of it.
![open_manage](img/day0/open_manage.gif)
1. Close out of manage.py by clicking the 'x' at the top.
4. Close out of manage.py by clicking the 'x' at the top.
1. Type `python manage.py runserver`
5. Type `python manage.py runserver`
![runserver](img/day0/runserver.gif)
1. Open a browser and navigate to <http://localhost:8000>
6. Open a browser and navigate to <http://localhost:8000>
![localhost8000](img/day0/localhost8000.gif)
1. You should see an install success page. If so, congratulations! You have successfully installed Django.
7. You should see an install success page. If so, congratulations! You have successfully installed Django.
1. Stop running server by clicking in the terminal and typing <kbd>ctrl</kbd>+<kbd>C</kbd>. You have successfully completed Day 0!
8. Stop running server by clicking in the terminal and typing ++ctrl++ + C. You have successfully completed Day 0!

View File

@@ -72,22 +72,21 @@ Before we can dive into our web project we have to cover some Python basics. Let
![open_file](img/day1/open_file.png)
1. In this file type `print('hello, world!')` and save with <kbd>ctrl</kbd>+<kbd>S</kbd>
2. In this file type `print('hello, world!')` and save with ++ctrl++ + S
![type_hw](img/day1/type_hw.png)
1. In the terminal type `python my_program.py` and press enter. You should see `hello, world!` printed to the terminal.
3. In the terminal type `python my_program.py` and press enter. You should see `hello, world!` printed to the terminal.
![run_hw](img/day1/run_hw.gif)
1. Congratulations! You ran your first python file. Just like the python command prompt above, running `python <filename>` on a file with python code in it will execute that python code. Now we can run multiple lines of python at once!
4. Congratulations! You ran your first python file. Just like the python command prompt above, running `python <filename>` on a file with python code in it will execute that python code. Now we can run multiple lines of python at once!
1. Below `print('hello, world!')` type `print('goodbye!)`
5. Below `print('hello, world!')` type `print('goodbye!)`
![print_goodbye](img/day1/print_goodbye.png)
1. Below `print('goodbye')` type
6. Below `print('goodbye')` type
```python
x = 1
@@ -99,7 +98,7 @@ Before we can dive into our web project we have to cover some Python basics. Let
![type_more_code](img/day1/type_more_code.png)
1. Save the file with <kbd>ctrl</kbd>+<kbd>S</kbd>. In your terminal type `python myprogram.py` and press enter. You should see
7. Save the file with ++ctrl++ + S. In your terminal type `python myprogram.py` and press enter. You should see
```bash
hello, world!
@@ -110,29 +109,29 @@ Before we can dive into our web project we have to cover some Python basics. Let
printed to the terminal
1. This is out of order. We want to print "goodbye" last. Let's fix that with functions.
8. This is out of order. We want to print "goodbye" last. Let's fix that with functions.
1. Above `print('hello, world!')` type `def print_hello():`
9. Above `print('hello, world!')` type `def print_hello():`
![def_ph](img/day1/def_ph.png)
1. Indent `print('hello, world!')` by pressing <kbd>tab</kbd>
10. Indent `print('hello, world!')` by pressing ++tab++
![indent_hw](img/day1/indent_hw.png)
1. Give 'goodbye' the same treatment. This time type `def print_goodbye():`
11. Give 'goodbye' the same treatment. This time type `def print_goodbye():`
![print_gb](img/day1/print_gb.png)
1. Finally add `def middle_stuff():` above the remaining code
12. Finally add `def middle_stuff():` above the remaining cod
![middle_stuff](img/day1/middle_stuff.png)
1. Save the file with <kbd>ctrl</kbd>+<kbd>S</kbd>. Now type `python my_program.py` in the terminal and press enter. Nothing will return.
13. Save the file with ++ctrl++ + S. Now type `python my_program.py` in the terminal and press enter. Nothing will return.
![functions_in_order](img/day1/functions_in_order.png)
1. We've given our snippets of code "names" by adding a "def" above them. These are called functions. We can call them in any order we want. Let's call them in the correct order by using their names. Add the following to the bottom of my_program.py
14. We've given our snippets of code "names" by adding a "def" above them. These are called functions. We can call them in any order we want. Let's call them in the correct order by using their names. Add the following to the bottom of my_program.py
```python
print_hello()
@@ -140,6 +139,120 @@ Before we can dive into our web project we have to cover some Python basics. Let
print_goodbye()
```
3. Type `python my_program.py` in the terminal and press enter. Now everything prints in order!
15. Type `python my_program.py` in the terminal and press enter. Now everything prints in order!
![in_order](img/day1/in_order.png)
## A Django Project
Now that we can write some basic python we can begin our django project. Let's start by creating a view.
1. Close out of my_program.py
2. In the terminal type `django-admin startapp mysite`
![startapp](img/day1/startapp.gif)
3. Expand the `config` folder by clicking on it
![config](img/day1/config.png)
4. Click on `settings.py` to open it
5. Scroll down to line 33 and add `mysite` above `'django.contrib.admin'`
![add_mysite](img/day1/add_mysite.png)
6. Save with ++ctrl++ + S
7. Click on `urls.py` to open it
![urls](img/day1/urlspy.png)
8. On line 17 add `, include` after `from django.urls import path`
![include](img/day1/include.png)
9. Add `path('', include('mysite.urls')),` above `path('admin/', admin.site.urls),`
![mysiteurls](img/day1/mysiteurls.png)
10. Expand the newly created `mysite` folder by clicking on it
![mysite](img/day1/mysite.png)
11. Right click on `mysite` and click "New Folder". Name it `templates`
![templates](img/day1/templates.gif)
12. Right click on `templates` and click "New Folder". Name it `mysite`
![mysitetemplate](img/day1/mysitetemplates.gif)
13. Right click on the `mysite` folder inside `templates` and click "New File". Name it `index.html`
![index](img/day1/index.gif)
14. Open `index.html` by clicking on it
15. Add the following to index.html
```html
<!DOCTYPE html>
<body>
{{ data }}
</body>
</html>
```
![indexdata](img/day1/indexdata.png)
16. Save with ++ctrl++ + S
17. Open `views.py` by clicking on it
18. In views.py under line 3 add the following:
```python
def index(request):
return render(
request,
"mysite/index.html",
{"data": "hello"}
)
```
![defindex](img/day1/defindex.png)
19. Save with ++ctrl++ + S
20. Right click on `mysite` and click "New File". Name it `urls.py`
![createurls](img/day1/createurls.gif)
21. Add the following to urls.py:
```python
from django.urls import path
from . import views
urlpatterns = [
path('', views.index),
]
```
![indexpath](img/day1/indexpath.png)
22. Save with ++ctrl++ + S
23. In the terminal type `python manage.py runserver`
![runserver](img/day1/runserver.gif)
24. In your browser navigate to <http://localhost:8000>
![hello](img/day1/hello.gif)
You've now passed python data to a browser! We'll explore what this really means in Day 2.

242
docs/day2.md Normal file
View File

@@ -0,0 +1,242 @@
# Day 2
## Back to the basics: and, or, not, if
Before we do anything more interesting we're going to have to cover our logical basics. In Python these are `not`, `and`, `or`, and `if`.
1. Stop your server with ++ctrl++ + C
2. Type `python` in the terminal to open your python interpretor
![python_prompt](img/day1/python_prompt.gif)
### not
1. Type `x = True` and press enter.
2. Type `x` and press enter to see that x is true.
3. Type `not x` and press enter. `not` inverts the value of `x`. So if `x` is True, `not x` is False.
4. Type `not not x` and press enter. `not not x` inverts `not x`. You can chain `not` as many times as you want.
5. Let's imagine we're building a weather app and we want to know if it's raining. Type `is_raining = True` and press enter.
6. Type `print(f"should I wear a raincoat? {is_raining}")` and press enter.
7. Today it's not raining. We could create a variable called `is_not_raining` but we could also just `not`. Type `print(f"should I wear a raincoat? {not is_raining}")`
8. Type `not 'hello'` and press enter. This might seem strange but Python interprets a string as `True`. `not 'hello'` will return `False`.
9. Type `not ''` and press enter. An empty string in Python is False. `not ''` returns `True`.
### and
1. In your terminal type `x = True` and press enter.
2. Type `x` and press enter to see that x is True.
3. Type `y = True` and press enter.
4. Type `y` and press enter to see that y is True.
5. Type `y and x` and press enter. `y` is true *and* `x` is true, so `y` and `x` is true.
6. We're building our weather app to be more useful. We want to tell people if it's rainy and windy. Type `rainy = True` and press enter.
7. Type `windy = True` and press enter.
8. Type `rainy and windy` and press enter. We get True because it's rainy and windy.
9. Today it's not windy. Type `rainy and not windy` and press enter. We get False because it isn't rainy *and* windy.
10. Tomorrow it won't be windy and it also won't be rainy. Type `not rainy and not windy` and press enter. We get False because neither weather conditions are met.
### or
1. In your terminal type `x = True` and press enter.
2. Type `x` and press enter to see that x is True.
3. Type `y = False` and press enter.
4. Type `y` and press enter to see that y is False.
5. Type `y or x` and press enter. `x` is True so asking if x or y is true will result in `True`.
6. Our weather app has millions of downloads. Our data suggests people don't like when it's cold or raining. Let's tell them when it's cold or raining.
7. Type `cold = True` and press enter.
8. Type `raining = True` and press enter.
9. Type `cold or raining` and press enter. We get `True`, it is cold and it is raining.
10. Today it isn't cold but it is raining. Type `not cold or raining`. We get `True`, it is still raining outside.
11. Tomorrow it won't be cold and it won't be raining. Type `not cold or not raining`. We get `False` because neither of our disliked weather conditions are met.
### if
1. In your terminal type `x = True` and press enter.
2. Type `x` and press enter to see that x is True.
3. Type `y = False` and press enter.
4. Type `y` and press enter to see that y is False.
5. Type `if x:` and press enter. You'll see a `...`. Python is waiting for another input.
6. Type ++tab++ `print('x is true!')` and press enter. You should see another `...`.
7. Press enter again. 'x is true!' will print to the terminal.
![if_interpreter](img/day2/if_interpreter.gif)
8. Type `if y:` and press enter. Now type ++tab++ `print('y is true!')` and press enter twice. You won't see anything print.
![y_is_false](img/day2/y_is_false.gif)
9. Type `if not y:` and press enter. Now type ++tab++ `print('y is false!')` and press enter twice. You'll see 'y is false!') printed.
10. Now that our weather app is sentient let's give it some decision making capability.
11. Type `raining = True` and press enter.
12. Type `if raining:` and press enter.
13. Type ++tab++ `print('You should wear a rain jacket')` and press enter twice. Your weather app can now tell you to wear a jacket if it's raining outside.
![rain_jacket](img/day2/rain_jacket.gif)
14. Type `exit()` to exit
## Building a Terrible Weather App
1. Create a new file called `weather_app.py` by clicking the "add file" icon in the top left of VSCode.
![create_file](img/day2/create_file.gif)
2. We're going to create an app where the user has to guess the weather. We're going to need the python random module to generate random weather conditions.
3. Add the following to the top of the page:
```python
import random
```
![import random](img/day2/import_random.png)
This tells python we intend to use the `random` package
4. We'll generate 4 weather conditions. Add the following after `import random`
```python
warm = random.choice([True, False])
cold = not warm
raining = random.choice([True, False])
snowing = not raining
```
![conditions](img/day2/conditions.png)
random.choice([True, False]) selects either True or False randomly.
5. Let's print our weather conditions in a cryptic way. Add the following below our variables:
```python
if warm or cold:
print("It's warm or cold.")
if raining or warm:
print("It's raining or warm.")
if raining or snowing:
print("It's raining or snowing.")
if cold or snowing:
print("It's cold or snowing.")
```
![if_prints](img/day2/if_prints.png)
This will print weather conditions in pairs to make it more challenging for our users to guess the weather.
6. Now let's get our user input. Since we have 4 possible weather conditions we'll need 4 "guessing modules". Let's build the first one:
```python
warm_guess = input("Is it warm? (y/n) ")
if warm_guess == 'y' and warm:
print('Correct!')
elif warm_guess == 'n' and not warm:
print('Correct!')
else:
print('Wrong!')
```
![warm_module](img/day2/warm_module.png)
We ask the user if it's warm. If they say 'y' and it is warm we tell them they got it right! If they guess wrong we tell them they are wrong.
7. We'll just repeat the guess module 3 more times for cold, raining, and snowing.
```python
cold_guess = input("Is it cold? (y/n) ")
if cold_guess == 'y' and cold:
print('Correct!')
elif cold_guess == 'n' and not cold:
print('Correct!')
else:
print('Wrong!')
raining_guess = input("Is it raining? (y/n) ")
if raining_guess == 'y' and raining:
print('Correct!')
elif raining_guess == 'n' and not raining:
print('Correct!')
else:
print('Wrong!')
snowing_guess = input("Is it snowing? (y/n) ")
if snowing_guess == 'y' and snowing:
print('Correct!')
elif snowing_guess == 'n' and not snowing:
print('Correct!')
else:
print('Wrong!')
```
![modules](img/day2/modules.png)
8. Save with ++ctrl++ + S and run your weather app by typing `python weather_app.py`. Try to guess the weather.
![run_app](img/day2/run_app.gif)
## Pulling it all together with some Django
1. Let's make a weather app! Open "views.py" by clicking on it.
![open_views](img/day2/open_views.gif)
2. At the top of views.py add the following:
```python
import random
```
![django_random](img/day2/django_random.gif)
3. Now under all of our existing code in views.py add the following:
```python
def weather(request):
warm = random.choice([True, False])
cold = not warm
raining = random.choice([True, False])
snowing = not raining
if warm:
temperature_report = "It's warm out! Don't wear a jacket."
else:
temperature_report = "It's cold out! Wear a jacket."
if raining:
precipitation_report = "It's raining! Bring an umbrella."
else:
precipitation_report = "It's snowing! Bring your skis."
return render(
request,
"mysite/index.html",
{"data": temperature_report + " " + precipitation_report}
)
```
![add_weather](img/day2/add_weather.gif)
This creates a new "view" in our django app.
4. Open mysite/urls.py by clicking on it.
![open_urls](img/day2/open_urls.gif)
5. Under `path('', views.index),` add:
```python
path('weather/', views.weather),
```
![add_weather_path](img/day2/add_weather_path.gif)
6. Run your server with `python manage.py runserver` (if it isn't already running)
![python_manage_run](img/day2/python_manage_run.gif)
7. Navigate to <http://localhost:8000/weather>
![navigate_to_weather](img/day2/navigate_to_weather.gif)
Congratulations! You've added a new page to your app!

Binary file not shown.

After

Width:  |  Height:  |  Size: 227 KiB

BIN
docs/img/day1/config.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 425 KiB

BIN
docs/img/day1/defindex.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 KiB

BIN
docs/img/day1/hello.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
docs/img/day1/include.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 KiB

BIN
docs/img/day1/index.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 626 KiB

BIN
docs/img/day1/indexdata.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 KiB

BIN
docs/img/day1/indexpath.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 KiB

BIN
docs/img/day1/mysite.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 528 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 KiB

BIN
docs/img/day1/runserver.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 253 KiB

BIN
docs/img/day1/startapp.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

BIN
docs/img/day1/templates.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 595 KiB

BIN
docs/img/day1/urlspy.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 234 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 367 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 465 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 359 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 342 KiB

BIN
docs/img/day2/if_prints.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 183 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 KiB

BIN
docs/img/day2/modules.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 254 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

BIN
docs/img/day2/open_urls.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 231 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 407 KiB

BIN
docs/img/day2/run_app.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 386 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 209 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 412 KiB

58
ffmpeg.yaml Normal file
View File

@@ -0,0 +1,58 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: ffmpeg
spec:
selector:
matchLabels:
app: ffmpeg
template:
metadata:
labels:
app: ffmpeg
spec:
containers:
- image: debian:latest
name: ffmpeg
command:
- sleep
- infinity
volumeMounts:
- mountPath: /in
name: in
- mountPath: /out
name: out
resources:
limits:
memory: "16Gi"
cpu: "16"
requests:
memory: "1Mi"
cpu: "1m"
restartPolicy: Always
volumes:
- name: out
persistentVolumeClaim:
claimName: ffmpeg
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ffmpeg-in
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 32Gi
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ffmpeg-out
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 32Gi

View File

@@ -3,5 +3,11 @@ nav:
- Home: index.md
- Day 0: day0.md
- Day 1: day1.md
- Day 2: day2.md
theme:
name: material
markdown_extensions:
- pymdownx.keys
- pymdownx.superfences
- pymdownx.highlight:
linenums_style: pymdownx.inline

16
my_program.py Normal file
View File

@@ -0,0 +1,16 @@
def print_hello():
print('hello, world!')
def print_goodbye():
print('goodbye!')
def middle_stuff():
x = 1
y = 2
print(x + y)
my_name = "Reese"
print(my_name)
print_hello()
middle_stuff()
print_goodbye()

51
weather_app.py Normal file
View File

@@ -0,0 +1,51 @@
import random
warm = random.choice([True, False])
cold = not warm
raining = random.choice([True, False])
snowing = not raining
if warm or cold:
print("It's warm or snowing.")
if raining or warm:
print("It's raining or warm.")
if raining or snowing:
print("It's raining or cold.")
if cold or snowing:
print("It's cold or snowing.")
warm_guess = input("Is it warm? (y/n) ")
if warm_guess == 'y' and warm:
print('Correct!')
elif warm_guess == 'n' and not warm:
print('Correct!')
else:
print('Wrong!')
cold_guess = input("Is it cold? (y/n) ")
if cold_guess == 'y' and cold:
print('Correct!')
elif cold_guess == 'n' and not cold:
print('Correct!')
else:
print('Wrong!')
raining_guess = input("Is it raining? (y/n) ")
if raining_guess == 'y' and raining:
print('Correct!')
elif raining_guess == 'n' and not raining:
print('Correct!')
else:
print('Wrong!')
snowing_guess = input("Is it snowing? (y/n) ")
if snowing_guess == 'y' and snowing:
print('Correct!')
elif snowing_guess == 'n' and not snowing:
print('Correct!')
else:
print('Wrong!')