Bashrc

#
# ~/.bashrc
#

# Show directory name and running process
#PROMPT_COMMAND='echo -en "\033]0;$(pwd|cut -d "/" -f 4-100)\007"' 
#trap 'echo -en "\033]0;(${BASH_COMMAND})\007"' DEBUG
#trap 'echo -ne "\033]0;$(pwd|cut -d "/" -f 4-100): (${BASH_COMMAND})\007"' DEBUG
#trap 'echo -en "\033]0;$(pwd|rev|cut -d "/" -f1,2|rev): (${BASH_COMMAND})\007"' DEBUG
#PROMPT_COMMAND='echo -en "\033]0;$(whoami)@$(hostname)|$(pwd|cut -d "/" -f 4-100)\a"'
#trap 'echo -en "\033]0;(${BASH_COMMAND})\007"' DEBUG
PROMPT_COMMAND='echo -en "\033]0;$(pwd|cut -d "/" -f 4-100)\a"'

# Aliases
alias vi="nvim"

# Activat vi mode with <Escape>:
set -o vi

EDITOR=/usr/bin/nvim

#save path on cd
function cd {
    builtin cd $@
    pwd > ~/.last_dir
}

# restore last saved path
if [ -f ~/.last_dir ]
    then cd `cat ~/.last_dir`
fi


combine-pdf() { gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=combinedpdf_`date +'%F_%Hh%M'`.pdf -f "$@" ;}

[[ $- != *i* ]] && return

colors() {
    local fgc bgc vals seq0

    printf "Color escapes are %s\n" '\e[${value};...;${value}m'
    printf "Values 30..37 are \e[33mforeground colors\e[m\n"
    printf "Values 40..47 are \e[43mbackground colors\e[m\n"
    printf "Value  1 gives a  \e[1mbold-faced look\e[m\n\n"

    # foreground colors
    for fgc in {30..37}; do
        # background colors
        for bgc in {40..47}; do
            fgc=${fgc#37} # white
            bgc=${bgc#40} # black

            vals="${fgc:+$fgc;}${bgc}"
            vals=${vals%%;}

            seq0="${vals:+\e[${vals}m}"
            printf "  %-9s" "${seq0:-(default)}"
            printf " ${seq0}TEXT\e[m"
            printf " \e[${vals:+${vals+$vals;}}1mBOLD\e[m"
        done
        echo; echo
    done
}

[ -r /usr/share/bash-completion/bash_completion ] && . /usr/share/bash-completion/bash_completion

# Change the window title of X terminals
case ${TERM} in
    xterm*|rxvt*|Eterm*|aterm|kterm|gnome*|interix|konsole*)
        PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/\~}\007"'
        ;;
    screen*)
        PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/\~}\033\\"'
        ;;
esac

use_color=true

# Set colorful PS1 only on colorful terminals.
# dircolors --print-database uses its own built-in database
# instead of using /etc/DIR_COLORS.  Try to use the external file
# first to take advantage of user additions.  Use internal bash
# globbing instead of external grep binary.
safe_term=${TERM//[^[:alnum:]]/?}   # sanitize TERM
match_lhs=""
[[ -f ~/.dir_colors   ]] && match_lhs="${match_lhs}$(<~/.dir_colors)"
[[ -f /etc/DIR_COLORS ]] && match_lhs="${match_lhs}$(</etc/DIR_COLORS)"
[[ -z ${match_lhs}    ]] \
    && type -P dircolors >/dev/null \
    && match_lhs=$(dircolors --print-database)
[[ $'\n'${match_lhs} == *$'\n'"TERM "${safe_term}* ]] && use_color=true

if ${use_color} ; then
    # Enable colors for ls, etc.  Prefer ~/.dir_colors #64489
    if type -P dircolors >/dev/null ; then
        if [[ -f ~/.dir_colors ]] ; then
            eval $(dircolors -b ~/.dir_colors)
        elif [[ -f /etc/DIR_COLORS ]] ; then
            eval $(dircolors -b /etc/DIR_COLORS)
        fi
    fi

    if [[ ${EUID} == 0 ]] ; then
        PS1='\[\033[01;31m\][\h\[\033[01;36m\] \W\[\033[01;31m\]]\$\[\033[00m\] '
    else
        PS1='\[\033[01;32m\][\u@\h\[\033[01;37m\] \W\[\033[01;32m\]]\$\[\033[00m\] '
    fi

    alias ls='ls --color=auto'
    alias grep='grep --colour=auto'
    alias egrep='egrep --colour=auto'
    alias fgrep='fgrep --colour=auto'
else
    if [[ ${EUID} == 0 ]] ; then
        # show root@ when we don't have colors
        PS1='\u@\h \W \$ '
    else
        PS1='\u@\h \w \$ '
    fi
fi

unset use_color safe_term match_lhs sh

alias cp="cp -i"                          # confirm before overwriting something
alias df='df -h'                          # human-readable sizes
alias free='free -m'                      # show sizes in MB
alias np='nano -w PKGBUILD'
alias more=less

xhost +local:root > /dev/null 2>&1

# Bash won't get SIGWINCH if another process is in the foreground.
# Enable checkwinsize so that bash will check the terminal size when
# it regains control.  #65623
# http://cnswww.cns.cwru.edu/~chet/bash/FAQ (E11)
shopt -s checkwinsize

shopt -s expand_aliases

# export QT_SELECT=4

# Enable history appending instead of overwriting.  #139609
shopt -s histappend

#
# # ex - archive extractor
# # usage: ex <file>
ex ()
{
  if [ -f $1 ] ; then
    case $1 in
      *.tar.bz2)   tar xjf $1   ;;
      *.tar.gz)    tar xzf $1   ;;
      *.bz2)       bunzip2 $1   ;;
      *.rar)       unrar x $1     ;;
      *.gz)        gunzip $1    ;;
      *.tar)       tar xf $1    ;;
      *.tbz2)      tar xjf $1   ;;
      *.tgz)       tar xzf $1   ;;
      *.zip)       unzip $1     ;;
      *.Z)         uncompress $1;;
      *.7z)        7z x $1      ;;
      *)           echo "'$1' cannot be extracted via ex()" ;;
    esac
  else
    echo "'$1' is not a valid file"
  fi
}

