-
-
Save andyyou/b88d74fc180375b9ede9 to your computer and use it in GitHub Desktop.
Common commands collection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1. Create empty branch and copy file from another branch | |
# 這種方式複製檔案路徑會跟原本的 repository 一樣, 有點不方便 | |
$ git checkout --orphan <branchname> | |
$ git rm --cached -r . | |
$ rm -rf * | |
$ git add . | |
$ git ci -m 'comment' | |
$ git checkout <branch_name> path/to/new/file | |
# 2. Splite a folder or module to another new branch | |
$ git subtree split --prefix=<your_folder_or_module> -b <branchname> | |
# Same with above but more concise | |
$ git subtree split -P <foldername> -b <branchname> | |
> npm run build-npm
> npm run build-site
> git subtree push --prefix site origin gh-pages
> npm version patch
> npm publish
> git push origin `git subtree split --prefix site master`:gh-pages --force
Install npm from private gitlab
> npm install git+ssh://git@192.168.1.1:andyyou/react-coverflow.git
Delete remote tag and branch
> git push origin :refs/tags/[tagname]
> git push origin :[branch_name]
Pull specific branch
$ git checkout -b serverfix origin/serverfix
[alias]
co = checkout
ci = commit
st = status
br = branch
hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
type = cat-file -t
dump = cat-file -p
# vim hex edit
> :%! xxd
# back to normal mode
> :%! xxd -r
- UTF-8 BOM
0xEF,0xBB,0xBF
- UTF-16
U+FEFF
Run docker in iTerm2 Details
> eval "$(docker-machine env default)"
# 執行映像檔
> docker run [repository_name]/[image_name]
> docker run docker-whale
# 列出本地的映像檔
> docker images
# 製作映像檔目錄與 Dockerfile 後編譯
> docker build -t [name] [path]
> docker build -t docker-whale .
# 打上標簽
> docker tag 7d9495d03763 andyyou/docker-whale:latest
> docker tog [image_id] [repository_name/account]/[image_name]
# push 前需要登入
> docker login
# push
> docker push andyyou/docker-whale
# 移除映像檔
> docker rmi -f 7d9495d03763
> docker rmi -f andyyou/docker-whale
> docker rmi -f [image_name or image_id]
# 重建
> docker-machine create --driver virtualbox default
[Error checking TLS connection: machine does not exist](docker-machine stop default && docker-machine start default)
# 重開
$ docker-machine stop default && docker-machine start default
# 砍掉重建
$ docker-machine rm default
$ docker-machine create --driver virtualbox default
產 SSL 憑證
> openssl genrsa -out server.key 2048
> openssl req -new -key server.key -out server.csr
> openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt
查版號
$ npm show [library name] version // 顯示某 library 最新版本
$ npm view [library name] versions // 看某 library 所有版本
$ nvm ls
$ nvm ls-remote // 顯示 node 可用版本
$ npm config set init.author.name "andyyou"
$ npm config set init.author.email andyyu0920@gmail.com
$ npm config set init.author.url http://andyyou.github.io
$ npm config set init.license MIT
# Remote version of package
$ npm view [package] version
# Locally in project
$ npm ls
# Locally in project specify a package name
$ npm ls [lodash]
# Client global
$ npm ls -g
$ npm ls --depth 0
# npm 打包
$ npm adduser
$ npm login
$ npm config ls
$ npm version 0.0.2
$ npm version patch
$ npm publish
npm 更新
# 更新全域
$ npm install -g jshint
# 檢查哪些過期
$ npm outdated -g --depth=0
# 全部更新
$ npm update -g
Check port
$ netstat -na | grep 8080
$ lsof -i tcp:3000
osx copy
$ pbcopy < ~/.ssh/id_rsa.pub
Fix could not connect to server: Connection refused
$ rm /usr/local/var/postgres/postmaster.pid
# 備份 MongoDB
$ mongodump --db [name]
$ mongodump --db [name] --collection [name]
$ mongodump --db [name] --collection [name] --out 'path'
# 還原
$ mongorestore --db [name] [/path/file.bson]
$ mongorestore --db [name] [/path/folder]
$ heroku create [app_name]
# Setting buildpacks
$ git push heroku master
$ figaro heroku:set -e production
$ heroku run rails db:migrate
$ heroku run rake assets:precompile
$ heroku pg:reset database
# 安裝 ngrok
$ brew cask install ngrok
# 先記得登入安裝憑證
# 使用
$ ngrok http 8080
New ssh key
$ ssh-keygen -o -a 100 -t ed25519
$ hexo new draft [draft-article-name] # No date necessary
$ hexo publish [draft-article-name]
$ hexo server
$ hexo generate # 產生靜態檔案
$ hexo deploy
$ hexo generate -d # 產完檔案及部署
$ hext deploy -g # 部署之前先產檔
$ system_profiler SPSoftwareDataType
macOS serria 使用來源未知軟體
$ sudo spctl --master-disable
Copy entire static website
> wget --mirror -p --html-extension --convert-links tnyummy.tw
To have launchd start postgresql now and restart at login:
brew services start postgresql
Or, if you don't want/need a background service you can just run:
pg_ctl -D /usr/local/var/postgres start
#!/bin/bash
echo "ctime: $(ls -lc a | awk '{print $6, $7, $8}')"
echo "atime: $(ls -lu a | awk '{print $6, $7, $8}')"
echo "mtime: $(ls -l a | awk '{print $6, $7, $8}')"
exit 0;
atime: Access Time 檔案上次被讀取的時間
ctime: Change Time 檔案的屬性
或內容
上次被修改的時間
mtime: Modify Time 檔案的內容
上次被修改的時間
$ echo 'a sentence' > a.txt # ctime, mtime updated
$ cat a.txt # # atime updated
$ chmod 644 a.txt # ctime updated
Add https://localhost
to OSX
$ cd; mkdir .ssl
$ openssl req -newkey rsa:2048 -x509 -nodes -keyout .ssl/localhost.key -new -out .ssl/localhost.crt -subj /CN=localhost -reqexts SAN -extensions SAN -config <(cat /System/Library/OpenSSL/openssl.cnf <(printf '[SAN]\nsubjectAltName=DNS:localhost')) -sha256 -days 3650
$ sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain .ssl/localhost.crt
# 查詢資訊 (包含設定檔案路徑)
$ gcloud info
# 設定
$ gcloud init
# 列出所有設定檔
$ gcloud config configurations list
# 刪除設定
$ gcloud config configurations delete <name>
# 切換設定
$ gcloud config configurations activate <name>
# 列出已安裝的元件
$ gcloud components list
# 安裝元件
$ gcloud components install
# 更新
$ gcloud components update
# 移除元件
gcloud components remove <component_name>
OSX mount
$ diskutil list
$ diskutil mount /dev/disk1
$ diskutil unmount /dev/disk1s2
Change filename access right for git:
$ git ls-files -m | xargs chmod 644
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just push dist to gh-pages