Prerequisites for Project Directory

Practice pulling code from git to your machine. This will create a project directory and add APCSP github project to the directory. There is conditional logic to make sure that directory and pull only happen if it does not (!) exist.

  • Hack:Change variables, make new directory, clone to that directory.
echo "Using conditional statement to create a project directory and project"

# Variable section
export project_dir=$HOME/HI  # change vscode to different name to test git clone
export project=$project_dir/Blog  # change APCSP to name of project from git clone
export project_repo="https://github.com/VyaanG22/Blog.git"  # change to project of choice

cd ~    # start in home directory

# Conditional block to make a project directory
if [ ! -d $project_dir ]
then 
    echo "Directory $project_dir does not exists... makinng directory $project_dir"
    mkdir -p $project_dir
fi
echo "Directory $project_dir exists." 

# Conditional block to git clone a project from project_repo
if [ ! -d $project ]
then
    echo "Directory $project does not exists... cloning $project_repo"
    cd $project_dir
    git clone $project_repo
    cd ~
fi
echo "Directory $project exists."
Using conditional statement to create a project directory and project
Directory /Users/vyaangautam/HI exists.
Directory /Users/vyaangautam/HI/Blog exists.

Look inside Fastpages/Github page project

All computers contain files and directories. The clone brought more files from cloud to your machine. Using the bash shell you will see some commands that show and interact with files and directories.

  • "ls" lists computer files in Unix and Unix-like operating systems
  • "cd" offers way to navigate and change working directory
  • "pwd" print working directory
  • "echo" used to display line of text/string that are passed as an argument
echo "Navigate to project, then navigate to area wwhere files were cloned"
cd $project
pwd

echo ""
echo "list top level or root of files with project pulled from github"
ls

echo ""
echo "list again with hidden files pulled from github"
ls -a   # hidden files flag, many shell commands have flags

echo ""
echo "list all files in long format"
ls -al   # all files and long listing
Navigate to project, then navigate to area wwhere files were cloned
/Users/vyaangautam/HI/Blog

list top level or root of files with project pulled from github
2022-05-15-07-21-16.png	_config.yml		_sass
2022-05-15-07-24-25.png	_fastpages_docs		_word
2022-05-15-07-25-15.png	_includes		assets
Gemfile			_layouts		docker-compose.yml
LICENSE			_notebooks		images
Makefile		_pages			index.html
README.md		_plugins
_action_files		_posts

list again with hidden files pulled from github
.			Gemfile			_pages
..			LICENSE			_plugins
.devcontainer.json	Makefile		_posts
.git			README.md		_sass
.gitattributes		_action_files		_word
.github			_config.yml		assets
.gitignore		_fastpages_docs		docker-compose.yml
2022-05-15-07-21-16.png	_includes		images
2022-05-15-07-24-25.png	_layouts		index.html
2022-05-15-07-25-15.png	_notebooks

