Skip to content

Instantly share code, notes, and snippets.

@andyyou

andyyou/cmd.sh Secret

Last active October 19, 2018 12:24
Show Gist options
  • Save andyyou/b88d74fc180375b9ede9 to your computer and use it in GitHub Desktop.
Save andyyou/b88d74fc180375b9ede9 to your computer and use it in GitHub Desktop.
Common commands collection
# 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>
@andyyou
Copy link
Author

andyyou commented Feb 12, 2017

#!/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

@andyyou
Copy link
Author

andyyou commented Nov 2, 2017

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
            

@andyyou
Copy link
Author

andyyou commented Nov 16, 2017

# 查詢資訊 (包含設定檔案路徑)
$ 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>

@andyyou
Copy link
Author

andyyou commented Jan 2, 2018

OSX mount

$ diskutil list
$ diskutil mount /dev/disk1
$ diskutil unmount /dev/disk1s2

@andyyou
Copy link
Author

andyyou commented Oct 18, 2018

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