Awesome
ml4w-homework
See Demos live:
- Week1 Image Classifier on Webcam
How to push code to a Github Repo and host sketch on Github
Before we get started, you can also work on top of this p5 sketch in p5 Web Editor for week 1. Since p5 Web Editor already hosts the sketch for you online, you don't need to host your sketch on Github. If you want to learn how to host your sketch on Github, please continue reading. :)
Here is a video about How to host p5 sketch on github pages.
Here is a step by step guide about how to push code to a Github Repo and host sketch on Github
-
Login to Github: https://github.com, go to https://github.com/YOUR_USERNAME.
-
Click on the "+" on the top-right corner, dropdown - click on "New repository".
<img src="https://raw.githubusercontent.com/yining1023/ml4w-homework/master/images/a.png" width="500"> -
Fill in the "Repository name", "Description", check the checkbox "Initialize this repository with a README", click on the "Create repository" button.
<img src="https://raw.githubusercontent.com/yining1023/ml4w-homework/master/images/b.png" width="500"> -
You will see a new repository page.
<img src="https://raw.githubusercontent.com/yining1023/ml4w-homework/master/images/c.png" width="500"> -
Put your
<img src="https://raw.githubusercontent.com/yining1023/ml4w-homework/master/images/d.png" width="500">sketch.js
andindex.html
file into a folder calledweek1
, and drag the folder into the new repository page.
-
Under the "Commit changes", type in commit message, like "added week 1", click on . "Commit changes" button.
<img src="https://raw.githubusercontent.com/yining1023/ml4w-homework/master/images/f.png" width="500"> -
You should be able to see a new folder
<img src="https://raw.githubusercontent.com/yining1023/ml4w-homework/master/images/g.png" width="400">week1
listed on the repository page. -
Go to right top corner, click on "Settings", you will be on https://github.com/YOUR_USERNAME/ml4w-homework/settings
<img src="https://raw.githubusercontent.com/yining1023/ml4w-homework/master/images/h.png" width="500"> -
Scroll down the page, find "Github Pages", click on "Source - None" dropdown, select "master branch".
<img src="https://raw.githubusercontent.com/yining1023/ml4w-homework/master/images/i.png" width="500"> -
After 2 mins, refresh the page, you should be able to see a green bar saying: "Your site is published at https://YOUR_USERNAME.github.io/ml4w-homwork.
<img src="https://raw.githubusercontent.com/yining1023/ml4w-homework/master/images/j.png" width="500"> -
Go to that link: https://YOUR_USERNAME.github.io/ml4w-homwork, you will see the following page.
<img src="https://raw.githubusercontent.com/yining1023/ml4w-homework/master/images/k.png" width="400"> -
Add
<img src="https://raw.githubusercontent.com/yining1023/ml4w-homework/master/images/l.png" width="500">/week1
at the end of the url(https://YOUR_USERNAME.github.io/ml4w-homwork/week1), you will see your week1 demo. -
Go to this link: https://github.com/yining1023/machine-learning-for-the-web/wiki/Week-1--2019-Spring, click on the "Edit" button on the top-right corner.
<img src="https://raw.githubusercontent.com/yining1023/ml4w-homework/master/images/m.png" width="500"> -
Add your name, homework link and description at the end, click on "Save" button.
<img src="https://raw.githubusercontent.com/yining1023/ml4w-homework/master/images/n.png" width="500"> -
That's it!! You should be able to see your homework link on the page: https://github.com/YOUR_USERNAME/machine-learning-for-the-web/wiki/Week-1--2019-Spring.
How to update your code and push it to Github
If you would like to update your code, you can follow these steps:
-
Make a new folder on your Desktop called "ml", open your terminal.
-
Type
<img src="https://raw.githubusercontent.com/yining1023/ml4w-homework/master/images/o.png" width="500">cd
(cd and a space), drag the "ml" folder into the terminal window. You will see your command changes to:cd /Users/YOUR_NAME/Desktop/ml
-
Hit
<img src="https://raw.githubusercontent.com/yining1023/ml4w-homework/master/images/s.png" width="500">enter
orreturn
on your keyboard. You will see in your terminal, you are at this path:~/Desktop/ml
-
Go to the ml4w-homework github repo we created before: https://github.com/YOUR_USERNAME/ml4w-homework, click on the green "Clone or download" button, copy the link highlighted in green: https://github.com/YOUR_USERNAME/ml4w-homework.
<img src="https://raw.githubusercontent.com/yining1023/ml4w-homework/master/images/r.png" width="500"> -
In your terminal, type in
<img src="https://raw.githubusercontent.com/yining1023/ml4w-homework/master/images/t.png" width="500">git clone
, with the link we just copied(git clone https://github.com/YOUR_USERNAME/ml4w-homework1.git). Hit enter. -
In your terminal, type in
<img src="https://raw.githubusercontent.com/yining1023/ml4w-homework/master/images/u.png" width="500">cd ml4w-homework
, hit enter. -
Go to the Desktop, open
<img src="https://raw.githubusercontent.com/yining1023/ml4w-homework/master/images/v.png" width="500">ml
folder, open theml4w-homework
folder with your code editor. Edit the code, make some changes. -
In the terminal, type in
<img src="https://raw.githubusercontent.com/yining1023/ml4w-homework/master/images/x2.png" width="500">python -m SimpleHTTPServer
orpython3 -m http.server
if you are using python 3. The terminal will say "Serving HTTP on 0.0.0.0 port 8000 ...". -
Go to
<img src="https://raw.githubusercontent.com/yining1023/ml4w-homework/master/images/w.png" width="500">localhost:8000/week1
in your browser, you will see your example. -
You can change some code, refresh the web page to see the changes.
-
After you are happy with the result, go back to terminal, hit "control + c" key, to quit the server,
<img src="https://raw.githubusercontent.com/yining1023/ml4w-homework/master/images/x.png" width="500"> -
In the terminal, type
<img src="https://raw.githubusercontent.com/yining1023/ml4w-homework/master/images/y.png" width="500">git status
to view your changes -
In the terminal, type
<img src="https://raw.githubusercontent.com/yining1023/ml4w-homework/master/images/z.png" width="500">git add .
to add all your changes -
In the terminal, type
<img src="https://raw.githubusercontent.com/yining1023/ml4w-homework/master/images/z1.png" width="500">git commit -m "updated week1"
to add a commit message. -
In the terminal, type
<img src="https://raw.githubusercontent.com/yining1023/ml4w-homework/master/images/z2.png" width="500">git push origin master
to push the changes tomaster
branch. -
Go to your github repo page: https://github.com/YOUR_USERNAME/ml4w-homework, you will see week1 is updated.
<img src="https://raw.githubusercontent.com/yining1023/ml4w-homework/master/images/z3.png" width="500"> -
After 5 mins, your public sketch (https://YOUR_USERNAME.github.io/ml4w-homwork/week1) will be updated with your new change too.
<img src="https://raw.githubusercontent.com/yining1023/ml4w-homework/master/images/z4.png" width="500">