Skip to content

Instantly share code, notes, and snippets.

@ruichuang
ruichuang / Setup Vagrant + nginx + nodejs
Last active November 16, 2016 17:29
config vagrant, nginx and node for load balancing
setup seperate vagrant box for nginx and node app, assign different ips for each box.
write script file in vagrant box and config in Vagrantfile:
config.vm.provision "shell", path: "script.sh"
------- script.sh --------
echo "---- start setting up ------"
echo "---- update package list ----"
sudo apt-get update
@ruichuang
ruichuang / nginx commands on Ubuntu
Last active November 16, 2016 17:03
nginx commands on Ubuntu
sudo service nginx start
sudo service nginx stop
sudo service nginx restart
view status of your server:
sudo service status nginx
reload nginx server(after change on config file such as nginx.con):
sudo service nginx reload
@ruichuang
ruichuang / RESTful API
Created November 17, 2016 14:25
notes for RESTful api
REST = REpresentational State Transfer
HTTP
----Request----------
1. Verb (get-ready only/post/delete-idempotent/put-idempotent)
2. URI <protocol>://<service-name>/<ResourceType>/<ResourceID>
3. Http version
4. Request Header: key<->value
5. Request Body
-------response----------
no nedd to push "node_modules" on git, only need 'npm init' create package.json.
************************************************************************************************
ANSI escape codes:
Black 0;30 Dark Gray 1;30
Red 0;31 Light Red 1;31
Green 0;32 Light Green 1;32
Brown/Orange 0;33 Yellow 1;33
Blue 0;34 Light Blue 1;34
--------- npm update dependencies -------
npm i -g npm-check-updates
npm-check-updates -u
npm install
update angular-cli
$ npm install -g npm-check-updates
$ npm-check-updates -u
$ npm install
https://www.npmjs.com/package/npm-check-updates
Mac:
1. cd - (hyphen) you’ll go back to the directory you were in before the last time you issued the cd command.
2. tilde (~) symbol is a shortcut for your Home folder
3. mv file1 file2 file3 ... -t DESTINATION
Vagrant
1. ioslate box.
2. run provisioning script(production env.) aganist box.
3. everyone using same provisioning script got same env.
Docker
1. docker file -- build --> docker image.
2. docker image contains all project code, env. and all installment needed to make project run --> docker container.
3. container run on top of VMs, any server with any Host OS as long as has Docker Engine installed.
4. deployi into cluster, running many containers let Nginx do load balancing.
npm init -y
npm i --save react react-dom
npm i -D babel-core babel-loader babel-preset-es2015 babel-preset-react react-hot-loader webpack webpack-dev-server
npm i -g webpack webpack-dev-server(one time)
---------Nov 25-----------
[1] each render() return JSX syntax html which is how we want this component looks like after state got changed.
[2] React re-renders the components all the way down beginning at the component that contains the render] which means that
React re-renders only components below the component that changed, and not the entire app.
****** css selectors:
1. id selector can only use once in html file.
2. class selector can chain multiple class apply to same element
3. child selector '>', only select direct children of elements
4. descendant selector,all child of selected element
5. ~ combinator ex. p ~ span means selecting all <span> tags which is preceded by the p
and both of them share a common parent
6. p + span means first <span> palced immediately after <p>
7. ::before/after add cosmetic content before/after a element by using content, eg:
.boring-text::after {