Free Code Camp - Responsive Web Design 3/20

Learn CSS Colors by Building a Set of colored Markers

Description: “Selecting the correct colors for your webpage can greatly improve the aesthetic appeal to your readers. In this course, you’ll build a set of colored markers. You’ll learn different ways to set color values and how to pair colors with each other.” Here is the HTML that demonstrates CSS colors.

Create A Website Using HUGO From Start To Finish 3/3

Certbot and HTTPS

Once you have a website, it is extremely important to enable encrypted connections over HTTPS/SSL. You might have no idea what that means, but it’s easy to do now that we’ve set our web server up.

Certbot is a program that automatically creates and deploys the certificates that allow encrypted connections. It used to be painful (and often expensive) to do this, but now it’s all free and automatic. Why is encryption important?

With HTTPS, users’ ISPs cannot snoop on what they are looking at on your website. They know that they have connected, but the particular pages they visit are private as everything is encrypted. HTTPS increases user privacy. If you later create usernames and passwords for any service on your site, lack of encryption can compromise that private data! Most well-designed software will automatically prevent any unencrypted connections over the internet. Search engines like Google favor pages with HTTPS over unencrypted HTTP. You get the official-looking green 🔒 symbol in the URL bar in most browsers which makes normies subtly trust your site more.

Let’s do it! website without https/ssl

Note in this picture that a browser accessing your site will say “Not secure” or something else to notify you that we are using an unencrypted HTTP connection rather than an encrypted HTTPS one. Installation

Just run:

apt install python3-certbot-nginx

And this will install certbot and its module for nginx. Run

As I mentioned in the previous article, firewalls might interfere with certbot, so you will want to either disable your firewall or at least ensure that it allows connections on ports 80 and 443:

ufw allow 80
ufw allow 443

Now let’s run certbot:

certbot --nginx

The command will ask you for your email. This is so when the certificates need to be renewed in three months, you will get an email about it. You can set the certificates to renew automatically, but it’s a good idea to check it the first time to ensure it renewed properly. You can avoid giving your email by running the command with the –register-unsafely-without-email option as well.

Agree to the terms, and optionally consent to give your email to the EFF (I recommend against this obviously).

Once all that is done, it will ask you what domains you want a certificate for. You can just press enter to select all. activate HTTPS for a site with certbot

It will take a moment to create the certificate, but afterwards, you will be asked if you want to automatically redirect all connections to be encrypted. Since this is preferable, choose 2 to Redirect. redirecting http to encrypted https with certbot Checking for success

You should now be able to go to your website and see that there is a 🔒 lock icon or some other notification that you are now on an encrypted connection. A 🔒 symbol symbolizing our new HTTPS layer for our website! Setting up certificate renewal

As I mentioned in passing, the Certbot certificates last for 3 months. To renew certificates, you just have to run certbot –nginx renew and it will renew any certificates close to expiry.

Of course, you don’t want to have to remember to log in to renew them every three months, so it’s easy to tell the server to automatically run this command. We will use a cronjob for this. Run the following command:

crontab -e

There might be a little menu that pops up asking what text editor you prefer when you run this command. If you don’t know how to use vim, choose nano, the first option.

This crontab command will open up a file for editing. A crontab is a list of commands that your operating system will run automatically at certain times. We are going to tell it to automatically try to renew our certificates every month so we never have to.

Create a new line at the end of the file and add this content:

0 0 1 * * certbot --nginx renew

Save the file and exit to activate this cronjob.

For more on cron and crontabs please click here!

You now have a live website on the internet. You can add to it what you wish.

As you add content to your site, there are many other things you can also install linked on the main page, and many more improvements, tweaks and bonuses.

Create A Website Using HUGO From Start To Finish 2/3

Setting Up an NginX Webserver


Logging in to the server

Login to your VPS (vultr), go to the Overview page:

