🍃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
Follow these steps to begin:
~represents your home directory.
lsand pressing enter. You should see a list of all of the folders and files directly inside of your home directory.
cdand pressing enter.
cd code-societiesyour bash prompt will now look something like this
lscommand. With the
lscommand you should see all of the folders and files inside the directory you are currently in.
code-socitiesfolder you can cd into
ls. Do you see the file
catcommand will display all of contents of that file right inside your terminal ! How beautiful !
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.shand press enter. A bunch of beautiful flowers should appear!
cat grow.shyou will see the contents of the script that produced the bunch of beautiful flowers!
The commands we’ve learned so far are:
Some more helpful commands:
opens the folder you are currently inside of
changes directories in reverse
tab key to autocomplete
up and down arrow keys
creates a new file
opens the folder you are currently inside of with Atom
makes a new directory
creates a new file called myfile.txt
removes a folder called foldername
removes a file called filename.txt
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
mkdircommand to create some new folders. mkdir stands for make directory. For example, you can run
mkdir my-new-folderand that folder will be created inside of your
cd ..to move in and out of folders
rm -rf name-of-folder-or-file(remove recursive force) to delete items but be careful you can’t undo this!
man lswill show you what ls stands for. You can press
qto exit the explanation.
clearcommand 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!
cd .. and
cd .. again until you are inside
✨Enter the command:
Now follow these steps:
git add .
sensations.txtfile in Atom
For the next 60s ⏲, inside the
sensations.txtfile 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”
qto exit log
git show <place your hash here>this allows you to review the detailed history of a given change
Now 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 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).
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)
save file changes
git status to see a list of what files changes have been made
git commit -am “my changes message”
computational-methods-code-societiesrepo of your partner
git 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”
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 :)
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.
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