Tools Installation and Loving my Tools

Learning to Accept It

Considering that the main hurdle I had to surpass before I could get to work on CSA work was related to tools, I wasn’t very inclined to say I love my tools during the first few days. I couldn’t get my local server up and, since I had forked the repository without creating a separate repo to host the GitHub Pages domain through, I basically had a nonexistent page. When I went on the search for solutions, though, I began to see the light.

bundler: command not found: 'jekyll'

My personal experience with the errors was most often related to my system’s attempts to track down locations of gems in different places at the same time. After searching around on the internet, I found that I could get started using rbenv.

Finding Success

I researched how to use rbenv to manage my Ruby environment. Since jekyll was having a bundler problem because it somehow ended up in Ruby 2.7.0, I tried shifting to Ruby 2.7.0 locally with rbenv local 2.7.0. Most often, however, even after once again running ruby -v, it would still say I was in the wrong environment. At some point, running rbenv rehash and reopening the terminal did the trick, but that wasn’t the end.

I ended up using bundle list to see which files I had. After running bundle install, I was repeatedly told that I was missing commonmarker, racc and something else, so it claimed to download it before saying the task was finished. I figured that they must not be downloading properly for some reason so I tried installing them individually, which revealed that the problem may have been with my Bundler version.

Long story short, by learning to understand the versions and locations of the various tools we used for setup, I came to love them. Now, here’s a whole section dedicated to why I loved all of these different tools.

Pair Programming

Because of the shared problems I was having with my partner Jishnu from the beginning of the year, we did a bit more pair debugging than we did pair programming. We started out both making adjustments to the Makefile in hopes that we could get it to work despite errors with Ruby, but I ended up moving away from the edits and using the original file so that the notebooks converted, and I advised him to use the original Makefile code too.

Soon after that, we realized we both couldn’t access our runtime GitHub Pages link because we had forked the repository. Having already made multiple edits, we looked for a way to avoid making a completely new repository. Others at our table, particularly David, mentioned creating a new repository and making it the origin for GitHub pushes and pulls.

We did do a bit of pair programming with my pixel art canvas, suggesting and trying ways to fix the “dragging isn’t working” problem. I ended up finding the solution at home, but his suggestion of using eventListeners to edit variables for other event functions ended up being the solution, just in a different form.

Love Stories

I discuss the many things I’ve worked with so far and why I love them so dearly below.

GitHub

GitHub is arguably the best thing that ever happened to coders. Not specifically to computer science, but to the people behind it. I can’t imagine how difficult it would be to work together with people on shared projects or store my progress on a bulky, complicated repository without the extremely easy-to-use and effective systems of GitHub. Collaboration has been the cornerstone of each trimester, and without GitHub, we would really be at a loss.

GitHub Pages

This is sort of a subset of GitHub itself, but GitHub pages has been such a boon because, the moment I create the repository, there’s a runtime link ready for me to look at. It coming styled and everything made the idea of creating things on it more inviting, since you have things to work with, but also a framework that could be drastically altered for your own personal interests. That’s basically what I’m in the process of doing with this site now.

Homebrew

Homebrew is the MVP G.O.A.T. of MacOS package and software installation. I’ve hardly ever had a problem with brew installations aside from the occasional brew update or brew uninstall -> reinstall [thing]. It also lets me actively manage packages and environments without much hassle, too.

Docker

When I was having trouble with Ruby last week, I kept thinking about how I could figure out how to make a Dockerfile and just run it through Docker. It makes deployment so much more manageable, and messing with the Dockerfile when we were working with AWS made solving errors so much more efficient. And speaking of AWS…

AWS

I won’t go on a whole rant about it, but we couldn’t have deployed without it. AWS was the backbone of all of my previous projects.

Python

Python was the perfect start to learning code for me. Lacking the syntactical asks of even easy languages like JavaScript, it was super easy to jump right into and made me eager to learn more. For a class dedicated to teaching the principles of computer science, it certainly help illustrate the foundations of what carries over between languages.

Ruby, Bundler and Jekyll

These have worked hand-in-hand, especially just in the last week, to put together and run sites like this. I struggled at first, but I soon came to realize that, as long as I properly managed my versions and environments, all of the errors that came up were manageable. Bundler is such an incredible help in that it installs all of the gems you could need in just one command, no confusion or anything. I’ve also found myself using --verbose with bundle install to solve problems I was having with Jekyll. And speaking of Jekyll, it’s been pretty much inseparable from all of the projects I’ve done in computer science here.

rbenv

I think I owe rbenv money. It saved my site (and my grades, if you think about it) by making it so easy to manage my horribly messy web of Ruby versions and environments. It let me change the local and global ruby environments to those that will make my life a whole lot easier in the future, and even when they continue to give me trouble (which they did recently), rbenv is so easy to use.

Honorable Mention: Postman

I see Postman whenever I restart my computer and it always reminds me of how helpful it was when I was first dealing with APIs and backend databases. I look forward to making more use of it this year.

Installation Hacks