ssh root@yourdomain.com

Enter the above command on a terminal. You will be prompted to enter your password. Enter the password found on the Overview page.

Installing the Webserver: NginX

If the command runs without error, you are now logged into your server.

apt update
apt upgrade
apt install nginx

Our nginx configuration file

Our nginx configuration file

nginx configuration files are in /etc/nginx/. The two main subdirectories on Debian, are /etc/nginx/sites-available and /etc/nginx/sites-enabled.

First, let’s create the settings for our website. You can copy and paste (with required changes) but I will also explain what the lines do.

Create a file in /etc/nginx/sites-available by doing this:

nano /etc/nginx/sites-available/mywebsite

Note that “nano” is a command line text editor. You will now be able to create and edit this file. By saving, this file will now appear. Note also I name the file mywebsite, but you can name it whatever you’d like.

I’m going to add the following content to the file. The content like this will be different depending on what you want to call your site.

server {
        listen 80 ;
        listen [::]:80 ;
        server_name example.org ;
        root /var/www/mysite ;
        index index.html index.htm index.nginx-debian.html ;
        location / {
                try_files $uri $uri/ =404 ;
        }
}

Explanation of those settings

The listen lines tell nginx to listen for connections on both IPv4 and IPv6.

The server_name is the website that we are looking for. By putting paulmackay.xyz here, that means whenever someone connects to this server and is looking for that address, they will be directed to the content in this block.

root specifies the directory we’re going to put our website files in. This can theoretically be wherever, but it is conventional to have them in /var/www/. Name the directory in that whatever you want.

index determine what the “default” file is; normally when you go to a website, say paulmackay.xyz, you are actually going to a file at paulmackay.xyz/index.html. That’s all that is. Note that that this in concert with the line above mean that /var/www/paulmackay/index.html, a file on our computer that we’ll create will be the main page of our website.

Lastly, the location block is really just telling the server how to look up files, otherwise throw a 404 error. Location settings are very powerful, but this is all we need them for now. Create the directory and index for the site

We’ll actually start making a “real” website later, but let’s go ahead and create a little page that will appear on when someone looks up the domain.

mkdir /var/www/mysite

Now let’s create and index file inside of that directory which will appear when the website is accessed:

nano /var/www/mysite/index.html

I’ll add the following basic content, but you can add whatever you want. This will appear on your website.

Enable the site

Once you save that file, we can enable it making a link to it in the sites-enabled directory:

ln -s /etc/nginx/sites-available/mywebsite /etc/nginx/sites-enabled

Now we can just reload or restart to make nginx service the new configuration:

systemctl reload nginx

The Firewall

Vultr and some other VPS automatically install and enable ufw, a firewall program. This will block basically everything by default, so we have to change that. If you don’t have ufw installed, you can skip this section.

We must open up at least ports 80 and 443 as below:

ufw allow 80
ufw allow 443

Port 80 is the canonical webserver port, while 443 is the port used for encrypted connections. We will certainly need that for the next page.

As you add more services to your website, they might need you to open more ports, but that will be mentioned on individual articles. (It should be noted that some local services only running for other services on your machine, so you don’t need to open ports for every process running locally, only those that directly interact with the internet, although it’s common to run those through NginX for simplicity and security.) Nginx security hint

By default, Nginx and most other webservers automatically show their version number on error pages. It’s a good idea to disable this from happening because if an exploit comes out for your server software, someone could exploit it. Open the main Nginx config file /etc/nginx/nginx.conf and find the line # server_tokens off;. Uncomment it, and reload Nginx.

Remember to keep your server software up to date to get the latest security fixes! We now have running website!

At this point you can now type in your website in your browser and this webpage will appear!he purpose of these subdirectories

Click here for Part 3/3

Create A Website Using HUGO From Start To Finish 1/3

Note: all software and products mentioned in this tutorial is what I used to make this website

Click here for Part 2/2: Setting up your server.

requirments:

  • Operating System: linux, mac
  • A Domain Name
  • A Server Provider

STEP 1: Buy A Domain Name

Go to www.epik.com

Search for the domain name you want and buy it. Usually its around $5 per year for a domain name.

STEP 2: Start A Server

Go to www.vultr.com using my referal code much appreciated!

Once you have an account, go ahead and click on deploy a server.

These are the options I chose (cheapest possible):

STEP 3: Linking Domain-Name To Your Server

Once you have your domain name and your server set up, lets get the website up and running.

  • Go to Vulr.
  • Click on Instances -> yourdomainname.com
  • Settings -> IPv4

Were going to copy the IPv4 and IPv6 address to our domain name.

  • Open up your epik account.
  • Click on the hamburger selector on the left of your domain name.
  • Click SET DNS HOST RECORDS

Add four new Records, two for A(IPv4), and two for AAAA(IPv6).

  • Copy and Paste your IPv4 into the first two Points to box
  • Copy and Paste your IPv6 into the last two Points to box
  • Copy my Host and TTL settings
    • * means if the user types in anything preceding .example.com it will still go to your site
    • space means if they enter example.com it will be registered as www.example.com
    • TTL is how fast the server updates

