đThe computer, the programmer, the relationship they have with each other, and the environments they createđ
A one-session class covering the primary computational methods of Code Societies Classes: Winter 2019. Together we will defamiliarize and refamiliarize ourselves with the Command Line Interface, Git/Github, running Python 3 in the terminal, & running Python 3 with Anaconda Jupyter Notebook. We will navigate folder structure narratives with the command line, time travel with Git, code socially with Github, and process language with Python.
Coding isnât something that just happens in your text editor or terminal. Coding can be a wholistic computer practice, a new relationship you have with your computer & your computer habits. from the way you name your files or organize your folders, to completely changing how you perform routine tasks on your computer such as moving a file.
To ensure that you can easily access Atom (the text editor we will be using throughout this guide) follow these steps:
Think about all of the applications you open on a day to day basis on your computer. One of the many mechanisms we use to do these things is dragging and clicking different icons and folders using a mouse or trackpad.
Letâs take a small tour of our computers by following these steps:
This folder structure follows the structure of a house which is a spatial metaphor for how we navigate folders on our computer. For example, when youâre in a house and standing in the kitchen and you wanted to go to bed you would need to navigate from the kitchen into your bedroom before you actually tried to lay down.
Another way to do this kind of navigation is by using the command line, a text-based mechanism for doing the same kind of navigation between folders and files.
The command line can be seen a more intimate way to interact with your computer, itâs kind of like having a conversation, you can ask your computer to do something and it might respond to you with a confirmation of what you typed or some kind of prompt or a scrolling list of crazy words letting you know that it is in the process of installing some stuff or nothing at all!
sometimes you will ask your computer to install something and it will not give you any kind of response but the thing you wanted to install was actually successful. the reason the computer will not return any kind of response takes us way back into the history of computing when the computer would respond to a programmer by printing out its response on a piece of paper. In order to save paper computers were programmed to just do nothing if the command was successful.
Moving forward you can think of the Terminal (command line) as the âsecret trap door/master key/teleportation portalâ to your computer.
The programming language of the terminal is called Bash. This is the language that allows us to write commands that the Terminal can understand so that we can do things like navigate the file system (as we did above) on our computers. Bash files, also known as scripts because they often execute pieces of code, look something like this name-of-bash-script.sh
Follow these steps to begin:
~
The ~
represents your home directory.ls
and pressing enter. You should see a list of all of the folders and files directly inside of your home directory.cd
and pressing enter.cd code-societies
your bash prompt will now look something like this your username:code-societies$
ls
command. With the ls
command you should see all of the folders and files inside the directory you are currently in.code-socities
folder you can cd into computational-methods-code-societies
cd
into the kitchen
!ls
. Do you see the file pots-and-pans.txt
?cat pots-and-pans.txt
cat
command will display all of contents of that file right inside your terminal ! How beautiful !cd
into the garden
grow.sh
. We know this is a bash script because of the .sh
. This means that we can execute this script (or program) inside of terminal.bash grow.sh
and press enter. A bunch of beautiful flowers should appear!cat grow.sh
you will see the contents of the script that produced the bunch of beautiful flowers!The commands weâve learned so far are:
cd
ls
cat
bash
Some more helpful commands:
pwd
open .
opens the folder you are currently inside of
cd ..
changes directories in reverse
tab key to autocomplete
up and down arrow keys
touch
creates a new file
atom .
opens the folder you are currently inside of with Atom
mkdir
makes a new directory
touch myfile.txt
creates a new file called myfile.txt
rm foldername
removes a folder called foldername
rm filename.txt
removes a file called filename.txt
say
asks your terminal to say whatever you have types
If you try to run cat on a jpg file the terminal will print out all of the âtextâ for the file.
Example of artist, Ryan Kuo who used navigating a generic looking Mac Application to talk about navigating family dynamics in his piece, Family Maker
cd ..
as many times as you need until your bash prompt tells you that you are inside of the computational-methods-code-societies
foldermkdir
command to create some new folders. mkdir stands for make directory. For example, you can run mkdir my-new-folder
and that folder will be created inside of your computational-methods-code-societies directory
.cd name-of-folder
and cd ..
to move in and out of foldersrm -rf name-of-folder-or-file
(remove recursive force) to delete items but be careful you canât undo this!man ls
will show you what ls stands for. You can press q
to exit the explanation.ls -AF
clear
command to refresh your terminal window.
| Subject | Link |
| City of my dreams | https://github.com/doodybrains/computational-methods-code-societies-iris/tree/master/cities-in-my-dreams |
| A physical desktop | https://github.com/mimidoan/methods |
| A bodega | https://github.com/a-sparse-city/computational-methods-code-societies/tree/master/bodega |
| Universe of Tushar | https://github.com/Saltzshaker/universe-of-tushar-computational-methods-code-societies-1 |
| The roots: a plant | https://github.com/jarretbryan/acgillette-computational-methods-code-society |
| Champagne glasses | https://github.com/acgillette/computational-methods-code-societies-jarret/tree/master/champagne_glass |
| Clouds | https://github.com/mattohagan/yesmoon-computational-methods-code-societies
| Space |https://github.com/yesmoon/mattohagan-computational-methods-code-societies
| Guilty pleasures |https://github.com/nadjao/computational-methods-code-societies-sonny
| Semantic world of familiar things | https://github.com/nicolch/computational-methods-code-societies
| Levels of hunger | https://github.com/sonnynomnom/computational-methods-code-society-nadjao
| Crowded train | https://github.com/iris-qu/computational-methods-code-societies-emma-rae
| Basic | https://github.com/vcampbell89/computational-methods-code-societies
| House | https://github.com/asd0999/emily-s-computational-methods-code-societies-1
| Stages of Life | https://github.com/csanchez73/ingrid-computational-methods-code-societies
| College Home | https://github.com/ilange/Carlos-computational-methods-code-societies
| Order of activities after waking up |
| People met today |
A version control and time travel software! Suspend your belief for just a moment!
To begin cd ..
and cd ..
again until you are inside computational-methods-code-societies
â¨Enter the command: git init
Now follow these steps:
git add .
cd time-travel/
ls
sensations.txt
atom .
sensations.txt
file in Atom
For the next 60s â˛, inside the sensations.txt
file write down the small sensations and sounds youâre experiencing right now in this moment. Volume of words > coherence
git commit -am âmy first sensationsâ
Repeat steps 6 - 7 two more times;
git commit -m âmy second sensationsâ
+ git commit -m âmy third sensationsâ
git log
6c750cb264c6d5ad0fac18863cafd0df35315fce
q
to exit loggit show <place your hash here>
this allows you to review the detailed history of a given changeNow weâre going to time travel!!
git checkout <place the hash of your first commit here>
This is like traveling through time to past versions of yourself and the record of the sensations you were feeling at multiple distinct moments in the past đŽ
git rebase
Git is an open source software that GitHub capitalizes on. Git allows for collaboration. GitHub will allow you to save, and edit and update your code. For this guide we will be pushing our Folder Strucuture Narrative up to a new GitHub repository
Make sure to run git checkout master
to go back to your latest code (all three sensations).
computational-methods-code-societies
git remote rm origin
(this ensures that you will be able to add your own github repository as the origin)git add .
Keep in mind that git only cares about files, so it will not upload folders if they donât have files inside of them.git commit -am âname of messageâ
(the message describes what you are adding)git push -u origin master
(the name origin is just a naming convention and is referring to the url for your repository)Common workflow:
git pull
make changes
save file changes
run git status
to see a list of what files changes have been made
git commit -am âmy changes messageâ
git push
computational-methods-code-societies
repo of your partnergit clone <the url of the forked repo>
into your terminal (make sure that you are doing this inside your home directory)git add .
git commit -am âmy addition to my partnerâs narrativeâ
git push
There are a lot of different ways to interact with Python. One way is using the interactive interpreter. Another way is using Jupyter Notebooks. In this guide we will mostly be working within a Jupyter Notebook.
Donât forget to check out Nabilâs workshop Mathematics as Religious Experience on Dec 23
Type word python and press enter you should get back something like this Python 3.7.1 (default, Dec 14 2018, 13:28:58)[Clang 4.0.1 (tags/RELEASE_401/final)] ::
In terminal you can write print(hello world)
and the terminal will print out the line âhello worldâ. In Python you will usually write the name of the function, open parentheses, argument, closed parentheses
When learning to program make sure to give yourself time! Check out the book Teach yourself programming in 10 years
Now we will do some more things with Python:
sensations = open(âsensations.txtâ)
<_io.TextIOWrapper name='sensations.txt' mode='r' encoding='UTF-8'>
In the sensations.txt file add the following lines:
for line in sensations:
print(line)
The sensations.txt file should now look like this:
sensations = open("sensations.txt")
for line in sensations:
print(line)
Now you can save the file and go back to the Terminal.
In the terminal you can write jupyter notebook
and press enter. This will automatically open up a new browser window.
Programming is like magic :)
Click on Introduction to Python
file.
Here is a list of Jupyter Notebook Keyboard Shortcuts:
think like a scientist and come up with a hypothesis for what you think is going on then do a series of test to try and prove yourself wrong
Once we have gotten to the end of the file remember that we need to open the file again before we can successfully run it!
Make sure to read the error messages. Try your best to understand what the computer is saying.
For example:
- Traceback (most recent call last)
is referring to the most recent place in the code where an error was found
- Io
stands for input ouput
More resources: