npx ionic start [app name] tabs --type=angular
tabs : example name
–type= : choose a framework ex. Angular or React
or
npx ionic start [app name]
npx -p @angular/cli ng new [name]
npx ng generate component [component name]
It will directly become a folder just inside app folder, so if you wanna put everything inside components folder, go for…
npx ng generate component components/[component name]
npx ng generate service [service name]
No folder, so if you wanna put them in a folder, go for…
npx ng generate service service/[service name]
Allow local ip rather than just localhost
npx ng serve --host 0.0.0.0 --disable-host-check
npx create-react-app my-app
npx create-react-app my-app --template redux-typescript
npx create-next-app my-app
npx create-next-app my-app --example with-chakra-ui-typescript
npm i -D eslint@7 @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-config-airbnb eslint-plugin-react eslint-import-resolver-typescript
npm i -D eslint-config-prettier prettier
{
"settings": {
"import/extensions": [".js", ".jsx", ".ts", ".tsx"],
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"]
},
"import/resolver": {
"node": {
"extensions": [".js", ".jsx", ".ts", ".tsx"]
},
"typescript": {}
}
},
"env": {
"browser": true,
"es2021": true
},
"extends": ["plugin:react/recommended", "airbnb", "prettier"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": ["react", "@typescript-eslint"],
"rules": {
"import/extensions": [
"error",
"ignorePackages",
{
"js": "never",
"jsx": "never",
"ts": "never",
"tsx": "never"
}
],
"import/no-cycle": "warn",
"import/prefer-default-export": "off",
"jsx-a11y/click-events-have-key-events": "off",
"jsx-a11y/no-static-element-interactions": "off",
"no-console": "off",
"no-param-reassign": "warn",
"no-promise-executor-return": "warn",
"no-use-before-define": "off",
"react/function-component-definition": [
2,
{
"namedComponents": "arrow-function",
"unnamedComponents": "arrow-function"
}
],
"react/jsx-filename-extension": ["warn", { "extensions": [".tsx"] }],
// suppress errors for missing 'import React' in files
"react/react-in-jsx-scope": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{ "argsIgnorePattern": "^_" }
]
}
}
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true,
"noFallthroughCasesInSwitch": true,
"isolatedModules": true,
"jsx": "react-jsx",
"typeRoots": ["node_modules/@types"],
"incremental": true
},
"include": ["**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}
install material ui
npm install @mui/material @emotion/react @emotion/styled
install styled-components
npm i styled-components
npm i -D @types/styled-components
import styled from 'styled-components'
install react router
npm i react-router-dom@6
others
npm i @material-ui/core
npm i -S prop-types
import PropTypes from 'prop-types'
comment: select the lines again and then press ctrl + / (in windows) Command ⌘ + / (in mac)
imp→ import moduleName from 'module'
exp→ export default moduleName
nfn→ const functionName = (params) => { }
imr→ import React from 'react'
impt→ import PropTypes from 'prop-types'
clg→ console.log(object)
npx @vue/cli create [name]
npx create-nuxt-app [name]
font-awesome nuxt module
npm install nuxt-fontawesome
// the icon packages.
npm install @fortawesome/free-brands-svg-icons
npm install @fortawesome/free-solid-svg-icons
// solid style
<fa :icon="['fas','lightbulb']" />
<fa :icon="['fab','github']" />
//will use style from first import
<fa icon="lightbulb" />
OR just install this
@fortawesome/fontawesome-free
<vue for file scaffolding snippets
<template for template scaffolding snippets
<style for style scaffolding snippets
<script for script scaffolding snippets
npm init -y
npm i express cors
npm i -D @types/cors @types/express @types/node cross-env ts-node ts-node-dev typescript
npm i -D @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint eslint-config-airbnb-typescript eslint-config-prettier eslint-plugin-import prettier
{
"env": {
"es2021": true,
"node": true
},
"extends": [
"airbnb-typescript/base",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"plugins": ["import"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module",
"project": "./tsconfig.json"
},
"rules": {}
}
"scripts": {
"start": "npm run build && cross-env NODE_ENV=production node --trace-warnings dist/index.js",
"build": "rimraf dist && tsc -p tsconfig.json",
"dev": "cross-env NODE_ENV=development ts-node-dev src/index.ts",
"lint": "eslint . --ext .ts",
"format": "prettier --write \"./src/**/*.{js,jsx,ts,tsx,json,css,scss,md}\"",
"release": "standard-version"
}
{
"compilerOptions": {
"target": "ES2015",
"module": "commonjs",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"allowSyntheticDefaultImports": true,
"isolatedModules": true,
"moduleResolution": "node",
"strict": true,
"skipLibCheck": true /* Skip type checking all .d.ts files. */,
"typeRoots": ["node_modules/@types", "src/@types"],
"baseUrl": "src/",
"outDir": "./dist"
},
"include": ["./src/**/*.ts"],
"exclude": ["node_modules"]
}
Install packages
npm i typeorm reflect-metadata mysql
add ormconfig.js
module.exports = [
{
name: 'development',
type: 'mysql',
host: process.env.DB_HOST_DEV,
port: process.env.DB_PORT,
username: process.env.DB_USERNAME,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
synchronize: false,
logging: false,
entities: ['src/orm/entities/index.ts'],
migrations: ['src/orm/migrations/index.ts']
},
{
name: 'production',
type: 'mysql',
host: process.env.DB_HOST_PROD,
port: process.env.DB_PORT,
username: process.env.DB_USERNAME,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
synchronize: false,
logging: false,
entities: ['dist/orm/entities/index.js'],
migrations: ['dist/orm/migrations/index.js']
}
];
(async () => {
try {
const options = await getConnectionOptions(
process.env.NODE_ENV || 'development'
);
await createConnection({
...options,
name: 'default',
synchronize: false
});
console.log('database ok');
} catch (e) {
console.log(e);
console.log('database connection failed!');
}
})();
{
"semi": true,
"trailingComma": "none",
"tabWidth": 2,
"arrowParens": "avoid",
"singleQuote": true,
"printWidth": 80,
"htmlWhitespaceSensitivity": "ignore"
}
npm i -D cz-conventional-changelog husky lint-staged standard-version
{
"path": "cz-conventional-changelog"
}
...
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"src/**/*.{js,jsx,ts,tsx,json}": [
"eslint --fix"
],
"src/**/*.{js,jsx,ts,tsx,json,css,scss,md}": [
"prettier --write"
]
}
...
npm init -y
npm list -g --depth 0
-D is short for –save-dev and -S is short for –save
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
nvm: command not found
, it's because your OS doesn't have .bash_profile, so just do touch ~/.bash_profile
, then re-install nvm again.source ~/.bashrc
sh deploy.sh
{
...
"homepage": "http://wolfzxcv.github.io/react-repos",
...
}
# build
npm run build
# navigate into the build output directory
cd build
# commit
git init
git add -A
git commit -m 'deploy'
# if you are deploying to git@github.com:<USERNAME>/<REPO>
git push -f git@github.com:wolfzxcv/react-repos.git master:gh-pages
sh deploy.sh
npm i -D gh-pages
{
...
"homepage": "http://wolfzxcv.github.io/[repo_name]",
...
"scripts": {
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
"start": "react-scripts start",
"build": "react-scripts build",
},
...
"devDependencies": {
"gh-pages": "^2.0.1"
}
}
git remote set-url origin git@github.com:<USERNAME>/<REPO>
npm run predeploy
npm run deploy
{
...
"projects": {
...
"architect": {
"build": {
...
"options": {
"outputPath": "dist",
...
},
...
},
...
}
}},
...
}
# build
# if you are deploying to https://<USERNAME>.github.io/<REPO>
# put REPO name between slashes
npx ng build --prod --base-href=/ng-todo/
# upload to GitHub
cd dist
git init
git add -A
git commit -m 'deploy'
# if you are deploying to https://<USERNAME>.github.io
# git push -f git@github.com:<USERNAME>/<USERNAME>.github.io.git master
# if you are deploying to https://<USERNAME>.github.io/<REPO>
git push -f https://github.com/wolfzxcv/ng-todo.git master:gh-pages
cd -
sh ./deploy.sh
Ctrl + Alt + T => open terminal
Ctrl + Shift +W => close current window
sudo lsof -i :5000
sudo kill -9 56412
sudo mysql -u root -p
SHOW VARIABLES LIKE 'validate_password%';
SET GLOBAL validate_password.policy = 0;
ALTER USER 'root'@'localhost' IDENTIFIED BY '0000';
ctrl + N => wizard
ctrl +shift +O => organize import
ctrl +shift +F => formatting
shift + alt +S => list
fn+F3 => check interface
// delete branch locally
git branch -d localBranchName
// delete branch remotely
git push origin --delete remoteBranchName
// update remote branch list =>sync remote branch
git fetch --prune
git tag -a v1.4 -m "my version 1.4"
git push origin --tags
npm install commitizen -g
commitizen init cz-conventional-changelog --save-dev --save-exact
前言
當你將本機端的 Git 加入到遠端的 repository 像是 GitHub …等,若之後你又另外建立新的的 repository 或是要將它搬移至其他遠端數據庫例如 GitLab。此時要刪除原本的 remote origin 該怎麼做?
解決方法
1 . Change the URI (URL) for a remote Git repository
git remote set-url origin git://new.url.here
2 . Delete remove origin
To remove a remote:
git remote remove origin
To add a remote:
git remote add origin yourRemoteUrl
Finally
git push -u origin master
check existing settings
git remote -v
add another remote url
git remote set-url origin --push --add [remote git url]
git branch -m new-name
If you are on a different branch:
git branch -m old-name new-name
git push origin :old-name new-name
git push origin -u new-name
git reset HEAD^
one ^ means a commit back, so ^^ mean 2 commits back
git push -f
// run query
cmd + enter
// auto complete
ctrl + space
!important(即使是標註在class底下) > Inline Styles > id > class (後declare的權重較高)
May 06, 2019 日記
不寫 return 嫌 function怎沒反應
typo 在哭到底錯在哪
括號{} () 分號逗號 , ; 打錯..在哭到底錯在哪
人家要你回傳字串 不是回傳 console.log 題目要求什麼,看清楚!!!
. # 到底要 id 還是要 class 還是指定 element ???
alternative: tinymce