I answered the Installation Hacks questions below.

  • Take note and describe the type of shell commands that you are using through Terminal in this installation procedure.
    • wsl, cd, git, apt, brew, …

See Bash Kernel work for all sorts of stuff like that, below this in the Week 0 notebook or on the separate lesson notes.

  • In the Development process, developers use Version control. Annotate in notes what you have learned about Version Control while doing this setup process.

Version control is tracking changes to code and documents over time. This is how coders (like us :D) avoid losing data or writing over each others’ work. Dependency management is a cornerstone of version control that is very present throughout the tools setup process.

  • Where are the files from GitHub placed on your local machine? How do you navigate to those files?

GitHub files are stored in my VSCode directory under their own subdirectories. I’m able to navigate those files by looking at what I have in my VSCode directory and selecting (by name) which GitHub project I’d like to work on with code [name]. I could use ls to list out all of the repositories in the VSCode directory.

  • Where are the files placed in the GitHub Cloud? How do you navigate to those files?

On the GitHub servers, you can find files by searching for them if you have their name of the username of the person who created it (assuming it isn’t a private project). You can navigate these files by clicking through the repository’s file tree or by searching for individual files using the site’s build-in search features.

  • Put into words the difference between viewing GitHub Pages running on localhost machine versus running on a deployed server.
    • What is the localhost URL for your distribution? Can anyone else see it?
    • What is the GitHub Pages URL for your distribution? Can anyone else see it?

When you’re viewing GitHub Pages on a localhost machine, you’re seeing the present, working state of the site as it is reflected in VSCode. Only you can see it, since it’s local only to your device (0.0.0.0:4200/drewtwo/). The GitHub Pages URL, on the other hand, specifically sees what has been committed and synced to the GitHub Pages repository on the GitHub servers (drewreed2005.github.io/drewtwo).

Linux Shell and Bash

Access the full lesson interactions here. Below are just my hacks.

Hacks

  • Come up with your own student view of this procedure to show your tools are installed.

I created a bash script that will check where various important tools are installed and show their versions.

%%script bash

# checking github info
echo "WHO ARE YOU (according to GitHub)?";
git config --global --get user.name;
echo "WHERE CAN YOU BE REACHED?";
git config --global --get user.email;
echo;

# checking homebrew info
echo "WHERE IS HOMEBREW?";
which brew;
echo "WHICH VERSION(S) OF HOMEBREW?";
brew -v;
echo;

# checking ruby info
eval "$(rbenv init -)"
echo "WHERE IS RUBY?";
which ruby;
echo "WHICH VERSION OF RUBY?";
ruby -v;
echo;

# checking rbenv info
echo "WHERE IS RBENV?";
which rbenv;
echo "WHICH VERSION OF RBENV?";
rbenv -v;
echo;

# checking python info
echo "WHERE IS PYTHON?";
which python;
echo "WHICH VERSION OF PYTHON?"
python3 --version
echo;

# checking jupyter
echo "WHERE IS JUPYTER?";
which jupyter;
echo "LET'S SEE SOME VERSIONS...";
jupyter --version;
echo "LET'S SEE SOME PACKAGES..."
jupyter kernelspec list;
echo;

# checking for bundler
echo "WHERE IS BUNDLER?";
which bundler;
echo "WHICH VERSION OF BUNDLER?";
bundle -v;
echo

# checking java
echo "WHERE IS JAVA?";
which java;
echo "WHICH VERSION OF JAVA?";
java -version;
WHO ARE YOU (according to GitHub)?
Drew Reed
WHERE CAN YOU BE REACHED?


drewdafox@gmail.com

WHERE IS HOMEBREW?
/usr/local/bin/brew
WHICH VERSION(S) OF HOMEBREW?
Homebrew 4.1.6-16-g3c8b494
Homebrew/homebrew-core (git revision f1cc1840f65; last commit 2023-08-17)
Homebrew/homebrew-cask (git revision 1a4702d1d4; last commit 2023-08-17)

WHERE IS RUBY?
/Users/mister_dew/.rbenv/shims/ruby
WHICH VERSION OF RUBY?
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin21]

WHERE IS RBENV?
/usr/local/bin/rbenv
WHICH VERSION OF RBENV?
rbenv 1.2.0

WHERE IS PYTHON?
/Users/mister_dew/opt/anaconda3/bin/python
WHICH VERSION OF PYTHON?
Python 3.9.12

WHERE IS JUPYTER?
/Users/mister_dew/opt/anaconda3/bin/jupyter
LET'S SEE SOME VERSIONS...
Selected Jupyter core packages...
IPython          : 8.7.0
ipykernel        : 6.19.2
ipywidgets       : 7.6.5
jupyter_client   : 6.1.12
jupyter_core     : 5.1.1
jupyter_server   : 1.13.5
jupyterlab       : 3.3.2
nbclient         : 0.5.13
nbconvert        : 6.4.4
nbformat         : 5.7.0
notebook         : 6.4.8
qtconsole        : 5.3.2
traitlets        : 5.7.1
LET'S SEE SOME PACKAGES...
Available kernels:
  bash          /Users/mister_dew/Library/Jupyter/kernels/bash
  java          /Users/mister_dew/Library/Jupyter/kernels/java
  javascript    /Users/mister_dew/Library/Jupyter/kernels/javascript
  python3       /Users/mister_dew/opt/anaconda3/share/jupyter/kernels/python3