list all files in long format
total 848
drwxr-xr-x  29 vyaangautam  staff     928 Aug 29 13:37 .
drwxr-xr-x   5 vyaangautam  staff     160 Sep  1 13:40 ..
-rw-r--r--   1 vyaangautam  staff     420 Aug 29 13:37 .devcontainer.json
drwxr-xr-x  15 vyaangautam  staff     480 Sep  1 13:36 .git
-rw-r--r--   1 vyaangautam  staff      84 Aug 29 13:37 .gitattributes
drwxr-xr-x   4 vyaangautam  staff     128 Aug 29 13:37 .github
-rw-r--r--   1 vyaangautam  staff     161 Aug 29 13:37 .gitignore
-rw-r--r--   1 vyaangautam  staff  207007 Aug 29 13:37 2022-05-15-07-21-16.png
-rw-r--r--   1 vyaangautam  staff   90979 Aug 29 13:37 2022-05-15-07-24-25.png
-rw-r--r--   1 vyaangautam  staff   81691 Aug 29 13:37 2022-05-15-07-25-15.png
-rwxr-xr-x   1 vyaangautam  staff    1304 Aug 29 13:37 Gemfile
-rw-r--r--   1 vyaangautam  staff   11351 Aug 29 13:37 LICENSE
-rwxr-xr-x   1 vyaangautam  staff    1422 Aug 29 13:37 Makefile
-rwxr-xr-x   1 vyaangautam  staff    3590 Aug 29 13:37 README.md
drwxr-xr-x  18 vyaangautam  staff     576 Aug 29 13:37 _action_files
-rw-r--r--   1 vyaangautam  staff    3665 Aug 29 13:37 _config.yml
drwxr-xr-x  24 vyaangautam  staff     768 Aug 29 13:37 _fastpages_docs
drwxr-xr-x  27 vyaangautam  staff     864 Aug 29 13:37 _includes
drwxr-xr-x   6 vyaangautam  staff     192 Aug 29 13:37 _layouts
drwxr-xr-x  10 vyaangautam  staff     320 Sep  1 13:27 _notebooks
drwxr-xr-x   6 vyaangautam  staff     192 Aug 29 13:37 _pages
drwxr-xr-x   4 vyaangautam  staff     128 Aug 29 13:37 _plugins
drwxr-xr-x   7 vyaangautam  staff     224 Aug 30 14:16 _posts
drwxr-xr-x   3 vyaangautam  staff      96 Aug 29 13:37 _sass
drwxr-xr-x   3 vyaangautam  staff      96 Aug 29 13:37 _word
drwxr-xr-x   4 vyaangautam  staff     128 Aug 29 13:37 assets
-rwxr-xr-x   1 vyaangautam  staff    1136 Aug 29 13:37 docker-compose.yml
drwxr-xr-x   7 vyaangautam  staff     224 Aug 29 13:37 images
-rw-r--r--   1 vyaangautam  staff     100 Aug 30 13:31 index.html
echo "Look for posts"
export posts=$project/_posts  # _posts inside project
cd $posts  # this should exist per fastpages
pwd  # present working directory
ls -l  # list posts
Look for posts
/Users/vyaangautam/HI/Blog/_posts
total 32
-rwxr-xr-x  1 vyaangautam  staff  1966 Aug 29 13:37 2020-01-14-test-markdown-post.md
-rw-r--r--  1 vyaangautam  staff    34 Aug 30 13:03 2022-08-24-CodE.md
-rw-r--r--  1 vyaangautam  staff   139 Aug 30 14:27 FirstMarkdown.md
-rw-r--r--  1 vyaangautam  staff   720 Aug 29 13:37 README.md
echo "Look for notebooks"
export notebooks=$project/_notebooks  # _notebooks is inside project
cd $notebooks   # this should exist per fastpages
pwd  # present working directory
ls -l  # list notebooks
Look for notebooks
/Users/vyaangautam/HI/Blog/_notebooks
total 6272
-rw-r--r--  1 vyaangautam  staff  3162468 Aug 30 14:20 2020-02-20-test.ipynb
-rw-r--r--  1 vyaangautam  staff      677 Aug 30 14:18 2022-08-30-Jupyter.ipynb
-rw-r--r--  1 vyaangautam  staff     2473 Aug 31 14:22 2022-08-31-quiz.ipynb
-rw-r--r--  1 vyaangautam  staff    26182 Sep  1 13:32 2022-09-1-bash_tutorial.ipynb
-rw-r--r--  1 vyaangautam  staff      771 Aug 29 13:37 README.md
-rw-r--r--  1 vyaangautam  staff      854 Aug 30 14:20 firstpython.ipynb
drwxr-xr-x  4 vyaangautam  staff      128 Aug 29 13:37 ghtop_images
drwxr-xr-x  3 vyaangautam  staff       96 Aug 29 13:37 my_icons
echo "Look for images in notebooks, print working directory, list files"
cd $notebooks/images  # this should exist per fastpages
pwd
ls -l
Look for images in notebooks, print working directory, list files
bash: cd: /Users/vyaangautam/HI/Blog/_notebooks/images: No such file or directory
/Users/vyaangautam/HI/Blog/_notebooks
total 6272
-rw-r--r--  1 vyaangautam  staff  3162468 Aug 30 14:20 2020-02-20-test.ipynb
-rw-r--r--  1 vyaangautam  staff      677 Aug 30 14:18 2022-08-30-Jupyter.ipynb
-rw-r--r--  1 vyaangautam  staff     2473 Aug 31 14:22 2022-08-31-quiz.ipynb
-rw-r--r--  1 vyaangautam  staff    26182 Sep  1 13:32 2022-09-1-bash_tutorial.ipynb
-rw-r--r--  1 vyaangautam  staff      771 Aug 29 13:37 README.md
-rw-r--r--  1 vyaangautam  staff      854 Aug 30 14:20 firstpython.ipynb
drwxr-xr-x  4 vyaangautam  staff      128 Aug 29 13:37 ghtop_images
drwxr-xr-x  3 vyaangautam  staff       96 Aug 29 13:37 my_icons

