Week 32 Homework đ» đ
New stuff we learned this week: đ€
Unix Wizardry
- typing
<Ctrl+r>
activates a search mode into your history of shell commands. Press it then start typing a semi-unique word or combination of letters to instantly find a command youâve recently run. Type<Enter>
to run the command you see appear, or<Ctrl+c>
to cancel - typing
^<find>^<replace>
will re-run the most recent shell command substituting<find>
for<replace>
, like so:
$ cat /this/is/a/really/long/path/i/dont/want/to/retype.js
> # some output from `cat`
$ ^cat^vim
$ vim /this/is/a/really/long/path/i/dont/want/to/retype.js
# the line above runs automatically, because of `^cat^vim`
VSCode
- VSCode is a free text-editor/lightweight IDE made by Microsoft. Itâs become so good that almost everyone uses it now who develops in the web world, and in many other worlds as well.
- just because VSCode allows you to use your mouse, doesnât mean you should do so! Treat it like vim. Every time you use your mouse, you should feel a small wave of shame and sadness.
- once you pull down my VSCode settings, youâll have a bunch of nice extensions
installed, and a bunch of good keyboard shortcuts (many of which are
vim-inspired). Definitely focus on learning the main keyboard shortcuts:
- NOTE in the examples below, Iâm putting
Cmd
as short for Macâs Command key, but if youâre on Windows or Linux, you would use the Alt key instead, so think ofCmd
as meaning âCommand or Altâ - NOTE #2 - but, if I say that the shortcut is
Ctrl
â that means the shortcut uses the Control key on Mac, Windows and Linux. <Cmd+Shift+P>
- open up the Command Pallete, in which you can start typing to see lots of wild stuff vscode can do for you<Cmd+t>
opens up the Fuzzy finder â it allows you to quickly switch between files.- once you have the Fuzzy finder open and activated,
<Ctrl+j>
and<Ctrl+k>
(like vim!) move your selection up and down. <Cmd+b>
toggles the visibility of the main sidebar<Ctrl+s>
toggles the visibility of the âactivity barâ<Ctrl+BACKTICK>
toggles and focuses the integrated terminal (BACKTICK is `)<Cmd+j>
toggles the whole bottom pane- pressing
<Cmd+/>
will comment out whatever line or lines you have selected
- NOTE in the examples below, Iâm putting
- When youâre editing a file, all your
vim
commands will just work. (Well, almost everything). - Vscode has the ability to let us edit code through ssh, so that weâre running vscode on our computer, but weâre actually working on a different computer that we have made an ssh connection to. Weâre going to use the feature heavily, because weâll still be doing our development on the HTC virtual machine, but weâll have all the goodies that vscode gives us.
- vscode comes with a sweet binary executable file which we can use from our
terminal to type
code .
orcode ~/some/path
and vscode will open up that folder for you to work in.
Useful Links:
Homework Plan:
- 1 day flashcard assignment
- 2 day touch typing practice
- 1 day VSCode homework
- 2 days web homework
- 2 days watch CCCS #29
Homework day 1
Homework day 2
Homework day 3
Flashcard Assignment
- add 2 new
unix
flashcards:<Ctrl-r>
^<find>^<replace>
- add 7 new flashcards in a new category called
vscode
. IMPORTANT make sure you write down the correct key for your computer: if youâre not on a Mac, changeCmd
to beCtrl
.<Cmd+Shift+P>
<Cmd+t>
<Cmd+b>
<Ctrl+s>
<Ctrl+BACKTICK>
<Cmd+j>
<Cmd+/>
VSCode Homework
- open up a new terminal window (outside of VSCode, not using the built-in
terminal) and type
which code
â you should see a path to thecode
executable file. If you get no response, Slack me. - still from terminal, create a new directory on your computer called
open-vscode
, thencd
into it and usevim
to create a new file calledtest.txt
that has a few words in it. - exit out of vim and type
code .
â this command is like saying âHey, vscode, open the folder that Iâm in as a workspaceâ. Vscode should open up. - practice using the keyboard shortcut to toggle the activity bar. (Itâs the narrow strip of icons on the far left.) After youâve toggled it a few times, leave it visible.
- put your mouse over each icon in the activity bar and leave it still for a few seconds, youâll see that vscode gives you some additional information.
- next, right-click on the source-control icon and click to âhideâ it. We wonât be using vscodeâs git integration, so weâll just get rid of that icon. Do the same for the âDockerâ icon.
- practice using the keyboard shortcut to toggle the whole sidebar.
- make sure that the
Explorer
is chosen from the activity-bar and that you can see the sidebar, then see if you can figure out how to create a new file from the explorer sidebar, name itfoobar.txt
. - next, try to create a new folder
- create a new file called
hello.js
inside the folder you created above. - now, use the keyboard shortcut to bring up the fuzzy finder and type a few
letters to narrow the search down to the
test.txt
file you created in step 6. Press enter to edit it. - while youâre editing the
test.txt
file, do all of thesevim
tasks, and watch the color and text of the bar at the very bottom of vscode change:- insert some text and return to normal mode
- search for a word using
/<word>
- go into visual mode, then come out
- go into visual-line mode, then come out
- go into visual-block mode, then come out
- type the keyboard shorcut which toggles and focuses the integrated terminal
- with the integrated terminal open, practice re-sizing the size of the bottom area by grabbing the line between the two sections and dragging it.
- in the integrated terminal, try out some normal commands like
ls
,pwd
, andecho
- for fun, open up vim inside the integrated terminal, and edit the
test.txt
file:vim test.txt
â make a few changes and then save. You should also see your changes in the vscode editor pane. - toggle the visibility of the bottom âpanelâ with
<Cmd+j>
. This keyboard shortcut is slightly different from<Ctrl+BACKTICK>
â because it just toggles the visibility of the whole bottom panel, instead of also selecting and focusing on the terminal. - with the bottom panel hidden again, use the shortcut for the Fuzzy finder to
open up the
hello.js
file inside the dir you created in step 13. - edit the
hello.js
file and add// @ts-check
at the very top of the file, on the first line. This means âhey typescript, even though Iâm just writing javascript not typescript, go ahead and help me out!â - type this line of javascript:
let animal = "dog";
- now move your cursor somewhere over the variable name
animal
and pressg
thenh
quickly (in vim normal mode). This commandgh
causes vscode to pop-up informational goodies about whatever is under the cursor. - read this whole step before trying it: on a new line in the
hello.js
file, youâre going to typeanimal.tri
and stop right there, after typing thetri
. You should see that vscode is trying to help you. It knows thatanimal
is a string, so it is suggesting methods you can call on a string. You should seetrim
,trimRight
,trimLeft
, and maybe some more. Use your arrow keys to cycle through the available options, and look closely â vscode gives you inline documentation telling you about the functions, how they work, and what they return. See if you can understand what the different methods do. Then, pick one by pressing enter. - now, if itâs not already open, click on the
test.txt
file from the explorer sidebar. You should now have two tabs (technically called editors) open. You can arrange these side by side (like vimâs:vsplit
) by grabbing one of the tabs and pulling it about 90% of the way over to the side of the window. Do this now. - try rearranging it to be on the bottom by dragging it there instead.
- next, weâre going to connect to our HTC virtual machine. To do that, use the
keyboard shortcut to bring up the Command Pallette. Start typing âremoteâ
and choose the option that says
Remote-SSH: Connect to host
. It should read your~/.ssh/config
file and offer you the option ofhowtocomputer.link
â select that one, and wait a few seconds while the remote development session is established. - once youâre connected, in the sidebar on the left it will say
No folder opened
and display a big blue button toOpen Folder
. Click the open folder button. - in the popup that appears, navigate to the
~/www/week-31/week-31-cars
dir you were using last week. - make a few changes to one of your files from inside vscode
- then, open up your terminal app (or putty) and ssh in to the HTC machine.
Navigate into the same directory and use
git diff
to verify that you were indeed making changes remotely using vscode. Wizardry! - spend a few minutes exploring around vscode and trying to figure out cool stuff. Find one thing you think is neat or helpful, and slack the #homework channel to tell us what it is.
Web Homework
- make sure youâve done the vscode homework FIRST
- go to this page and work through all of the exercizes for a review of Flexbox. Youâre going to need it.
- go to this GitLab URL, itâs a bare-bones repo I created to get you started with this assignment: https://gitlab.howtocomputer.link/htc/week-32-virtuoso
- fork this repo
- copy the ssh clone url from your fork
- ssh into your home dir (with terminal or putty, not vscode)
- cd into the
~/www
dir and make a new~/www/week32
dir, thencd
into it. - clone the repo (using the clone URL you copied in step 3)
- you should now have a
week-32-virtuoso
dir cd
into that newweek-32-virtuoso
dir, and create and switch to a NEW BRANCH- close out terminal or putty
- open vscode and use the instructions at the end of the VSCode Homework to
connect back to the HTC computer remote host. When you get connected, click
the âOpen Folderâ button, and point it to
~/www/week32/week-32-virtuoso
â thatâs the repo you just cloned - visit this page in your browser, and study it for a bit. Change the size of your browser from large to small to see how media-queries are used to change the layout for different screen sizes. Youâre going to (mostly) recreate this webpage. You may not inspect the HTML or CSS of the real site.
- To make it a little easier, there are two things you do NOT need to
replicate:
- the green âWadsworth, Ohioâ text in the header
- the mobile menu you can skip. You will just make the main black links dissappear at small screen sizes, and donât worry about creating the alternate menu
- A General Hint: youâll be using Flexbox to do all the layout of the site, but youâll also need to use a bunch of padding and some margin to get the SPACING of elements to look right. So think to yourself âFlexbox for LAYOUT, padding (and margin) for SPACINGâ.
- to prevent you from getting ahead of yourself, YOU MUST complete the task in these steps.
- Step 1. Treat the top brown bar, the main white section, and the black
footer as if they were the only thing on the page, and think of it as a simple
flexbox puzzle. Get three divs styled with some random bright background
colors and no content, just work on the flexbox layout. (hint: youâll
probably need to put
min-height: 100vh;
on thebody
element in order to get the middle section to grow properly). - When youâve completed Step 1 and you have 3 sections (brown, white, and black) about the right size, type a command in vscode to toggle and focus the integrated terminal. Youâll see that youâre dropped into a shell on the HTC virtual machine in the same directory where youâre working. Down in the terminal, commit your work. Then, type a shortcut to hide the bottom panel so you can get back to work.
- Step 2. Next, treat the inside of the brown header as itâs own mini flexbox puzzle. Hereâs a hint: start by making two divs inside the header, make them each take up half of the width of the whole header. Pop the logo into the first div, and then put the four black links in the second div. The Four black links themselves will be flex items of their parent. When youâve got it, commit your work in the same method as described above.
- Step 3. Next, work on the main, largest section in the middle. It has two
columns (the text-ish area, and the form). Treat these two columns as their
own mini flexbox puzzle - create two divs, temporarily set their background
color to some weird bright color, and get them looking about right. Put some
simple text in the contact-form div that says âForm will go hereâ and ignore
it for now. Then, Work on replicating the left column. Youâll need to bring in
the
patio.jpg
image I put in the repo. (Hint: at the bottom of the left column I used SIX different<ul>
elements to make the 6 list chunks). When youâre done, commit your work. - Step 4. Create the form in the left hand column. Make it
POST
to this URL:http://server.howtocomputer.link/week24/echo
. Commit your work. - Step 5. Add media queries so that at small screens, your page adapts in the same way as the real page does. Note: ignore the mobile menu, just hide it at small screens. Commit your work when youâre done.
- Step 6. Work a little bit on spacing, colors, fonts â trying to get it to
mostly match the appearance of the real site. Donât worry about 100%
perfection, just get it mostly there, then commit your work. Here are some
colors to help:
- brown:
rgb(208, 209, 198)
- green:
rgb(172, 206, 146)
- dark green:
rgb(124, 157, 99)
- brown:
- When youâre done, youâre going to submit a MR to your own fork â which is a
little different. Last week with the âcarsâ repo, you submited a MR to the
repo owned by the
htc
group which is the default behavior in GitLab. Just follow these steps: - push the branch you created in step 10:
git push origin <branch-name>
- in the terminal, click the URL to create a new MR
- on the MR screen click the
Change branches
link:
- after clicking change branches, change the TARGET PROJECT to your own fork:
- Then submit the PR, and Slack me the MR url.
- I will leave you some feedback on your MR, and have you improve some of your code. đ