Test it out

Now that we have linked our domain name to our server it should be up and running.

Congradulations! You now have your own website. In the next tutorial we are going to set-up the server, and add an html page. Click here for Part 2/2: Setting up your server.

SENG 265 - Portfolio

Welcome to my SENG 265 Term Portfolio Project

hello

Paul MacKay

3rd Year, Computer Science Major

University of Victoria

This Jupyter Notebook documents my SENG 265 experience. I will summarize here what I am learning in this course about: programming languages (i.e., C, Python 3, Bash, Jupyter Markdown, LaTex, SVG),

  • software development methods (i.e, version control, configuration management, object-oriented programming, debugging, testing, seperate compilation), and
  • software development techniques and tools (i.e., Jupyter Notebooks, Unix, Bash, Git, Gitlab, make, makefiles, GNU C, C libraries, Python C interpreter, Python 3 libraries).

Part 1

Part 1 of this project, deals with the following aspects of my software development journey as follows:

1. What is my background in Jupyter Notebooks? What is the core functionality of Jupyter notebooks?

  • I have used Jupyter Notebooks in order to ducument small to medium python programs in order to solve a number of math problems on Project Euler.
  • In my understanding and experience - Jupyter Notebooks are an all-in-one interpreter, formatting and documentation platform. Used extensively, though commonly used to present or document acedemic research, software development, science or engineering logbooks, and professoinal portfolios.
  • Markdown is similar to HTML in function. Markdown is used to add and modify text in the following ways:
    • Headings can be made by inserting “# “, …, “###### " before text, the user can create different sizes of headers in decending order (# is the largest sized heading)
    • Paragraphs can be formatted by leaving one cariage return between two lines of text.
    • line Breaks are made by simply pressing return at the end of the line which you desire to have a line break.
    • Emphasis can be made on text in the following ways:
      • Text can be made bold by adding double asterisk’s on both sides of some given text. (ex. ** text ** )
      • Italicized text can be made my adding single asterisk’s on both side of the text. (ex. * text * )
      • Bold and Italic text can be made by adding tripple asterisk’s on both sides of the text. (ex. *** text *** )
    • Blockquotes allows having a part of the content from another source link. These are similar to reply email text. Add the symbol greater than ‘>’ to the line that contains the text.
    • Lists allow the user to organize information in a readable way.
      • Ordered Lists is a numbered list from (1-n). Can be nested where every level up is indented.
      • Unordered Lists is a non-numbered list. Can be nested where every level up is indented.
        • Unordered list nested in an ordered list, or vice versa.
    • Links can be inserted by [link] (https://www.example.com)
    • Images can be inserted by ![description] (filepath/image.png)

3. How can I typeset mathematical formulas including Greek letters using LaTeX Markdown in Jupyter Notebooks?

  • Mathematical formulas and symbols are rendered using LaTeX inside Markdown using MathJax.

  • To use LaTeX in markdown surround the desired math inside dollar signs.

  • For example Euler’s identity: $ e^{i \pi} + 1 = 0 $ can be rendered like so.

4. What is my background in Unix or Linux? How prevalent is Unix or Linux in software development?

  • Linux has been my daily driver for the past two years. During that time I’ve had to learn lots about bash commands, editing config files in vim, using vim for any file editing and creation, using Linux as a software development platform, using almost exclusively free and open source software, debugging if I run into any issues on Linux, been exposed to many Linux distributions, downloading software from repositories git, Arch User/Official Repository, and apt (Debian based)
  • The internet runs on Linux, it is the backbone to the structure of the internet. Basically all internet servers are built on Linux, most software development companies use linux for every component of their work, front-end and back-end.

5. What is my background in the programming language C? How prevalent is C in software development?

  • I have written small to medium sized programs in C. Written in vim and compiled with gcc in a terminal. Made use and continuing to master the following attributes of C:

    • Functions
    • Variable Declaration, Definition and Scope
    • Pointers
    • Data Types
    • Struct
    • Input/Output
    • Memory Management
    • File Handling
    • Operators
    • Arrays & Strings
  • C is very prevalent in software development. Like all other programming languages C has a specific use. C being a low-level programming language it is superior for large, complex, and long term supported software. The other reason C is used for long living programs is because no new features are being added to it, so a program from 20 years ago will still run today. The low level nature of C gives the programmer more control over the hardware and memory, therefore programs can be written more efficiently, and in a manner that is executed faster therefore is light on resources.

6. What is my background in the programming language Python 3? How prevalent is Python 3 in software development?

  • Written small programs interpereted in Jupyter Notebooks, in order to solve math problems on Project Euler. Used the following attributes of Python3:

    • Data Structures
      • Tuple
      • Dictionary
      • Operators
      • Arrays
    • Conditional loops
      • if…else, elif, switch
      • For and While loops
    • Strings
      • Replace, Join, Split, Reverse, Uppercase, Lowercase
      • strip() Function
      • count() Function
      • format() Function
      • len() Function
      • find() Function
    • Functions
    • File handling
    • List
    • DateTime
  • Python one of the most used languages on the planet. Its a very versitile language, but usually used for prototyping. You wouldn’t want to use Python to write a long lasting software, for one because it is always being updated and it would be a nightmare to change millions of lines of code to update it. Second it is much heavier of a language due to the fact that it is interpereted instead of compiled, therefore using more resourses making it much slower than a compiled language like C.

7. What is the core functionality of the Bash command and scripting language?

  • Bash commands provide the user with a robust set of commands that are administered in the terminal (stdin). The purpose of these commands is to do operations on files and directories.
  • Scrips are used for automation. A script would be comprised of a series of bash commands in order to achieve a desired outcome.

8. Why is version control and configuration management critical in software development projects.

  • version control enables a team of developers to work on a project together. Each developer is able to take a fork of the main branch make changes (improve, fix bugs, add/remove features, etc), and then if the team agrees on the changes they are merged to the master branch. Each time the master is worked on a new branch is made, this is a version and can be restored if needed at a later date. This is also useful if someone messes up, the messed up branch can be discarded and the team or individual can revert back to a working version of the project. The ability to work on a copy of the project without having to work on the original is important because if the developer were to be working exclusively on the original project, the project would have to be taken offline which would be a terrible buisness model, being that development on projects is always taking place.

9. What are the core functionalities of Git, Github, and Gitlab?

  • Git is the most widely used version control platform. Git has many features but most common for a work flow is the following.

    • Staging: git add ~/file.ext. Add a file or modifications to a file to the staging area.
    • git commit -m “Meaningful message”. commit encapsulates all of the changes made to the local repository, ready to be “pushed” to the remote server.
    • git push - updates the masterbranch (remote server) with the development branch (local server).
  • Github is just git but it offers the developer a user interface. This is useful for group projects and individuals . Group projects can be worked on and submitted on github in order to distribute open-source software to the public, acting as a platform to host open-source projects. For the individual - github is used to showcase projects and experience to employers other developers. Hense acting as a platform to record all of the work the developer has done, current and future projects.

10. What are your personal insights, aha moments, and epiphanies you experienced in the first part of SENG 265?

  • Realizing that some tasks are actually hard, but if you have the right mindset and strategy that difficult task becomes managable.
Sources:

https://www.guru99.com/python-tutorials.html

https://www.w3schools.io/file/markdown-blockquotes/

https://www.markdownguide.org/basic-syntax/

https://towardsdatascience.com/write-markdown-latex-in-the-jupyter-notebook-10985edb91fd

https://www.geeksforgeeks.org/c-programming-language/

Part 2

1. How is Git used as a version control system?

  • Just like if someone was working on a text document like an essay for school, they may have multiple versions to go back to. For example: essay1.odt, essay2.odt, essay3.odt. This would be an exaple of version control in a nieve sense. Git makes version control more sophisticated and useful in the following ways: When using git, there is a remote and local repository. The remote repository contains the main branch - the most up-to-date version of the software. Plus all of the other previous versions of the project (can be found in the .git file in all git repositories). The remote repository is useful to have because multiple people can then work on the project. The function of the local repository is - to clone the remote repository to your local repository (which is just your local computer your are using). Develop the code taken from the remote repo, make changes to the code, then - if your working alone use the following commands, add, commit, push. If youre working with others then you may have to submit a merge request. Whenever a push, or merge is performed git will make that the main branch which will be recorded as a “version” next time a push or merge is executed.

2. How can Git be used effectively in a highly distributed software development environment involving multiple countries?

  • Unlike a centralized workflow, which is used by having one central hub, or repository, with a number of developers. A distributed workflow has many applications as it can be structured hierarchical. Distributed workflow uses multiple repositories, distributed among developers, access to such repository is dictated by the permission structure for that specific development team. Each development team would have a different hierarchy depending on the role of each member. For example, take a development team, the members of which are located around the world. From https://git-scm.com/book/en/v2/Distributed-Git-Distributed-Workflows there are two common ways to deploy distributed workflows:
    • Integreation-Manager Workflow:
      1. The project maintainer pushes to their public repository.
      2. A contributor clones that repository and makes changes.
      3. The contributor pushes to their own public copy.
      4. The contributor sends the maintainer an email asking them to pull changes.
      5. The maintainer adds the contributor’s repository as a remote and merges locally.
      6. The maintainer pushes merged changes to the main repository.
    • Dictator and Lieutenants Workflow:
      1. Regular developers work on their topic branch and rebase their work on top of master. The master branch is that of the reference repository to which the dictator pushes.
      2. Lieutenants merge the developers’ topic branches into their master branch.
      3. The dictator merges the lieutenants’ master branches into the dictator’s master branch.
      4. Finally, the dictator pushes that master branch to the reference repository so the other developers can rebase on it.

3. Breifly describe the history of version control systems.

  • Version control has a long history. One of the first VCS’s was Source Code Control System (SCCS) introduced in 1973. There were many releases of VCS’s from 1973 until 2005 when Linus Torvalds released git. None of these older releases gained mass adoption like git did. A couple reason that git was so successful was (1) Linus was a huge name in the open source community at the time, therefore the word got out and it became the most successful and most used VSC (2) Linus’s was able to solve the inefficiencies faced in the early developers of VCS’s, making it a better, more useful, and space efficient program.
  • Top 5 programming languages:

    1. Python
    2. C
    3. Java
    4. C++
    5. C#
  • Python has gained popularity due to the rise in AI, machine learning and its application to these feilds. Its also used for web development, data science, automation. Another reason that Python is so popular is because it is a high-level prototyping language, meaning - developers can use Python to create a prototype of a project, then export it to a production language like C, or Java. Its also easy for humans to read and use (more intuitive).

  • C is the most popular production programming language. Gives the programmer lots of control (lower level) but remains a fairly straight forward language to learn. The low level nature, rigidity,and simplicity makes C the most widely used programming language for long lasting software that can survive through the test of time. Also that C is a lower level language and is compiled, makes it lighter on resources, therefore would be good for huge and complex programs.

  • Java is another popular production language, its a bit higher level than C but still low level enough to be fast. Is an object oriented language, platform independent, simple, secure, etc.

  • I am very excited that we are learning the top two programming languages, gives good experience in the persuit of mastering these languages. I feel more confident using C after completing assignment 1, and I’m exited to complete assignment 2 and get familiar with python. It’s a really good place to build off, and it makes me excited to work on projects in the future.

6. Describe the fundamental differences between C and Python.

  • C:

    • Type:
      • C is a structured programming language, statically typed.
    • Variable Declaration:
      • Variables must be declared before using a variable, and the data-type must be declared.
    • Compilation:
      • C code is compiled by a compiler, hence it is defined as a compiled language.
    • Built-in Functions:
      • C has a limited as percise set of built-in library functions.
    • Execution:
      • Since C is a compiled language, code is compiled directly to machine code which is executed directly by the CPU.
  • Python:

    • Type:
      • Python is an object-oriendted type programming language and is dynamically typed.
    • Variable Declaration:
      • Python declaring the data-type will result in error.
    • Compilation:
      • Python code is interpreted, hence it is defined as a interpreted language.
    • Built-in Functions:
      • Python has an extensive and robust set of built-in library functions.
    • Execution:
      • Python code is vist compile to a byte-code then it is interpreted by a C program.

7. How challenging was Assignment 1 for you?

  • Assignment 1 was difficult, but once I knew the strategy I was going to deploy everything fell into place and I was able to get it done. There was a whole lot of background knowledge required to complete assignment 1 and if I didn’t have some degree of mastery over the language I would not have been able to finish it. Bill Bird’s C video’s really helped me understand the foundational concepts of C. The video’s gave me a comprehensive enough overview of C to be able to implement the language to a real world problem. Really an invaluable resource for anyone learning C, my thanks goes out to Bill Bird for those video’s.

8. Describe your continued learning experience in SENG 265.

  • In order to be an asset to either a company, development team, or customer, I’m looking forward to continuing my development as a software developer. The remainder of SENG 265 will be focused on dynamic memory, make files, GDB debugging tool in C, this will take place among assignment 3, labs, and exams. In Python we will be continuing learning object oriented programming, and solving small to medium sized problems, this will take place during assignment 2, and 4, labs, and exams.
Sources:

https://www.codesweetly.com/git-basic-introduction/

https://git-scm.com/book/en/v2/Distributed-Git-Distributed-Workflows

https://ericsink.com/vcbe/html/history_of_version_control.html#idp129536

https://www.tiobe.com/tiobe-index/

https://www.tutorialspoint.com/java/java_overview.htm

https://www.youtube.com/watch?v=rlA89I3Y0nQ&list=PLU4IQLU9e_Oq2dqhFV6n9shODnN8DR9b_

Part 3

1. How useful is SENG 265 for building your resume for future co-op applications and furture job applications?

  • SENG 265 has been a very exciting and useful course, packed with very useful information. My ability to read, and develop software has been sharpened as a result of taking this course. It has extended my knowledge in using bash, and using Linux as a development environment (including Vim as a text editor). Learning about incremental development changed my outlook on how to develop software effectively and efficiently. Learning about quantum computing opened my eyes to the future applications of this technology, and potential job opportunities related to this field. Some of these skills I was already working on and this class helped me extend my knowledge in those categories, I was also introduced to new ideas. In both cases I’m excited to extend my knowledge and learn more in the near future. The way in which I believe this course will help me find a co-op and job in the future is being competent in the field, also being exposed to, and interested in future technologies will be an important asset to posses. Given that most tech jobs and CSC co-op’s recommend or require some experience with at least one of the topics we covered in SENG 265, it is extremely useful taking this course.

2. In SENG 265 you acquired significant systems programming knowledge and learned many different skills (e.g., C, Python, Unix, Bash, make, pipes & filters SVG, HTML, static and dynamic data structures, testing and debugging, text processing, and many more. Which skills are most valuable for you? Which skills are you going to add to your resume?

  • I have been using Linux as my daily driver OS for the past two years. Learning more about, and using Unix, Bash, pipes, and filters daily made me much more efficient, confident when using them, hence increasing the utility of these systems in my development. In other words going over Unix, Bash, pipes, and filters increased my mastery over Linux as a development environment, it was quite useful for me. Completing the assignments made me substantially better at reading, and debugging code, also I got a lot better at structuring a programs. I plan on including most of, if not all of these learning outcomes on my resume. Given that most of the topics we went over in this class are recommended or required for most of the positions posted, and also for most tech jobs.That I’m going to be applying for a co-op next fall I’m quite happy to have gone over the topics covered in this course, and that it has sparked some ideas for projects I can work on to gain more experience.

Uvic COOP Resume Outline

a2

3. Describe the difference between object-based and object-oriented programming. The first part of the Python lectures was object-based programming. The second part involves classes and is called object-oriented programming.

  • Object-based programming is where the programmer uses imported packages and modules, primitive data types, functions, built-in functions, and their functionality in code, but does not write classes and methods themselves. Usually the program is decomposed into various functions and main calls those functions.
  • Object-oriented programming is where the entire project is evolves around the OOP philosophy. Meaning the program functionality is encapsulated in classes and their methods. When a class is instantiated that is classically called an object. That object then has access to all of the methods contained in that class. The benefits of OOP is that bugs can be found locally in the class/ method, making debugging much more straight forward and obvious where the bug might be. Another benefit is having private attributes in a class. Where the instance variable does not have direct access to attributes, in this case setters and getters are used when manipulating and viewing attribute members of that object.

Code sample from Assignment 2

  • Here in assignment 2 we used Oject-based program most of the functionality is wrapped up in definitions, then those functions are called in main.

a2

Code sample from Assignment 4

  • Here in assignment 4 we used Oject-oriented programming. All of the functionality is wrapped up in classes, and their methods.

a4

4. Describe the notion of and motivation for typing and typing hints in Python.

  • When declaring a variable the data type is specified, this is called type hinting. The benefits of using type hints is – if a bug occurs where the data type was changed somewhere in the program, this would be a difficult bug to find. If type hints were used when run this “type miss-match” would be detected and the bug would easily be found and fixed. Type hints make programs much easier to read and understand the functionality. Hence if working with others it would be a good idea to use type hints.

a4

5. Python classes package and encapsulate data and functions that operate on those data. What are the big advantages of classes with respect to packaging and encapsulation.

  • Simplicity – Break down a project into smaller portions rather than having one massive block of code. This makes code easier to write and less prone to buggy code.
  • Maintainability – having a program broken up into classes and methods means the software will have high cohesion and low coupling. Meaning the code will not contain inter-dependencies, that would lead to a highly coupled program that would be virtually impossible to maintain.
  • Reusability – since each module has specific functionality the code from a package or module can easily be reused in one or more projects.
  • Scoping – each module is made of classes, those classes contain methods. Hence the scope of each defined in separate namespace, which helps to avoid collisions among identifiers.

6. How challenging was Assignment 4 for you?

  • I started off by integrating the provided methods given in the part 1 template into a class called ProEpilogue. The function of this class is to write the headers for the html document and to open the svg block, and to close these blocks with appropriate white space padding. I then created two simple classes called Circle and Rectangle, and followed the logic and structure proposed in the given code. The function of these classes is to write a line of text to a file that represents a circle or a rectangle in the svg format. To draw a circle or rectangle specific parameters are required. For example to specify the color parameters would be r=255, g=255, b=255 for that particular circle or rectangle to be drawn. Now the goal is to repeat this for n number of shape objects, in this case Circle and Rectangles, with random values. The approach I took was to make each randomly created art page an object. To achieve this I made a class called PyArt. PyArt’s instance method receives all of the information to create an HTML, SVG art page, ie number of shapes, size, color, which shape. Therefore all we have to do is create one “art object” with all the values specified once, when that object is instantiated. This makes modifying values and flavor of the art straight forward and easy to do. I would say it was not a trivial project, it was certainly in reach to achieve for a student with limited python experience.
  • For example all I have to do is: pa1: PyArt = PyArt(f, “Python SVG Art1”,
    5000, (0, 1000, 0, 250), (0,0), (0, 10), (5, 100, 5, 50),
    (0,0,0, 255, 255, 255, 0.5, 1.0))

7. Did you send your art work to your friends and family?

  • I sent the code to one of my brothers to run to show him what I did for assignment 4. I showed most of my family members the artwork I created, and I plan to send the rest there very own randomly generated greetings card.

8. Describe your continued learning experience in SENG 265.

  • I plan on expanding the knowledge and concepts introduced in SENG 265. All of the concepts were foundational and spanned across many important subjects. I plan on applying the knowledge gained to side projects, I can see that I will need C and Python for the side projects I have in mind. This would also give me a chance to apply this knowledge to a real world example, thereby solidifying and expanding that knowledge. For example I’m planning on installing a car PC which includes GPS, speedometer, tachometer, engine load meter, backup camera, music from scratch in my car via raspberry pi connected to a screen and an OBD-II connection. I’m hoping to use exclusively open source software, therefore I can modify the code to my needs. From my research I see that most of the software and config files are written in either C or Python. I also have other projects in mind that I plan to do over the summer.
Sources:

https://realpython.com/lessons/type-hinting/

Commands I Use Frequently (Vim, Bash, more)

VIM:


Numerate numerable element in visual selection:

visual select - g - ctrl+a

example:

![](/serv1.png)
![](/serv1.png)
![](/serv1.png)
![](/serv1.png)
![](/serv1.png)
![](/serv1.png)
![](/serv1.png)

![](/serv1.png)
![](/serv2.png)
![](/serv3.png)
![](/serv4.png)
![](/serv5.png)
![](/serv6.png)
![](/serv7.png)

Visual block:

ctrl-v - select - shift+I - write -  esc

example: say we want to append ![] to the beginning of multiple lines.

(/serv1.png)
(/serv1.png)
(/serv1.png)
(/serv1.png)
(/serv1.png)
(/serv1.png)
(/serv1.png)

It can be done simply with the above command.

![](/serv1.png)
![](/serv1.png)
![](/serv1.png)
![](/serv1.png)
![](/serv1.png)
![](/serv1.png)
![](/serv1.png)

Copy and paste from vim

"*y  "*p 

to “yank” text into the * register then to paste …or

"+y then "+p

Capitalize first letter of each word in selected region

s/\<./\u&/g

\< matches the start of a word

. matches the first character of a word

\u tells Vim to uppercase the following character in the substitution string (&)

& means substitute whatever was matched on the left-hand side

g means substitute all matches, not only the first

BASH:


Find what directory a file is in.

example

find . -name "*.py" -type f 

locate any file name ending in .py

find . -name "*.py" -type f -exec cat {} + > all.py

locate any file name ending in .py, then execute cat for each file into a new
file called all.py

Turn down brightness and soften screen (reduce bluelight)

example

xrandr --output VGA-1 --brightness .80 && redshift -O 2500

Concatinate multiple files into one:

cat *.html > output.html

Convert .docx to pdf

 libreoffice --headless --convert-to pdf *.docx   

New terminal opens in most recent working directory:

#save path on cd
function cd {
    builtin cd $@
    pwd > ~/.last_dir
}


#restore last saved path
if [ -f ~/.last_dir ]
    then cd `cat ~/.last_dir`
fi

WEBSITE:


Sync local copy of website to website server

rsync -uvrP --delete-after /home/paul/new-site2/public/ root@paulmackay.xyz:/var/www/paulmackay/

My init.vim

Feel free to try out these settings by copying and pasting them into your

~/.config/nvim/init.vim (neovim) or ~/.vimrc (vim)

note - the only dependency is Plug, you can view it on github here: vim-plug

Here is a sample of my neovim configuration:

set exrc
set guicursor=
set relativenumber
set nu
set nohlsearch
set hidden
set noerrorbells
set tabstop=4 softtabstop=4
set shiftwidth=4
set expandtab
set smartindent
set nowrap
set smartcase
set noswapfile
set nobackup
set undodir=~/.vim/undodir
set undofile
set incsearch
set termguicolors
set scrolloff=8
set noshowmode
set completeopt=menuone,noinsert,noselect
set colorcolumn=80
set signcolumn=yes
set clipboard=unnamedplus

"Set terminal window title to name of current open file 
set title
augroup WindowTitleGroup
  autocmd!
  autocmd BufEnter,BufFilePost * let &titlestring = expand('%:t')
augroup end

nnoremap <SPACE> <Nop>
let mapleader = " "

call plug#begin('~/.vim/plugged')
Plug 'nvim-telescope/telescope.nvim'
Plug 'gruvbox-community/gruvbox'
Plug 'xiyaowong/nvim-transparent' 
"Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'junegunn/fzf', {'do': { -> fzf#install()}}
Plug 'junegunn/fzf.vim'
Plug 'xuhdev/vim-latex-live-preview', { 'for': 'tex' }
call plug#end()

colorscheme gruvbox
highlight Normal ctermfg=grey ctermbg=darkblue
"highlight Normal guibg=none
let g:transparent_enabled = v:false
nmap <leader>gd <Plug>(coc-definition)
nmap <leader>gr <Plug>(coc-references)
nnoremap <C-p> :GFiles<CR>

"Keeping it centered
nnoremap n nzzzv
nnoremap N Nzzzv
nnoremap J mzJ'z
"undo
inoremap , ,<c-g>u
inoremap . .<c-g>u
inoremap [ [<c-g>u
inoremap ! !<c-g>u
inoremap ? ?<c-g>u
"
vnoremap J :m '>+1<CR>gv=gv
vnoremap K :m '<-2<CR>gv=gv
inoremap <C-j> <esc>:m .+1<CR>==
inoremap <C-k> <esc>:m .-2<CR>==
nnoremap <leader>j :m .+1<CR>==
nnoremap <leader>k :m .-2<CR>==