Lab Book — Week 2
The most exciting thing is that I finally got my new laptop and it’s really a speed boost.
Stack Overflow is a really powerful platform and I can find the solutions to almost all of the problems I encountered. However, you need to judge whether an answer is suitable for your certain situation and select the most appropriate one. I usually see the users’ reputation score and the replies under their answers that whether their solutions worked.
ei. BIOS banned me from opening the virtual box.
I have installed Oracle VM VirtualBox 5.0.12, and now trying to start it up. But shortly after trying to power it up, I…stackoverflow.com
In the lecture we learnt the unix commands and the Editor Fu. The hotkeys are quite helpful to speed up scripting.
cd + next directory: go to the next directory
cd ..: go to the parent directory
cd ~: go to the begining
ls: list the file names in the current directory
python + python file: run the file
atom + python file: open the file in atom
pwd: print working directory, figure out where you are
hostname: my computer’s network name
mkdir: make directory
rmdir: remove directory
mv: move a file or directory
pushd: push directory
cp: copy a file or directory
robocopy: robust copy
more: page through a file
type: print the whole file
forfiles: run a command on lots of files
dir -r: find files
select-string: find things inside files
help: read a manual page
helpctr: find what man page is appropriate
echo: print some arguements
set: export/set a new environment variable
exit: exit the shell
runas: DANGER! become super user root DANGER!
Alt + F3: select all that match
Shift + Alt + up/down arrow: extend cursor
Ctrl + left/right error: Jump to word boundary
Shift + left/right error: select
Ctrl + Shift + left/right error: select to word boundary
Exercise 3 in this week’s homework is quite challenging but I felt good each time my scripts worked. It seems you can write different scripts for the same aim, but you should think which one is the simplest and the most readable way. At the same time, give the variables understandable names and write comments to make sure that next time when you read the script you can still understand what the variables mean or what the functions do.
In the example, the car turns right by n1 degrees if on the left of the road, and turns left by n2 degrees if on the right of the road. We abstract n1 and n2 so that they can be set/reassigned in the future. We can abstract a variable over time to depict a system of all time instead of any particular time.
I like codecombats a lot. It’s a game that you code to let the character collect things and attack enemies. It has problem running on google chrome so I have to switch to firefox. It’s interesting because you have to consider do you collect diamond first or attack enemies first, because you loose blood by being attacked.