Look inside a Markdown File

"cat" reads data from the file and gives its content as output

echo "Navigate to project, then navigate to area wwhere files were cloned"

cd $project
echo "show the contents of README.md"
echo ""

cat README.md  # show contents of file, in this case markdown
echo ""
echo "end of README.md"
Navigate to project, then navigate to area wwhere files were cloned
show the contents of README.md

[//]: # (This template replaces README.md when someone creates a new repo with the fastpages template.)

![](https://github.com/VyaanG22/Blog/workflows/CI/badge.svg) 
![](https://github.com/VyaanG22/Blog/workflows/GH-Pages%20Status/badge.svg) 
[![](https://img.shields.io/static/v1?label=fastai&message=fastpages&color=57aeac&labelColor=black&style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAjCAYAAABhCKGoAAAGMklEQVR42q1Xa0xTVxyfKExlui9blszoB12yDzPGzJhtyT5s+zBxUxELBQSHm2ZzU5epBF/LclXae29pCxR5VEGgLQUuIOKDuClhm8oUK7S9ve19tLTl/fA5p9MNc/Y/hRYEzGLxJL/87zk9Ob/zf5++NGHMALzYgdDYmWh0Qly3Lybtw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RARJCcm9We2sgsZhGZmgMYjJOU7UhpOIqhRwwlmEwrBZHgCBRKkKX4ySVvbmzQnXoSDHWCyS6SV20Ha+VaSFTiSE8/ttVheDe4NarLxVB1kdE0fYAgjGaOWGYD1vxKrqmInkSBchRkmiuC4KILhonAo4+9gWVHYnElQMEsAxbRDSHtp7dq5CRWly2VlZe/EFRcvDcBQvBTPZeXly1JMpvlThzBBRASBoDsSBIpgOBQV6C+sUJzffwflQX8BTevCTZMZeoslUo9QJJZYTZDw3RuIKtIhlhXdfhDoJ7TTXY/XdBBpgUshwFMSRYTVwim7FJvt6aFyOnoVKqc7MZQDzzNwsmnd3UegCudl8R2qzHZ7bJbQoYGyn692+zMULCfXenoOacTOTBUnJYRFsq+5+a3sjp5BXM6hEz7ObHNoVEIHyocekiX6WIiykwWDd1HhzT8RzY2YqxnK0HNQBJtW500ddiwrDgdIeCABZ4MPnKQdk9xDhUP3wfHSqbBI9v/e9jo0Iy30cCOgAMyVgMMVCMwql/cQxfKp2R1dWWrRm0PzUkrIXC9ykDY+hnJ5DqkE709guriwSRgGzWTQCPABWJZ6vbNHQlgo099+CCEMPnF6xnwynYETEWd8ls0WPUpSWnTrfuAhAWacPslUiQRNLBGXFSA7TrL8V3gNhesTnLFY0jb+bYWVp0i7SClY184jVtcayi7so2yuA0r4npbjsV8CJHZhPQ7no323cJ5w8FqpLwR/YJNRnHs0hNGs6ZFw/Lpsb+9oj/dZSbuL0XUNojx4d9Gch5mOT0ImINsdKyHzT9Muz1lcXhRWbo9a8J3B72H8Lg6+bKb1hyWMPeERBXMGRxEBCM7Ddfh/1jDuWhb5+QkAAAAASUVORK5CYII=)](https://github.com/fastai/fastpages)

https://VyaanG22.github.io/Blog/

# My Blog


_powered by [fastpages](https://github.com/fastai/fastpages)_


## What To Do Next?

Great!  You have setup your repo.  Now its time to start writing content.  Some helpful links:

- [Writing Blogs With Jupyter](https://github.com/fastai/fastpages#writing-blog-posts-with-jupyter)

- [Writing Blogs With Markdown](https://github.com/fastai/fastpages#writing-blog-posts-with-markdown)

- [Writing Blog Posts With Word](https://github.com/fastai/fastpages#writing-blog-posts-with-microsoft-word)

- [(Optional) Preview Your Blog Locally](_fastpages_docs/DEVELOPMENT.md)

Note: you may want to remove example blog posts from the `_posts`,  `_notebooks` or `_word` folders (but leave them empty, don't delete these folders) if you don't want these blog posts to appear on your site.

Please use the [nbdev & blogging channel](https://forums.fast.ai/c/fastai-users/nbdev/48) in the fastai forums for any questions or feature requests.

end of README.md

Env, Git and GitHub

Env(ironment) is used to capture things like path to Code or Home directory. Git and GitHub is NOT Only used to exchange code between individuals, it is often used to exchange code through servers, in our case deployment for Website. All tools we use have a behind the scenes hav relationship with the system they run on (MacOS, Windows, Linus) or a relationship with servers which they are connected to (ie GitHub). There is an "env" command in bash. There are environment files and setting files (.git/config) for Git. They both use a key/value concept.

  • "env" show setting for your shell
  • "git clone" sets up a director of files
  • "cd $project" allows user to move inside that directory of files
  • ".git" is a hidden directory that is used by git to establish relationship between machine and the git server on GitHub.
echo "Show the shell environment variables, key on left of equal value on right"
echo ""

env
Show the shell environment variables, key on left of equal value on right

SHELL=/bin/zsh
TMPDIR=/var/folders/g1/gs8rcsvx0n3fs0qgmgxqppc80000gp/T/
CONDA_SHLVL=1
PYTHONUNBUFFERED=1
CONDA_PROMPT_MODIFIER=(base) 
OLDPWD=/Users/vyaangautam/HI/Blog/_notebooks
ORIGINAL_XDG_CURRENT_DESKTOP=undefined
MallocNanoZone=0
PYDEVD_USE_FRAME_EVAL=NO
PYTHONIOENCODING=utf-8
USER=vyaangautam
COMMAND_MODE=unix2003
CONDA_EXE=/Users/vyaangautam/opt/anaconda3/bin/conda
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.N0ZbqePwtV/Listeners
__CF_USER_TEXT_ENCODING=0x1F6:0x0:0x0
PAGER=cat
VSCODE_AMD_ENTRYPOINT=vs/workbench/api/node/extensionHostProcess
ELECTRON_RUN_AS_NODE=1
_CE_CONDA=
PATH=/Users/vyaangautam/opt/anaconda3/bin:/Users/vyaangautam/opt/anaconda3/condabin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
CONDA_PREFIX=/Users/vyaangautam/opt/anaconda3
__CFBundleIdentifier=com.microsoft.VSCode
PWD=/Users/vyaangautam/HI/Blog
notebooks=/Users/vyaangautam/HI/Blog/_notebooks
VSCODE_HANDLES_UNCAUGHT_ERRORS=true
project_repo=https://github.com/VyaanG22/Blog.git
project=/Users/vyaangautam/HI/Blog
project_dir=/Users/vyaangautam/HI
XPC_FLAGS=0x0
PS1=[PEXP\[\]ECT_PROMPT>
_CE_M=
XPC_SERVICE_NAME=0
SHLVL=1
HOME=/Users/vyaangautam
VSCODE_NLS_CONFIG={"locale":"en-us","availableLanguages":{},"_languagePackSupport":true}
CONDA_PYTHON_EXE=/Users/vyaangautam/opt/anaconda3/bin/python
LOGNAME=vyaangautam
LC_CTYPE=UTF-8
VSCODE_IPC_HOOK=/Users/vyaangautam/Library/Application Support/Code/1.70.2-main.sock
VSCODE_CODE_CACHE_PATH=/Users/vyaangautam/Library/Application Support/Code/CachedData/e4503b30fc78200f846c62cf8091b76ff5547662
CONDA_DEFAULT_ENV=base
VSCODE_PID=2216
posts=/Users/vyaangautam/HI/Blog/_posts
VSCODE_CWD=/
_=/usr/bin/env
cd $project

echo ""
echo "show the secrets of .git"
cd .git
ls -l

echo ""
echo "look at config file"
cat config
show the secrets of .git
total 88
-rw-r--r--    1 vyaangautam  staff    293 Sep  1 13:36 COMMIT_EDITMSG
-rw-r--r--    1 vyaangautam  staff    547 Aug 31 14:22 FETCH_HEAD
-rw-r--r--    1 vyaangautam  staff     23 Aug 29 13:37 HEAD
-rw-r--r--    1 vyaangautam  staff     41 Aug 31 14:22 ORIG_HEAD
-rw-r--r--    1 vyaangautam  staff    306 Aug 29 13:37 config
-rw-r--r--    1 vyaangautam  staff     73 Aug 29 13:37 description
drwxr-xr-x   15 vyaangautam  staff    480 Aug 29 13:37 hooks
-rw-r--r--    1 vyaangautam  staff  12290 Sep  1 13:36 index
drwxr-xr-x    3 vyaangautam  staff     96 Aug 29 13:37 info
drwxr-xr-x    4 vyaangautam  staff    128 Aug 29 13:37 logs
drwxr-xr-x  124 vyaangautam  staff   3968 Sep  1 13:36 objects
-rw-r--r--    1 vyaangautam  staff    411 Aug 29 13:37 packed-refs
drwxr-xr-x    5 vyaangautam  staff    160 Aug 29 13:37 refs

look at config file
[core]
	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
	ignorecase = true
	precomposeunicode = true
[remote "origin"]
	url = https://github.com/VyaanG22/Blog.git
	fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
	remote = origin
	merge = refs/heads/master

Student Request - Make a file in Bash

This example was requested by a student (Jun Lim, CSA). The request was to make jupyer file using bash, I adapted the request to markdown. This type of thought will have great extrapolation to coding and possibilities of using List, Arrays, or APIs to build user interfaces. JavaScript is a language where building HTML is very common.

To get more interesting output from terminal, this will require using something like mdless (https://github.com/ttscoff/mdless). This enables see markdown in rendered format.- On Desktop Install PKG from MacPorts

Output of the example is much nicer in "jupyter"

cd /tmp

file="sample.md"
if [ -f "$file" ]; then
    rm $file
fi

tee -a $file >/dev/null <<EOF
# Show Generated Markdown
This introductory paragraph and this line and the title above are generated using tee with the standard input (<<) redirection operator.
- This bulleted element is still part of the tee body.
EOF

echo "- This bulleted element and lines below are generated using echo with standard output (>>) redirection operator." >> $file
echo "- The list definition, as is, is using space to seperate lines.  Thus the use of commas and hyphens in output." >> $file
actions=("ls,list-directory" "cd,change-directory" "pwd,present-working-directory" "if-then-fi,test-condition" "env,bash-environment-variables" "cat,view-file-contents" "tee,write-to-output" "echo,display-content-of-string" "echo_text_>\$file,write-content-to-file" "echo_text_>>\$file,append-content-to-file")
for action in ${actions[@]}; do  # for loop is very similar to other language, though [@], semi-colon, do are new
  action=${action//-/ }  # convert dash to space
  action=${action//,/: } # convert comma to colon
  action=${action//_text_/ \"sample text\" } # convert _text_ to sample text, note escape character \ to avoid "" having meaning
  echo "    - ${action//-/ }" >> $file  # echo is redirected to file with >>
done

echo ""
echo "File listing and status"
ls -l $file # list file
wc $file   # show words
mdless $file  # this requires installation, but renders markown from terminal

rm $file  # clean up termporary file
File listing and status
-rw-r--r--  1 vyaangautam  wheel  809 Sep  1 13:42 sample.md
      15     132     809 sample.md
bash: mdless: command not found

Hacks

Go back to some of the deployment procedures and think about some thing you could verify through Bash notebook.

  • Is there anything we use to verify tools we install? Think about versions.
  • Is there anything we could verify with Anaconda?
  • How would you update a repository?
  • Really cool would be automating a procedure from installation.