Code Self Study Wiki

This is the home of the new Code Self Study Wiki. It's still under construction, but more content is coming soon.

To edit or add pages, make a pull request on the Github repo.

Study Guides

This section will contain self-study guides for members.

Command Line Study Guide

This is a guide for becoming more familiar with the command line. These are some basic GNU/Linux terminal commands that are useful to know as a minimum.

Built-in Documentation

Most commands come with documentation in the form of "man[ual] pages". To read the man page for a command use the man command.

Example: to read the documentation for the ls command, type man ls in a terminal. You can also search Google for information on any command.

If the man pages are too overwheming, there is also a simpler tool called tldr.

List of Useful Commands

Click on the name of a command for more information.


  • clear -- clear the terminal. Also ctrl-l


  • man -- read the built-in documentation
  • tldr -- shorter, simpler documentation for commands

Where Am I?

  • pwd -- show your current location in the filesystem
  • cd -- change directory
  • ls -- list directory contents. Also ls -l, ls -R, and ls -al.
  • tree -- list a directory as a tree. e.g., tree -d >> outputfile.txt. You may need to install it first.

An alternative way to move around and keep track of where you've been is to use dirs.

  • dirs -- a stack of recently visited directories
  • pushd -- move to another directory with a bookmark (actually a stack of directories you've jumped from, so you can use it multiple times)
  • popd -- jump back to the place where you pushd'd from

Manipulating Files

  • cp -- copy files
  • mv -- move a file or directory. Also for renaming things
  • mkdir -- make a directory
  • rm -- remove a file. Also rm -rf, but very dangerous. See this story for a warning on how dangerous it can be.
  • rmdir --- remove a directory
  • touch -- create a new empty file

Finding Files

  • grep -- search the contents of files
  • rg -- ripgrep
  • locate -- find files
  • find -- find files. E.g., find / -name '*.desktop'
  • fd -- a find command with some improvements


  • which -- tells you where a program is located
  • apropos -- can't remember a command? Use this to find commands about a keyword, like: apropos wireless


  • ping
  • dig
  • traceroute

Reading and Editing Files

  • less -- display output with pagination
  • vim -- type vimtutor and see the [[Vim]] page.
  • nano -- simple console editor
  • cat -- display a file and/or concatenate it.
  • bat -- like cat but with syntax highlighting and other improvements
  • tee -- redirect the output to a file and the screen at the same time. E.g., ls -1 *.py | wc -l | tee count.txt which counts the number of Python files in your directory, writes it to the screen, and saves it to a file.
  • wc -- count things: lines, bytes, characters, words, etc. Example: wc -l filename.txt will count the lines in a file.
  • head -- view the first lines of a file
  • tail -- view the last lines of a file
  • diff -- compare two different files

Users, Groups, and Permissions

  • chmod
  • chown

The System

  • top -- show processes. If you like that, install htop.
  • htop
  • du
  • df
  • kill
  • ps
  • shutdown
  • reboot
  • uptime
  • date
  • sleep

Compressing and Extracting Files

  • tar
  • zip
  • gzip

Other Tips

  • tab completion
  • pipes |, >, and >>
  • aliases
  • ctrl-r -- reverse search
  • keyboard shortcuts: ctrl-u, ctrl-k, ctrl-a, ctrl-e, alt-f, alt-v, ctrl-d, alt-d (from Emacs)

For managing remote servers: ssh, scp, and rsync

And Tmux.

Additional Utilities

Some of these may need to be installed.

  • sort -- sorts items
  • uniq -- gets only unique items
  • mc -- Midnight Commander file browser
  • tr -- translate
  • fold -- wrap lines to a specified width
  • jq -- tools for JSON
  • curl -- do stuff with URLs
  • wget -- download pages and sites
  • sql2csv (npm install -g sql2csv)
  • csvkit (pip install csvkit)
  • xml2json (git clone it and add to path)
  • ImageMagick -- process and view images, e.g., display cat_pic.jpg, convert --resize 200x200 giant_hubble_photo.jpg hubble_photo_thumb.jpg
  • rename -- bulk rename files with regular expressions. Example: rename all files with the extension .GIF to .gif: rename -v 's/\.GIF$/\.gif/' *.GIF
  • lynx -- a browser in your terminal.

You will occasionally come across these:

  • sed -- stream editor for filtering and transforming text
  • awk -- pattern scanning and processing language
  • Perl one line scripts

See additional tools that you might want to investigate:

How to use the terminal for everything:

tig can be used as an alternative to git log. ranger is a file browser.


See this post for useful keyboard shortcuts:

Additional Resources

See also 7 command line tools for data science.

See also GNU Coreutils Manual.

There are additional posts here: #command-line.

Docker Guide

At the moment, this Docker guide focuses on tips that can help while working on the Code Self Study website. To learn the basics of Docker, it might be a good idea to start with the official Docker guides.

Basic Concepts

A Docker container is something like a virtual computer that runs inside of your computer. Instead of installing software (like a database) on your computer directly, you can put it in its own container and run it from there. Multiple containers can be networked with each other to communicate. An end result of using Docker is that all the programmers on a project have the same development environment, including the same versions of all the required software.

A Docker image is a kind of blueprint for a container.

Docker containers are created from the images. You can have multiple docker containers that are based on the same image.

A Docker network connects multiple containers. If you use Docker Compose to manage your containers, it will automatically create the network for you.

A Docker volume mounts files and persists data after a Docker container is destroyed.

The base Docker command is docker. Other parts of Docker have sub-commands. For example, the commands for managing containers are behind docker container, the commands for managing images are behind docker image, and the commands for managing volumes are behind docker volume.

To list your Docker images, you would use:

$ docker image ls

To list your Docker containers, you would use:

$ docker container ps

The built-in help is good -- just type docker container to see the options for that sub-command.

You can download pre-made Docker images with the docker pull command, but the Code Self Study website creates custom images by using Docker Compose and Dockerfiles. If you look inside the files in the project, you can see the commands that are run.

For example, the file for the Express.js server looks something like this:

FROM node:12-alpine
COPY package*.json ./
RUN npm install
COPY . .
CMD ["npm", "start"]

It says:

  1. Start with a preexisting Node.js image from Docker Hub (like Github for Docker images), using Node version 12 and Alpine Linux (a very small Linux distro).
  2. Set the working directory inside the images to /app.
  3. Copy the package.json file(s) to the working directory.
  4. Install the dependencies.
  5. Copy the Express.js code into the working directory.
  6. Suggest exposing port 5000 for the Express server.
  7. Start the Express server with npm start.

A Dockerfile can be built manually, but in the case of Code Self Study, all the containers are built with the docker-compose.yml file. Take a look in that file to see how the Dockerfiles are used.

# The API for the puzzle server
    # wait for other containers to start first
        - mongo
        - redis
    # build from the ./containers/express_api/ file
        context: ./containers/express_api
    # mount the project files inside the container
        - /app/node_modules
        - ./containers/express_api:/app
    # set some environment variables
        - REDIS_HOST=redis
        - REDIS_PORT=6379
        - SESSION_SECRET="this is only for development"

Restarting Containers

Rebuilding the entire application can take a while, and sometimes you will just want to restart one container (like the Gatsby container).

Here's how to restart a Docker container.

First, get a list of running containers:

$ docker container ps
CONTAINER ID        IMAGE                       COMMAND                  CREATED             STATUS              PORTS                  NAMES
f9466971430a        codeselfstudy_nginx         "nginx -g 'daemon of…"   6 minutes ago       Up 6 minutes>80/tcp   codeselfstudy_nginx_1
b9b10f71037f        codeselfstudy_gatsby        "docker-entrypoint.s…"   6 minutes ago       Up 6 minutes                               codeselfstudy_gatsby_1
18febd3d8b84        codeselfstudy_express_api   "docker-entrypoint.s…"   6 minutes ago       Up 6 minutes        5000/tcp               codeselfstudy_express_api_1
d2d54e20f529        mongo                       "docker-entrypoint.s…"   6 minutes ago       Up 6 minutes        27017/tcp              codeselfstudy_mongo_1
75df2bbce79f        redis:latest                "docker-entrypoint.s…"   6 minutes ago       Up 6 minutes        6379/tcp               codeselfstudy_redis_1

If the container that you want to restart is codeselfstudy_gatsby_1, then copy the container ID and restart it like this:

$ docker container restart b9b10f71037f

You can also refer to it by the full name, if that's easier:

$ docker container restart codeselfstudy_gatsby_1

Freeing Disk Space

After a while, it's possible that Docker images will take up a lot of hard drive space. It's easy to clean them.

To list the images use this command:

$ docker image ls

REPOSITORY                  TAG                 IMAGE ID            CREATED             SIZE
<none>                      <none>              7d3aa3d696c0        2 minutes ago       307MB
codeselfstudy_express_api   latest              c7a0d49e0ade        2 minutes ago       140MB

To remove an image, for example the unnamed image above, refer to it by the IMAGE ID:

$ docker image rm 7d3aa3d696c0

You can list the dangling images (untagged as <none>) with this command:

$ docker image ls -f "dangling=true" -q

And delete them with this command:

$ docker image rm $(docker image ls -f "dangling=true" -q)

Or just use this command to remove the dangling images, stopped containers, and reclaim other space:

$ docker system prune

To see how much space Docker is using type this:

$ docker system df
TYPE                TOTAL               ACTIVE              SIZE                RECLAIMABLE
Images              28                  5                   14.27GB             13.53GB (94%)
Containers          5                   5                   263B                0B (0%)
Local Volumes       58                  5                   784.7MB             428.7MB (54%)
Build Cache         0                   0                   0B                  0B

Docker Cookbook

Here are some quick tips for common tasks.

How to run a stopped container with a custom command

Get the ID of the stopped container:

docker container ps -a
docker container commit <container_id> tmp_container

The name tmp_container is arbitrary. Name it whatever you want.

Then run it like this:

docker container run -it --entrypoint=sh tmp_container

More info is here.

How to manage containers with docker-compose

Here are some examples of how to run commands inside of containers by name when using docker-compose.

# start up the docker containers
docker-compose -f up --build

# run commands inside of containers
docker-compose -f exec django python makemigrations
docker-compose -f exec django python migrate
docker-compose -f exec django python createsuperuser

# restart containers
docker-compose -f exec django restart

# load seed data
docker-compose -f exec django python loaddata apps/app_name/fixtures/my_data.fixtures.json
docker-compose -f exec django python loaddata apps/app_name/fixtures/other_data.yaml

# shut down docker containers
docker-compose -f down


This page will contain a JavaScript self-study guide.


This page will contain a Python self-study guide.


Data Structures and Algorithms

This is the entry point for the data structures and algorithms section. (under construction)

Big O

This page will contain information on big O notation.

(under construction)

Linked Lists




The Terminal

This section contains information for learning about basic GNU or other command line tools.

You might also be interested in the command line study guide.









dirs (and pushd/popd)

The dirs command lists a stack of recently visited directories. You can push into the history with the pushd command, and pop off the stack (going back one location) with the popd command.

Compare dirs with the cd command. The cd command will change directory, but it won't remember your navigation history. You can use pushd like a version of the cd command that saves a history of where you've been.


Some common flags for dirs are:

  • -c -- clear the stack
  • -l -- long format
  • -p -- one path per line
  • -v -- one path per line with indices


These examples assume a unix-like operating system like GNU/Linux or Mac.

This command will navigate to the /var/ directory, pushing your last location onto the dirs stack.

$ pushd /var/

Display the stack:

$ dirs

Navigate back to the last visited directory by popping off the stack.

$ popd

dirs command example

Regular format (home is represented with a tilde):

$ dirs
/var ~/code/CSS/codeselfstudy_wiki

Long format:

$ dirs -l
/var /home/pv/code/CSS/codeselfstudy_wiki

Verbose option:

$ dirs -v
0       /var
1       ~/code/CSS/codeselfstudy_wiki







bat is similar to cat or less but with syntax highlighting.
















The shutdown command shuts down or reboots the computer.


$ sudo shutdown -r 0


















This section of the wiki contains documentation for our group's projects. Use the left sidebar for navigation to the various pages.


Code Self Study Website

The website repo can be found here. See the main in that repo for installation instructions.

Browser Extensions

The browser extensions (Firefox and Chrome) can be found at codeselfstudy/codeselfstudy_browser_extension.

They can be installed here.

News Site


Technology Overview

This page contains an overview the technologies used on the main website.



  • Nginx -- requests get passed through an nginx container
  • Gatsby -- server-rendered React with content loaded from a headless CMS
  • Express API -- this authenticates with Discourse (forum) and serves coding puzzles
  • Redis -- session store for the Express API
  • Mongo -- data storage for coding puzzles


  • Phoenix/Postgres -- coming later once the site is ready for real-time features and the data gets more complex
  • Rust/Wasm -- visualization of algorithms & data structures with WebAssembly.

Check out the containers directory. Each directory there is a separate Docker container.

For an introduction to Docker, see our Docker guide.

Here's a diagram. See the other pages in this section for details.



The entry point is an nginx Docker container. It proxies all the requests to other containers.

Nginx internally serves on port 80, but port 80 is mapped to the host's machine (your laptop's) port 4444. To visit the site in development, visit localhost:4444.

