%%script bash
## Personal Experimentation
echo "Hello World!"
echo "Using the echo command!"
Hello World!
Using the echo command!
Bash Tutorial
A brief overview of Bash, on your way to becoming a Linux expert. When a computer boots up, a kernel (MacOS, Windows, Linux) is started. This kernel provides a shell, or terminal, that allows user to interact with a most basic set of commands. Typically, the casual user will not interact with the shell/terminal as a Desktop User Interface is started by the computer boot up process. To activate a shell directly, users will run a “terminal” through the Desktop. VS Code provides ability to activate "terminal" while in the IDE.
Variable Prerequisites
Setup bash shell dependency variables for this page. Variables are one of the first aspects of programming. Variables have "name" and a "value".
- Hack Note: Change variables to match your student project.
Define variable
The following code cell defines 3 variables and assigns each a value. There are some extra command, called a HERE document, that write these variables to a file. This is so we can use these variables over and over below.
%%script bash
# Dependency Variables, set to match your project directories
cat <<EOF > /tmp/variables.sh
export project_dir=$HOME/vscode # change vscode to different name to test git clone
export project=\$project_dir/teacher # change teacher to name of project from git clone
export project_repo="https://github.com/nighthawkcoders/teacher.git" # change to project of choice
EOF
Output the value of a variable
The following code cell outputs the value of the variables, using the echo command. For visual understanding in the output, each echo command provide a title before the $variable
%%script bash
# Extract saved variables
source /tmp/variables.sh
# Output shown title and value variables
echo "Project dir: $project_dir"
echo "Project: $project"
echo "Repo: $project_repo"
Project dir: /home/kasm-user/vscode
Project: /home/kasm-user/vscode/teacher
Repo: https://github.com/nighthawkcoders/teacher.git
Project Setup and Analysis with Bash Scripts
The bash scripts that follow automate what was done in the setup procedures. The purpose of this is to show that many of the commands we performed can be added to a script, then performed automatically.
Pull Code
Pull code from GitHub to your machine. This is a bash script, a sequence of commands, that will create a project directory and add the “project” from GitHub to the vscode directory. There is conditional logic to make sure that clone only happen if it does not (!) exist. Here are some key elements in this code…
- cd command (change directory), remember this from terminal session
- if statements (conditional statement, called selection statement by College Board), code inside only happens if condition is met
%%script bash
# Extract saved variables
source /tmp/variables.sh
echo "Using conditional statement to create a project directory and project"
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 /home/kasm-user/vscode exists.
Directory /home/kasm-user/vscode/teacher exists.
Look at files Github project
All computers contain files and directories. The clone brought more files from cloud to your machine. Review the bash shell script, observe the commands that show and interact with files and directories. These were used during setup.
- “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
%%script bash
# Extract saved variables
source /tmp/variables.sh
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
Navigate to project, then navigate to area wwhere files were cloned
/home/kasm-user/vscode/teacher
list top level or root of files with project pulled from github
assets
_config.yml
csa.md
csp.md
csse.md
_data
Gemfile
Gemfile.lock
images
_includes
indexBlogs.md
index.md
_layouts
LICENSE
Makefile
_notebooks
_posts
README.md
scripts
_site
Look at file list with hidden and long attributes
Most linux commands have options to enhance behavior. The enhanced listing below shows permission bits, owner of file, size and date.
%%script bash
# Extract saved variables
source /tmp/variables.sh
echo "Navigate to project, then navigate to area wwhere files were cloned"
cd $project
pwd
echo ""
echo "list all files in long format"
ls -al # all files -a (hidden) in -l long listing
Navigate to project, then navigate to area wwhere files were cloned
/home/kasm-user/vscode/teacher
list all files in long format
total 112
drwxr-xr-x 13 kasm-user kasm-user 4096 Sep 5 18:21 .
drwxr-xr-x 8 kasm-user kasm-user 4096 Aug 30 19:57 ..
drwxr-xr-x 4 kasm-user kasm-user 4096 Aug 18 19:31 assets
-rw-r--r-- 1 kasm-user kasm-user 607 Aug 18 19:31 _config.yml
-rw-r--r-- 1 kasm-user kasm-user 92 Aug 18 19:31 csa.md
-rw-r--r-- 1 kasm-user kasm-user 98 Aug 18 19:31 csp.md
-rw-r--r-- 1 kasm-user kasm-user 108 Aug 18 19:31 csse.md
drwxr-xr-x 2 kasm-user kasm-user 4096 Aug 18 19:31 _data
-rw-r--r-- 1 kasm-user kasm-user 122 Aug 18 19:31 Gemfile
-rw-r--r-- 1 kasm-user kasm-user 7294 Aug 18 19:35 Gemfile.lock
drwxr-xr-x 8 kasm-user kasm-user 4096 Sep 5 18:21 .git
drwxr-xr-x 3 kasm-user kasm-user 4096 Aug 18 19:31 .github
-rw-r--r-- 1 kasm-user kasm-user 176 Aug 28 18:16 .gitignore
drwxr-xr-x 4 kasm-user kasm-user 4096 Sep 5 18:21 images
drwxr-xr-x 2 kasm-user kasm-user 4096 Aug 28 18:16 _includes
-rw-r--r-- 1 kasm-user kasm-user 53 Aug 18 19:31 indexBlogs.md
-rw-r--r-- 1 kasm-user kasm-user 5149 Aug 18 19:31 index.md
drwxr-xr-x 2 kasm-user kasm-user 4096 Aug 18 19:31 _layouts
-rw-r--r-- 1 kasm-user kasm-user 1081 Aug 18 19:31 LICENSE
-rw-r--r-- 1 kasm-user kasm-user 3136 Sep 5 18:21 Makefile
drwxr-xr-x 3 kasm-user kasm-user 4096 Sep 5 18:21 _notebooks
drwxr-xr-x 2 kasm-user kasm-user 4096 Sep 5 18:21 _posts
-rw-r--r-- 1 kasm-user kasm-user 6853 Sep 5 18:21 README.md
drwxr-xr-x 2 kasm-user kasm-user 4096 Aug 21 18:27 scripts
drwxr-xr-x 13 kasm-user kasm-user 4096 Aug 21 18:50 _site
%%script bash
# Extract saved variables
source /tmp/variables.sh
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
/home/kasm-user/vscode/teacher/_posts
total 108
-rw-r--r-- 1 kasm-user kasm-user 4650 Aug 18 19:31 2023-08-16-pair_programming.md
-rw-r--r-- 1 kasm-user kasm-user 7685 Aug 18 19:31 2023-08-16-Tools_Equipment.md
-rw-r--r-- 1 kasm-user kasm-user 7139 Aug 28 18:16 2023-08-17-markdown-html_fragments.md
-rw-r--r-- 1 kasm-user kasm-user 4687 Aug 28 18:16 2023-08-21-python_flask.md
-rw-r--r-- 1 kasm-user kasm-user 6670 Aug 28 18:16 2023-08-23-javascript-calculator.md
-rw-r--r-- 1 kasm-user kasm-user 10691 Sep 5 18:21 2023-08-30-agile_methodolgy.md
-rw-r--r-- 1 kasm-user kasm-user 4397 Sep 5 18:21 2023-08-30-javascript-music-api.md
-rw-r--r-- 1 kasm-user kasm-user 5312 Aug 28 18:16 2023-09-06-javascript-motion-mario-oop.md
-rw-r--r-- 1 kasm-user kasm-user 3688 Sep 5 18:21 2023-09-12-python-flask-repo.md
-rw-r--r-- 1 kasm-user kasm-user 2848 Sep 5 18:21 2023-09-12-unit-1-summary.md
-rw-r--r-- 1 kasm-user kasm-user 4812 Aug 18 19:31 2023-09-13-java-free_response.md
-rw-r--r-- 1 kasm-user kasm-user 13219 Aug 28 18:16 2023-10-16-java-api-pojo-jpa.md
-rw-r--r-- 1 kasm-user kasm-user 6819 Aug 18 19:31 2023-11-13-jwt-java-spring.md
%%script bash
# Extract saved variables
source /tmp/variables.sh
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
/home/kasm-user/vscode/teacher/_notebooks
total 1956
-rw-r--r-- 1 kasm-user kasm-user 992100 Aug 28 18:16 2023-07-15-machine_learning.ipynb
-rw-r--r-- 1 kasm-user kasm-user 13245 Sep 5 18:21 2023-07-29-cloud_database.ipynb
-rw-r--r-- 1 kasm-user kasm-user 43705 Aug 28 18:16 2023-07-29-cloud-workspace-automation.ipynb
-rw-r--r-- 1 kasm-user kasm-user 3584 Aug 28 18:16 2023-07-30-mario_overview.ipynb
-rw-r--r-- 1 kasm-user kasm-user 10600 Aug 28 18:16 2023-08-01-mario_player.ipynb
-rw-r--r-- 1 kasm-user kasm-user 14783 Aug 28 18:16 2023-08-02-mario_platform.ipynb
-rw-r--r-- 1 kasm-user kasm-user 22612 Aug 28 18:16 2023-08-03-mario_tube.ipynb
-rw-r--r-- 1 kasm-user kasm-user 25779 Aug 28 18:16 2023-08-04-mario_block.ipynb
-rw-r--r-- 1 kasm-user kasm-user 26462 Aug 28 18:16 2023-08-05-mario_goomba.ipynb
-rw-r--r-- 1 kasm-user kasm-user 30617 Aug 28 18:16 2023-08-06-mario_background.ipynb
-rw-r--r-- 1 kasm-user kasm-user 10283 Aug 28 18:16 2023-08-15-java-hello.ipynb
-rw-r--r-- 1 kasm-user kasm-user 26361 Aug 28 18:16 2023-08-16-github_pages_setup.ipynb
-rw-r--r-- 1 kasm-user kasm-user 16157 Aug 28 18:18 2023-08-16-linux_shell.ipynb
-rw-r--r-- 1 kasm-user kasm-user 11466 Aug 18 19:31 2023-08-16-python_hello.ipynb
-rw-r--r-- 1 kasm-user kasm-user 11158 Aug 28 18:16 2023-08-23-github_pages_anatomy.ipynb
-rw-r--r-- 1 kasm-user kasm-user 23636 Aug 28 18:16 2023-08-23-java-console_games.ipynb
-rw-r--r-- 1 kasm-user kasm-user 9663 Sep 5 18:21 2023-08-23-python_tricks.ipynb
-rw-r--r-- 1 kasm-user kasm-user 11546 Sep 5 18:21 2023-08-29-basics-of-js.ipynb
-rw-r--r-- 1 kasm-user kasm-user 3214 Aug 28 18:16 2023-08-30-javascript_grab.ipynb
-rw-r--r-- 1 kasm-user kasm-user 9858 Sep 5 18:21 2023-08-30-js-with-html.ipynb
-rw-r--r-- 1 kasm-user kasm-user 9689 Aug 18 19:31 2023-08-30-showcase-S1-pair.ipynb
-rw-r--r-- 1 kasm-user kasm-user 14380 Aug 18 19:31 2023-09-06-java-primitives.ipynb
-rw-r--r-- 1 kasm-user kasm-user 11501 Sep 5 18:21 2023-09-06-javascript-input.ipynb
-rw-r--r-- 1 kasm-user kasm-user 14910 Sep 5 18:21 2023-09-06-javascript-output-jquery.ipynb
-rw-r--r-- 1 kasm-user kasm-user 8892 Sep 5 18:21 2023-09-06-python-flask_in_jupyter.ipynb
-rw-r--r-- 1 kasm-user kasm-user 15944 Sep 5 18:21 2023-09-12-AP-python_lists.ipynb
-rw-r--r-- 1 kasm-user kasm-user 13706 Aug 28 18:16 2023-09-12-java_menu_class.ipynb
-rw-r--r-- 1 kasm-user kasm-user 7174 Sep 5 18:21 2023-09-12-python-flask-anatomy.ipynb
-rw-r--r-- 1 kasm-user kasm-user 9562 Aug 18 19:31 2023-09-13-java_fibonaccii_class.ipynb
-rw-r--r-- 1 kasm-user kasm-user 28297 Sep 5 18:31 2023-09-13-javascript_output_api.ipynb
-rw-r--r-- 1 kasm-user kasm-user 8474 Sep 5 18:21 2023-09-13-python-errors_fries.ipynb
-rw-r--r-- 1 kasm-user kasm-user 43423 Aug 18 19:31 2023-09-13-python-pandas_intro.ipynb
-rw-r--r-- 1 kasm-user kasm-user 22313 Sep 5 18:21 2023-09-17-python-images-U2-2.ipynb
-rw-r--r-- 1 kasm-user kasm-user 34764 Sep 5 18:21 2023-09-18-python-pandas-U2-3.ipynb
-rw-r--r-- 1 kasm-user kasm-user 49093 Sep 5 18:21 2023-09-19-python-sql-U2-4a.ipynb
-rw-r--r-- 1 kasm-user kasm-user 11553 Sep 5 18:21 2023-09-19-python-sql-U2-4b.ipynb
-rw-r--r-- 1 kasm-user kasm-user 11578 Aug 28 18:16 2023-09-20-java-image_2D.ipynb
-rw-r--r-- 1 kasm-user kasm-user 26732 Aug 28 18:16 2023-09-20-javascript_motion_dog.ipynb
-rw-r--r-- 1 kasm-user kasm-user 22157 Sep 5 18:21 2023-09-27-aws-deployment.ipynb
-rw-r--r-- 1 kasm-user kasm-user 13599 Aug 28 18:16 2023-10-02-java-spring-anatomy.ipynb
-rw-r--r-- 1 kasm-user kasm-user 12429 Aug 28 18:16 2023-10-09-java-chatgpt.ipynb
-rw-r--r-- 1 kasm-user kasm-user 15632 Aug 18 19:31 2023-10-09-javascript_api.ipynb
-rw-r--r-- 1 kasm-user kasm-user 113091 Aug 18 19:31 2023-10-09-python_machine_learing_fitness.ipynb
-rw-r--r-- 1 kasm-user kasm-user 20077 Aug 28 18:16 2023-10-16-java_jpa.ipynb
-rw-r--r-- 1 kasm-user kasm-user 16271 Aug 18 19:31 2023-11-13-jwt-python-flask.ipynb
-rw-r--r-- 1 kasm-user kasm-user 15951 Aug 18 19:31 2023-11-13-vulnerabilities.ipynb
-rw-r--r-- 1 kasm-user kasm-user 18328 Aug 18 19:31 2023-11-20-jwt-java-spring-challenge.md
-rw-r--r-- 1 kasm-user kasm-user 10745 Aug 18 19:31 2024-01-04-cockpit-setup.ipynb
drwxr-xr-x 2 kasm-user kasm-user 4096 Aug 18 19:31 files
%%script bash
# Extract saved variables
source /tmp/variables.sh
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
/home/kasm-user/vscode/GavinCopley.github.io/_notebooks
total 120
-rw-r--r-- 1 kasm-user kasm-user 16359 Sep 6 20:03 2023-08-16-linux_shell.ipynb
-rw-r--r-- 1 kasm-user kasm-user 5515 Aug 30 19:57 2023-08-17-Markdown_Table_Code_Hack.ipynb
-rw-r--r-- 1 kasm-user kasm-user 8957 Aug 30 19:57 2023-08-21-HTML_Image_Hack.ipynb
-rw-r--r-- 1 kasm-user kasm-user 1831 Aug 29 19:51 2023-08-24-First_Blog.ipynb
-rw-r--r-- 1 kasm-user kasm-user 17562 Aug 30 19:57 2023-08-30-Calculator.ipynb
-rw-r--r-- 1 kasm-user kasm-user 1515 Sep 6 19:46 2023-08-31-Review_Ticket_1.ipynb
-rw-r--r-- 1 kasm-user kasm-user 3097 Sep 1 18:26 2023-08-31-Review_Ticket.ipynb
-rw-r--r-- 1 kasm-user kasm-user 1352 Sep 5 18:41 2023-09-01-plan_2.ipynb
-rw-r--r-- 1 kasm-user kasm-user 1809 Sep 6 19:53 2023-09-04-plan_3.ipynb
-rw-r--r-- 1 kasm-user kasm-user 44175 Sep 6 20:03 2023-09-05-javascript_output_api.ipynb
bash: line 6: cd: /images: No such file or directory
Look inside a Markdown File
“cat” reads data from the file and gives its content as output
%%script bash
# Extract saved variables
source /tmp/variables.sh
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
## Teacher Blog site
This site is intended for the development of Teacher content. This blogging site is built using GitHub Pages [GitHub Pages](https://docs.github.com/en/pages/getting-started-with-github-pages/creating-a-github-pages-site).
- The purpose is to build lessons and distribute across different Computer Science sections (CSSE, CSP, CSA), a pathway that covers 3 years of High School instruction.
- The primary languages and frameworks that are taught are `JavaScript/HTML/CSS`, `Python/Flask`, `Java/Spring`. Read below for more details.
- In this course, Teacher content is not exclusively developed by Teachers. In fact, many Students have been invited to develop and publish content into this repository. Their names will appear as authors on the content which they aided in producing.
- This site has incorporated ideas and has radically modified scripts from the now deprecated [fastpages](https://github.com/fastai/fastpages) repository.
- This site includes assistance and guideance from ChatGPT, [chat.openai.com](https://chat.openai.com/)
### Courses and Pathway
The focus of the Del Norte Computer Science three-year pathway is `Full Stack Web Development`. This focus provides a variety of technologies and exposures. The intention of the pathway is breadth and exposure.
- `JavaScript` documents are focused on frontend development and for entry class into the Del Norte Computer Science pathway. JavaScript documents and materials are a prerequisites to Python and Java classes.
- `Python` documents are focused on backend development and requirements for the AP Computer Science Principles exam.
- `Java` documents are focused on backend development and requirements for the AP Computer Sciene A exam.
- `Data Structures` materials embedded into JavaScript, Python, or Java documents are focused on college course articulation.
### Resources and Instruction
The materials, such as this README, as well as `Tools`, `DevOps`, and `Collaboration` resources are integral part of this course and Computer Science in general. Everything in our environment is part of our learning of Computer Science.
- `Visual Studio Code` is key the code-build-debug cycle editor used in this course, [VSCode download](https://code.visualstudio.com/). This is an example of a resource, but inside of it it has features for collaboration.
- `Tech Talks`, aka lectures, are intended to be interactive and utilize `Jupyter Notebooks` and Websites. This is an example of blending instruction and tools together, which in turn provide additional resources for learning. For instance, deep knowledge on GitHub Pages and Notebooks are valuable in understanding principles behind Full Stack Development and Data Science.
## GitHub Pages
All `GitHub Pages` websites are managed on GitHub infrastructure. GitHub uses `Jekyll` to tranform your content into static websites and blogs. Each time we change files in GitHub it initiates a GitHub Action that rebuilds and publishes the site with Jekyll.
- GitHub Pages is powered by: [Jekyll](https://jekyllrb.com/).
- Publised teacher website: [nighthawkcoders.github.io/teacher](https://nighthawkcoders.github.io/teacher/)
## Preparing a Preview Site
In all development, it is recommended to test your code before deployment. The GitHub Pages development process is optimized by testing your development on your local machine, prior to files on GitHub
Development Cycle. For GitHub pages, the tooling described below will create a development cycle `make-code-save-preview`. In the development cycle, it is a requirement to preview work locally, prior to doing a VSCode `commit` to git.
Deployment Cycle. In the deplopyment cycle, `sync-github-action-review`, it is a requirement to complete the development cycle prior to doing a VSCode `sync`. The sync triggers github repository update. The action starts the jekyll build to publish the website. Any step can have errors and will require you to do a review.
### WSL and/or Ubuntu installation requirements
- The result of these step is Ubuntu tools to run preview server. These procedures were created using [jekyllrb.com](https://jekyllrb.com/docs/installation/ubuntu/)
```bash
#
# WSL/Ubuntu setup
#
mkdir mkdir vscode
git clone https://github.com/nighthawkcoders/teacher.git
# run script, path vscode/teacher are baked in script
~/vscode/teacher/scripts/activate_ubuntu.sh
#=== !!!Start a new Terminal!!! ===
#=== Continue to next section ===
```
### MacOs installation requirements
- Ihe result of these step are MacOS tools to run preview server. These procedures were created using [jekyllrb.com](https://jekyllrb.com/docs/installation/macos/).
```bash
#
# MacOS setup
#
mkdir mkdir vscode
git clone https://github.com/nighthawkcoders/teacher.git
# run script, path vscode/teacher are baked in script
~/vscode/teacher/scripts/activate_macos.sh
#=== !!!Start a new Terminal!!! ===
#=== Continue to next section ===
```
### Run Preview Server
- The result of these step is server running on: http://0.0.0.0:4100/teacher/. Regeneration messages will run in terminal on any save and update site upon refresh. Terminal is active, press the Enter or Return key in the terminal at any time to see prompt to enter commands.
- Complete installation
```bash
cd ~/vscode/teacher
bundle install
make
```
- Run Server. This requires running terminal commands `make`, `make stop`, `make clean`, or `make convert` to manage the running server. Logging of details will appear in terminal. A `Makefile` has been created in project to support commands and start processes.
- Start preview server in terminal
```bash
cd ~/vscode/teacher # my project location, adapt as necessary
make
```
- Terminal output of shows server address. Cmd or Ctl click http location to open preview server in browser. Example Server address message...
```
Server address: http://0.0.0.0:4100/teacher/
```
- Save on ipynb or md activiates "regeneration". Refresh browser to see updates. Example terminal message...
```
Regenerating: 1 file(s) changed at 2023-07-31 06:54:32
_notebooks/2024-01-04-cockpit-setup.ipynb
```
- Terminal message are generated from background processes. Click return or enter to obtain prompt and use terminal as needed for other tasks. Alway return to root of project `cd ~/vscode/teacher` for all "make" actions.
- Stop preview server, but leave constructed files in project for your review.
```bash
make stop
```
- Stop server and "clean" constructed files, best choice when renaming files to eliminate potential duplicates in constructed files.
```bash
make clean
```
- Test notebook conversions, best choice to see if IPYNB conversion is acting up.
```bash
make convert
```
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 relationships 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.
%%script bash
# This command has no dependencies
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/bash
SESSION_MANAGER=local/kasm:@/tmp/.ICE-unix/84,unix/kasm:/tmp/.ICE-unix/84
VNCOPTIONS=-PreferBandwidth -DynamicQualityMin=4 -DynamicQualityMax=7 -DLP_ClipDelay=0 -select-de manual
XDG_CONFIG_DIRS=/etc/xdg
PYTHONUNBUFFERED=1
XDG_MENU_PREFIX=xfce-
APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL=1
PULSE_RUNTIME_PATH=/var/run/pulse
HOSTNAME=kasm
LANGUAGE=en_US:en
SDL_GAMECONTROLLERCONFIG=030000005e040000be02000014010000,XInput Controller,platform:Linux,a:b0,b:b1,x:b2,y:b3,back:b8,guide:b16,start:b9,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:b12,dpdown:b13,dpleft:b14,dpright:b15,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7
KASM_SVC_SEND_CUT_TEXT=-SendCutText 1
DISTRO=ubuntu
INST_DIR=/dockerstartup/install
SSH_AUTH_SOCK=/tmp/ssh-XXXXXXhJcNRz/agent.146
ELECTRON_RUN_AS_NODE=1
START_PULSEAUDIO=1
DESKTOP_SESSION=xfce
SSH_AGENT_PID=150
KASM_SVC_AUDIO_INPUT=1
NO_AT_BRIDGE=1
VSCODE_AMD_ENTRYPOINT=vs/workbench/api/node/extensionHostProcess
KASM_SVC_AUDIO=1
PWD=/home/kasm-user/vscode/GavinCopley.github.io/_notebooks
VNC_RESOLUTION=1366x612
KASM_ID=8884907a-ee46-4d17-9325-6ea81e93dffb
NVIDIA_DRIVER_CAPABILITIES=graphics,compat32,utility
PYDEVD_IPYTHON_COMPATIBLE_DEBUGGING=1
VSCODE_CODE_CACHE_PATH=/home/kasm-user/.config/Code/CachedData/6c3e3dba23e8fadc360aed75ce363ba185c49794
KASM_SVC_DOWNLOADS=1
OMP_WAIT_POLICY=PASSIVE
HOME=/home/kasm-user
LANG=en_US.UTF-8
XDG_CURRENT_DESKTOP=XFCE
AUDIO_PORT=4901
VSCODE_IPC_HOOK=/home/kasm-user/.config/Code/1.81-main.sock
DONT_PROMPT_WSL_INSTALL=No_Prompt_please
STARTUPDIR=/dockerstartup
CLICOLOR=1
VSCODE_L10N_BUNDLE_LOCATION=
PROXYPATH=f5262684-abd7-43/b43159c2-f50f-4a7b-8593-511b1b797c0f
SKIP_CLEAN=true
CHROME_DESKTOP=code-url-handler.desktop
KASM_SVC_GAMEPAD=0
GEM_HOME=/home/kasm-user/gems
TERM=xterm-color
GOMP_SPINCOUNT=0
GIT_PAGER=cat
KASMVNC_AUTO_RECOVER=true
VNC_COL_DEPTH=24
KASM_SVC_UPLOADS=1
PYTHONIOENCODING=utf-8
START_XFCE4=1
DISPLAY=:1.0
VSCODE_PID=271
SHLVL=1
PAGER=cat
MAX_FRAME_RATE=24
VSCODE_CWD=/home/kasm-user
KASM_VNC_PATH=/usr/share/kasmvnc
MPLBACKEND=module://matplotlib_inline.backend_inline
KASM_RX_HOME=/dockerstartup/kasmrx
LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:/usr/lib/i386-linux-gnu:/opt/libjpeg-turbo/lib64/:/usr/local/lib/:/usr/local/nvidia/lib:/usr/local/nvidia/lib64
VSCODE_CRASH_REPORTER_PROCESS_TYPE=extensionHost
LC_ALL=en_US.UTF-8
KASM_SVC_ACCEPT_CUT_TEXT=-AcceptCutText 1
INST_SCRIPTS=/ubuntu/install/tools/install_tools.sh /ubuntu/install/chrome/install_chrome.sh /ubuntu/install/chromium/install_chromium.sh /ubuntu/install/sublime_text/install_sublime_text.sh /ubuntu/install/slack/install_slack.sh /ubuntu/install/vs_code/install_vs_code.sh /ubuntu/install/cleanup/cleanup.sh
XDG_DATA_DIRS=/usr/local/share:/usr/share
GDK_BACKEND=x11
VNC_PORT=5901
PATH=/bin:/home/kasm-user/.local/bin:/home/kasm-user/gems/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/kasm-user/gems/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
NO_VNC_PORT=6901
ORIGINAL_XDG_CURRENT_DESKTOP=XFCE
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-tpBuyQLD2H,guid=00a96b1ff2fa2ff470d1d02664f8cf27
VSCODE_NLS_CONFIG={"locale":"en-us","osLocale":"en-us","availableLanguages":{},"_languagePackSupport":true}
DEBIAN_FRONTEND=noninteractive
VSCODE_HANDLES_UNCAUGHT_ERRORS=true
_=/bin/env
%%script bash
# Extract saved variables
source /tmp/variables.sh
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 64
drwxr-xr-x 2 kasm-user kasm-user 4096 Aug 18 19:31 branches
-rw-r--r-- 1 kasm-user kasm-user 267 Aug 18 19:31 config
-rw-r--r-- 1 kasm-user kasm-user 73 Aug 18 19:31 description
-rw-r--r-- 1 kasm-user kasm-user 102 Sep 5 18:21 FETCH_HEAD
-rw-r--r-- 1 kasm-user kasm-user 21 Aug 18 19:31 HEAD
drwxr-xr-x 2 kasm-user kasm-user 4096 Aug 18 19:31 hooks
-rw-r--r-- 1 kasm-user kasm-user 15323 Sep 5 18:21 index
drwxr-xr-x 2 kasm-user kasm-user 4096 Aug 18 19:31 info
drwxr-xr-x 3 kasm-user kasm-user 4096 Aug 18 19:31 logs
drwxr-xr-x 4 kasm-user kasm-user 4096 Sep 5 18:21 objects
-rw-r--r-- 1 kasm-user kasm-user 41 Sep 5 18:21 ORIG_HEAD
-rw-r--r-- 1 kasm-user kasm-user 112 Aug 18 19:31 packed-refs
drwxr-xr-x 5 kasm-user kasm-user 4096 Aug 18 19:31 refs
look at config file
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = https://github.com/nighthawkcoders/teacher.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "main"]
remote = origin
merge = refs/heads/main
Advanced 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
- In Terminal on MacOS
- Install ncurses
gem install mdless
Output of the example is much nicer in “jupyter”
%%script bash
# This example has error in VSCode, it run best on 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 kasm-user kasm-user 809 Sep 6 20:03 sample.md
15 132 809 sample.md
bash: line 30: mdless: command not found
Hack Preparation.
Review Tool Setup Procedures and think about some thing you could verify through a Shell notebook.
- Come up with your own student view of this procedure to show your tools are installed. It is best that you keep the few things you understand, add things later as you start to understand them.
- Name and create blog notes on some Linux commands you will use frequently.
- Is there anything we use to verify tools we installed? Review versions? We can verify tools we installed if everything works and we can check versions with -v
- How would you update a repository? Use the git command line? To update a repository I need to do git push to push mu local version to the Github version. I can also do git pull to pull the github version to my local machine.