- MacOS/Linux
- Terminal
- Windows
- WSL
- Git Bash
- https://swcarpentry.github.io/shell-novice/
COMMAND --helpls [OPTION] [PATTERN]-F: showing /-a: showing ../-r: reverse-R: recursive- [PATTERN]: *.ext, ? (any single character)
pwdcd- w/o options: going back to home ~
..
- TAB completion
mkdir-p: for multi-level folders
nano(text editor)- Ctrl-o + Enter: save
- Ctrl-x: exit
mv SRC/ DEST/cp FILE_A FILE_Brm-i: interactive mode-r: for folders
wc(word counts)-l: lines
>: print intosort-n: numeric-r: reverse
head/tail-n #: # of lines
|(pipe)uniq-c: unique counts of sequential lines
cut-d ,: delimiter-f #: field #
- Shell scripts (.sh)
bash script.sh#: comments"$#": shorthand for argument #
- https://swcarpentry.github.io/python-novice-inflammation/
- Installation took time.
- Miniforge
jupyter- Re-run
- Mouse vs. Keyboard strokes
conda env list- Variables
- Naming convention
- Data types
type(): type of variableprint()help()import numpyloadtxt('*.csv', delimiter=',')- type
numpy.ndarrayfloat64(larger than afloat)
shape(rows, columns)- index
- Python is a "zero-indexed" language.
- Slicing
- up to but not including the number after the colon
- no final number means go to the end
mean(),std(),amin(),amax(),diff()(..., axis=0)(0 by column, 1 by row)
import matplotlib.pyplot as plt- create a graph --> show the graph (
plt.show()) --> save figure (plt.savefig(FILE.EXT)) imshowplotfig = figure(figsize=(8,8)ax = fig.add_subplot(nrows, ncols, index)ax.set_xlabel(),ax.set_ylabel(),ax.set_xlim(),ax.set_ylim()ax.grid('on')fig.tight_layout()
- create a graph --> show the graph (
- List
[]- mutable
- nested list
- heterogeneousness
append(),pop(),reverse()vs.reversed()
- Tuple
()- immutable
- Loops
for [VARIABLE] in [List]:- indentation
- comments with instructions
import globglob.glob('PATTERN'): all matched filenamessorted()
- Conditions
if (CONDITIONS):elif (CONDI_A and CONDI_B):else:- indentation
>,>=,<,<=,==,!='''COMMENTS'''
- Functions
def FUNCTION(INPUTS):return OUTPUTS
- indentation
OUTPUTS = FUNCTION(INPUTS)- Scopes (local, global)
- https://swcarpentry.github.io/git-novice/index.html
- Configuration
git config --global user.name "NAME"git config --global user.email "EMAIL"git config --global core.editor "nano -w"git config --global init.defaultBranch main
- Local repository
git initls -a(.git/)
git statusgit add FILE_or_DIR--> (staged) -->git commit -m "DESCRIPTION"--> (committed)git log- "q": leave log
-#: last # entries--oneline
git diff- +(green): added
- -(red): deleted
--staged: for staged
.gitignore- files/folders or patterns of files/folders to be ignored
- Useful commands
touch FILE: create an empty filecat FILE: print file content
- Remote repository
- Github account
git remote add origin git@github.com:ACCOUNT/REPO_NAME.gitgit remote -v- SSH key
ssh-keygen -t ed25519 -C "COMMENTS"- copy & paste the public key (
~/.ssh/id_ed25519.pub) to Github/Settings/SSH and GPG keys/ ssh -T git@github.com(test connection)
git push origin main(or with-uoption)