See the containers/nginx/default*.conf files for details on how the requests are sent to the other containers.

# Defining the upstream applications. Gatsby, for example, is running on port 8000 in development.
upstream gatsby {
    server gatsby:8000;

# Express is running on port 5000
upstream express_api {
    server express_api:5000;

# Nginx listens on port 80 and proxies requests to the upstream servers.
server {
    listen 80;

    location /api {
        # Express doesn't know about the `/api` prefix, so this rewrites
        # the requests for Express.
        rewrite /api/(.*) /$1 break;
        proxy_pass http://express_api;

    # Routes not matched above will go to Gatsby.
    location / {
        proxy_pass http://gatsby;


Gatsby serves the main pages of the site. If we need SPA functionality, Gatsby can do client-side routing.

Express API

Express.js is mounted at /api and will serve the coding puzzles as well as handle authentication via the forum.


This will hold the coding puzzle database for now. (MERN stack experiment)


This container holds Express.js sessions.


This wiki is in a separate repo and auto-deploys on Netlify.

These resources were useful in setting up the CI pipline:


Basically, Travis CI builds and deploys the site. A deploy key is encrypted and added with the Travis CI command-line interface (linked to above). The command travis login will connect the CLI to Travis, and then this command will add the encrypted Netlify token to the .travis.yml file.

$ travis encrypt --add deploy.auth <auth>

(Netlify doesn't have to be connected to Github.)


Phoenix/Postgres is coming later for real-time features and LiveView experiments (write frontend features with backend Elixir code).

WebAssembly / Rust

TODO: visualization of algorithms & data structures in WebAssembly (Rust).

I'm picturing something along the general lines of this but in WebAsseembly. (That code is here.)


TODO: this page is a work in progress.

Coding Style

Please use Prettier.js to format the JavaScript, Sass/CSS, and HTML code. Every major editor has a plugin to auto-format the files on save (including one for vscode).

TODO: we could probably set this up with git hooks. I think there is a node module that runs git hooks from package.json.

JavaScript, CSS, HTML

The .prettierrc file contains the instructions for the editor. Just use an editor plugin that formats on save, and it will be correct. You can also format it manually by running this command at the root of the project:

$ make format


  • Other languages that we use (like Elixir) require double quotes for strings, so the JS uses double quotes for consistency.
  • 4-space indentation is easier to skim.

This project transpiles the JS so it's okay to use the latest JS features.


The project uses Elixir's auto-formatter. You can set up your editor to format on save or just run this command in the directory where the Elixir code is:

$ mix format


Follow PEP8 where possible. Use double quotes for the same reason as the JS. Line length can be 160 chars. (See tox.ini.)



For now, see the project board and issue queue and/or talk to us at a meetup.