WHERE IS BUNDLER?
/Users/mister_dew/.rbenv/shims/bundler
WHICH VERSION OF BUNDLER?
Bundler version 2.4.19

WHERE IS JAVA?
/usr/bin/java
WHICH VERSION OF JAVA?


java version "1.8.0_301"
Java(TM) SE Runtime Environment (build 1.8.0_301-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.301-b09, mixed mode)
  • Name and create notes on some Linux commands you will use frequently.

Frequently-used commands:

Directory and file commands

  • mkdir [directory name]: make a new directory
  • touch [file name]: make a new file
  • rm [file/directory]: delete a file/directory
  • mv [original location] [new location]: move a file/directory
  • cp [original location] [new location]: copy a file/directory to another file/directory

Listing and searching files

  • ls: lists files and directories in the current directory
  • ls -l: lists files and directories in long format (includes permissions, owner)
  • ls -a: lists all files and directories, including hidden ones
  • find [directory] -name [file name]: Search for files within a directory
  • grep [search term] [file name]: Search for text within a file

Others

  • cat [file]: shows the contents of a given file
  • ps: lists running processes
  • kill [process ID]: kill a running process
  • echo $[variable name]: display the value of an environment variable
  • export [variable name]=[value]: set an environment variable to a given value

There are many more, but these are some that I’ve used before.

  • Is there anything we use to verify tools we install? Review versions checks.

There are tons, and I showed them in the shell that checks for everything.

  • Is there anything we could verify with Anaconda? or WSL?

There’s plenty. I’ll show some Anaconda possibilities below.

%%script bash

# using conda list
# conda list lets you varify certain package installation (see examples in output)
echo "PYTHON CONTENTS";
conda list python;
echo;
echo "NumPY CONTENTS";
conda list NumPy;
echo;

# you can also create isolated Python environments and get info on them
echo "ANACONDA ENVIRONMENTS";
conda info --envs;
# conda activate [environment name] would activate a new environment

# update packages in the format below:
# conda update [package_name]
PYTHON CONTENTS
# packages in environment at /Users/mister_dew/opt/anaconda3:
#
# Name                    Version                   Build  Channel
ipython                   8.7.0            py39hecd8cb5_0  
ipython_genutils          0.2.0              pyhd3eb1b0_1  
msgpack-python            1.0.3            py39haf03e11_0  
python                    3.9.12               hdfd78df_0  
python-dateutil           2.8.2              pyhd3eb1b0_0  
python-fastjsonschema     2.16.2           py39hecd8cb5_0  
python-libarchive-c       2.9                pyhd3eb1b0_1  
python-lsp-black          1.0.0              pyhd3eb1b0_0  
python-lsp-jsonrpc        1.0.0              pyhd3eb1b0_0  
python-lsp-server         1.2.4              pyhd3eb1b0_0  
python-slugify            5.0.2              pyhd3eb1b0_0  
python-snappy             0.6.1            py39hcec6c5f_0  
python-vlc                3.0.16120                pypi_0    pypi
python.app                3                py39hca72f7f_0  

NumPY CONTENTS
# packages in environment at /Users/mister_dew/opt/anaconda3:
#
# Name                    Version                   Build  Channel
numpy                     1.21.5           py39h2e5f0a9_3  
numpy-base                1.21.5           py39h3b1a694_3  
numpydoc                  1.2                pyhd3eb1b0_0  

ANACONDA ENVIRONMENTS
# conda environments:
#
base                  *  /Users/mister_dew/opt/anaconda3
  • How would you update a repository? Could you do that in script above?

I can do it in the script below.

%%script bash

# navigate to the repo
cd /path/to/repo

# use git fetch command to retrieve updates from the remote repository
git fetch origin #(or replace "origin" with the remote repo's name)

# you can then review the changes with git log
git log

# pull changes
git pull origin main #main is an example; it can be another branch

Pixel Art Canvas

I’ve made plenty of games and I feel like a calculator would be pretty basic, so I wanted to challenge myself to make something I’ve never really made before in JavaScript. So I decided to make a pixel art canvas, which you can find here.

I added extra features like being able to drag the mouse and draw fluidly (which took a lot of research and problem-solving with event listeners) and undoing the last move.

Running Java

We saw earlier that I have the Java kernel installed, but we didn’t look at the Java on its own.

// Define Static Method within a Class
public class HelloStatic {
    // Java standard runtime entry point
    public static void main(String[] args) {    
        System.out.println("Hello World!");
    }
}
// A method call allows us to execute code that is wrapped in Class
HelloStatic.main(null);   // Class prefix allows reference of Static Method
Hello World!

You can see the full Java Hello notebook here.