commit 0a5471dc016a31080a1039b562f163c36b3c7ce3 Author: Randy8080 Date: Sat Dec 19 21:40:24 2020 +0800 first commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..6791fb7 --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +# reference + +> Share quick reference cheat sheet for developers. + +![Quick reference](https://quickref.me/assets/image/quickref-preview.png) + + +**[LiveView](https://quickref.me/)** _(quickref.me)_ + + diff --git a/bash.md b/bash.md new file mode 100644 index 0000000..36951d2 --- /dev/null +++ b/bash.md @@ -0,0 +1,893 @@ +--- +title: Bash scripting +date: 2020-11-25 18:28:43 +icon: icon-bash +background: bg-gray-400 +tags: + - shell + - sh + - echo + - linux +categories: + - Linux +intro: This is a quick reference to getting started with Bash scripting. +--- + +Getting started {.cols-3} +--------------- + +### Introduction {.-intro} + +This is a quick reference to getting started with Bash scripting. + +- [Learn bash in y minutes](https://learnxinyminutes.com/docs/bash/) _(learnxinyminutes.com)_ +- [Bash Guide](http://mywiki.wooledge.org/BashGuide) _(mywiki.wooledge.org)_ + +### Example + +```bash +#!/usr/bin/env bash + +NAME="John" +echo "Hello $NAME!" +``` + +### Variables + +```bash +NAME="John" +echo $NAME +echo "$NAME" +echo "${NAME}!" +``` + +### String quotes + +```bash +NAME="John" +echo "Hi $NAME" #=> Hi John +echo 'Hi $NAME' #=> Hi $NAME +``` + +### Shell execution + +```bash +echo "I'm in $(pwd)" +echo "I'm in `pwd`" +# Same +``` + +See [Command substitution](http://wiki.bash-hackers.org/syntax/expansion/cmdsubst) + +### Conditional execution + +```bash +git commit && git push +git commit || echo "Commit failed" +``` + +### Functions {#functions-example} + +```bash +get_name() { + echo "John" +} + +echo "You are $(get_name)" +``` + +See: [Functions](#functions-2) + +### Conditionals {#conditionals-example} + +```bash +if [[ -z "$string" ]]; then + echo "String is empty" +elif [[ -n "$string" ]]; then + echo "String is not empty" +fi +``` + +See: [Conditionals](#conditionals-2) + +### Strict mode + +```bash +set -euo pipefail +IFS=$'\n\t' +``` + +See: [Unofficial bash strict mode](http://redsymbol.net/articles/unofficial-bash-strict-mode/) + +### Brace expansion + +```bash +echo {A,B}.js +``` + +| Expression | Description | +| ---------- | ------------------- | +| `{A,B}` | Same as `A B` | +| `{A,B}.js` | Same as `A.js B.js` | +| `{1..5}` | Same as `1 2 3 4 5` | + +See: [Brace expansion](http://wiki.bash-hackers.org/syntax/expansion/brace) + + +Parameter expansions {.cols-3} +-------------------- + +### Basics {.row-span-4} + +```bash +name="John" +echo ${name} +echo ${name/J/j} #=> "john" (substitution) +echo ${name:0:2} #=> "Jo" (slicing) +echo ${name::2} #=> "Jo" (slicing) +echo ${name::-1} #=> "Joh" (slicing) +echo ${name:(-1)} #=> "n" (slicing from right) +echo ${name:(-2):1} #=> "h" (slicing from right) +echo ${food:-Cake} #=> $food or "Cake" +``` + +```bash +length=2 +echo ${name:0:length} #=> "Jo" +``` + +See: [Parameter expansion](http://wiki.bash-hackers.org/syntax/pe) + +```bash +STR="/path/to/foo.cpp" +echo ${STR%.cpp} # /path/to/foo +echo ${STR%.cpp}.o # /path/to/foo.o +echo ${STR%/*} # /path/to + +echo ${STR##*.} # cpp (extension) +echo ${STR##*/} # foo.cpp (basepath) + +echo ${STR#*/} # path/to/foo.cpp +echo ${STR##*/} # foo.cpp + +echo ${STR/foo/bar} # /path/to/bar.cpp +``` + +```bash +STR="Hello world" +echo ${STR:6:5} # "world" +echo ${STR: -5:5} # "world" +``` + +```bash +SRC="/path/to/foo.cpp" +BASE=${SRC##*/} #=> "foo.cpp" (basepath) +DIR=${SRC%$BASE} #=> "/path/to/" (dirpath) +``` + +### Substitution {.row-span-3} + +| Code | Description | +| ----------------- | ------------------- | +| `${FOO%suffix}` | Remove suffix | +| `${FOO#prefix}` | Remove prefix | +| `${FOO%%suffix}` | Remove long suffix | +| `${FOO##prefix}` | Remove long prefix | + +| `${FOO/from/to}` | Replace first match | +| `${FOO//from/to}` | Replace all | +| `${FOO/%from/to}` | Replace suffix | +| `${FOO/#from/to}` | Replace prefix | + +### Comments + +```bash +# Single line comment +``` + +```bash +: ' +This is a +multi line +comment +' +``` + +### Substrings + +| Expression | Description | +| --------------- | ------------------------------ | +| `${FOO:0:3}` | Substring _(position, length)_ | +| `${FOO:(-3):3}` | Substring from the right | + +### Length + +| Expression | Description | +| ---------- | ---------------- | +| `${#FOO}` | Length of `$FOO` | + +### Manipulation + +```bash +STR="HELLO WORLD!" +echo ${STR,} #=> "hELLO WORLD!" (lowercase 1st letter) +echo ${STR,,} #=> "hello world!" (all lowercase) + +STR="hello world!" +echo ${STR^} #=> "Hello world!" (uppercase 1st letter) +echo ${STR^^} #=> "HELLO WORLD!" (all uppercase) +``` + +### Default values + +| Expression | Description | +| ----------------- | -------------------------------------------------------- | +| `${FOO:-val}` | `$FOO`, or `val` if unset (or null) | +| `${FOO:=val}` | Set `$FOO` to `val` if unset (or null) | +| `${FOO:+val}` | `val` if `$FOO` is set (and not null) | +| `${FOO:?message}` | Show error message and exit if `$FOO` is unset (or null) | + +Omitting the `:` removes the (non)nullity checks, e.g. `${FOO-val}` expands to `val` if unset otherwise `$FOO`. + +Loops {.cols-3} +----- + +### Basic for loop + +```bash +for i in /etc/rc.*; do + echo $i +done +``` + +### C-like for loop + +```bash +for ((i = 0 ; i < 100 ; i++)); do + echo $i +done +``` + +### Ranges {.row-span-2} + +```bash +for i in {1..5}; do + echo "Welcome $i" +done +``` + + +#### With step size + +```bash +for i in {5..50..5}; do + echo "Welcome $i" +done +``` + + + +### Auto increment + +```bash +i=1 +while [[ $i -lt 4 ]]; do + echo "Number: $i" + ((i++)) +done +``` + +### Auto decrement + +```bash +i=3 +while [[ $i -gt 0 ]]; do + echo "Number: $i" + ((i--)) +done +``` + + +### Continue {.col-span-2} + +```bash {data=3,5} +for number in $(seq 1 3); do + if [[ $number == 2 ]]; then + continue; # Skip rest of this particular loop iteration. + fi + echo "$number" # This will not print 2 +done +``` + + +### Break + +```bash +for number in $(seq 1 3); do + if [[ $number == 2 ]]; then + # Skip entire rest of loop. + break; + fi + # This will only print 1 + echo "$number" +done +``` + + + +### Reading lines + +```bash +cat file.txt | while read line; do + echo $line +done +``` + +### Forever + +```bash +while true; do + # here is some code. +done +``` +or +```bash +while :; do + # here is some code. +done +``` + + +Functions {.cols-3} +--------- + +### Defining functions + +```bash +myfunc() { + echo "hello $1" +} +``` + +```bash +# Same as above (alternate syntax) +function myfunc() { + echo "hello $1" +} +``` + +```bash +myfunc "John" +``` + +### Returning values + +```bash +myfunc() { + local myresult='some value' + echo $myresult +} +``` + +```bash +result="$(myfunc)" +``` + +### Raising errors + +```bash +myfunc() { + return 1 +} +``` + +```bash +if myfunc; then + echo "success" +else + echo "failure" +fi +``` + + +### Arguments + +| Expression | Description | +| --- | --- | +| `$#` | Number of arguments | +| `$*` | All arguments | +| `$@` | All arguments, starting from first | +| `$1` | First argument | +| `$_` | Last argument of the previous command | + +See [Special parameters](http://wiki.bash-hackers.org/syntax/shellvars#special_parameters_and_shell_variables). + +Conditionals {.cols-3} +------------ + +### Conditions + +Note that `[[` is actually a command/program that returns either `0` (true) or `1` (false). Any program that obeys the same logic (like all base utils, such as `grep(1)` or `ping(1)`) can be used as condition, see examples. + +| Condition | Description | +| --- | --- | +| `[[ -z STRING ]]` | Empty string | +| `[[ -n STRING ]]` | Not empty string | +| `[[ STRING == STRING ]]` | Equal | +| `[[ STRING != STRING ]]` | Not Equal | + +| `[[ NUM -eq NUM ]]` | Equal | +| `[[ NUM -ne NUM ]]` | Not equal | +| `[[ NUM -lt NUM ]]` | Less than | +| `[[ NUM -le NUM ]]` | Less than or equal | +| `[[ NUM -gt NUM ]]` | Greater than | +| `[[ NUM -ge NUM ]]` | Greater than or equal | + +| `[[ STRING =~ STRING ]]` | Regexp | + +| `(( NUM < NUM ))` | Numeric conditions | + +#### More conditions + +| Condition | Description | +| -------------------- | ------------------------ | +| `[[ -o noclobber ]]` | If OPTIONNAME is enabled | + +| `[[ ! EXPR ]]` | Not | +| `[[ X && Y ]]` | And | +| `[[ X || Y ]]` | Or | + +### File conditions + +| Condition | Description | +| --- | --- | +| `[[ -e FILE ]]` | Exists | +| `[[ -r FILE ]]` | Readable | +| `[[ -h FILE ]]` | Symlink | +| `[[ -d FILE ]]` | Directory | +| `[[ -w FILE ]]` | Writable | +| `[[ -s FILE ]]` | Size is > 0 bytes | +| `[[ -f FILE ]]` | File | +| `[[ -x FILE ]]` | Executable | + +| `[[ FILE1 -nt FILE2 ]]` | 1 is more recent than 2 | +| `[[ FILE1 -ot FILE2 ]]` | 2 is more recent than 1 | +| `[[ FILE1 -ef FILE2 ]]` | Same files | + +### Example + +#### String +```bash +if [[ -z "$string" ]]; then + echo "String is empty" +elif [[ -n "$string" ]]; then + echo "String is not empty" +else + echo "This never happens" +fi +``` + +#### Combinations +```bash +if [[ X && Y ]]; then + ... +fi +``` + +#### Equal +```bash +if [[ "$A" == "$B" ]]; then + ... +fi +``` + +#### Regex +```bash +if [[ '1. abc' =~ ([a-z]+) ]]; then + echo ${BASH_REMATCH[1]} +fi +``` + +#### Smaller +```bash +if (( $a < $b )); then + echo "$a is smaller than $b" +fi +``` + +#### Exists +```bash +if [[ -e "file.txt" ]]; then + echo "file exists" +fi +``` + +Arrays {.cols-2} +------ + +### Defining arrays + +```bash +Fruits=('Apple' 'Banana' 'Orange') +``` + +```bash +Fruits[0]="Apple" +Fruits[1]="Banana" +Fruits[2]="Orange" +``` + + +### Iteration + +```bash +for i in "${arrayName[@]}"; do + echo $i +done +``` + + +### Working with arrays + +```bash +echo ${Fruits[0]} # Element #0 +echo ${Fruits[-1]} # Last element +echo ${Fruits[@]} # All elements, space-separated +echo ${#Fruits[@]} # Number of elements +echo ${#Fruits} # String length of the 1st element +echo ${#Fruits[3]} # String length of the Nth element +echo ${Fruits[@]:3:2} # Range (from position 3, length 2) +echo ${!Fruits[@]} # Keys of all elements, space-separated +``` + +### Operations + +```bash +Fruits=("${Fruits[@]}" "Watermelon") # Push +Fruits+=('Watermelon') # Also Push +Fruits=( ${Fruits[@]/Ap*/} ) # Remove by regex match +unset Fruits[2] # Remove one item +Fruits=("${Fruits[@]}") # Duplicate +Fruits=("${Fruits[@]}" "${Veggies[@]}") # Concatenate +lines=(`cat "logfile"`) # Read from file +``` + +Dictionaries {.cols-3} +------------ + +### Defining + +```bash +declare -A sounds +``` + +```bash +sounds[dog]="bark" +sounds[cow]="moo" +sounds[bird]="tweet" +sounds[wolf]="howl" +``` + +Declares `sound` as a Dictionary object (aka associative array). + +### Working with dictionaries + +```bash +echo ${sounds[dog]} # Dog's sound +echo ${sounds[@]} # All values +echo ${!sounds[@]} # All keys +echo ${#sounds[@]} # Number of elements +unset sounds[dog] # Delete dog +``` + +### Iteration + +#### Iterate over values + +```bash +for val in "${sounds[@]}"; do + echo $val +done +``` + +#### Iterate over keys + +```bash +for key in "${!sounds[@]}"; do + echo $key +done +``` + +Options {.cols-2} +------- + +### Options + +```bash +set -o noclobber # Avoid overlay files (echo "hi" > foo) +set -o errexit # Used to exit upon error, avoiding cascading errors +set -o pipefail # Unveils hidden failures +set -o nounset # Exposes unset variables +``` + +### Glob options + +```bash +shopt -s nullglob # Non-matching globs are removed ('*.foo' => '') +shopt -s failglob # Non-matching globs throw errors +shopt -s nocaseglob # Case insensitive globs +shopt -s dotglob # Wildcards match dotfiles ("*.sh" => ".foo.sh") +shopt -s globstar # Allow ** for recursive matches ('lib/**/*.rb' => 'lib/a/b/c.rb') +``` + +Set `GLOBIGNORE` as a colon-separated list of patterns to be removed from glob +matches. + +History {.cols-2} +------- + +### Commands + +| Command | Description | +| --------------------- | ----------------------------------------- | +| `history` | Show history | +| `shopt -s histverify` | Don't execute expanded result immediately | + +### Expansions + +| Expression | Description | +| ------------ | ---------------------------------------------------- | +| `!$` | Expand last parameter of most recent command | +| `!*` | Expand all parameters of most recent command | +| `!-n` | Expand `n`th most recent command | +| `!n` | Expand `n`th command in history | +| `!` | Expand most recent invocation of command `` | + +### Operations + +| Code | Description | +| -------------------- | --------------------------------------------------------------------- | +| `!!` | Execute last command again | +| `!!:s///` | Replace first occurrence of `` to `` in most recent command | +| `!!:gs///` | Replace all occurrences of `` to `` in most recent command | +| `!$:t` | Expand only basename from last parameter of most recent command | +| `!$:h` | Expand only directory from last parameter of most recent command | + +`!!` and `!$` can be replaced with any valid expansion. + +### Slices + +| Code | Description | +| -------- | ---------------------------------------------------------------------------------------- | +| `!!:n` | Expand only `n`th token from most recent command (command is `0`; first argument is `1`) | +| `!^` | Expand first argument from most recent command | +| `!$` | Expand last token from most recent command | +| `!!:n-m` | Expand range of tokens from most recent command | +| `!!:n-$` | Expand `n`th token to last from most recent command | + +`!!` can be replaced with any valid expansion i.e. `!cat`, `!-2`, `!42`, etc. + + +Miscellaneous {.cols-3} +------------- + +### Numeric calculations + +```bash +$((a + 200)) # Add 200 to $a +``` + +```bash +$(($RANDOM%200)) # Random number 0..199 +``` + +### Subshells + +```bash +(cd somedir; echo "I'm now in $PWD") +pwd # still in first directory +``` + + +### Inspecting commands + +```bash +command -V cd +#=> "cd is a function/alias/whatever" +``` + + +### Redirection {.row-span-2 .col-span-2} + +```bash +python hello.py > output.txt # stdout to (file) +python hello.py >> output.txt # stdout to (file), append +python hello.py 2> error.log # stderr to (file) +python hello.py 2>&1 # stderr to stdout +python hello.py 2>/dev/null # stderr to (null) +python hello.py &>/dev/null # stdout and stderr to (null) +``` + +```bash +python hello.py < foo.txt # feed foo.txt to stdin for python +``` + + +### Source relative + +```bash +source "${0%/*}/../share/foo.sh" +``` + +### Directory of script + +```bash +DIR="${0%/*}" +``` + +### Case/switch + +```bash +case "$1" in + start | up) + vagrant up + ;; + + *) + echo "Usage: $0 {start|stop|ssh}" + ;; +esac +``` + + +### Trap errors {.col-span-2} + +```bash +trap 'echo Error at about $LINENO' ERR +``` + +or + +```bash +traperr() { + echo "ERROR: ${BASH_SOURCE[1]} at about ${BASH_LINENO[0]}" +} + +set -o errtrace +trap traperr ERR +``` + + +### printf + +```bash +printf "Hello %s, I'm %s" Sven Olga +#=> "Hello Sven, I'm Olga + +printf "1 + 1 = %d" 2 +#=> "1 + 1 = 2" + +printf "This is how you print a float: %f" 2 +#=> "This is how you print a float: 2.000000" +``` + +### Getting options {.col-span-2} + +```bash +while [[ "$1" =~ ^- && ! "$1" == "--" ]]; do case $1 in + -V | --version ) + echo $version + exit + ;; + -s | --string ) + shift; string=$1 + ;; + -f | --flag ) + flag=1 + ;; +esac; shift; done +if [[ "$1" == '--' ]]; then shift; fi +``` + +### Check for command's result {.col-span-2} + +```bash +if ping -c 1 google.com; then + echo "It appears you have a working internet connection" +fi +``` + + +### Special variables {.row-span-2} + +| Expression | Description | +| ---------- | ---------------------------- | +| `$?` | Exit status of last task | +| `$!` | PID of last background task | +| `$$` | PID of shell | +| `$0` | Filename of the shell script | + +See [Special parameters](http://wiki.bash-hackers.org/syntax/shellvars#special_parameters_and_shell_variables). + + +### Grep check {.col-span-2} + +```bash +if grep -q 'foo' ~/.bash_history; then + echo "You appear to have typed 'foo' in the past" +fi +``` + + +### Backslash escapes {.row-span-2} + +-   +- \! +- \" +- \# +- \& +- \' +- \( +- \) +- \, +- \; +- \< +- \> +- \[ +- \| +- \\ +- \] +- \^ +- \{ +- \} +- \` +- \$ +- \* +- \? +{.cols-4 .style-none} + + +Escape these special characters with `\` + + + + +### Heredoc + +```sh +cat <_(non-standard)_ | + + +### Special strings + +| Special String | Meaning | +|----------------|----------------------------------------------------| +| @reboot | Run once, at system startup _(non-standard)_ | +| @yearly | Run once every year, "0 0 1 1 *" _(non-standard)_ | +| @annually | (same as @yearly) _(non-standard)_ | +| @monthly | Run once every month, "0 0 1 * *" _(non-standard)_ | +| @weekly | Run once every week, "0 0 * * 0" _(non-standard)_ | +| @daily | Run once each day, "0 0 * * *" _(non-standard)_ | +| @midnight | (same as @daily) _(non-standard)_ | +| @hourly | Run once an hour, "0 * * * *" _(non-standard)_ | + + +### Crontab command + +|------|-------------------------------------------------------------------------| +| `crontab -e` | Edit or create a crontab file if doesn’t already exist. | +| `crontab -l` | Display the crontab file. | +| `crontab -r` | Remove the crontab file. | +| `crontab -v` | Display the last time you edited your crontab file.
_(non-standard)_ | +{.shortcuts} + + +### Special characters {.col-span-2} +| Special Character | Description | +|---------------------|------------------------------------------------------------------------------------------------------------------------------------------------------| +| `Asterik(*)` | Matches all values in the field or any possible value. | +| `Hyphen(-)` | Used to define a range.Ex: 1-5 in 5th field(Day Of Week) Every Weekday i.e., Monday to Friday | +| `Slash (/)` | 1st field(Minute) /15 meaning every fifteen minute or increment of range. | +| `Comma (,)` | Used to separate items.Ex: 2,6,8 in 2nd fields(Hour) executes at 2am,6am and 8am | +| `L` | It is allowed only for Day of Month or Day Of Week field, 2L in Day of week indicates Last tuesday of every month | +| `Hash (#)` | It is allowed only for Day Of Week field, which must be followed within range of 1 to 5. For example, 4#1 means "The first Thursday" of given month. | +| `Question mark (?)` | Can be instead of '*' and allowed for Day of Month and Day Of Week. Usage is restricted to either Day of Month or Day Of Week in a cron expression. | + + + +## Also see {.cols-1} + +* [Crontab Generator](https://crontab-generator.org/) _(crontab-generator.org)_ +* [Crontab guru](https://crontab.guru/) _(crontab.guru)_ diff --git a/emacs.md b/emacs.md new file mode 100644 index 0000000..d5d61c7 --- /dev/null +++ b/emacs.md @@ -0,0 +1,519 @@ +--- +title: Emacs +date: 2020-12-17 16:21:49 +icon: icon-emacs +background: bg-purple-500 +tags: + - editor +categories: + - Toolkit +intro: | + [Emacs](https://www.gnu.org/software/emacs) is the extensible, customizable, self-documenting real time display text editor. + This reference was made for Emacs 27. +--- + + +## Getting started {.cols-3} + + +### Starting Emacs +To enter GNU Emacs 27, just type its name: +```bash +$ emacs +``` + +------ + +|-------------|---------------------------------------------| +| `C-z` | Suspend Emacs
_(or iconify it under X)_ | +| `C-x` `C-c` | Exit Emacs permanently | +{.shortcuts} + + + +### Motion {.row-span-2} + +| Backward | Forward | Entity to move over | +|------------|-----------|----------------------------------| +| `C-b` | `C-f` | Haracter | +| `M-b` | `M-f` | Word | +| `C-p` | `C-n` | Line | +| `C-a` | `C-e` | To line beginning
_(or end)_ | +| `M-a` | `M-e` | Sentence | +| `M-{` | `M-}` | Paragraph | +| `C-x [` | `C-x ]` | Page | +| `C-M-b` | `C-M-f` | Sexp | +| `C-M-a` | `C-M-e` | Function | +| `M-<` | `M->` | To buffer beginning
_(or end)_| +{.shortcuts .show-header} + + + +### Case Change +|-----------|------------------| +| `M-u` | Uppercase word | +| `M-l` | Lowercase word | +| `M-c` | Capitalize word | +| `C-x C-u` | Uppercase region | +| `C-x C-l` | Lowercase region | +{.shortcuts} + + + +### Files +|-------------|--------------------------------------------------| +| `C-x` `C-f` | Read a file into Emacs | +| `C-x` `C-s` | Save a file back to disk | +| `C-x` `s` | Save all files | +| `C-x` `i` | Insert contents of another file into this buffer | +| `C-x` `C-v` | Replace this file with your file | +| `C-x` `C-w` | Write buffer to a specified file | +| `C-x` `C-q` | Toggle read-only status of buffer | +{.shortcuts} + + + + +### Error Recovery +|-----------------------|--------------------------------------------| +| `C-g` | Abort partially typed or executing command | +| `M-x` recover-session | Recover files lost by a system crash | +| `C-x u` / `C-_` / `C-/` | Undo an unwanted change | +| `M-x` revert-buffer | Restore a buffer to its original contents | +| `C-l` | Redraw garbaged screen | +{.shortcuts} + + + + +### Transposing {.row-span-2} +|-----------|----------------------| +| `C-t` | Transpose characters | +| `M-t` | Transpose words | +| `C-x C-t` | Transpose lines | +| `C-M-t` | Transpose sexps | +{.shortcuts} + +#### Scroll +|---------|--------------------------------------------------| +| `C-v` | Scroll to next screen | +| `M-v` | Scroll to previous screen | +| `C-x <` | Scroll left | +| `C-x >` | Scroll right | +| `C-l` | Scroll current line to
_center, top, bottom_ | +{.shortcuts .show-header} + +#### Goto +|---------|----------------------| +| `M-g g` | Goto line | +| `M-g c` | Goto char | +| `M-m` | Back to indentation | +{.shortcuts .show-header} + + + + + +### Marking +|----------------|-------------------------| +| `C-@` \/ `C-SPC`| Uet mark here | +| `C-x C-x` | Exchange point and mark | +| `M-@` | Set mark arg words away | +| `M-h` | Mark paragraph | +| `C-x C-p` | Mark page | +| `C-M-@` | Mark sexp | +| `C-M-h` | Mark function | +| `C-x h` | Mark entire buffer | +{.shortcuts} + + + + +### Killing and Deleting {.row-span-2} + +| Backward | Forward | Entity to kill | +|-------------|------------|--------------------------------------| +| `DEL` | `C-d` | Character
_(delete, not kill)_ | +| `M-DEL` | `M-d` | Word | +| `M-0 C-k` | `C-k` | Line (to end of) | +| `C-x DEL` | `M-k` | Sentence | +| `M-- C-M-k` | `C-M-k` | Sexp | +{.shortcuts .show-header} +#### Killing +|------------|--------------------------------------| +| `C-W` | Kill region C-w | +| `M-w` | Copy region to kill ring | +| `M-z` char | Kill through next occurrence of char | +| `C-y` | Yank back last thing killed | +| `M-y` | Replace last yank with previous kill | +{.shortcuts} + + + + + +### Getting Help +|---------|------------------------------------------| +| `C-x 1` | Remove help window | +| `C-M-v` | Scroll help window | +| `C-h a` | Apropos: show commands matching a string | +| `C-h k` | Describe the function a key runs | +| `C-h f` | Describe a function | +| `C-h m` | Get mode-specific information | +{.shortcuts} + +The help system is simple. Type `C-h` (or `F1`) and follow the directions. If you are a first-time user, type `C-h t` for a tutorial. + + + + +### Multiple Windows {.col-span-2} +When two commands are shown, the second is a similar command for a frame instead of a window. +|-------------|-------------|-------------------------------------| +| `C-x 5 1` | `C-x 1` | Delete all other windows | +| `C-x 5 2` | `C-x 2` | Split window, above and below | +| `C-x 5 0` | `C-x 0` | Delete this window | + +| `C-x 3` || Split window, side by side | +| `C-M-v` || Scroll other window | + +| `C-x 5 o` | `C-x o` | Switch cursor to another window | +| `C-x 5 b` | `C-x 4 b` | Select buffer in other window | +| `C-x 5 C-o` | `C-x 4 C-o` | Display buffer in other window | +| `C-x 5 f` | `C-x 4 f` | Find file in other window | +| `C-x 5 r` | `C-x 4 r` | Find file read-only in other window | +| `C-x 5 d` | `C-x 4 d` | Run Dired in other window | +| `C-x 5 .` | `C-x 4 .` | Find tag in other window | + +| `C-x ^` || Grow window taller | +| `C-x {` || Shrink window narrower | +| `C-x }` || Grow window wider | +{.shortcuts} + + + + +### Formatting +|-----------|------------------------------------------| +| `TAB` | Indent current line (mode-dependent) | +| `C-M-\` | Indent region (mode-dependent) | +| `C-M-q` | Indent sexp (mode-dependent) | +| `C-x TAB` | Indent region rigidly arg columns | +| `M-;` | Indent for comment | +| `C-o` | Insert newline after point | +| `C-M-o` | Move rest of line vertically down | +| `C-x C-o` | Delete blank lines around point | +| `M-^` | Join line with previous (with arg, next) | +| `M-\` | Delete all white space around point | +| `M-SPC` | Put exactly one space at point | +| `M-q` | Fill paragraph | +| `C-x f` | Set fill column to arg | +| `C-x .` | Set prefix each line starts with | +| `M-o` | Set face | +{.shortcuts} + + + + +### Info {.row-span-2} +|---------|---------------------------------------------| +| `C-h i` | Enter the Info documentation reader | +| `C-h S` | Find specified function or variable in Info | +{.shortcuts} + +#### Moving within a node +|---------|---------------------------------------------| +| `SPC` | Scroll forward | +| `DEL` | Scroll reverse | +| `b` | Beginning of node | +{.shortcuts} + +#### Moving between nodes +|---------|---------------------------------------------| +| `n` | Next node | +| `p` | Previous node | +| `u` | Move up | +| `m` | Select menu item by name | +| `n` | Select nth menu item by number (1–9) | +| `f` | Follow cross reference (return with l) | +| `l` | Return to last node you saw | +| `d` | Return to directory node | +| `t` | Go to top node of Info file | +| `g` | Go to any node by name | +{.shortcuts} + +#### Other +|---------|---------------------------------------------| +| `h` | Run Info tutorial | +| `i` | Look up a subject in the indices | +| `s` | Search nodes for regexp | +| `q` | Quit Info | +{.shortcuts} + + + + +### Minibuffer +The following keys are defined in the minibuffer. +|-------|-----------------------------------------| +| `TAB` | Complete as much as possible | +| `SPC` | Complete up to one word | +| `RET` | Complete and execute | +| `?` | Show possible completions | +| `M-p` | Fetch previous minibuffer input | +| `M-n` | Fetch later minibuffer input or default | +| `M-r` | Regexp search backward through history | +| `M-s` | Regexp search forward through history | +| `C-g` | Abort command | +{.shortcuts} + +Type `C-x ESC ESC` to edit and repeat the last command that used the minibuffer. Type `F10` to activate menu bar items on text terminals. + + + + + +### Tags +|--------------------------|--------------------------------------------| +| `M-.` | Find a tag (a definition) | +| `C-u M-.` | Find next occurrence of tag | +| `M-x` visit-tags-table | Specify a new tags file | +| `M-x` tags-search | Regexp search on all files in tags table | +| `M-x` tags-query-replace | Run query-replace on all the files | +| `M-,` | Continue last tags search or query-replace | +{.shortcuts} + + + +### Rectangles +|-----------|-------------------------------------| +| `C-x r r` | Copy rectangle to register | +| `C-x r k` | Kill rectangle | +| `C-x r y` | Yank rectangle | +| `C-x r o` | Open rectangle, shifting text right | +| `C-x r c` | Blank out rectangle | +| `C-x r t` | Prefix each line with a string | +{.shortcuts} + + + +### Keyboard Macros +|---------------------------|-------------------------------------| +| `C-x (` | Start defining a keyboard macro | +| `C-x )` | End keyboard macro definition | +| `C-x e` | Execute last-defined keyboard macro | +| `C-u C-x (` | Append to last keyboard macro | +| `M-x` name-last-kbd-macro | Name last keyboard macro | +| `M-x` insert-kbd-macro | Insert Lisp definition in buffer | +{.shortcuts} + + + + +### Buffers +|-----------|-----------------------| +| `C-x b` | Select another buffer | +| `C-x C-b` | List all buffers | +| `C-x k` | Kill a buffer | +{.shortcuts} + + + +Search{.cols-3} +------ + + + +### Regex (common) {.row-span-2} +|-------------------|----------------------------------------------| +| `. (dot)` | Any single character except a newline | +| `*` | Zero or more repeats | +| `+` | One or more repeats | +| `?` | Zero or one repeat | +| `\` | Quote special characters | +| `\c` | Quote regular expression special character c | +| `\|` | Alternative (“or”) | +| `\(...\)` | Grouping | +| `\(:?...\)` | Shy grouping | +| `\(:NUM...\)` | Explicit numbered grouping | +| `\n` | Same text as nth group | +| `\b` | At word break | +| `\B` | Not at word break | + +### Regex (entry) +| Start | End | Entity | +|-------------|-----------|--------| +| `^` | `$` | Line | +| `\<` | `\>` | Word | +| `\_<` | `\_>` | Symbol | +| `\‘` | `\’` | Buffer | +{.show-header} + +### Regex (conflict) + +| These | Others | class | +|-------------|--------------|---------------------------| +| `[...]` | `[^...]` | Explicit set | +| `\w` | `\W` | Word-syntax character | +| `\sc` | `\Sc` | Character with syntax c | +| `\cc` | `\Cc` | Character with category c | +{.show-header} + + +### Incremental Search +|---------|-----------------------------------| +| `C-s` | Search forward | +| `C-r` | Search backward | +| `C-M-s` | Regular expression search | +| `C-M-r` | Reverse regular expression search | +| `M-p` | Select previous search string | +| `M-n` | Select next later search string | +| `RET` | Exit incremental search | +| `DEL` | Undo effect of last character | +| `C-g` | Abort current search | +{.shortcuts} + +Use `C-s` or `C-r` again to repeat the search in either direction. If Emacs is still searching, `C-g` cancels only the part not matched. + + + + +### Query Replace +|----------------------------|--------------------------------------| +| `M-%` | Interactively replace a text string | +| `M-x` regexp | Using regular expressions | +| `SPC` / `y` | Replace this one, go on to next | +| `,` | Replace this one, don’t move | +| `DEL` / `n` | Skip to next without replacing | +| `!` | Replace all remaining matches | +| `^` | Back up to the previous match | +| `RET` | Exit query-replace | +| `C-r` | Enter recursive edit (C-M-c to exit) | +{.shortcuts} + + + +Misc {.cols-3} +---- + + +### Shells +|-------------|----------------------------------------| +| `M-!` | Execute a shell command | +| `M-&` | Execute a shell command asynchronously | +| `M-` | Run a shell command on the region | +| `C-u M-` | Filter region through a shell command | +| `M-x` shell | Start a shell in window **shell** | +{.shortcuts} + + + +### International Character Sets {.col-span-2} +|----------------------------|------------------------------------| +| `C-x RET l` | specify principal language | +| `M-x` list-input-methods | show all input methods | +| `C-\` | enable or disable input method | +| `C-x RET c` | set coding system for next command | +| `M-x` list-coding-systems | show all coding systems | +| `M-x` prefer-coding-system | choose preferred coding system | +{.shortcuts} + + +### Registers +|-------------|--------------------------------------| +| `C-x r s` | Save region in register | +| `C-x r i` | Insert register contents into buffer | +| `C-x r SPC` | Save value of point in register | +| `C-x r j` | Jump to point saved in register | +{.shortcuts} + + + + +### Miscellaneous +|------------|-------------------| +| `C-u` num | Numeric argument | +| `M--` | Negative argument | +| `C-q` char | Quoted insert | +{.shortcuts} + + + +### Commands Dealing with Emacs Lisp +|--------------------|------------------------------------| +| `C-x C-e` | Eval sexp before point | +| `C-M-x` | Eval current defun | +| `M-x` eval-region | Eval region | +| `M-:` | Read and eval minibuffer | +| `M-x` load-library | Load a Lisp library from load-path | +{.shortcuts} + + + + +### Simple Customization +|-----------------|-------------------------------| +| `M-x customize` | customize variables and faces | + +Making global key bindings in Emacs Lisp: + +``` {.wrap} +(global-set-key (kbd "C-c g") ’search-forward) +(global-set-key (kbd "M-#") ’query-replace-regexp) +``` + + + + +### Abbrevs +|-------------|------------------------------------------| +| `C-x a g` | Add global abbrev | +| `C-x a l` | Add mode-local abbrev | +| `C-x a i g` | Add global expansion for this abbrev | +| `C-x a i l` | Add mode-local expansion for this abbrev | +| `C-x a e` | Explicitly expand abbrev | +| `M-/` | Expand previous word dynamically | +{.shortcuts} + + + + +### Spelling Check +|---------------------|---------------------------------------| +| `M-$` | Check spelling of current word | +| `M-x` ispell-region | Check spelling of all words in region | +| `M-x` ispell-buffer | Check spelling of entire buffer | +| `M-x` flyspell-mode | Toggle on-the-fly spell checking | +{.shortcuts} + + + + +### Writing Commands {.col-span-2} + +#### Syntax +``` +(defun command-name (args) +"documentation" (interactive "template") +body) +``` + +#### Example +``` +(defun this-line-to-top-of-window (line) + "Reposition current line to top of window. +With prefix argument LINE, put point on LINE." + (interactive "P") + (recenter (if (null line) + 0 + (prefix-numeric-value line)))) +``` + + + + + +The interactive spec says how to read arguments interactively. Type `C-h f` interactive `RET` for more details. + + + diff --git a/emmet.md b/emmet.md new file mode 100644 index 0000000..50493b7 --- /dev/null +++ b/emmet.md @@ -0,0 +1,291 @@ +--- +title: Emmet +date: 2020-12-14 18:28:43 +icon: icon-emmet +background: bg-green-400 +tags: + - snippets + - coding + - html + - css + - abbr +categories: + - Toolkit +intro: Emmet is a web-developer’s toolkit for boosting HTML & CSS code writing, which allows you to write large HTML code blocks at speed of light using well-known CSS selectors. +--- + + +Syntax {.cols-3} +--------------- + + +### Getting started + +Let us start to improve your development to the speed of light. + +- [Emmet in Visual Studio Code](https://code.visualstudio.com/docs/editor/emmet) _(code.visualstudio.com)_ +- [Emmet 2 for Sublime Text](https://github.com/emmetio/sublime-text-plugin) _(github.com)_ +- [Emmet for Coda](https://emmet.io/download/coda/) _(emmet.io)_ +- [Emmet for Atom](https://github.com/emmetio/emmet-atom#readme) _(github.com)_ + + +### Multiplication: * + +ul>li*5 + +```html +
    +
  • +
  • +
  • +
  • +
  • +
+``` + + + +### Child: > +`nav>ul>li` + +```html + +``` + + +### Custom attributes {.col-span-2} + +p[title="Hello world"] + +```html +

+``` + +td[rowspan=2 colspan=3 title] + +```html + +``` + +[a='value1' b="value2"] + +```html +
+``` + + + + + +### Text: {} + +a{Click me} + +```html +Click me +``` + +p>{Click }+a{here}+{ to continue} + +```html {.wrap} +

Click here to continue

+``` + + +### ID and CLASS attributes {.row-span-2} + +`#header` + +```html + +``` + +.title + +```html +
+``` + + +form#search.wide + +```html + +``` + +p.class1.class2.class3 + +```html +

+``` + + +### Implicit tag names {.row-span-2} +.class + +```html +
+``` + +em>.class + +```html + +``` + + +ul>.class +```html +
    +
  • +
+``` + + +table>.row>.col + +```html + + + + +
+``` + + +### Sibling: + + +div+p+bq + +```html +
+

+
+``` + + +### Climb-up: ^ + +div+div>p>span+em^bq + + +```html +
+
+

+
+
+``` + + +div+div>p>span+em^^bq + +```html +
+
+

+
+
+``` + + +### Grouping: () + +div>(header>ul>li*2>a)+footer>p + +```html +
+
+
    +
  • +
  • +
+
+
+

+
+
+``` + +(div>dl>(dt+dd)*3)+footer>p +```html +
+
+
+
+
+
+
+
+
+
+
+

+
+``` + + +### Item numbering: $ {.row-span-2} + +ul>li.item$*5 + +```html +
    +
  • +
  • +
  • +
  • +
  • +
+``` + +h$[title=item$]{Header $}*3 + +```html +

Header 1

+

Header 2

+

Header 3

+``` + +ul>li.item$$$*5 + +```html +
    +
  • +
  • +
  • +
  • +
  • +
+``` + +ul>li.item$@-*5 +```html +
    +
  • +
  • +
  • +
  • +
  • +
+``` + +ul>li.item$@3*5 +```html +
    +
  • +
  • +
  • +
  • +
  • +
+``` + +Also see {.cols-1} +-------- + +* [Emmet Cheat sheet](https://docs.emmet.io/cheat-sheet/) _(docs.emmet.io)_ diff --git a/emoji.md b/emoji.md new file mode 100644 index 0000000..fa5a051 --- /dev/null +++ b/emoji.md @@ -0,0 +1,892 @@ +--- +title: Emoji +date: 2020-12-15 18:28:43 +icon: icon-emoji +background: bg-yellow-400 +tags: +categories: + - Other +intro: Some of the emoji codes are not super easy to remember, so here is a little cheat sheet. +--- + +Get Started {.cols-3} +---------- + +### People +|-----|-----| +| :smile: | `:smile:` | +| :laughing: | `:laughing:` | +| :blush: | `:blush:` | +| :smiley: | `:smiley:` | +| :relaxed: | `:relaxed:` | +| :smirk: | `:smirk:` | +| :heart_eyes: | `:heart_eyes:` | +| :kissing_heart: | `:kissing_heart:` | +| :kissing_closed_eyes: | `:kissing_closed_eyes:` | +| :flushed: | `:flushed:` | +| :relieved: | `:relieved:` | +| :satisfied: | `:satisfied:` | +| :grin: | `:grin:` | +| :wink: | `:wink:` | +| :stuck_out_tongue_winking_eye: | `:stuck_out_tongue_winking_eye:` | +| :stuck_out_tongue_closed_eyes: | `:stuck_out_tongue_closed_eyes:` | +| :grinning: | `:grinning:` | +| :kissing: | `:kissing:` | +| :kissing_smiling_eyes: | `:kissing_smiling_eyes:` | +| :stuck_out_tongue: | `:stuck_out_tongue:` | +| :sleeping: | `:sleeping:` | +| :worried: | `:worried:` | +| :frowning: | `:frowning:` | +| :anguished: | `:anguished:` | +| :open_mouth: | `:open_mouth:` | +| :grimacing: | `:grimacing:` | +| :confused: | `:confused:` | +| :hushed: | `:hushed:` | +| :expressionless: | `:expressionless:` | +| :unamused: | `:unamused:` | +| :sweat_smile: | `:sweat_smile:` | +| :sweat: | `:sweat:` | +| :disappointed_relieved: | `:disappointed_relieved:` | +| :weary: | `:weary:` | +| :pensive: | `:pensive:` | +| :disappointed: | `:disappointed:` | +| :confounded: | `:confounded:` | +| :fearful: | `:fearful:` | +| :cold_sweat: | `:cold_sweat:` | +| :persevere: | `:persevere:` | +| :cry: | `:cry:` | +| :sob: | `:sob:` | +| :joy: | `:joy:` | +| :astonished: | `:astonished:` | +| :scream: | `:scream:` | +| :tired_face: | `:tired_face:` | +| :angry: | `:angry:` | +| :rage: | `:rage:` | +| :triumph: | `:triumph:` | +| :sleepy: | `:sleepy:` | +| :yum: | `:yum:` | +| :mask: | `:mask:` | +| :sunglasses: | `:sunglasses:` | +| :dizzy_face: | `:dizzy_face:` | +| :imp: | `:imp:` | +| :smiling_imp: | `:smiling_imp:` | +| :neutral_face: | `:neutral_face:` | +| :no_mouth: | `:no_mouth:` | +| :innocent: | `:innocent:` | +| :alien: | `:alien:` | +| :yellow_heart: | `:yellow_heart:` | +| :blue_heart: | `:blue_heart:` | +| :purple_heart: | `:purple_heart:` | +| :heart: | `:heart:` | +| :green_heart: | `:green_heart:` | +| :broken_heart: | `:broken_heart:` | +| :heartbeat: | `:heartbeat:` | +| :heartpulse: | `:heartpulse:` | +| :two_hearts: | `:two_hearts:` | +| :revolving_hearts: | `:revolving_hearts:` | +| :cupid: | `:cupid:` | +| :sparkling_heart: | `:sparkling_heart:` | +| :sparkles: | `:sparkles:` | +| :star: | `:star:` | +| :star2: | `:star2:` | +| :dizzy: | `:dizzy:` | +| :boom: | `:boom:` | +| :collision: | `:collision:` | +| :anger: | `:anger:` | +| :exclamation: | `:exclamation:` | +| :question: | `:question:` | +| :grey_exclamation: | `:grey_exclamation:` | +| :grey_question: | `:grey_question:` | +| :zzz: | `:zzz:` | +| :dash: | `:dash:` | +| :sweat_drops: | `:sweat_drops:` | +| :notes: | `:notes:` | +| :musical_note: | `:musical_note:` | +| :fire: | `:fire:` | +| :hankey: | `:hankey:` | +| :poop: | `:poop:` | +| :shit: | `:shit:` | +| :+1: | `:+1:` | +| :thumbsup: | `:thumbsup:` | +| :-1: | `:-1:` | +| :thumbsdown: | `:thumbsdown:` | +| :ok_hand: | `:ok_hand:` | +| :punch: | `:punch:` | +| :facepunch: | `:facepunch:` | +| :fist: | `:fist:` | +| :v: | `:v:` | +| :wave: | `:wave:` | +| :hand: | `:hand:` | +| :raised_hand: | `:raised_hand:` | +| :open_hands: | `:open_hands:` | +| :point_up: | `:point_up:` | +| :point_down: | `:point_down:` | +| :point_left: | `:point_left:` | +| :point_right: | `:point_right:` | +| :raised_hands: | `:raised_hands:` | +| :pray: | `:pray:` | +| :point_up_2: | `:point_up_2:` | +| :clap: | `:clap:` | +| :muscle: | `:muscle:` | +| :metal: | `:metal:` | +| :fu: | `:fu:` | +| :runner: | `:runner:` | +| :running: | `:running:` | +| :couple: | `:couple:` | +| :family: | `:family:` | +| :two_men_holding_hands: | `:two_men_holding_hands:` | +| :two_women_holding_hands: | `:two_women_holding_hands:` | +| :dancer: | `:dancer:` | +| :dancers: | `:dancers:` | +| :ok_woman: | `:ok_woman:` | +| :no_good: | `:no_good:` | +| :information_desk_person: | `:information_desk_person:` | +| :raising_hand: | `:raising_hand:` | +| :bride_with_veil: | `:bride_with_veil:` | +| :bow: | `:bow:` | +| :couplekiss: | `:couplekiss:` | +| :couple_with_heart: | `:couple_with_heart:` | +| :massage: | `:massage:` | +| :haircut: | `:haircut:` | +| :nail_care: | `:nail_care:` | +| :boy: | `:boy:` | +| :girl: | `:girl:` | +| :woman: | `:woman:` | +| :man: | `:man:` | +| :baby: | `:baby:` | +| :older_woman: | `:older_woman:` | +| :older_man: | `:older_man:` | +| :man_with_gua_pi_mao: | `:man_with_gua_pi_mao:` | +| :man_with_turban: | `:man_with_turban:` | +| :construction_worker: | `:construction_worker:` | +| :cop: | `:cop:` | +| :angel: | `:angel:` | +| :princess: | `:princess:` | +| :smiley_cat: | `:smiley_cat:` | +| :smile_cat: | `:smile_cat:` | +| :heart_eyes_cat: | `:heart_eyes_cat:` | +| :kissing_cat: | `:kissing_cat:` | +| :smirk_cat: | `:smirk_cat:` | +| :scream_cat: | `:scream_cat:` | +| :crying_cat_face: | `:crying_cat_face:` | +| :joy_cat: | `:joy_cat:` | +| :pouting_cat: | `:pouting_cat:` | +| :japanese_ogre: | `:japanese_ogre:` | +| :japanese_goblin: | `:japanese_goblin:` | +| :see_no_evil: | `:see_no_evil:` | +| :hear_no_evil: | `:hear_no_evil:` | +| :speak_no_evil: | `:speak_no_evil:` | +| :guardsman: | `:guardsman:` | +| :skull: | `:skull:` | +| :feet: | `:feet:` | +| :lips: | `:lips:` | +| :kiss: | `:kiss:` | +| :droplet: | `:droplet:` | +| :ear: | `:ear:` | +| :eyes: | `:eyes:` | +| :nose: | `:nose:` | +| :tongue: | `:tongue:` | +| :love_letter: | `:love_letter:` | +| :bust_in_silhouette: | `:bust_in_silhouette:` | +| :busts_in_silhouette: | `:busts_in_silhouette:` | +| :speech_balloon: | `:speech_balloon:` | +| :thought_balloon: | `:thought_balloon:` | +{.plus-first .shortcuts-right} + + + + +### Symbols +|-----|-----| +| :one: | `:one:` | +| :two: | `:two:` | +| :three: | `:three:` | +| :four: | `:four:` | +| :five: | `:five:` | +| :six: | `:six:` | +| :seven: | `:seven:` | +| :eight: | `:eight:` | +| :nine: | `:nine:` | +| :keycap_ten: | `:keycap_ten:` | +| :1234: | `:1234:` | +| :zero: | `:zero:` | +| :hash: | `:hash:` | +| :symbols: | `:symbols:` | +| :arrow_backward: | `:arrow_backward:` | +| :arrow_down: | `:arrow_down:` | +| :arrow_forward: | `:arrow_forward:` | +| :arrow_left: | `:arrow_left:` | +| :capital_abcd: | `:capital_abcd:` | +| :abcd: | `:abcd:` | +| :abc: | `:abc:` | +| :arrow_lower_left: | `:arrow_lower_left:` | +| :arrow_lower_right: | `:arrow_lower_right:` | +| :arrow_right: | `:arrow_right:` | +| :arrow_up: | `:arrow_up:` | +| :arrow_upper_left: | `:arrow_upper_left:` | +| :arrow_upper_right: | `:arrow_upper_right:` | +| :arrow_double_down: | `:arrow_double_down:` | +| :arrow_double_up: | `:arrow_double_up:` | +| :arrow_down_small: | `:arrow_down_small:` | +| :arrow_heading_down: | `:arrow_heading_down:` | +| :arrow_heading_up: | `:arrow_heading_up:` | +| :leftwards_arrow_with_hook: | `:leftwards_arrow_with_hook:` | +| :arrow_right_hook: | `:arrow_right_hook:` | +| :left_right_arrow: | `:left_right_arrow:` | +| :arrow_up_down: | `:arrow_up_down:` | +| :arrow_up_small: | `:arrow_up_small:` | +| :arrows_clockwise: | `:arrows_clockwise:` | +| :arrows_counterclockwise: | `:arrows_counterclockwise:` | +| :rewind: | `:rewind:` | +| :fast_forward: | `:fast_forward:` | +| :information_source: | `:information_source:` | +| :ok: | `:ok:` | +| :twisted_rightwards_arrows: | `:twisted_rightwards_arrows:` | +| :repeat: | `:repeat:` | +| :repeat_one: | `:repeat_one:` | +| :new: | `:new:` | +| :top: | `:top:` | +| :up: | `:up:` | +| :cool: | `:cool:` | +| :free: | `:free:` | +| :ng: | `:ng:` | +| :cinema: | `:cinema:` | +| :koko: | `:koko:` | +| :signal_strength: | `:signal_strength:` | +| :u6e80: | `:u6e80:` | +| :sa: | `:sa:` | +| :restroom: | `:restroom:` | +| :mens: | `:mens:` | +| :womens: | `:womens:` | +| :baby_symbol: | `:baby_symbol:` | +| :no_smoking: | `:no_smoking:` | +| :parking: | `:parking:` | +| :wheelchair: | `:wheelchair:` | +| :metro: | `:metro:` | +| :baggage_claim: | `:baggage_claim:` | +| :accept: | `:accept:` | +| :wc: | `:wc:` | +| :potable_water: | `:potable_water:` | +| :put_litter_in_its_place: | `:put_litter_in_its_place:` | +| :secret: | `:secret:` | +| :congratulations: | `:congratulations:` | +| :m: | `:m:` | +| :passport_control: | `:passport_control:` | +| :left_luggage: | `:left_luggage:` | +| :customs: | `:customs:` | +| :ideograph_advantage: | `:ideograph_advantage:` | +| :cl: | `:cl:` | +| :sos: | `:sos:` | +| :id: | `:id:` | +| :no_entry_sign: | `:no_entry_sign:` | +| :underage: | `:underage:` | +| :no_mobile_phones: | `:no_mobile_phones:` | +| :do_not_litter: | `:do_not_litter:` | +| :non-potable_water: | `:non-potable_water:` | +| :no_bicycles: | `:no_bicycles:` | +| :no_pedestrians: | `:no_pedestrians:` | +| :children_crossing: | `:children_crossing:` | +| :no_entry: | `:no_entry:` | +| :eight_spoked_asterisk: | `:eight_spoked_asterisk:` | +| :sparkle: | `:sparkle:` | +| :eight_pointed_black_star: | `:eight_pointed_black_star:` | +| :heart_decoration: | `:heart_decoration:` | +| :vs: | `:vs:` | +| :vibration_mode: | `:vibration_mode:` | +| :mobile_phone_off: | `:mobile_phone_off:` | +| :chart: | `:chart:` | +| :currency_exchange: | `:currency_exchange:` | +| :aries: | `:aries:` | +| :taurus: | `:taurus:` | +| :gemini: | `:gemini:` | +| :cancer: | `:cancer:` | +| :leo: | `:leo:` | +| :virgo: | `:virgo:` | +| :libra: | `:libra:` | +| :scorpius: | `:scorpius:` | +| :sagittarius: | `:sagittarius:` | +| :capricorn: | `:capricorn:` | +| :aquarius: | `:aquarius:` | +| :pisces: | `:pisces:` | +| :ophiuchus: | `:ophiuchus:` | +| :six_pointed_star: | `:six_pointed_star:` | +| :negative_squared_cross_mark: | `:negative_squared_cross_mark:` | +| :a: | `:a:` | +| :b: | `:b:` | +| :ab: | `:ab:` | +| :o2: | `:o2:` | +| :diamond_shape_with_a_dot_inside: | `:diamond_shape_with_a_dot_inside:` | +| :recycle: | `:recycle:` | +| :end: | `:end:` | +| :back: | `:back:` | +| :on: | `:on:` | +| :soon: | `:soon:` | +| :clock1: | `:clock1:` | +| :clock130: | `:clock130:` | +| :clock10: | `:clock10:` | +| :clock1030: | `:clock1030:` | +| :clock11: | `:clock11:` | +| :clock1130: | `:clock1130:` | +| :clock12: | `:clock12:` | +| :clock1230: | `:clock1230:` | +| :clock2: | `:clock2:` | +| :clock230: | `:clock230:` | +| :clock3: | `:clock3:` | +| :clock330: | `:clock330:` | +| :clock4: | `:clock4:` | +| :clock430: | `:clock430:` | +| :clock5: | `:clock5:` | +| :clock530: | `:clock530:` | +| :clock6: | `:clock6:` | +| :clock630: | `:clock630:` | +| :clock7: | `:clock7:` | +| :clock730: | `:clock730:` | +| :clock8: | `:clock8:` | +| :clock830: | `:clock830:` | +| :clock9: | `:clock9:` | +| :clock930: | `:clock930:` | +| :heavy_dollar_sign: | `:heavy_dollar_sign:` | +| :copyright: | `:copyright:` | +| :registered: | `:registered:` | +| :tm: | `:tm:` | +| :x: | `:x:` | +| :heavy_exclamation_mark: | `:heavy_exclamation_mark:` | +| :bangbang: | `:bangbang:` | +| :interrobang: | `:interrobang:` | +| :o: | `:o:` | +| :heavy_multiplication_x: | `:heavy_multiplication_x:` | +| :heavy_plus_sign: | `:heavy_plus_sign:` | +| :heavy_minus_sign: | `:heavy_minus_sign:` | +| :heavy_division_sign: | `:heavy_division_sign:` | +| :white_flower: | `:white_flower:` | +| :100: | `:100:` | +| :heavy_check_mark: | `:heavy_check_mark:` | +| :ballot_box_with_check: | `:ballot_box_with_check:` | +| :radio_button: | `:radio_button:` | +| :link: | `:link:` | +| :curly_loop: | `:curly_loop:` | +| :wavy_dash: | `:wavy_dash:` | +| :part_alternation_mark: | `:part_alternation_mark:` | +| :trident: | `:trident:` | +| :black_small_square: | `:black_small_square:` | +| :white_small_square: | `:white_small_square:` | +| :black_medium_small_square: | `:black_medium_small_square:` | +| :white_medium_small_square: | `:white_medium_small_square:` | +| :black_medium_square: | `:black_medium_square:` | +| :white_medium_square: | `:white_medium_square:` | +| :black_large_square: | `:black_large_square:` | +| :white_large_square: | `:white_large_square:` | +| :white_check_mark: | `:white_check_mark:` | +| :black_square_button: | `:black_square_button:` | +| :white_square_button: | `:white_square_button:` | +| :black_circle: | `:black_circle:` | +| :white_circle: | `:white_circle:` | +| :red_circle: | `:red_circle:` | +| :large_blue_circle: | `:large_blue_circle:` | +| :large_blue_diamond: | `:large_blue_diamond:` | +| :large_orange_diamond: | `:large_orange_diamond:` | +| :small_blue_diamond: | `:small_blue_diamond:` | +| :small_orange_diamond: | `:small_orange_diamond:` | +| :small_red_triangle: | `:small_red_triangle:` | +| :small_red_triangle_down: | `:small_red_triangle_down:` | +{.plus-first} + + + +### Objects {.row-span-2} +|-----|-----| +| :bamboo: | `:bamboo:` | +| :gift_heart: | `:gift_heart:` | +| :dolls: | `:dolls:` | +| :school_satchel: | `:school_satchel:` | +| :mortar_board: | `:mortar_board:` | +| :flags: | `:flags:` | +| :fireworks: | `:fireworks:` | +| :sparkler: | `:sparkler:` | +| :wind_chime: | `:wind_chime:` | +| :rice_scene: | `:rice_scene:` | +| :jack_o_lantern: | `:jack_o_lantern:` | +| :ghost: | `:ghost:` | +| :santa: | `:santa:` | +| :christmas_tree: | `:christmas_tree:` | +| :gift: | `:gift:` | +| :bell: | `:bell:` | +| :no_bell: | `:no_bell:` | +| :tanabata_tree: | `:tanabata_tree:` | +| :tada: | `:tada:` | +| :confetti_ball: | `:confetti_ball:` | +| :balloon: | `:balloon:` | +| :crystal_ball: | `:crystal_ball:` | +| :cd: | `:cd:` | +| :dvd: | `:dvd:` | +| :floppy_disk: | `:floppy_disk:` | +| :camera: | `:camera:` | +| :video_camera: | `:video_camera:` | +| :movie_camera: | `:movie_camera:` | +| :computer: | `:computer:` | +| :tv: | `:tv:` | +| :iphone: | `:iphone:` | +| :phone: | `:phone:` | +| :telephone: | `:telephone:` | +| :telephone_receiver: | `:telephone_receiver:` | +| :pager: | `:pager:` | +| :fax: | `:fax:` | +| :minidisc: | `:minidisc:` | +| :vhs: | `:vhs:` | +| :sound: | `:sound:` | +| :speaker: | `:speaker:` | +| :mute: | `:mute:` | +| :loudspeaker: | `:loudspeaker:` | +| :mega: | `:mega:` | +| :hourglass: | `:hourglass:` | +| :hourglass_flowing_sand: | `:hourglass_flowing_sand:` | +| :alarm_clock: | `:alarm_clock:` | +| :watch: | `:watch:` | +| :radio: | `:radio:` | +| :satellite: | `:satellite:` | +| :loop: | `:loop:` | +| :mag: | `:mag:` | +| :mag_right: | `:mag_right:` | +| :unlock: | `:unlock:` | +| :lock: | `:lock:` | +| :lock_with_ink_pen: | `:lock_with_ink_pen:` | +| :closed_lock_with_key: | `:closed_lock_with_key:` | +| :key: | `:key:` | +| :bulb: | `:bulb:` | +| :flashlight: | `:flashlight:` | +| :high_brightness: | `:high_brightness:` | +| :low_brightness: | `:low_brightness:` | +| :electric_plug: | `:electric_plug:` | +| :battery: | `:battery:` | +| :calling: | `:calling:` | +| :email: | `:email:` | +| :mailbox: | `:mailbox:` | +| :postbox: | `:postbox:` | +| :bath: | `:bath:` | +| :bathtub: | `:bathtub:` | +| :shower: | `:shower:` | +| :toilet: | `:toilet:` | +| :wrench: | `:wrench:` | +| :nut_and_bolt: | `:nut_and_bolt:` | +| :hammer: | `:hammer:` | +| :seat: | `:seat:` | +| :moneybag: | `:moneybag:` | +| :yen: | `:yen:` | +| :dollar: | `:dollar:` | +| :pound: | `:pound:` | +| :euro: | `:euro:` | +| :credit_card: | `:credit_card:` | +| :money_with_wings: | `:money_with_wings:` | +| :e-mail: | `:e-mail:` | +| :inbox_tray: | `:inbox_tray:` | +| :outbox_tray: | `:outbox_tray:` | +| :envelope: | `:envelope:` | +| :incoming_envelope: | `:incoming_envelope:` | +| :postal_horn: | `:postal_horn:` | +| :mailbox_closed: | `:mailbox_closed:` | +| :mailbox_with_mail: | `:mailbox_with_mail:` | +| :mailbox_with_no_mail: | `:mailbox_with_no_mail:` | +| :package: | `:package:` | +| :door: | `:door:` | +| :smoking: | `:smoking:` | +| :bomb: | `:bomb:` | +| :gun: | `:gun:` | +| :hocho: | `:hocho:` | +| :pill: | `:pill:` | +| :syringe: | `:syringe:` | +| :page_facing_up: | `:page_facing_up:` | +| :page_with_curl: | `:page_with_curl:` | +| :bookmark_tabs: | `:bookmark_tabs:` | +| :bar_chart: | `:bar_chart:` | +| :chart_with_upwards_trend: | `:chart_with_upwards_trend:` | +| :chart_with_downwards_trend: | `:chart_with_downwards_trend:` | +| :scroll: | `:scroll:` | +| :clipboard: | `:clipboard:` | +| :calendar: | `:calendar:` | +| :date: | `:date:` | +| :card_index: | `:card_index:` | +| :file_folder: | `:file_folder:` | +| :open_file_folder: | `:open_file_folder:` | +| :scissors: | `:scissors:` | +| :pushpin: | `:pushpin:` | +| :paperclip: | `:paperclip:` | +| :black_nib: | `:black_nib:` | +| :pencil2: | `:pencil2:` | +| :straight_ruler: | `:straight_ruler:` | +| :triangular_ruler: | `:triangular_ruler:` | +| :closed_book: | `:closed_book:` | +| :green_book: | `:green_book:` | +| :blue_book: | `:blue_book:` | +| :orange_book: | `:orange_book:` | +| :notebook: | `:notebook:` | +| :notebook_with_decorative_cover: | `:notebook_with_decorative_cover:` | +| :ledger: | `:ledger:` | +| :books: | `:books:` | +| :bookmark: | `:bookmark:` | +| :name_badge: | `:name_badge:` | +| :microscope: | `:microscope:` | +| :telescope: | `:telescope:` | +| :newspaper: | `:newspaper:` | +| :football: | `:football:` | +| :basketball: | `:basketball:` | +| :soccer: | `:soccer:` | +| :baseball: | `:baseball:` | +| :tennis: | `:tennis:` | +| :8ball: | `:8ball:` | +| :rugby_football: | `:rugby_football:` | +| :bowling: | `:bowling:` | +| :golf: | `:golf:` | +| :mountain_bicyclist: | `:mountain_bicyclist:` | +| :bicyclist: | `:bicyclist:` | +| :horse_racing: | `:horse_racing:` | +| :snowboarder: | `:snowboarder:` | +| :swimmer: | `:swimmer:` | +| :surfer: | `:surfer:` | +| :ski: | `:ski:` | +| :spades: | `:spades:` | +| :hearts: | `:hearts:` | +| :clubs: | `:clubs:` | +| :diamonds: | `:diamonds:` | +| :gem: | `:gem:` | +| :ring: | `:ring:` | +| :trophy: | `:trophy:` | +| :musical_score: | `:musical_score:` | +| :musical_keyboard: | `:musical_keyboard:` | +| :violin: | `:violin:` | +| :space_invader: | `:space_invader:` | +| :video_game: | `:video_game:` | +| :black_joker: | `:black_joker:` | +| :flower_playing_cards: | `:flower_playing_cards:` | +| :game_die: | `:game_die:` | +| :dart: | `:dart:` | +| :mahjong: | `:mahjong:` | +| :clapper: | `:clapper:` | +| :memo: | `:memo:` | +| :pencil: | `:pencil:` | +| :book: | `:book:` | +| :art: | `:art:` | +| :microphone: | `:microphone:` | +| :headphones: | `:headphones:` | +| :trumpet: | `:trumpet:` | +| :saxophone: | `:saxophone:` | +| :guitar: | `:guitar:` | +| :shoe: | `:shoe:` | +| :sandal: | `:sandal:` | +| :high_heel: | `:high_heel:` | +| :lipstick: | `:lipstick:` | +| :boot: | `:boot:` | +| :shirt: | `:shirt:` | +| :tshirt: | `:tshirt:` | +| :necktie: | `:necktie:` | +| :womans_clothes: | `:womans_clothes:` | +| :dress: | `:dress:` | +| :running_shirt_with_sash: | `:running_shirt_with_sash:` | +| :jeans: | `:jeans:` | +| :kimono: | `:kimono:` | +| :bikini: | `:bikini:` | +| :ribbon: | `:ribbon:` | +| :tophat: | `:tophat:` | +| :crown: | `:crown:` | +| :womans_hat: | `:womans_hat:` | +| :mans_shoe: | `:mans_shoe:` | +| :closed_umbrella: | `:closed_umbrella:` | +| :briefcase: | `:briefcase:` | +| :handbag: | `:handbag:` | +| :pouch: | `:pouch:` | +| :purse: | `:purse:` | +| :eyeglasses: | `:eyeglasses:` | +| :fishing_pole_and_fish: | `:fishing_pole_and_fish:` | +| :coffee: | `:coffee:` | +| :tea: | `:tea:` | +| :sake: | `:sake:` | +| :baby_bottle: | `:baby_bottle:` | +| :beer: | `:beer:` | +| :beers: | `:beers:` | +| :cocktail: | `:cocktail:` | +| :tropical_drink: | `:tropical_drink:` | +| :wine_glass: | `:wine_glass:` | +| :fork_and_knife: | `:fork_and_knife:` | +| :pizza: | `:pizza:` | +| :hamburger: | `:hamburger:` | +| :fries: | `:fries:` | +| :poultry_leg: | `:poultry_leg:` | +| :meat_on_bone: | `:meat_on_bone:` | +| :spaghetti: | `:spaghetti:` | +| :curry: | `:curry:` | +| :fried_shrimp: | `:fried_shrimp:` | +| :bento: | `:bento:` | +| :sushi: | `:sushi:` | +| :fish_cake: | `:fish_cake:` | +| :rice_ball: | `:rice_ball:` | +| :rice_cracker: | `:rice_cracker:` | +| :rice: | `:rice:` | +| :ramen: | `:ramen:` | +| :stew: | `:stew:` | +| :oden: | `:oden:` | +| :dango: | `:dango:` | +| :egg: | `:egg:` | +| :bread: | `:bread:` | +| :doughnut: | `:doughnut:` | +| :custard: | `:custard:` | +| :icecream: | `:icecream:` | +| :ice_cream: | `:ice_cream:` | +| :shaved_ice: | `:shaved_ice:` | +| :birthday: | `:birthday:` | +| :cake: | `:cake:` | +| :cookie: | `:cookie:` | +| :chocolate_bar: | `:chocolate_bar:` | +| :candy: | `:candy:` | +| :lollipop: | `:lollipop:` | +| :honey_pot: | `:honey_pot:` | +| :apple: | `:apple:` | +| :green_apple: | `:green_apple:` | +| :tangerine: | `:tangerine:` | +| :lemon: | `:lemon:` | +| :cherries: | `:cherries:` | +| :grapes: | `:grapes:` | +| :watermelon: | `:watermelon:` | +| :strawberry: | `:strawberry:` | +| :peach: | `:peach:` | +| :melon: | `:melon:` | +| :banana: | `:banana:` | +| :pear: | `:pear:` | +| :pineapple: | `:pineapple:` | +| :sweet_potato: | `:sweet_potato:` | +| :eggplant: | `:eggplant:` | +| :tomato: | `:tomato:` | +| :corn: | `:corn:` | +{.plus-first} + + + +### Places +|-----|-----| +| :house: | `:house:` | +| :house_with_garden: | `:house_with_garden:` | +| :school: | `:school:` | +| :office: | `:office:` | +| :post_office: | `:post_office:` | +| :hospital: | `:hospital:` | +| :bank: | `:bank:` | +| :convenience_store: | `:convenience_store:` | +| :love_hotel: | `:love_hotel:` | +| :hotel: | `:hotel:` | +| :wedding: | `:wedding:` | +| :church: | `:church:` | +| :department_store: | `:department_store:` | +| :european_post_office: | `:european_post_office:` | +| :city_sunrise: | `:city_sunrise:` | +| :city_sunset: | `:city_sunset:` | +| :japanese_castle: | `:japanese_castle:` | +| :european_castle: | `:european_castle:` | +| :tent: | `:tent:` | +| :factory: | `:factory:` | +| :tokyo_tower: | `:tokyo_tower:` | +| :japan: | `:japan:` | +| :mount_fuji: | `:mount_fuji:` | +| :sunrise_over_mountains: | `:sunrise_over_mountains:` | +| :sunrise: | `:sunrise:` | +| :stars: | `:stars:` | +| :statue_of_liberty: | `:statue_of_liberty:` | +| :bridge_at_night: | `:bridge_at_night:` | +| :carousel_horse: | `:carousel_horse:` | +| :rainbow: | `:rainbow:` | +| :ferris_wheel: | `:ferris_wheel:` | +| :fountain: | `:fountain:` | +| :roller_coaster: | `:roller_coaster:` | +| :ship: | `:ship:` | +| :speedboat: | `:speedboat:` | +| :boat: | `:boat:` | +| :sailboat: | `:sailboat:` | +| :rowboat: | `:rowboat:` | +| :anchor: | `:anchor:` | +| :rocket: | `:rocket:` | +| :airplane: | `:airplane:` | +| :helicopter: | `:helicopter:` | +| :steam_locomotive: | `:steam_locomotive:` | +| :tram: | `:tram:` | +| :mountain_railway: | `:mountain_railway:` | +| :bike: | `:bike:` | +| :aerial_tramway: | `:aerial_tramway:` | +| :suspension_railway: | `:suspension_railway:` | +| :mountain_cableway: | `:mountain_cableway:` | +| :tractor: | `:tractor:` | +| :blue_car: | `:blue_car:` | +| :oncoming_automobile: | `:oncoming_automobile:` | +| :car: | `:car:` | +| :red_car: | `:red_car:` | +| :taxi: | `:taxi:` | +| :oncoming_taxi: | `:oncoming_taxi:` | +| :articulated_lorry: | `:articulated_lorry:` | +| :bus: | `:bus:` | +| :oncoming_bus: | `:oncoming_bus:` | +| :rotating_light: | `:rotating_light:` | +| :police_car: | `:police_car:` | +| :oncoming_police_car: | `:oncoming_police_car:` | +| :fire_engine: | `:fire_engine:` | +| :ambulance: | `:ambulance:` | +| :minibus: | `:minibus:` | +| :truck: | `:truck:` | +| :train: | `:train:` | +| :station: | `:station:` | +| :train2: | `:train2:` | +| :bullettrain_front: | `:bullettrain_front:` | +| :bullettrain_side: | `:bullettrain_side:` | +| :light_rail: | `:light_rail:` | +| :monorail: | `:monorail:` | +| :railway_car: | `:railway_car:` | +| :trolleybus: | `:trolleybus:` | +| :ticket: | `:ticket:` | +| :fuelpump: | `:fuelpump:` | +| :vertical_traffic_light: | `:vertical_traffic_light:` | +| :traffic_light: | `:traffic_light:` | +| :warning: | `:warning:` | +| :construction: | `:construction:` | +| :beginner: | `:beginner:` | +| :atm: | `:atm:` | +| :slot_machine: | `:slot_machine:` | +| :busstop: | `:busstop:` | +| :barber: | `:barber:` | +| :hotsprings: | `:hotsprings:` | +| :checkered_flag: | `:checkered_flag:` | +| :crossed_flags: | `:crossed_flags:` | +| :izakaya_lantern: | `:izakaya_lantern:` | +| :moyai: | `:moyai:` | +| :circus_tent: | `:circus_tent:` | +| :performing_arts: | `:performing_arts:` | +| :round_pushpin: | `:round_pushpin:` | +| :triangular_flag_on_post: | `:triangular_flag_on_post:` | +| :jp: | `:jp:` | +| :kr: | `:kr:` | +| :cn: | `:cn:` | +| :us: | `:us:` | +| :fr: | `:fr:` | +| :es: | `:es:` | +| :it: | `:it:` | +| :ru: | `:ru:` | +| :gb: | `:gb:` | +| :uk: | `:uk:` | +| :de: | `:de:` | +{.plus-first} + + + + + +### Nature +|-----|-----| +| :sunny: | `:sunny:` | +| :umbrella: | `:umbrella:` | +| :cloud: | `:cloud:` | +| :snowflake: | `:snowflake:` | +| :snowman: | `:snowman:` | +| :zap: | `:zap:` | +| :cyclone: | `:cyclone:` | +| :foggy: | `:foggy:` | +| :ocean: | `:ocean:` | +| :cat: | `:cat:` | +| :dog: | `:dog:` | +| :mouse: | `:mouse:` | +| :hamster: | `:hamster:` | +| :rabbit: | `:rabbit:` | +| :wolf: | `:wolf:` | +| :frog: | `:frog:` | +| :tiger: | `:tiger:` | +| :koala: | `:koala:` | +| :bear: | `:bear:` | +| :pig: | `:pig:` | +| :pig_nose: | `:pig_nose:` | +| :cow: | `:cow:` | +| :boar: | `:boar:` | +| :monkey_face: | `:monkey_face:` | +| :monkey: | `:monkey:` | +| :horse: | `:horse:` | +| :racehorse: | `:racehorse:` | +| :camel: | `:camel:` | +| :sheep: | `:sheep:` | +| :elephant: | `:elephant:` | +| :panda_face: | `:panda_face:` | +| :snake: | `:snake:` | +| :bird: | `:bird:` | +| :baby_chick: | `:baby_chick:` | +| :hatched_chick: | `:hatched_chick:` | +| :hatching_chick: | `:hatching_chick:` | +| :chicken: | `:chicken:` | +| :penguin: | `:penguin:` | +| :turtle: | `:turtle:` | +| :bug: | `:bug:` | +| :honeybee: | `:honeybee:` | +| :ant: | `:ant:` | +| :beetle: | `:beetle:` | +| :snail: | `:snail:` | +| :octopus: | `:octopus:` | +| :tropical_fish: | `:tropical_fish:` | +| :fish: | `:fish:` | +| :whale: | `:whale:` | +| :whale2: | `:whale2:` | +| :dolphin: | `:dolphin:` | +| :cow2: | `:cow2:` | +| :ram: | `:ram:` | +| :rat: | `:rat:` | +| :water_buffalo: | `:water_buffalo:` | +| :tiger2: | `:tiger2:` | +| :rabbit2: | `:rabbit2:` | +| :dragon: | `:dragon:` | +| :goat: | `:goat:` | +| :rooster: | `:rooster:` | +| :dog2: | `:dog2:` | +| :pig2: | `:pig2:` | +| :mouse2: | `:mouse2:` | +| :ox: | `:ox:` | +| :dragon_face: | `:dragon_face:` | +| :blowfish: | `:blowfish:` | +| :crocodile: | `:crocodile:` | +| :dromedary_camel: | `:dromedary_camel:` | +| :leopard: | `:leopard:` | +| :cat2: | `:cat2:` | +| :poodle: | `:poodle:` | +| :paw_prints: | `:paw_prints:` | +| :bouquet: | `:bouquet:` | +| :cherry_blossom: | `:cherry_blossom:` | +| :tulip: | `:tulip:` | +| :four_leaf_clover: | `:four_leaf_clover:` | +| :rose: | `:rose:` | +| :sunflower: | `:sunflower:` | +| :hibiscus: | `:hibiscus:` | +| :maple_leaf: | `:maple_leaf:` | +| :leaves: | `:leaves:` | +| :fallen_leaf: | `:fallen_leaf:` | +| :herb: | `:herb:` | +| :mushroom: | `:mushroom:` | +| :cactus: | `:cactus:` | +| :palm_tree: | `:palm_tree:` | +| :evergreen_tree: | `:evergreen_tree:` | +| :deciduous_tree: | `:deciduous_tree:` | +| :chestnut: | `:chestnut:` | +| :seedling: | `:seedling:` | +| :blossom: | `:blossom:` | +| :ear_of_rice: | `:ear_of_rice:` | +| :shell: | `:shell:` | +| :globe_with_meridians: | `:globe_with_meridians:` | +| :sun_with_face: | `:sun_with_face:` | +| :full_moon_with_face: | `:full_moon_with_face:` | +| :new_moon_with_face: | `:new_moon_with_face:` | +| :new_moon: | `:new_moon:` | +| :waxing_crescent_moon: | `:waxing_crescent_moon:` | +| :first_quarter_moon: | `:first_quarter_moon:` | +| :waxing_gibbous_moon: | `:waxing_gibbous_moon:` | +| :full_moon: | `:full_moon:` | +| :waning_gibbous_moon: | `:waning_gibbous_moon:` | +| :last_quarter_moon: | `:last_quarter_moon:` | +| :waning_crescent_moon: | `:waning_crescent_moon:` | +| :last_quarter_moon_with_face: | `:last_quarter_moon_with_face:` | +| :first_quarter_moon_with_face: | `:first_quarter_moon_with_face:` | +| :crescent_moon: | `:crescent_moon:` | +| :earth_africa: | `:earth_africa:` | +| :earth_americas: | `:earth_americas:` | +| :earth_asia: | `:earth_asia:` | +| :volcano: | `:volcano:` | +| :milky_way: | `:milky_way:` | +| :partly_sunny: | `:partly_sunny:` | +{.plus-first} + diff --git a/git.md b/git.md new file mode 100644 index 0000000..c4cde5a --- /dev/null +++ b/git.md @@ -0,0 +1,292 @@ +--- +title: Git +date: 2020-11-25 18:28:43 +icon: icon-git +background: bg-gray-400 +tags: + - github + - gitlab + - command +categories: + - Toolkit +intro: This cheat sheet summarizes commonly used Git command line instructions for quick reference. +--- + +Getting Started {.cols-3} +--------------- + +### Create a Repository + +From scratch -- Create a new local repository +``` +git init [project name] +``` + +Download from an existing repository +``` +git clone my_url +``` + + + + +### Make a change {.row-span-2} +Show modified files in working directory, staged for your next commit +``` +git status +``` + +Stages the file, ready for commit +``` +git add [file] +``` + +Stage all changed files, ready for commit +``` +git add . +``` + +Commit all staged files to versioned history +``` +git commit -m "commit message" +``` + +Commit all your tracked files to versioned history +``` +git commit -am "commit message" +``` + +Unstages file, keeping the file changes +``` +git reset [file] +``` + +Revert everything to the last commit +``` +git reset --hard +``` + +Diff of what is changed but not staged +``` +git diff +``` + +Diff of what is staged but not yet commited +``` +git diff --staged +``` + +Apply any commits of current branch ahead of specified one +``` +git rebase [branch] +``` + + +### Configuration + +Set the name that will be attached to your commits and tags +``` +git config --global user.name "name" +``` + +Set an email address that will be attached to your commits and tags +``` +git config --global user.email "email" +``` + +Enable some colorization of Git output +``` +git config --global color.ui auto +``` + +Edit the global configuration file in a text editor +``` +git config --global --edit +``` + + + +### Working with Branches + +List all local branches +``` +git branch +``` + +List all branches, local and remote +``` +git branch -av +``` + +Switch to a branch, my_branch, and update working directory +``` +git checkout my_branch +``` + +Create a new branch called new_branch +``` +git branch new_branch +``` + +Delete the branch called my_branch +``` +git branch -d my_branch +``` + +Merge branchA into branchB +``` +git checkout branchB +git merge branchA +``` + +Tag the current commit +``` +git tag my_tag +``` + + +### Observe your Repository +Show the commit history for the currently active branch +``` +git log +``` +Show the commits on branchA that are not on branchB +``` +git log branchB..branchA +``` +Show the commits that changed file, even across renames +``` +git log --follow [file] +``` +Show the diff of what is in branchA that is not in branchB +``` +git diff branchB...branchA +``` +Show any object in Git in human-readable format +``` +git show [SHA] +``` + + + +### Synchronize + +Fetch down all the branches from that Git remote +``` +git fetch [alias] +``` + +Merge a remote branch into your current branch to bring it up to date +``` +git merge [alias]/[branch] +``` + +Transmit local branch commits to the remote repository branch +``` +git push [alias] [branch] +``` + +Fetch and merge any commits from the tracking remote branch +``` +git pull +``` + +Merge just one specific commit from another branch to your current branch +``` +git cherry-pick [commit_id] +``` + + + + +### Remote +Add a git URL as an alias +``` +git remote add [alias] [url] +``` + +Show the names of the remote repositories you've set up +``` +git remote +``` + +Show the names and URLs of the remote repositories +``` +git remote -v +``` + +Remove a remote repository +``` +git remote rm [remote repo name] +``` + +Change the URL of the git repo +``` +git remote set-url origin [git_url] +``` + + + + + + +### Temporary Commits + +Save modified and staged changes +``` +git stash +``` + +List stack-order of stashed file changes +``` +git stash list +``` + +Write working from top of stash stack +``` +git stash pop +``` + +Discard the changes from top of stash stack +``` +git stash drop +``` + + + + +### Tracking path Changes +Delete the file from project and stage the removal for commit +``` +git rm [file] +``` + +Change an existing file path and stage the move +``` +git mv [existing-path] [new-path] +``` + +Show all commit logs with indication of any paths that moved +``` +git log --stat -M +``` + + +### Ignoring Files + +``` +/logs/* + +!logs/.gitkeep + +/# Ignore Mac system files +.DS_store + +# Ignore node_modules folder +node_modules + +# Ignore SASS config files +.sass-cache +``` +A `.gitignore` file specifies intentionally untracked files that Git should ignore + diff --git a/go.md b/go.md new file mode 100644 index 0000000..def08fb --- /dev/null +++ b/go.md @@ -0,0 +1,775 @@ +--- +title: Go +date: 2020-12-17 21:51:44 +icon: icon-golang +background: bg-blue-400 +tags: + - Golang +categories: + - Go +intro: +--- + + +Getting started {.cols-3} +-------- + +### Introduction + +- [A tour of Go](https://tour.golang.org/welcome/1) _(tour.golang.org)_ +- [Go repl](https://repl.it/languages/go) _(repl.it)_ +- [Golang wiki](https://github.com/golang/go/wiki/) _(github.com)_ + +### Hello world {.row-span-2} + + +#### hello.go {.file} + +```go +package main + +import "fmt" + +func main() { + message := greetMe("world") + fmt.Println(message) +} + +func greetMe(name string) string { + return "Hello, " + name + "!" +} +``` + +```bash +$ go build +``` + +Or try it out in the [Go repl](https://repl.it/languages/go), or [A Tour of Go](https://tour.golang.org/welcome/1). + +### Variables + +#### Variable declaration + +```go +var msg string +msg = "Hello" +``` + +#### Shortcut of above (Infers type) + +```go +msg := "Hello" +``` + +### Constants +Constants can be character, string, boolean, or numeric values. + +```go +const Phi = 1.618 +``` + +See: [Constants](https://tour.golang.org/basics/15) + +Basic types {.cols-3} +-------- + +### Strings + +```go +str := "Hello" + +str := `Multiline +string` +``` + +#### Operators +```go +// Outputs: 11 +fmt.Println(len("Hello World")) + +// Outputs: Hello +fmt.Println(string("Hello World"[0:5])) + +// Outputs: Hello World +fmt.Println("Hello " + "World") +``` + +Strings are of type `string`. + +### Numbers + + +#### Typical types + +```go +num := 3 // int +num := 3. // float64 +num := 3 + 4i // complex128 +num := byte('a') // byte (alias: uint8) +``` + +#### Other types + +```go +var u uint = 7 // uint (unsigned) +var p float32 = 22.7 // 32-bit float +``` +#### Operators +```go +// Outputs: 1 + 1 = 2 +fmt.Println("1 + 1 =", 1.0 + 1.0) +``` + +----- +|------|----------------| +| `+` | addition | +| `-` | subtraction | +| `*` | multiplication | +| `/` | division | +| `%` | remainder | + +Slices have a dynamic size, unlike arrays. + + + + + +### Booleans + +```go +isTrue := true +isFalse := false +``` + +#### Operators +```go +// Outputs: true +fmt.Println(true && true) + +// Outputs: false +fmt.Println(true && false) + +// Outputs: true +fmt.Println(true || true) + +// Outputs: true +fmt.Println(true || false) + +// Outputs: false +fmt.Println(!true) +``` + +### Arrays {.row-span-2} + +```go +var a [2]string +a[0] = "Hello" +a[1] = "World" + +// Outputs: Hello World +fmt.Println(a[0], a[1]) + +// Outputs: [Hello World] +fmt.Println(a) + +primes := [6]int{2, 3, 5, 7, 11, 13} + +// Outputs: [2 3 5 7 11 13] +fmt.Println(primes) + +// Same as [:3], Outputs: [2 3 5] +fmt.Println(primes[0:3]) +``` + +Arrays have a fixed size. + + + +### Pointers {.row-span-2} + +```go +func main () { + b := *getPointer() + fmt.Println("Value is", b) +} +``` + + +```go +func getPointer () (myPointer *int) { + a := 234 + return &a +} +``` + + +```go +a := new(int) +*a = 234 +``` + + +Pointers point to a memory location of a variable. Go is fully garbage-collected. +

+See: [Pointers](https://tour.golang.org/moretypes/1) + +### Type conversions + +```go +i := 90 +f := float64(i) +u := uint(i) + +// Will be equal to the character Z +s := string(i) +``` + +#### How to get int string? + +```go +i := 90 + +// need import "strconv" +s := strconv.Itoa(i) +fmt.Println(s) // Outputs: 90 +``` + +See: [Type conversions](https://tour.golang.org/basics/13) + + + +### Slices + +```go +slice := []int{2, 3, 4} +``` + +```go +slice := []byte("Hello") +``` + +Flow control {.cols-3} +-------- + +### Conditional + +```go +if day == "sunday"||day == "saturday" { + rest() +} else if day == "monday" && isTired() { + groan() +} else { + work() +} +``` + + +See: [If](https://tour.golang.org/flowcontrol/5) + +### Statements in if + +```go +if _, err := doThing(); err != nil { + fmt.Println("Uh oh") +} +``` + + +A condition in an `if` statement can be preceded with a statement before a `;`. Variables declared by the statement are only in scope until the end of the `if`. +

+See: [If with a short statement](https://tour.golang.org/flowcontrol/6) + +### Switch + +```go {.wrap} +switch day { + case "sunday": + // cases don't "fall through" by default! + fallthrough + + case "saturday": + rest() + + default: + work() +} +``` + +See: [Switch](https://github.com/golang/go/wiki/Switch) + +### For loop + +```go +for count := 0; count <= 10; count++ { + fmt.Println("My counter is at", count) +} +``` + +See: [For loops](https://tour.golang.org/flowcontrol/1) + +### For-Range loop + +```go {.wrap} +entry := []string{"Jack","John","Jones"} +for i, val := range entry { + fmt.Printf("At position %d, the character %s is present\n", i, val) +} +``` + +See: [For-Range loops](https://gobyexample.com/range) + +### While loop + +```go +n := 0 +x := 42 +for n != x { + n := guess() +} +``` + +See: [Go's "while"](https://tour.golang.org/flowcontrol/3) + +Functions {.cols-3} +-------- + +### Lambdas + +```go +myfunc := func() bool { + return x > 10000 +} +``` + + +Functions are first class objects. + +### Multiple return types + +```go +a, b := getMessage() +``` + +```go +func getMessage() (a string, b string) { + return "Hello", "World" +} +``` + + + +### Named return values + +```go +func split(sum int) (x, y int) { + x = sum * 4 / 9 + y = sum - x + return +} +``` + + +By defining the return value names in the signature, a `return` (no args) will return variables with those names. + +See: [Named return values](https://tour.golang.org/basics/7) + +Packages {.cols-3} +-------- + + +### Packages + +```go +package hello +``` + +Every package file has to start with `package`. + + +### Importing {.row-span-2} + +```go +import "fmt" +import "math/rand" +``` + +```go +import ( + "fmt" // gives fmt.Println + "math/rand" // gives rand.Intn +) +``` + +Both are the same. +
+
+See: [Importing](https://tour.golang.org/basics/1) + + +### Exporting names + +```go +func Hello () { + ··· +} +``` + +Exported names begin with capital letters. +

+See: [Exported names](https://tour.golang.org/basics/3) + + +### Aliases + +```go +import r "math/rand" +``` + + +```go +r.Intn() +``` + + + +Concurrency {.cols-3} +-------- + +### Goroutines + +```go +func main() { + // A "channel" + ch := make(chan string) + + // Start concurrent routines + go push("Moe", ch) + go push("Larry", ch) + go push("Curly", ch) + + // Read 3 results + //(Since our goroutines are concurrent + // the order isn't guaranteed!) + fmt.Println(<-ch, <-ch, <-ch) +} +``` + + +```go +func push(name string, ch chan string) { + msg := "Hey, " + name + ch <- msg +} +``` + + +Channels are concurrency-safe communication objects, used in goroutines. +
+
+See: [Goroutines](https://tour.golang.org/concurrency/1), [Channels](https://tour.golang.org/concurrency/2) + + + + +### WaitGroup + +```go +import "sync" + +func main() { + var wg sync.WaitGroup + + for _, item := range itemList { + // Increment WaitGroup Counter + wg.Add(1) + go doOperation(item) + } + // Wait for goroutines to finish + wg.Wait() + +} +``` + + +```go +func doOperation(item string) { + defer wg.Done() + // do operation on item + // ... +} +``` + + +A WaitGroup waits for a collection of goroutines to finish. The main goroutine calls Add to set the number of goroutines to wait for. The goroutine calls `wg.Done()` when it finishes. +See: [WaitGroup](https://golang.org/pkg/sync/#WaitGroup) + + + + +### Closing channels + +#### Closes a channel + +```go +ch <- 1 +ch <- 2 +ch <- 3 +close(ch) +``` + + +#### Iterates across a channel until its closed + +```go +for i := range ch { + ··· +} +``` + + +#### Closed if `ok == false` + +```go +v, ok := <- ch +``` + +See: [Range and close](https://tour.golang.org/concurrency/4) + + + +### Buffered channels + +```go +ch := make(chan int, 2) +ch <- 1 +ch <- 2 +ch <- 3 +// fatal error: +// all goroutines are asleep - deadlock +``` + +Buffered channels limit the amount of messages it can keep. +
+
+See: [Buffered channels](https://tour.golang.org/concurrency/3) + + + + + +Error control {.cols-2} +-------- + +### Deferring functions {.row-span-2} + +```go +func main() { + defer func() { + fmt.Println("Done") + }() + fmt.Println("Working...") +} +``` + + +Lambdas are better suited for defer blocks. + +```go +func main() { + var d = int64(0) + defer func(d *int64) { + fmt.Printf("& %v Unix Sec\n", *d) + }(&d) + fmt.Print("Done ") + d = time.Now().Unix() +} +``` + +The defer func uses current value of d, unless we use a pointer to get final value at end of main. + + + + +### Defer + +```go +func main() { + defer fmt.Println("Done") + fmt.Println("Working...") +} +``` + + +Defers running a function until the surrounding function returns. +The arguments are evaluated immediately, but the function call is not ran until later. +
+
+See: [Defer, panic and recover](https://blog.golang.org/defer-panic-and-recover) + + + + +Structs {.cols-3} +-------- + +### Defining + +```go +type Vertex struct { + X int + Y int +} +``` + + +```go +func main() { + v := Vertex{1, 2} + v.X = 4 + fmt.Println(v.X, v.Y) +} +``` + +See: [Structs](https://tour.golang.org/moretypes/2) + +### Literals + +```go +v := Vertex{X: 1, Y: 2} +``` + +```go +// Field names can be omitted +v := Vertex{1, 2} +``` + +```go +// Y is implicit +v := Vertex{X: 1} +``` + +You can also put field names. + +### Pointers to structs + +```go +v := &Vertex{1, 2} +v.X = 2 +``` + +Doing `v.X` is the same as doing `(*v).X`, when `v` is a pointer. + +Methods {.cols-2} +-------- + +### Receivers + +```go +type Vertex struct { + X, Y float64 +} +``` + +```go +func (v Vertex) Abs() float64 { + return math.Sqrt(v.X * v.X + v.Y * v.Y) +} +``` + + +```go +v := Vertex{1, 2} +v.Abs() +``` + +There are no classes, but you can define functions with _receivers_. + +See: [Methods](https://tour.golang.org/methods/1) + +### Mutation + +```go +func (v *Vertex) Scale(f float64) { + v.X = v.X * f + v.Y = v.Y * f +} +``` + + +```go +v := Vertex{6, 12} +v.Scale(0.5) +// `v` is updated +``` + +By defining your receiver as a pointer (`*Vertex`), you can do mutations. +
+
+See: [Pointer receivers](https://tour.golang.org/methods/4) + +Interfaces {.cols-2} +-------- + +### A basic interface + +```go +type Shape interface { + Area() float64 + Perimeter() float64 +} +``` + +### Struct + +```go +type Rectangle struct { + Length, Width float64 +} +``` + +Struct `Rectangle` implicitly implements interface `Shape` by implementing all of its methods. + +### Methods + +```go +func (r Rectangle) Area() float64 { + return r.Length * r.Width +} + +func (r Rectangle) Perimeter() float64 { + return 2 * (r.Length + r.Width) +} +``` + +The methods defined in `Shape` are implemented in `Rectangle`. + +### Interface example + +```go +func main() { + var r Shape = Rectangle{Length: 3, Width: 4} + fmt.Printf("Type of r: %T, Area: %v, Perimeter: %v.", r, r.Area(), r.Perimeter()) +} +``` + +References {.cols-2} +-------- + +### Official resources + + +- [A tour of Go](https://tour.golang.org/welcome/1) _(tour.golang.org)_ +- [Golang wiki](https://github.com/golang/go/wiki/) _(github.com)_ +- [Effective Go](https://golang.org/doc/effective_go.html) _(golang.org)_ + +### Other links + + +- [Go by Example](https://gobyexample.com/) _(gobyexample.com)_ +- [Awesome Go](https://awesome-go.com/) _(awesome-go.com)_ +- [JustForFunc Youtube](https://www.youtube.com/channel/UC_BzFbxG2za3bp5NRRRXJSw) _(youtube.com)_ +- [Style Guide](https://github.com/golang/go/wiki/CodeReviewComments) _(github.com)_ + + + + diff --git a/markdown.md b/markdown.md new file mode 100644 index 0000000..53ff419 --- /dev/null +++ b/markdown.md @@ -0,0 +1,199 @@ +--- +title: Markdown +date: 2020-12-14 18:28:43 +icon: icon-markdown +background: bg-purple-500 +tags: + - md + - Markup +categories: + - Toolkit +intro: A quick reference cheatsheet to the Markdown syntax. +--- + +Quick Reference {.cols-3} +--------------- + +### Headers (atx style) + +```markdown +# h1 +## h2 +### h3 +#### h4 +##### h5 +###### h6 +``` + +### Headers (setext style) + +```markdown +Header 1 +======== +``` + +```markdown +Header 2 +-------- +``` + + +### Blockquotes + +```markdown +> This is +> a blockquote +> +> > Nested +> > Blockquote +``` + + +### Unordered List {.row-span-2} + +```markdown +* Item 1 +* Item 2 + * item 3a + * item 3b +``` + +or +```markdown +- Item 1 +- Item 2 +``` + +or + +```markdown ++ Item 1 ++ Item 2 +``` +or + +```markdown +- [ ] Checkbox off +- [x] Checkbox on +``` + +### Ordered List + +```markdown +1. Item 1 +2. Item 2 + a. item 3a + b. item 3b +``` + + +### Emphasis + +```markdown +*italic* +_italic_ +``` + +```markdown +**bold** +__bold__ +``` + +```markdown +`inline code` +~~struck out~~ +``` + +### Links + +```markdown +[link](http://google.com) +``` + +```markdown +[link][google] +[google]: http://google.com +``` + +```markdown + +``` + + +### Horizontal line + +```markdown +---- +``` +or +```markdown +**** +``` + + +### Tables + +```markdown +| Column 1 Heading | Column 2 Heading | +| ---------------- | ---------------- | +| Some content | Other content | +``` + +or +```markdown +Column 1 Heading | Column 2 Heading +--- | --- +Some content | Other content +``` + + +### Images {.col-span-2} + +```markdown +![Alt text](/path/to/img.jpg) +![Alt text](/path/to/img.jpg "title") +![Alt text][img] +``` + +```markdown +[img]: http://foo.com/img.jpg +``` + +### Code + +``` + 4 space indent + makes a code block +``` + +~~~markdown +```p­ython +def print (str) + ­ ­ ­ ­pri­nt(str) +``` +~~~ + + +~~~markdown +```js +codeFences.withLanguage() +``` +~~~ + +### Backslash escapes + +| Characters | Escape | Description | +|------------|--------|-----------------------| +| \\ | \\\\ | backslash | +| \` | \\\` | backtick | +| \* | \\\* | asterisk | +| \_ | \\\_ | underscore | +| \{\} | \\\{\} | curly braces | +| \[\] | \\\[\] | square brackets | +| \(\) | \\\(\) | parentheses | +| \# | \\\# | hash mark | +| \+ | \\\+ | plus sign | +| \- | \\\- | minus sign \(hyphen\) | +| \. | \\\. | dot | +| \! | \\\! | exclamation mark | +{.show-header} \ No newline at end of file diff --git a/mysql.md b/mysql.md new file mode 100644 index 0000000..72dad33 --- /dev/null +++ b/mysql.md @@ -0,0 +1,929 @@ +--- +title: MySQL +date: 2020-12-16 18:28:43 +icon: icon-mysql +background: bg-blue-400 +tags: + - sql +categories: + - Toolkit +intro: The SQL cheat sheet provides you with the most commonly used SQL statements for your reference. +--- + + +Getting started {.cols-2} +--------------- + + +### Connect MySQL +``` +mysql -u -p + +mysql [db_name] + +mysql -h -P -u -p [db_name] + +mysql -h -u -p [db_name] +``` + + + +### Commons {.row-span-2} + +#### Database +|------------------------|-------------------------| +| `create database` db `;` | Create database | +| `show databases;` | List databases | +| `use` db`;` | Switch to db | +| `drop database` db`;` | Delete db | + +#### Table +|------------------------|-------------------------| +| `show tables;` | List tables for current db | +| `show fields from` t`;` | List fields for a table | +| `desc` t`;` | Show table structure | +| `show create table `t`;` | Show create table sql | +| `truncate table `t`;` | Remove all data in a table | +| `drop table `t`;` | Delete table | +#### Proccess +|------------------------|-------------------------| +| `show processlist;` | List processes | +| `kill` pid`;` | kill process | +#### Other +|------------------------|-------------------------| +| `exit` or `\q` | Exit MySQL session | + + + +### Backups + +Create a backup +```sql +mysqldump -u user -p db_name > db.sql +``` + +Export db without schema +``` {.wrap} +mysqldump -u user -p db_name --no-data=true --add-drop-table=false > db.sql +``` + +Restore a backup +``` +mysql -u user -p db_name < db.sql +``` + + + + +Examples {.cols-3} +-------------- + + +### Managing tables +Create a new table with three columns + +```sql +CREATE TABLE t ( + id INT PRIMARY KEY, + name VARCHAR NOT NULL, + price INT DEFAULT 0 +); +``` + +Delete the table from the database +```sql +DROP TABLE t ; +``` + +Add a new column to the table +```sql +ALTER TABLE t ADD column; +``` + +Drop column c from the table +```sql +ALTER TABLE t DROP COLUMN c ; +``` + +Add a constraint +```sql +ALTER TABLE t ADD constraint; +``` + +Drop a constraint +```sql +ALTER TABLE t DROP constraint; +``` + +Rename a table from t1 to t2 +```sql +ALTER TABLE t1 RENAME TO t2; +``` + +Rename column c1 to c2 +```sql +ALTER TABLE t1 RENAME c1 TO c2 ; +``` + +Remove all data in a table +```sql +TRUNCATE TABLE t; +``` + + + +### Querying data from a table +Query data in columns c1, c2 from a table + +```sql +SELECT c1, c2 FROM t +``` + + +Query all rows and columns from a table + +```sql +SELECT * FROM t +``` + + +Query data and filter rows with a condition + +```sql +SELECT c1, c2 FROM t +WHERE condition +``` + + +Query distinct rows from a table + +```sql +SELECT DISTINCT c1 FROM t +WHERE condition +``` + + +Sort the result set in ascending or descending order + +```sql +SELECT c1, c2 FROM t +ORDER BY c1 ASC [DESC] +``` + + +Skip offset of rows and return the next n rows + +```sql +SELECT c1, c2 FROM t +ORDER BY c1 +LIMIT n OFFSET offset +``` + + +Group rows using an aggregate function + +```sql +SELECT c1, aggregate(c2) +FROM t +GROUP BY c1 +``` + + +Filter groups using HAVING clause + +```sql +SELECT c1, aggregate(c2) +FROM t +GROUP BY c1 +HAVING condition +``` + + +### Querying from multiple tables {.row-span-2} +Inner join t1 and t2 + +```sql +SELECT c1, c2 +FROM t1 +INNER JOIN t2 ON condition +``` + + +Left join t1 and t1 + +```sql +SELECT c1, c2 +FROM t1 +LEFT JOIN t2 ON condition +``` + + +Right join t1 and t2 + +```sql +SELECT c1, c2 +FROM t1 +RIGHT JOIN t2 ON condition +``` + + +Perform full outer join + +```sql +SELECT c1, c2 +FROM t1 +FULL OUTER JOIN t2 ON condition +``` + + +Produce a Cartesian product of rows in tables + +```sql +SELECT c1, c2 +FROM t1 +CROSS JOIN t2 +``` + + +Another way to perform cross join + +```sql +SELECT c1, c2 +FROM t1, t2 +``` + + +Join t1 to itself using INNER JOIN clause + +```sql +SELECT c1, c2 +FROM t1 A +INNER JOIN t1 B ON condition +``` + + +Using SQL Operators +Combine rows from two queries + +```sql +SELECT c1, c2 FROM t1 +UNION [ALL] +SELECT c1, c2 FROM t2 +``` + + +Return the intersection of two queries + +```sql +SELECT c1, c2 FROM t1 +INTERSECT +SELECT c1, c2 FROM t2 +``` + + +Subtract a result set from another result set + +```sql +SELECT c1, c2 FROM t1 +MINUS +SELECT c1, c2 FROM t2 +``` + + +Query rows using pattern matching %, _ + +```sql +SELECT c1, c2 FROM t1 +WHERE c1 [NOT] LIKE pattern +``` + + +Query rows in a list + +```sql +SELECT c1, c2 FROM t +WHERE c1 [NOT] IN value_list +``` + + +Query rows between two values + +```sql +SELECT c1, c2 FROM t +WHERE c1 BETWEEN low AND high +``` + + +Check if values in a table is NULL or not + +```sql +SELECT c1, c2 FROM t +WHERE c1 IS [NOT] NULL +``` + + +### Using SQL constraints + + +Set c1 and c2 as a primary key + +```sql +CREATE TABLE t( + c1 INT, c2 INT, c3 VARCHAR, + PRIMARY KEY (c1,c2) +); +``` + + +Set c2 column as a foreign key + +```sql +CREATE TABLE t1( + c1 INT PRIMARY KEY, + c2 INT, + FOREIGN KEY (c2) REFERENCES t2(c2) +); +``` + + +Make the values in c1 and c2 unique + +```sql +CREATE TABLE t( + c1 INT, c1 INT, + UNIQUE(c2,c3) +); +``` + + +Ensure c1 > 0 and values in c1 >= c2 + +```sql +CREATE TABLE t( + c1 INT, c2 INT, + CHECK(c1> 0 AND c1 >= c2) +); +``` + +Set values in c2 column not NULL + +```sql +CREATE TABLE t( + c1 INT PRIMARY KEY, + c2 VARCHAR NOT NULL +); +``` + + +### Modifying Data + + +Insert one row into a table + +```sql +INSERT INTO t(column_list) +VALUES(value_list); +``` + + +Insert multiple rows into a table + +```sql +INSERT INTO t(column_list) +VALUES (value_list), + (value_list), …; +``` + + +Insert rows from t2 into t1 + +```sql +INSERT INTO t1(column_list) +SELECT column_list +FROM t2; +``` + + +Update new value in the column c1 for all rows + +```sql +UPDATE t +SET c1 = new_value; +``` + + +Update values in the column c1, c2 that match the condition + +```sql +UPDATE t +SET c1 = new_value, + c2 = new_value +WHERE condition; +``` + + +Delete all data in a table + +```sql +DELETE FROM t; +``` + + +Delete subset of rows in a table + +```sql +DELETE FROM t +WHERE condition; +``` + + +### Managing Views + + +Create a new view that consists of c1 and c2 + +```sql +CREATE VIEW v(c1,c2) +AS +SELECT c1, c2 +FROM t; +``` + + +Create a new view with check option + +```sql +CREATE VIEW v(c1,c2) +AS +SELECT c1, c2 +FROM t; +WITH [CASCADED | LOCAL] CHECK OPTION; +``` + + +Create a recursive view + +```sql +CREATE RECURSIVE VIEW v +AS +select-statement -- anchor part +UNION [ALL] +select-statement; -- recursive part +``` + + +Create a temporary view + +```sql +CREATE TEMPORARY VIEW v +AS +SELECT c1, c2 +FROM t; +``` + + +Delete a view + +```sql +DROP VIEW view_name; +``` + + +### Managing triggers + + +Create or modify a trigger + +```sql +CREATE OR MODIFY TRIGGER trigger_name +WHEN EVENT +ON table_name TRIGGER_TYPE +EXECUTE stored_procedure; +``` +#### WHEN +|----------|--------------------------------| +| `BEFORE` | invoke before the event occurs | +| `AFTER` | invoke after the event occurs | + +#### EVENT +|----------|-------------------| +| `INSERT` | invoke for INSERT | +| `UPDATE` | invoke for UPDATE | +| `DELETE` | invoke for DELETE | + +#### TRIGGER_TYPE +|----------------------|---| +| `FOR EACH ROW` | | +| `FOR EACH STATEMENT` | | + + + + +### Managing indexes + +Create an index on c1 and c2 of the t table + +```sql +CREATE INDEX idx_name +ON t(c1,c2); +``` + + +Create a unique index on c3, c4 of the t table + +```sql +CREATE UNIQUE INDEX idx_name +ON t(c3,c4) +``` + + +Drop an index + +```sql +DROP INDEX idx_name; +``` + + +Data Types {.cols-3} +--------- + + +### Strings +|---------------|-------------------------------| +| `CHAR` | String (0 - 255) | +| `VARCHAR` | String (0 - 255) | +| `TINYTEXT` | String (0 - 255) | +| `TEXT` | String (0 - 65535) | +| `BLOB` | String (0 - 65535) | +| `MEDIUMTEXT` | String (0 - 16777215) | +| `MEDIUMBLOB` | String (0 - 16777215) | +| `LONGTEXT` | String (0 - 429496­7295) | +| `LONGBLOB` | String (0 - 429496­7295) | +| `ENUM` | One of preset options | +| `SET` | Selection of preset options | + + +### Date & time +| Data Type | Format | +|-------------|---------------------| +| `DATE ` | yyyy-MM-dd | +| `TIME ` | hh:mm:ss | +| `DATETIME ` | yyyy-MM-dd hh:mm:ss | +| `TIMESTAMP` | yyyy-MM-dd hh:mm:ss | +| `YEAR ` | yyyy | + + +### Numeric +|---------------|---------------------------------------------------------------| +| `TINYINT x` | Integer (-128 to 127) | +| `SMALLINT x` | Integer (-32768 to 32767) | +| `MEDIUMINT x` | Integer (-8388608 to 8388607) | +| `INT x` | Integer (-2147­483648 to 214748­3647) | +| `BIGINT x` | Integer (-9223­372­036­854­775808 to 922337­203­685­477­5807) | +| `FLOAT` | Decimal (precise to 23 digits) | +| `DOUBLE` | Decimal (24 to 53 digits) | +| `DECIMAL` | "­DOU­BLE­" stored as string | + + + + +Functions & Operators {.cols-3} +--------- + + +### Strings {.row-span-2} +- [ASCII()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_ascii){data-tooltip="Return numeric value of left-most character"} +- [BIN()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_bin){data-tooltip="Return a string containing binary representation of a number"} +- [BIT_LENGTH()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_bit-length){data-tooltip="Return length of argument in bits"} +- [CHAR()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_char){data-tooltip="Return the character for each integer passed"} +- [CHARACTER_LENGTH()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_character-length){data-tooltip="Synonym for CHAR_LENGTH()"} +- [CHAR_LENGTH()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_char-length){data-tooltip="Return number of characters in argument"} +- [CONCAT()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_concat){data-tooltip="Return concatenated string"} +- [CONCAT_WS()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_concat-ws){data-tooltip="Return concatenate with separator"} +- [ELT()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_elt){data-tooltip="Return string at index number"} +- [EXPORT_SET()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_export-set){data-tooltip="Return a string such that for every bit set in the value bits, you get an on string and for every unset bit, you get an off string"} +- [FIELD()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_field){data-tooltip="Index (position) of first argument in subsequent arguments"} +- [FIND_IN_SET()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_find-in-set){data-tooltip="Index (position) of first argument within second argument"} +- [FORMAT()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_format){data-tooltip="Return a number formatted to specified number of decimal places"} +- [FROM_BASE64()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_from-base64){data-tooltip="Decode base64 encoded string and return result"} +- [HEX()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_hex){data-tooltip="Hexadecimal representation of decimal or string value"} +- [INSERT()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_insert){data-tooltip="Insert substring at specified position up to specified number of characters"} +- [INSTR()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_instr){data-tooltip="Return the index of the first occurrence of substring"} +- [LCASE()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_lcase){data-tooltip="Synonym for LOWER()"} +- [LEFT()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_left){data-tooltip="Return the leftmost number of characters as specified"} +- [LENGTH()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_length){data-tooltip="Return the length of a string in bytes"} +- [LIKE](https://dev.mysql.com/doc/refman/8.0/en/string-comparison-functions.html#operator_like){data-tooltip="Simple pattern matching"} +- [LOAD_FILE()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_load-file){data-tooltip="Load the named file"} +- [LOCATE()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_locate){data-tooltip="Return the position of the first occurrence of substring"} +- [LOWER()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_lower){data-tooltip="Return the argument in lowercase"} +- [LPAD()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_lpad){data-tooltip="Return the string argument, left-padded with the specified string"} +- [LTRIM()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_ltrim){data-tooltip="Remove leading spaces"} +- [MAKE_SET()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_make-set){data-tooltip="Return a set of comma-separated strings that have the corresponding bit in bits set"} +- [MATCH](https://dev.mysql.com/doc/refman/8.0/en/fulltext-search.html#function_match){data-tooltip="Perform full-text search"} +- [MID()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_mid){data-tooltip="Return a substring starting from the specified position"} +- [NOT LIKE](https://dev.mysql.com/doc/refman/8.0/en/string-comparison-functions.html#operator_not-like){data-tooltip="Negation of simple pattern matching"} +- [NOT REGEXP](https://dev.mysql.com/doc/refman/8.0/en/regexp.html#operator_not-regexp){data-tooltip="Negation of REGEXP"} +- [OCT()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_oct){data-tooltip="Return a string containing octal representation of a number"} +- [OCTET_LENGTH()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_octet-length){data-tooltip="Synonym for LENGTH()"} +- [ORD()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_ord){data-tooltip="Return character code for leftmost character of the argument"} +- [POSITION()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_position){data-tooltip="Synonym for LOCATE()"} +- [QUOTE()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_quote){data-tooltip="Escape the argument for use in an SQL statement"} +- [REGEXP](https://dev.mysql.com/doc/refman/8.0/en/regexp.html#operator_regexp){data-tooltip="Whether string matches regular expression"} +- [REGEXP_INSTR()](https://dev.mysql.com/doc/refman/8.0/en/regexp.html#function_regexp-instr){data-tooltip="Starting index of substring matching regular expression"} +- [REGEXP_LIKE()](https://dev.mysql.com/doc/refman/8.0/en/regexp.html#function_regexp-like){data-tooltip="Whether string matches regular expression"} +- [REGEXP_REPLACE()](https://dev.mysql.com/doc/refman/8.0/en/regexp.html#function_regexp-replace){data-tooltip="Replace substrings matching regular expression"} +- [REGEXP_SUBSTR()](https://dev.mysql.com/doc/refman/8.0/en/regexp.html#function_regexp-substr){data-tooltip="Return substring matching regular expression"} +- [REPEAT()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_repeat){data-tooltip="Repeat a string the specified number of times"} +- [REPLACE()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_replace){data-tooltip="Replace occurrences of a specified string"} +- [REVERSE()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_reverse){data-tooltip="Reverse the characters in a string"} +- [RIGHT()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_right){data-tooltip="Return the specified rightmost number of characters"} +- [RLIKE](https://dev.mysql.com/doc/refman/8.0/en/regexp.html#operator_regexp){data-tooltip="Whether string matches regular expression"} +- [RPAD()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_rpad){data-tooltip="Append string the specified number of times"} +- [RTRIM()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_rtrim){data-tooltip="Remove trailing spaces"} +- [SOUNDEX()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_soundex){data-tooltip="Return a soundex string"} +- [SOUNDS LIKE](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#operator_sounds-like){data-tooltip="Compare sounds"} +- [SPACE()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_space){data-tooltip="Return a string of the specified number of spaces"} +- [STRCMP()](https://dev.mysql.com/doc/refman/8.0/en/string-comparison-functions.html#function_strcmp){data-tooltip="Compare two strings"} +- [SUBSTR()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_substr){data-tooltip="Return the substring as specified"} +- [SUBSTRING()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_substring){data-tooltip="Return the substring as specified"} +- [SUBSTRING_INDEX()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_substring-index){data-tooltip="Return a substring from a string before the specified number of occurrences of the delimiter"} +- [TO_BASE64()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_to-base64){data-tooltip="Return the argument converted to a base-64 string"} +- [TRIM()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_trim){data-tooltip="Remove leading and trailing spaces"} +- [UCASE()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_ucase){data-tooltip="Synonym for UPPER()"} +- [UNHEX()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_unhex){data-tooltip="Return a string containing hex representation of a number"} +- [UPPER()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_upper){data-tooltip="Convert to uppercase"} +- [WEIGHT_STRING()](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_weight-string){data-tooltip="Return the weight string for a string"} +{.cols-2} + + + +### Date and Time {.row-span-2} +- [ADDDATE()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_adddate){data-tooltip="Add time values (intervals) to a date value"} +- [ADDTIME()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_addtime){data-tooltip="Add time"} +- [CONVERT_TZ()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_convert-tz){data-tooltip="Convert from one time zone to another"} +- [CURDATE()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_curdate){data-tooltip="Return the current date"} +- [CURRENT_DATE()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_current-date){data-tooltip="Synonyms for CURDATE()"} +- [CURRENT_TIME()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_current-time){data-tooltip="Synonyms for CURTIME()"} +- [CURRENT_TIMESTAMP()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_current-timestamp){data-tooltip="Synonyms for NOW()"} +- [CURTIME()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_curtime){data-tooltip="Return the current time"} +- [DATE()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_date){data-tooltip="Extract the date part of a date or datetime expression"} +- [DATE_ADD()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_date-add){data-tooltip="Add time values (intervals) to a date value"} +- [DATE_FORMAT()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_date-format){data-tooltip="Format date as specified"} +- [DATE_SUB()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_date-sub){data-tooltip="Subtract a time value (interval) from a date"} +- [DATEDIFF()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_datediff){data-tooltip="Subtract two dates"} +- [DAY()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_day){data-tooltip="Synonym for DAYOFMONTH()"} +- [DAYNAME()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_dayname){data-tooltip="Return the name of the weekday"} +- [DAYOFMONTH()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_dayofmonth){data-tooltip="Return the day of the month (0-31)"} +- [DAYOFWEEK()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_dayofweek){data-tooltip="Return the weekday index of the argument"} +- [DAYOFYEAR()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_dayofyear){data-tooltip="Return the day of the year (1-366)"} +- [EXTRACT()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_extract){data-tooltip="Extract part of a date"} +- [FROM_DAYS()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_from-days){data-tooltip="Convert a day number to a date"} +- [FROM_UNIXTIME()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_from-unixtime){data-tooltip="Format Unix timestamp as a date"} +- [GET_FORMAT()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_get-format){data-tooltip="Return a date format string"} +- [HOUR()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_hour){data-tooltip="Extract the hour"} +- [LAST_DAY](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_last-day){data-tooltip="Return the last day of the month for the argument"} +- [LOCALTIME()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_localtime){data-tooltip="Synonym for NOW()"} +- [LOCALTIMESTAMP()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_localtimestamp){data-tooltip="Synonym for NOW()"} +- [MAKEDATE()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_makedate){data-tooltip="Create a date from the year and day of year"} +- [MAKETIME()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_maketime){data-tooltip="Create time from hour, minute, second"} +- [MICROSECOND()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_microsecond){data-tooltip="Return the microseconds from argument"} +- [MINUTE()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_minute){data-tooltip="Return the minute from the argument"} +- [MONTH()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_month){data-tooltip="Return the month from the date passed"} +- [MONTHNAME()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_monthname){data-tooltip="Return the name of the month"} +- [NOW()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_now){data-tooltip="Return the current date and time"} +- [PERIOD_ADD()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_period-add){data-tooltip="Add a period to a year-month"} +- [PERIOD_DIFF()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_period-diff){data-tooltip="Return the number of months between periods"} +- [QUARTER()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_quarter){data-tooltip="Return the quarter from a date argument"} +- [SEC_TO_TIME()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_sec-to-time){data-tooltip="Converts seconds to 'hh:mm:ss' format"} +- [SECOND()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_second){data-tooltip="Return the second (0-59)"} +- [STR_TO_DATE()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_str-to-date){data-tooltip="Convert a string to a date"} +- [SUBDATE()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_subdate){data-tooltip="Synonym for DATE_SUB() when invoked with three arguments"} +- [SUBTIME()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_subtime){data-tooltip="Subtract times"} +- [SYSDATE()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_sysdate){data-tooltip="Return the time at which the function executes"} +- [TIME()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_time){data-tooltip="Extract the time portion of the expression passed"} +- [TIME_FORMAT()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_time-format){data-tooltip="Format as time"} +- [TIME_TO_SEC()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_time-to-sec){data-tooltip="Return the argument converted to seconds"} +- [TIMEDIFF()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_timediff){data-tooltip="Subtract time"} +- [TIMESTAMP()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_timestamp){data-tooltip="With a single argument, this function returns the date or datetime expression; with two arguments, the sum of the arguments"} +- [TIMESTAMPADD()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_timestampadd){data-tooltip="Add an interval to a datetime expression"} +- [TIMESTAMPDIFF()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_timestampdiff){data-tooltip="Subtract an interval from a datetime expression"} +- [TO_DAYS()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_to-days){data-tooltip="Return the date argument converted to days"} +- [TO_SECONDS()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_to-seconds){data-tooltip="Return the date or datetime argument converted to seconds since Year 0"} +- [UNIX_TIMESTAMP()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_unix-timestamp){data-tooltip="Return a Unix timestamp"} +- [UTC_DATE()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_utc-date){data-tooltip="Return the current UTC date"} +- [UTC_TIME()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_utc-time){data-tooltip="Return the current UTC time"} +- [UTC_TIMESTAMP()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_utc-timestamp){data-tooltip="Return the current UTC date and time"} +- [WEEK()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_week){data-tooltip="Return the week number"} +- [WEEKDAY()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_weekday){data-tooltip="Return the weekday index"} +- [WEEKOFYEAR()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_weekofyear){data-tooltip="Return the calendar week of the date (1-53)"} +- [YEAR()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_year){data-tooltip="Return the year"} +- [YEARWEEK()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_yearweek){data-tooltip="Return the year and week"} +- [GET_FORMAT()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_get-format){data-tooltip="'%m.%d.%Y'"} +{.cols-2} + + + + +### Numeric +- [%, MOD](https://dev.mysql.com/doc/refman/8.0/en/arithmetic-functions.html#operator_mod){data-tooltip="Modulo operator"} +- [*](https://dev.mysql.com/doc/refman/8.0/en/arithmetic-functions.html#operator_times){data-tooltip="Multiplication operator"} +- [+](https://dev.mysql.com/doc/refman/8.0/en/arithmetic-functions.html#operator_plus){data-tooltip="Addition operator"} +- [-](https://dev.mysql.com/doc/refman/8.0/en/arithmetic-functions.html#operator_minus){data-tooltip="Minus operator"} +- [-](https://dev.mysql.com/doc/refman/8.0/en/arithmetic-functions.html#operator_unary-minus){data-tooltip="Change the sign of the argument"} +- [/](https://dev.mysql.com/doc/refman/8.0/en/arithmetic-functions.html#operator_divide){data-tooltip="Division operator"} +- [ABS()](https://dev.mysql.com/doc/refman/8.0/en/mathematical-functions.html#function_abs){data-tooltip="Return the absolute value"} +- [ACOS()](https://dev.mysql.com/doc/refman/8.0/en/mathematical-functions.html#function_acos){data-tooltip="Return the arc cosine"} +- [ASIN()](https://dev.mysql.com/doc/refman/8.0/en/mathematical-functions.html#function_asin){data-tooltip="Return the arc sine"} +- [ATAN()](https://dev.mysql.com/doc/refman/8.0/en/mathematical-functions.html#function_atan){data-tooltip="Return the arc tangent"} +- [ATAN2(), ATAN()](https://dev.mysql.com/doc/refman/8.0/en/mathematical-functions.html#function_atan2){data-tooltip="Return the arc tangent of the two arguments"} +- [CEIL()](https://dev.mysql.com/doc/refman/8.0/en/mathematical-functions.html#function_ceil){data-tooltip="Return the smallest integer value not less than the argument"} +- [CEILING()](https://dev.mysql.com/doc/refman/8.0/en/mathematical-functions.html#function_ceiling){data-tooltip="Return the smallest integer value not less than the argument"} +- [CONV()](https://dev.mysql.com/doc/refman/8.0/en/mathematical-functions.html#function_conv){data-tooltip="Convert numbers between different number bases"} +- [COS()](https://dev.mysql.com/doc/refman/8.0/en/mathematical-functions.html#function_cos){data-tooltip="Return the cosine"} +- [COT()](https://dev.mysql.com/doc/refman/8.0/en/mathematical-functions.html#function_cot){data-tooltip="Return the cotangent"} +- [CRC32()](https://dev.mysql.com/doc/refman/8.0/en/mathematical-functions.html#function_crc32){data-tooltip="Compute a cyclic redundancy check value"} +- [DEGREES()](https://dev.mysql.com/doc/refman/8.0/en/mathematical-functions.html#function_degrees){data-tooltip="Convert radians to degrees"} +- [DIV](https://dev.mysql.com/doc/refman/8.0/en/arithmetic-functions.html#operator_div){data-tooltip="Integer division"} +- [EXP()](https://dev.mysql.com/doc/refman/8.0/en/mathematical-functions.html#function_exp){data-tooltip="Raise to the power of"} +- [FLOOR()](https://dev.mysql.com/doc/refman/8.0/en/mathematical-functions.html#function_floor){data-tooltip="Return the largest integer value not greater than the argument"} +- [LN()](https://dev.mysql.com/doc/refman/8.0/en/mathematical-functions.html#function_ln){data-tooltip="Return the natural logarithm of the argument"} +- [LOG()](https://dev.mysql.com/doc/refman/8.0/en/mathematical-functions.html#function_log){data-tooltip="Return the natural logarithm of the first argument"} +- [LOG10()](https://dev.mysql.com/doc/refman/8.0/en/mathematical-functions.html#function_log10){data-tooltip="Return the base-10 logarithm of the argument"} +- [LOG2()](https://dev.mysql.com/doc/refman/8.0/en/mathematical-functions.html#function_log2){data-tooltip="Return the base-2 logarithm of the argument"} +- [MOD()](https://dev.mysql.com/doc/refman/8.0/en/mathematical-functions.html#function_mod){data-tooltip="Return the remainder"} +- [PI()](https://dev.mysql.com/doc/refman/8.0/en/mathematical-functions.html#function_pi){data-tooltip="Return the value of pi"} +- [POW()](https://dev.mysql.com/doc/refman/8.0/en/mathematical-functions.html#function_pow){data-tooltip="Return the argument raised to the specified power"} +- [POWER()](https://dev.mysql.com/doc/refman/8.0/en/mathematical-functions.html#function_power){data-tooltip="Return the argument raised to the specified power"} +- [RADIANS()](https://dev.mysql.com/doc/refman/8.0/en/mathematical-functions.html#function_radians){data-tooltip="Return argument converted to radians"} +- [RAND()](https://dev.mysql.com/doc/refman/8.0/en/mathematical-functions.html#function_rand){data-tooltip="Return a random floating-point value"} +- [ROUND()](https://dev.mysql.com/doc/refman/8.0/en/mathematical-functions.html#function_round){data-tooltip="Round the argument"} +- [SIGN()](https://dev.mysql.com/doc/refman/8.0/en/mathematical-functions.html#function_sign){data-tooltip="Return the sign of the argument"} +- [SIN()](https://dev.mysql.com/doc/refman/8.0/en/mathematical-functions.html#function_sin){data-tooltip="Return the sine of the argument"} +- [SQRT()](https://dev.mysql.com/doc/refman/8.0/en/mathematical-functions.html#function_sqrt){data-tooltip="Return the square root of the argument"} +- [TAN()](https://dev.mysql.com/doc/refman/8.0/en/mathematical-functions.html#function_tan){data-tooltip="Return the tangent of the argument"} +- [TRUNCATE()](https://dev.mysql.com/doc/refman/8.0/en/mathematical-functions.html#function_truncate){data-tooltip="Truncate to specified number of decimal places"} +{.cols-2} + + + +### Aggregate +- [AVG()](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_avg){data-tooltip="Return the average value of the argument"} +- [BIT_AND()](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_bit-and){data-tooltip="Return bitwise AND"} +- [BIT_OR()](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_bit-or){data-tooltip="Return bitwise OR"} +- [BIT_XOR()](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_bit-xor){data-tooltip="Return bitwise XOR"} +- [COUNT()](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_count){data-tooltip="Return a count of the number of rows returned"} +- [COUNT(DISTINCT)](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_count-distinct){data-tooltip="Return the count of a number of different values"} +- [GROUP_CONCAT()](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_group-concat){data-tooltip="Return a concatenated string"} +- [JSON_ARRAYAGG()](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_json-arrayagg){data-tooltip="Return result set as a single JSON array"} +- [JSON_OBJECTAGG()](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_json-objectagg){data-tooltip="Return result set as a single JSON object"} +- [MAX()](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_max){data-tooltip="Return the maximum value"} +- [MIN()](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_min){data-tooltip="Return the minimum value"} +- [STD()](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_std){data-tooltip="Return the population standard deviation"} +- [STDDEV()](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_stddev){data-tooltip="Return the population standard deviation"} +- [STDDEV_POP()](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_stddev-pop){data-tooltip="Return the population standard deviation"} +- [STDDEV_SAMP()](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_stddev-samp){data-tooltip="Return the sample standard deviation"} +- [SUM()](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_sum){data-tooltip="Return the sum"} +- [VAR_POP()](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_var-pop){data-tooltip="Return the population standard variance"} +- [VAR_SAMP()](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_var-samp){data-tooltip="Return the sample variance"} +- [VARIANCE()](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_variance){data-tooltip="Return the population standard variance"} +{.cols-2} + + + + +### JSON {.row-span-4} +- [->](https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html#operator_json-column-path){data-tooltip="Return value from JSON column after evaluating path; equivalent to JSON_EXTRACT()."} +- [->>](https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html#operator_json-inline-path){data-tooltip="Return value from JSON column after evaluating path and unquoting the result; equivalent to JSON_UNQUOTE(JSON_EXTRACT())."} +- [JSON_ARRAY()](https://dev.mysql.com/doc/refman/8.0/en/json-creation-functions.html#function_json-array){data-tooltip="Create JSON array"} +- [JSON_ARRAY_APPEND()](https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-array-append){data-tooltip="Append data to JSON document"} +- [JSON_ARRAY_INSERT()](https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-array-insert){data-tooltip="Insert into JSON array"} +- [JSON_CONTAINS()](https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html#function_json-contains){data-tooltip="Whether JSON document contains specific object at path"} +- [JSON_CONTAINS_PATH()](https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html#function_json-contains-path){data-tooltip="Whether JSON document contains any data at path"} +- [JSON_DEPTH()](https://dev.mysql.com/doc/refman/8.0/en/json-attribute-functions.html#function_json-depth){data-tooltip="Maximum depth of JSON document"} +- [JSON_EXTRACT()](https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html#function_json-extract){data-tooltip="Return data from JSON document"} +- [JSON_INSERT()](https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-insert){data-tooltip="Insert data into JSON document"} +- [JSON_KEYS()](https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html#function_json-keys){data-tooltip="Array of keys from JSON document"} +- [JSON_LENGTH()](https://dev.mysql.com/doc/refman/8.0/en/json-attribute-functions.html#function_json-length){data-tooltip="Number of elements in JSON document"} +- [JSON_MERGE() (deprecated)](https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-merge){data-tooltip="Merge JSON documents, preserving duplicate keys. Deprecated synonym for JSON_MERGE_PRESERVE()"} +- [JSON_MERGE_PATCH()](https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-merge-patch){data-tooltip="Merge JSON documents, replacing values of duplicate keys"} +- [JSON_MERGE_PRESERVE()](https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-merge-preserve){data-tooltip="Merge JSON documents, preserving duplicate keys"} +- [JSON_OBJECT()](https://dev.mysql.com/doc/refman/8.0/en/json-creation-functions.html#function_json-object){data-tooltip="Create JSON object"} +- [JSON_OVERLAPS() (introduced 8.0.17)](https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html#function_json-overlaps){data-tooltip="Compares two JSON documents, returns TRUE (1) if these have any key-value pairs or array elements in common, otherwise FALSE (0)"} +- [JSON_PRETTY()](https://dev.mysql.com/doc/refman/8.0/en/json-utility-functions.html#function_json-pretty){data-tooltip="Print a JSON document in human-readable format"} +- [JSON_QUOTE()](https://dev.mysql.com/doc/refman/8.0/en/json-creation-functions.html#function_json-quote){data-tooltip="Quote JSON document"} +- [JSON_REMOVE()](https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-remove){data-tooltip="Remove data from JSON document"} +- [JSON_REPLACE()](https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-replace){data-tooltip="Replace values in JSON document"} +- [JSON_SCHEMA_VALID() (introduced 8.0.17)](https://dev.mysql.com/doc/refman/8.0/en/json-validation-functions.html#function_json-schema-valid){data-tooltip="Validate JSON document against JSON schema; returns TRUE/1 if document validates against schema, or FALSE/0 if it does not"} +- [JSON_SCHEMA_VALIDATION_REPORT() (introduced 8.0.17)](https://dev.mysql.com/doc/refman/8.0/en/json-validation-functions.html#function_json-schema-validation-report){data-tooltip="Validate JSON document against JSON schema; returns report in JSON format on outcome on validation including success or failure and reasons for failure"} +- [JSON_SEARCH()](https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html#function_json-search){data-tooltip="Path to value within JSON document"} +- [JSON_SET()](https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-set){data-tooltip="Insert data into JSON document"} +- [JSON_STORAGE_FREE()](https://dev.mysql.com/doc/refman/8.0/en/json-utility-functions.html#function_json-storage-free){data-tooltip="Freed space within binary representation of JSON column value following partial update"} +- [JSON_STORAGE_SIZE()](https://dev.mysql.com/doc/refman/8.0/en/json-utility-functions.html#function_json-storage-size){data-tooltip="Space used for storage of binary representation of a JSON document"} +- [JSON_TABLE()](https://dev.mysql.com/doc/refman/8.0/en/json-table-functions.html#function_json-table){data-tooltip="Return data from a JSON expression as a relational table"} +- [JSON_TYPE()](https://dev.mysql.com/doc/refman/8.0/en/json-attribute-functions.html#function_json-type){data-tooltip="Type of JSON value"} +- [JSON_UNQUOTE()](https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-unquote){data-tooltip="Unquote JSON value"} +- [JSON_VALID()](https://dev.mysql.com/doc/refman/8.0/en/json-attribute-functions.html#function_json-valid){data-tooltip="Whether JSON value is valid"} +- [JSON_VALUE() (introduced 8.0.21)](https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html#function_json-value){data-tooltip="Extract value from JSON document at location pointed to by path provided; return this value as VARCHAR(512) or specified type"} +- [MEMBER OF() (introduced 8.0.17)](https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html#operator_member-of){data-tooltip="Returns true (1) if first operand matches any element of JSON array passed as second operand, otherwise returns false (0)"} +{.cols-1} + + +### Cast +- [BINARY](https://dev.mysql.com/doc/refman/8.0/en/cast-functions.html#operator_binary){data-tooltip="Cast a string to a binary string"} +- [CAST()](https://dev.mysql.com/doc/refman/8.0/en/cast-functions.html#function_cast){data-tooltip="Cast a value as a certain type"} +- [CONVERT()](https://dev.mysql.com/doc/refman/8.0/en/cast-functions.html#function_convert){data-tooltip="Cast a value as a certain type"} +{.cols-2} + + +### Flow Control +- [CASE](https://dev.mysql.com/doc/refman/8.0/en/flow-control-functions.html#operator_case){data-tooltip="Case operator"} +- [IF()](https://dev.mysql.com/doc/refman/8.0/en/flow-control-functions.html#function_if){data-tooltip="If/else construct"} +- [IFNULL()](https://dev.mysql.com/doc/refman/8.0/en/flow-control-functions.html#function_ifnull){data-tooltip="Null if/else construct"} +- [NULLIF()](https://dev.mysql.com/doc/refman/8.0/en/flow-control-functions.html#function_nullif){data-tooltip="Return NULL if expr1 = expr2"} +{.cols-2} + + +### Information +- [BENCHMARK()](https://dev.mysql.com/doc/refman/8.0/en/information-functions.html#function_benchmark){data-tooltip="Repeatedly execute an expression"} +- [CHARSET()](https://dev.mysql.com/doc/refman/8.0/en/information-functions.html#function_charset){data-tooltip="Return the character set of the argument"} +- [COERCIBILITY()](https://dev.mysql.com/doc/refman/8.0/en/information-functions.html#function_coercibility){data-tooltip="Return the collation coercibility value of the string argument"} +- [COLLATION()](https://dev.mysql.com/doc/refman/8.0/en/information-functions.html#function_collation){data-tooltip="Return the collation of the string argument"} +- [CONNECTION_ID()](https://dev.mysql.com/doc/refman/8.0/en/information-functions.html#function_connection-id){data-tooltip="Return the connection ID (thread ID) for the connection"} +- [CURRENT_ROLE()](https://dev.mysql.com/doc/refman/8.0/en/information-functions.html#function_current-role){data-tooltip="Return the current active roles"} +- [CURRENT_USER()](https://dev.mysql.com/doc/refman/8.0/en/information-functions.html#function_current-user){data-tooltip="The authenticated user name and host name"} +- [DATABASE()](https://dev.mysql.com/doc/refman/8.0/en/information-functions.html#function_database){data-tooltip="Return the default (current) database name"} +- [FOUND_ROWS()](https://dev.mysql.com/doc/refman/8.0/en/information-functions.html#function_found-rows){data-tooltip="For a SELECT with a LIMIT clause, the number of rows that would be returned were there no LIMIT clause"} +- [ICU_VERSION()](https://dev.mysql.com/doc/refman/8.0/en/information-functions.html#function_icu-version){data-tooltip="ICU library version"} +- [LAST_INSERT_ID()](https://dev.mysql.com/doc/refman/8.0/en/information-functions.html#function_last-insert-id){data-tooltip="Value of the AUTOINCREMENT column for the last INSERT"} +- [ROLES_GRAPHML()](https://dev.mysql.com/doc/refman/8.0/en/information-functions.html#function_roles-graphml){data-tooltip="Return a GraphML document representing memory role subgraphs"} +- [ROW_COUNT()](https://dev.mysql.com/doc/refman/8.0/en/information-functions.html#function_row-count){data-tooltip="The number of rows updated"} +- [SCHEMA()](https://dev.mysql.com/doc/refman/8.0/en/information-functions.html#function_schema){data-tooltip="Synonym for DATABASE()"} +- [SESSION_USER()](https://dev.mysql.com/doc/refman/8.0/en/information-functions.html#function_session-user){data-tooltip="Synonym for USER()"} +- [SYSTEM_USER()](https://dev.mysql.com/doc/refman/8.0/en/information-functions.html#function_system-user){data-tooltip="Synonym for USER()"} +- [USER()](https://dev.mysql.com/doc/refman/8.0/en/information-functions.html#function_user){data-tooltip="The user name and host name provided by the client"} +- [VERSION()](https://dev.mysql.com/doc/refman/8.0/en/information-functions.html#function_version){data-tooltip="Return a string that indicates the MySQL server version"} +{.cols-2} + + +### Encryption and Compression +- [AES_DECRYPT()](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_aes-decrypt){data-tooltip="Decrypt using AES"} +- [AES_ENCRYPT()](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_aes-encrypt){data-tooltip="Encrypt using AES"} +- [COMPRESS()](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_compress){data-tooltip="Return result as a binary string"} +- [MD5()](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_md5){data-tooltip="Calculate MD5 checksum"} +- [RANDOM_BYTES()](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_random-bytes){data-tooltip="Return a random byte vector"} +- [SHA1(), SHA()](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_sha1){data-tooltip="Calculate an SHA-1 160-bit checksum"} +- [SHA2()](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_sha2){data-tooltip="Calculate an SHA-2 checksum"} +- [STATEMENT_DIGEST()](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_statement-digest){data-tooltip="Compute statement digest hash value"} +- [STATEMENT_DIGEST_TEXT()](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_statement-digest-text){data-tooltip="Compute normalized statement digest"} +- [UNCOMPRESS()](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_uncompress){data-tooltip="Uncompress a string compressed"} +- [UNCOMPRESSED_LENGTH()](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_uncompressed-length){data-tooltip="Return the length of a string before compression"} +- [VALIDATE_PASSWORD_STRENGTH()](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_validate-password-strength){data-tooltip="Determine strength of password"} +{.cols-1} + + + +### Locking +- [GET_LOCK()](https://dev.mysql.com/doc/refman/8.0/en/locking-functions.html#function_get-lock){data-tooltip="Get a named lock"} +- [IS_FREE_LOCK()](https://dev.mysql.com/doc/refman/8.0/en/locking-functions.html#function_is-free-lock){data-tooltip="Whether the named lock is free"} +- [IS_USED_LOCK()](https://dev.mysql.com/doc/refman/8.0/en/locking-functions.html#function_is-used-lock){data-tooltip="Whether the named lock is in use; return connection identifier if true"} +- [RELEASE_ALL_LOCKS()](https://dev.mysql.com/doc/refman/8.0/en/locking-functions.html#function_release-all-locks){data-tooltip="Release all current named locks"} +- [RELEASE_LOCK()](https://dev.mysql.com/doc/refman/8.0/en/locking-functions.html#function_release-lock){data-tooltip="Release the named lock"} +{.cols-1} + + + +### Bit +- [&](https://dev.mysql.com/doc/refman/8.0/en/bit-functions.html#operator_bitwise-and){data-tooltip="Bitwise AND"} +- [>>](https://dev.mysql.com/doc/refman/8.0/en/bit-functions.html#operator_right-shift){data-tooltip="Right shift"} +- [<<](https://dev.mysql.com/doc/refman/8.0/en/bit-functions.html#operator_left-shift){data-tooltip="Left shift"} +- [^](https://dev.mysql.com/doc/refman/8.0/en/bit-functions.html#operator_bitwise-xor){data-tooltip="Bitwise XOR"} +- [BIT_COUNT()](https://dev.mysql.com/doc/refman/8.0/en/bit-functions.html#function_bit-count){data-tooltip="Return the number of bits that are set"} +- [|](https://dev.mysql.com/doc/refman/8.0/en/bit-functions.html#operator_bitwise-or){data-tooltip="Bitwise OR"} +- [~](https://dev.mysql.com/doc/refman/8.0/en/bit-functions.html#operator_bitwise-invert){data-tooltip="Bitwise inversion"} +{.cols-2} + + + +### Miscellaneous +- [ANY_VALUE()](https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_any-value){data-tooltip="Suppress ONLY_FULL_GROUP_BY value rejection"} +- [BIN_TO_UUID()](https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_bin-to-uuid){data-tooltip="Convert binary UUID to string"} +- [DEFAULT()](https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_default){data-tooltip="Return the default value for a table column"} +- [GROUPING()](https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_grouping){data-tooltip="Distinguish super-aggregate ROLLUP rows from regular rows"} +- [INET_ATON()](https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_inet-aton){data-tooltip="Return the numeric value of an IP address"} +- [INET_NTOA()](https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_inet-ntoa){data-tooltip="Return the IP address from a numeric value"} +- [INET6_ATON()](https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_inet6-aton){data-tooltip="Return the numeric value of an IPv6 address"} +- [INET6_NTOA()](https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_inet6-ntoa){data-tooltip="Return the IPv6 address from a numeric value"} +- [IS_IPV4()](https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_is-ipv4){data-tooltip="Whether argument is an IPv4 address"} +- [IS_IPV4_COMPAT()](https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_is-ipv4-compat){data-tooltip="Whether argument is an IPv4-compatible address"} +- [IS_IPV4_MAPPED()](https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_is-ipv4-mapped){data-tooltip="Whether argument is an IPv4-mapped address"} +- [IS_IPV6()](https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_is-ipv6){data-tooltip="Whether argument is an IPv6 address"} +- [IS_UUID()](https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_is-uuid){data-tooltip="Whether argument is a valid UUID"} +- [MASTER_POS_WAIT()](https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_master-pos-wait){data-tooltip="Block until the replica has read and applied all updates up to the specified position"} +- [NAME_CONST()](https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_name-const){data-tooltip="Cause the column to have the given name"} +- [SLEEP()](https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_sleep){data-tooltip="Sleep for a number of seconds"} +- [UUID()](https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_uuid){data-tooltip="Return a Universal Unique Identifier (UUID)"} +- [UUID_SHORT()](https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_uuid-short){data-tooltip="Return an integer-valued universal identifier"} +- [UUID_TO_BIN()](https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_uuid-to-bin){data-tooltip="Convert string UUID to binary"} +- [VALUES()](https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_values){data-tooltip="Define the values to be used during an INSERT"} +{.cols-2} + diff --git a/numpy.md b/numpy.md new file mode 100644 index 0000000..e2e7663 --- /dev/null +++ b/numpy.md @@ -0,0 +1,148 @@ +--- +title: Numpy +date: 2020-12-14 18:28:43 +icon: icon-numpy +background: bg-blue-500 +tags: + - scientific + - computing +categories: + - Python +intro: The fundamental package for scientific computing with Python +--- + +Getting started {.cols-2} +--------------- + +### Introduction + +You’ll also need to import numpy to get started: + +```python +import numpy as np +``` + + +### Importing/exporting + +|-----|-----| +| `np.loadtxt('file.txt')` | From a text file | +| `np.genfromtxt('file.csv',delimiter=',')` | From a CSV file | +| `np.savetxt('file.txt',arr,delimiter=' ')` | Writes to a text file | +| `np.savetxt('file.csv',arr,delimiter=',')` | Writes to a CSV file | + + +### Creating Arrays {.row-span-2} + +|-----|-----| +| `np.array([1,2,3])` | One dimensional array | +| `np.array([(1,2,3),(4,5,6)])` | Two dimensional array | +| `np.zeros(3)` | 1D array of length 3 all values 0 | +| `np.ones((3,4))` | 3x4 array with all values 1 | +| `np.eye(5)` | 5x5 array of 0 with 1 on diagonal (Identity matrix) +| `np.linspace(0,100,6)` | Array of 6 evenly divided values from 0 to 100 | +| `np.arange(0,10,3)` | Array of values from 0 to less than 10 with step 3 (eg [0,3,6,9]) +| `np.full((2,3),8)` | 2x3 array with all values 8 | +| `np.random.rand(4,5)` | 4x5 array of random floats between 0–1 | +| `np.random.rand(6,7)*100` | 6x7 array of random floats between 0–100 | +| `np.random.randint(5,size=(2,3))` | 2x3 array with random ints between 0–4 | + + +### Inspecting Properties + +|-----|-----| +| `arr.size` | Returns number of elements in arr | +| `arr.shape` | Returns dimensions of arr (rows,columns) +| `arr.dtype` | Returns type of elements in arr | +| `arr.astype(dtype)` | Convert arr elements to type dtype | +| `arr.tolist()` | Convert arr to a Python list | +| `np.info(np.eye)` | View documentation for np.eye | + + +### Copying/sorting/reshaping + +|-----|-----| +| `np.copy(arr)` | Copies arr to new memory | +| `arr.view(dtype)` | Creates view of arr elements with type dtype | +| `arr.sort()` | Sorts arr | +| `arr.sort(axis=0)` | Sorts specific axis of arr | +| `two_d_arr.flatten()` | Flattens 2D array two_d_arr to 1D | +| `arr.T` | Transposes arr (rows become columns and vice versa) +| `arr.reshape(3,4)` | Reshapes arr to 3 rows, 4 columns without changing data | +| `arr.resize((5,6))` | Changes arr shape to 5x6 and fills new values with 0 | + + +### Adding/removing Elements + +|-----|-----| +| `np.append(arr,values)` | Appends values to end of arr | +| `np.insert(arr,2,values)` | Inserts values into arr before index 2 | +| `np.delete(arr,3,axis=0)` | Deletes row on index 3 of arr | +| `np.delete(arr,4,axis=1)` | Deletes column on index 4 of arr | + + +### Combining/splitting + +|-----|-----| +| `np.concatenate((arr1,arr2),axis=0)` | Adds arr2 as rows to the end of arr1 | +| `np.concatenate((arr1,arr2),axis=1)` | Adds arr2 as columns to end of arr1 | +| `np.split(arr,3)` | Splits arr into 3 sub-arrays | +| `np.hsplit(arr,5)` | Splits arr horizontally on the 5th index | + + +### Indexing/slicing/subsetting + +|-----|-----| +| `arr[5]` | Returns the element at index 5 | +| `arr[2,5]` | Returns the 2D array element on index [2][5] +| `arr[1]=4` | Assigns array element on index 1 the value 4 | +| `arr[1,3]=10` | Assigns array element on index [1][3] the value 10 | +| `arr[0:3]` | Returns the elements at indices 0,1,2 (On a 2D array: returns rows 0,1,2) +| `arr[0:3,4]` | Returns the elements on rows 0,1,2 at column 4 | +| `arr[:2]` | Returns the elements at indices 0,1 (On a 2D array: returns rows 0,1) +| `arr[:,1]` | Returns the elements at index 1 on all rows | +| `arr<5` | Returns an array with boolean values | +| `(arr1<3) & (arr2>5)` | Returns an array with boolean values | +| `~arr` | Inverts a boolean array | +| `arr[arr<5]` | Returns array elements smaller than 5 | + + + +### Vector Math + +|-----|-----| +| `np.add(arr1,arr2)` | Elementwise add arr2 to arr1 | +| `np.subtract(arr1,arr2)` | Elementwise subtract arr2 from arr1 | +| `np.multiply(arr1,arr2)` | Elementwise multiply arr1 by arr2 | +| `np.divide(arr1,arr2)` | Elementwise divide arr1 by arr2 | +| `np.power(arr1,arr2)` | Elementwise raise arr1 raised to the power of arr2 | +| `np.array_equal(arr1,arr2)` | Returns True if the arrays have the same elements and shape | +| `np.sqrt(arr)` | Square root of each element in the array | +| `np.sin(arr)` | Sine of each element in the array | +| `np.log(arr)` | Natural log of each element in the array | +| `np.abs(arr)` | Absolute value of each element in the array | +| `np.ceil(arr)` | Rounds up to the nearest int | +| `np.floor(arr)` | Rounds down to the nearest int | +| `np.round(arr)` | Rounds to the nearest int | + + +### Scalar Math + +|-----|-----| +| `np.add(arr,1)` | Add 1 to each array element | +| `np.subtract(arr,2)` | Subtract 2 from each array element | +| `np.multiply(arr,3)` | Multiply each array element by 3 | +| `np.divide(arr,4)` | Divide each array element by 4 (returns np.nan for division by zero) +| `np.power(arr,5)` | Raise each array element to the 5th power | + + +### Statistics + +|-----|-----| +| `np.mean(arr,axis=0)` | Returns mean along specific axis | +| `arr.sum()` | Returns sum of arr | +| `arr.min()` | Returns minimum value of arr | +| `arr.max(axis=0)` | Returns maximum value of specific axis | +| `np.var(arr)` | Returns the variance of array | +| `np.std(arr,axis=1)` | Returns the standard deviation of specific axis | +| `arr.corrcoef()` | Returns correlation coefficient of array | \ No newline at end of file diff --git a/quickref.md b/quickref.md new file mode 100644 index 0000000..52dc74f --- /dev/null +++ b/quickref.md @@ -0,0 +1,452 @@ +--- +title: QuickRef +date: 2020-11-25 18:28:43 +icon: icon-style +background: bg-green-600 +tags: +categories: + - Other +intro: This is a reference of styles that you can use on quickref cheatsheets! +--- + +Variants {.cols-3} +-------- + +### H2 section +|---------------|---------------------------------| +| `cols-1` | one column _(default)_ | +| `cols-2` | | +| `cols-3` | three column | +| ... | | +| `cols-11` | | +| `cols-12` | | + + + +See: [H2 section](#h2-section-2) + +### H3 section + +|-------------------|-------------------------------------| +| `primary` | Primary section | +| `secondary` | Secondary section | +#### Span n columns. +|---------------|-----------------------------------| +| `col-span-1` | | +| ... | | +| `col-span-12` | | +#### Span n rows. +|---------------|-----------------------------------| +| `row-span-1` | | +| ... | | +| `row-span-12` | | +| | | + +See: [H3 section](#h3-section-2) + +### Tables + +|---------------|----------------| +| `bold-first` | Bold first column | +| `plus-first` | Plus first column | +| `show-header` | Show headers | +| `left-text` | Align the last column left | +| `no-wrap` | Don't wrap text | +| `shortcuts` | Shortcut keys | + +See: [Tables](#tables-2) + + +### Lists {.row-span-2} + +|---------------|----------------| +| `style-none` | No marker is shown | +#### Layout +|---------------|----------------| +| `cols-1` | one column _(default)_ | +| `cols-2` | | +| `cols-3` | three column | +| ... | | +| `cols-11` | | +| `cols-12` | | + + + +### Code + +|---------------|----------------| +| `wrap` | Enables line-wrapping | + +See: [Code](#code-2) + +### Paragraphs + +|---------------|----------------| +| `link-arrow` | Pretty links with arrows | + +See: [Paragraphs](#paragraphs-2) + + + +See: [Lists](#lists-2) + +### Global +|---------------|----------------| +| `hidden` | Hide an element| + + + +### How to add variants {.secondary} + +``` +H2 section {.cols-3} +---------- + +### H3 section {.col-span-2} + +### primary section {.primary} + +[Home](/) {.link-arrow} +``` + +QuickRefs uses [markdown-it-attrs](https://github.com/arve0/markdown-it-attrs#markdown-it-attrs---), and supports adding classes via its syntax. + +Code {.cols-3} +---- + +### Basic code + +```js +here.is(() => { + some.code() +}) +``` + +```js +here.is.some.more() +``` + +Code blocks can be placed one after the other. +
+
+See: [Cheatsheets](/) + +### Code with headings + +#### index.js + +```js +here.is(() => { + some.code() +}) +``` + +#### other.js + +```js +here.is.some.more() +``` + +Code blocks can have headings. + +### Setup blocks + +```js +import React from 'react' +``` + +```js +class Hello extends React.Component { + render () { + return Hello + } +} +``` + +Add `{.bg-gray}` to a `pre` or `table` or `ul`__. + +### Line wrapping + +```js {.wrap} + +``` + +Add `{.wrap}` to wrap long lines. + + +### Long lines + +```js +function createNode(nodeName: string, options: { key: string }) { + return true +} +``` + +Long lines will have scrollbars. + +Paragraphs {.cols-3} +-------- + +### Basic paragraphs +The text that appears in the header + +This is a basic section with paragraphs in it. When paragraphs are the first elements in an H3 section's body, they appear as white. + + +### Description +``` +... +``` +A gray background +``` +··· +``` + +When paragraphs appear after `pre`/`table`/`ul`, they appear with a gray background. + + +### Crosslink + +Add `{.link-arrow}` to make big loud external links: + +``` +··· +``` + +[Home](/) {.link-arrow} + + + + +Tables {.cols-3} +------ + +### Basic table + +#### Date + +| Example | Output | +| --- | --- | +| `%m/%d/%Y` | `06/05/2013` | +| `%A, %B %e, %Y` | `Sunday, June 5, 2013` | +| `%b %e %a` | `Jun 5 Sun` | + +#### Time + +| Example | Output | +| --- | --- | +| `%H:%M` | `23:05` | +| `%I:%M %p` | `11:05 PM` | + +A basic table with heading level 4. + +### Shortcuts + +|------|-------| +| `V` | Vector | +| `P` | Pencil | +| `T` | Text | +| `L` | Line | +| `R` | Rectangle | +| `O` | Oval | +| `U` | Rounded | + {.shortcuts} + + +Add `{.shortcuts}` to tables. + +### Show headers + +| Prefix | Example | What | +| --- | --- | --- | +| `//` | `//hr[@class='edge']` | Anywhere | +| `./` | `./a` | Relative | +| `/` | `/html/body/div` | Root | +{.show-header} + +Add `{.show-header}` to add headers. + + +### Rowspan {.col-span-2} +| Stage | Direct Products | ATP Yields | +|--------------------|-----------------|------------| +| Glycolysis | 2 ATP || +| ^^ | 2 NADH | 3--5 ATP | +| Pyruvaye oxidation | 2 NADH | 5 ATP | +| Citric acid cycle | 2 ATP || +| ^^ | 6 NADH | 15 ATP | +| ^^ | 2 FADH2 | 3 ATP | +| **30--32** ATP ||| +{.show-header} + +#### Source Code + +``` +| Stage | Direct Products | ATP Yields | +|--------------------|-----------------|------------| +| Glycolysis | 2 ATP || +| ^^ | 2 NADH | 3--5 ATP | +| Pyruvaye oxidation | 2 NADH | 5 ATP | +| Citric acid cycle | 2 ATP || +| ^^ | 6 NADH | 15 ATP | +| ^^ | 2 FADH2 | 3 ATP | +| **30--32** ATP ||| +{.show-header} +``` + +QuickRef uses markdown-it-multimd-table to render the table, See:[markdown-it-multimd-table](https://www.npmjs.com/package/markdown-it-multimd-table#rowspan-optional) + + + +### Headerless + +|---|---|---|---|---|---|---|---| +| ♜ | | ♝ | ♛ | ♚ | ♝ | ♞ | ♜ | +| | ♟ | ♟ | ♟ | | ♟ | ♟ | ♟ | +| ♟ | | ♞ | | | | | | +| | ♗ | | | ♟ | | | | +| | | | | ♙ | | | | +| | | | | | ♘ | | | +| ♙ | ♙ | ♙ | ♙ | | ♙ | ♙ | ♙ | +| ♖ | ♘ | ♗ | ♕ | ♔ | | | ♖ | + +#### Source Code + +``` +|---|---|---|---|---|---|---|---| +| ♜ | | ♝ | ♛ | ♚ | ♝ | ♞ | ♜ | +| | ♟ | ♟ | ♟ | | ♟ | ♟ | ♟ | +| ♟ | | ♞ | | | | | | +| | ♗ | | | ♟ | | | | +| | | | | ♙ | | | | +| | | | | | ♘ | | | +| ♙ | ♙ | ♙ | ♙ | | ♙ | ♙ | ♙ | +| ♖ | ♘ | ♗ | ♕ | ♔ | | | ♖ | +``` +See:[markdown-it-multimd-table](https://www.npmjs.com/package/markdown-it-multimd-table#headerless-optional) + + + +Lists {.cols-3} +-------- + +### One column (Default) +- Item 1 +- Item 2 +- Item 3 + +### Five column +- Item 1 +- Item 2 +- Item 3 +- Item 4 +- Item 5 +- Item 6 +- Item 7 +- Item 8 +- Item 9 +{.cols-4} + +### No marker is shown +- Item 1 +- Item 2 +- Item 3 +- Item 4 +- Item 5 +- Item 6 +{.cols-2 .style-none} + + +H2 section {.cols-5} +---------- + +### One + +``` +··· +``` + +### Two + +``` +··· +``` + +### Three + +``` +··· +``` + +### Four + +``` +··· +``` + +### Five + +``` +··· +``` + + +H3 section {.cols-3} +---------- + +### row-span-2 {.row-span-2} + +``` +··· +``` + + +### col-span-2 {.col-span-2} + +``` +··· +``` + +### Primary section {.primary} + +``` +··· +··· +``` +Add `{.primary}` to make the title red. + + +### Secondary section {.secondary} + +``` +··· +``` +Add `{.secondary}` to make the title yellow. + +### col-span-3 {.col-span-3} + +``` +··· +``` + +### Supported + +Each section can have the following children: + +#### White + +- `pre` +- `ul` +- `table` + +#### Gray + +- `p` +- `h4` + +### H3 section + +Every box is an H3 section. The box will encompass everything inside the body of the H3. + +This is a basic section with paragraphs in it. + diff --git a/regex.md b/regex.md new file mode 100644 index 0000000..20da947 --- /dev/null +++ b/regex.md @@ -0,0 +1,684 @@ +--- +title: RegEX +date: 2020-11-25 18:28:43 +icon: icon-regex +background: bg-yellow-500 +tags: + - Regular expressions + - regexp + - pattern +categories: + - Toolkit +intro: | + A quick reference guide for regular expressions (regex), including symbols, ranges, grouping, assertions and some sample patterns to get you started. + This cheat sheet was made for [PCRE](https://en.wikipedia.org/wiki/Perl_Compatible_Regular_Expressions). +--- + +Get Started {.cols-3} +-------- + +### Introduction + +This is a quick cheat sheet to getting started with regular expressions. +- [Regex in Python](#regex-in-python) _(quickref.me)_ +- [Regex in JavaScript](#regex-in-javascript) _(quickref.me)_ +- [Regex in PHP](#regex-in-php) _(quickref.me)_ +- [Regex in Java](#regex-in-java) _(quickref.me)_ +- [Regex in Emacs](/emacs#search) _(quickref.me)_ +- [Online regex tester](https://regex101.com/) _(regex101.com)_ +{.cols-2} + +### Character Classes + +| Pattern | Description | +|------------|--------------------------------------| +|`[abc]` | A single character of: a, b or c| +|`[^abc]` | A character except: a, b or c| +|`[a-z]` | A character in the range: a-z| +|`[^a-z]` | A character not in the range: a-z| +|`[0-9]` | A digit in the range: 0-9| +|`[a-zA-Z]` | A character in the range:
a-z or A-Z| +|`[a-zA-Z0-9]` | A character in the range:
a-z, A-Z or 0-9| + + +### Quantifiers + +| Pattern | Description | +|------------|--------------------------------------| +|`a?` | Zero or one of a| +|`a*` | Zero or more of a| +|`a+` | One or more of a| + +|`[0-9]+` | One or more of 0-9| + +|`a{3}` | Exactly 3 of a| +|`a{3,}` | 3 or more of a| +|`a{3,6}` | Between 3 and 6 of a| + +|`a*` | Greedy quantifier| +|`a*?` | Lazy quantifier| +|`a*+` | Possessive quantifier| + + + + + +### Common Metacharacters + +- \^ +- \{ +- \+ +- \< +- \[ +- \* +- \) +- \> +- \. +- \( +- \| +- \$ +- \\ +- \? +{.cols-3 .style-none} + +Escape these special characters with `\` + + + + + + +### Meta Sequences {.row-span-4} + +| Pattern | Description | +|------------|--------------------------------------| +|`.` | Any single character| +|`\s` | Any whitespace character| +|`\S` | Any non-whitespace character| +|`\d` | Any digit, Same as [0-9]| +|`\D` | Any non-digit, Same as [^0-9]| +|`\w` | Any word character | +|`\W` | Any non-word character | +|`\X` | Any Unicode sequences, linebreaks included| +|`\C` | Match one data unit| +|`\R` | Unicode newlines| +|`\v` | Vertical whitespace character| +|`\V` | Negation of \v - anything except newlines and vertical tabs| +|`\h` | Horizontal whitespace character| +|`\H` | Negation of \h| +|`\K` | Reset match| +|`\n` | Match nth subpattern| +|`\pX` | Unicode property X| +|`\p{...}` | Unicode property or script category| +|`\PX` | Negation of \pX| +|`\P{...}` | Negation of \p| +|`\Q...\E` | Quote; treat as literals| +|`\k` | Match subpattern `name`| +|`\k'name'` | Match subpattern `name`| +|`\k{name}` | Match subpattern `name`| +|`\gn` | Match nth subpattern| +|`\g{n}` | Match nth subpattern| +|`\g` | Recurse nth capture group| +|`\g'n'` | Recurses nth capture group.| +|`\g{-n}` | Match nth relative previous subpattern| +|`\g<+n>` | Recurse nth relative upcoming subpattern| +|`\g'+n'` | Match nth relative upcoming subpattern| +|`\g'letter'` | Recurse named capture group `letter`| +|`\g{letter}` | Match previously-named capture group `letter`| +|`\g` | Recurses named capture group `letter`| +|`\xYY` | Hex character YY| +|`\x{YYYY}` | Hex character YYYY| +|`\ddd` | Octal character ddd| +|`\cY` | Control character Y| +|`[\b]` | Backspace character| +|`\` | Makes any character literal| + + + + +### Anchors + +| Pattern | Description | +|------------|--------------------------------------| +|`\G` | Start of match| +|`^` | Start of string| +|`$` | End of string| +|`\A` | Start of string| +|`\Z` | End of string| +|`\z` | Absolute end of string| +|`\b` | A word boundary| +|`\B` | Non-word boundary| + + + + +### Substitution + +| Pattern | Description | +|------------|--------------------------------------| +|`\0` | Complete match contents| +|`\1` | Contents in capture group 1| +|`$1` | Contents in capture group 1| +|`${foo}` | Contents in capture group `foo`| +|`\x20` | Hexadecimal replacement values| +|`\x{06fa}` | Hexadecimal replacement values| +|`\t` | Tab| +|`\r` | Carriage return| +|`\n` | Newline| +|`\f` | Form-feed| +|`\U` | Uppercase Transformation| +|`\L` | Lowercase Transformation| +|`\E` | Terminate any Transformation| + + + + +### Group Constructs + +| Pattern | Description | +|------------|--------------------------------------| +|`(...)` | Capture everything enclosed| +|`(a|b)` | Match either a or b| +|`(?:...)` | Match everything enclosed| +|`(?>...)` | Atomic group (non-capturing)| +|`(?|...)` | Duplicate subpattern group number| +|`(?#...)` | Comment| + +|`(?'name'...)` | Named Capturing Group| +|`(?...)` | Named Capturing Group| +|`(?P...)` | Named Capturing Group| + +|`(?imsxXU)` | Inline modifiers| +|`(?(DEFINE)...)` | Pre-define patterns before using them| + + + +### Assertions + +|------------|--------------------------------------| +|`(?(1)yes|no)` | Conditional statement| +|`(?(R)yes|no)` | Conditional statement| +|`(?(R#)yes|no)` | Recursive Conditional statement| +|`(?(R&name)yes|no)` | Conditional statement| +|`(?(?=...)yes|no)` | Lookahead conditional| +|`(?(?<=...)yes|no)` | Lookbehind conditional| + + + +### Lookarounds +|------------|--------------------------------------| +|`(?=...)` | Positive Lookahead| +|`(?!...)` | Negative Lookahead| +|`(?<=...)` | Positive Lookbehind| +|`(?name)` | Recurse subpattern `name`| + + + + +### POSIX Character Classes {.col-span-2} +| Character Class| Same as | Meaning | +|----------------|-------------------------------------------------------------|--------------------------------| +| `[[:alnum:]]` | `[0-9A-Za-z]` | Letters and digits | +| `[[:alpha:]]` | `[A-Za-z]` | Letters | +| `[[:ascii:]]` | `[\x00-\x7F]` | ASCII codes 0-127 | +| `[[:blank:]]` | `[\t ]` | Space or tab only | +| `[[:cntrl:]]` | `[\x00-\x1F\x7F]` | Control characters | +| `[[:digit:]]` | `[0-9]` | Decimal digits | +| `[[:graph:]]` | `[[:alnum:][:punct:]]` | Visible characters (not space) | +| `[[:lower:]]` | `[a-z]` | Lowercase letters | +| `[[:print:]]` | `[ -~] == [ [:graph:]]` | Visible characters | +| `[[:punct:]]` | [!"#$%&’()*+,-./:;<=>?@[]^_\`{\|}~] | Visible punctuation characters | +| `[[:space:]]` | [\t\n\v\f\r ] | Whitespace | +| `[[:upper:]]` | `[A-Z]` | Uppercase letters | +| `[[:word:]]` | `[0-9A-Za-z_]` | Word characters | +| `[[:xdigit:]]` | `[0-9A-Fa-f]` | Hexadecimal digits | +| `[[:<:]]` | `[\b(?=\w)]` | Start of word | +| `[[:>:]]` | `[\b(?<=\w)]` | End of word | +{.show-header} + + + + + +### Control verb +|------------|--------------------------------------| +|`(*ACCEPT)` | Control verb| +|`(*FAIL)` | Control verb| +|`(*MARK:NAME)` | Control verb| +|`(*COMMIT)` | Control verb| +|`(*PRUNE)` | Control verb| +|`(*SKIP)` | Control verb| +|`(*THEN)` | Control verb| +|`(*UTF)` | Pattern modifier| +|`(*UTF8)` | Pattern modifier| +|`(*UTF16)` | Pattern modifier| +|`(*UTF32)` | Pattern modifier| +|`(*UCP)` | Pattern modifier| +|`(*CR)` | Line break modifier| +|`(*LF)` | Line break modifier| +|`(*CRLF)` | Line break modifier| +|`(*ANYCRLF)` | Line break modifier| +|`(*ANY)` | Line break modifier| +|`\R` | Line break modifier| +|`(*BSR_ANYCRLF)` | Line break modifier| +|`(*BSR_UNICODE)` | Line break modifier| +|`(*LIMIT_MATCH=x)` | Regex engine modifier| +|`(*LIMIT_RECURSION=d)` | Regex engine modifier| +|`(*NO_AUTO_POSSESS)` | Regex engine modifier| +|`(*NO_START_OPT)` | Regex engine modifier| + + + + + +RegEx in Python {.cols-3} +--------------- + +### Getting started + +Import the regular expressions module + +```python +import re +``` + + +### Example {.col-span-2 .row-span-3} + +#### re.search() +```python +>>> sentence = 'This is a sample string' +>>> bool(re.search(r'this', sentence, flags=re.I)) +True +>>> bool(re.search(r'xyz', sentence)) +False +``` + +#### re.findall() +```python +>>> re.findall(r'\bs?pare?\b', 'par spar apparent spare part pare') +['par', 'spar', 'spare', 'pare'] +>>> re.findall(r'\b0*[1-9]\d{2,}\b', '0501 035 154 12 26 98234') +['0501', '154', '98234'] +``` + + +#### re.finditer() +```python +>>> m_iter = re.finditer(r'[0-9]+', '45 349 651 593 4 204') +>>> [m[0] for m in m_iter if int(m[0]) < 350] +['45', '349', '4', '204'] +``` + + +#### re.split() +```python +>>> re.split(r'\d+', 'Sample123string42with777numbers') +['Sample', 'string', 'with', 'numbers'] +``` + + +#### re.sub() +```python +>>> ip_lines = "catapults\nconcatenate\ncat" +>>> print(re.sub(r'^', r'* ', ip_lines, flags=re.M)) +* catapults +* concatenate +* cat +``` + +#### re.compile() +```python +>>> pet = re.compile(r'dog') +>>> type(pet) + +>>> bool(pet.search('They bought a dog')) +True +>>> bool(pet.search('A cat crossed their path')) +False +``` + +### Functions + +| Function | Description | +|----------|-------------------------------------------------------------------| +| `re.findall` | Returns a list containing all matches | +| `re.finditer` | Return an iterable of match objects (one for each match) | +| `re.search` | Returns a Match object if there is a match anywhere in the string | +| `re.split` | Returns a list where the string has been split at each match | +| `re.sub` | Replaces one or many matches with a string | +| `re.compile` | Compile a regular expression pattern for later use | +| `re.escape` | Return string with all non-alphanumerics backslashed | + + + +### Flags + +|--------|-----------------|-------------------------------------------| +| `re.I` | `re.IGNORECASE` | Ignore case | +| `re.M` | `re.MULTILINE` | Multiline | +| `re.L` | `re.LOCALE` | Make `\w`,`\b`,`\s` _locale dependent_ | +| `re.S` | `re.DOTALL` | Dot matches all _(including newline)_ | +| `re.U` | `re.UNICODE` | Make `\w`,`\b`,`\d`,`\s` _unicode dependent_ | +| `re.X` | `re.VERBOSE` | Readable style | + + + +Regex in JavaScript {.cols-3} +--------------- + +### test() +```javascript +let textA = 'I like APPles very much'; +let textB = 'I like APPles'; +let regex = /apples$/i + +// Output: false +console.log(regex.test(textA)); + +// Output: true +console.log(regex.test(textB)); +``` + +### search() + +```javascript +let text = 'I like APPles very much'; +let regexA = /apples/; +let regexB = /apples/i; + +// Output: -1 +console.log(text.search(regexA)); + +// Output: 7 +console.log(text.search(regexB)); +``` + + +### exec() + +```javascript +let text = 'Do you like apples?'; +let regex= /apples/; + +// Output: apples +console.log(regex.exec(text)[0]); + +// Output: Do you like apples? +console.log(regex.exec(text).input); +``` + + +### match() + +```javascript +let text = 'Here are apples and apPleS'; +let regex = /apples/gi; + +// Output: [ "apples", "apPleS" ] +console.log(text.match(regex)); +``` + + + + +### split() {.col-span-2} + +```javascript +let text = 'This 593 string will be brok294en at places where d1gits are.'; +let regex = /\d+/g + +// Output: [ "This ", " string will be brok", "en at places where d", "gits are." ] +console.log(text.split(regex)) +``` + + + +### matchAll() + +```javascript +let regex = /t(e)(st(\d?))/g; +let text = 'test1test2'; +let array = [...text.matchAll(regex)]; + +// Output: ["test1", "e", "st1", "1"] +console.log(array[0]); + +// Output: ["test2", "e", "st2", "2"] +console.log(array[1]); +``` + + + +### replace() + +```javascript {.wrap} +let text = 'Do you like aPPles?'; +let regex = /apples/i + +// Output: Do you like mangoes? +let result = text.replace(regex, 'mangoes'); +console.log(result); +``` + + +### replaceAll() + +```javascript +let regex = /apples/gi; +let text = 'Here are apples and apPleS'; + +// Output: Here are mangoes and mangoes +let result = text.replaceAll(regex, "mangoes"); +console.log(result); +``` + + + +Regex in PHP {.cols-3} +------------ + +### Functions {.col-span-2} + +|---------------------------|------------------------------------------------------------------| +| `preg_match()` | performs a regex match | +| `preg_match_all()` | perform a global regular expression match | +| `preg_replace_callback()` | perform a regular expression search and replace using a callback | +| `preg_replace()` | perform a regular expression search and replace | +| `preg_split()` | splits a string by regex pattern | +| `preg_grep()` | returns array entries that match a pattern | + + + +### preg_replace +```php {.wrap} +$str = "Visit Microsoft!"; +$regex = "/microsoft/i"; + +// Output: Visit QuickRef! +echo preg_replace($regex, "QuickRef", $str); +``` + + + +### preg_match +```php +$str = "Visit QuickRef"; +$regex = "#quickref#i"; + +// Output: 1 +echo preg_match($regex, $str); +``` + + + +### preg_matchall {.col-span-2 .row-span-2} +```php +$regex = "/[a-zA-Z]+ (\d+)/"; +$input_str = "June 24, August 13, and December 30"; +if (preg_match_all($regex, $input_str, $matches_out)) { + + // Output: 2 + echo count($matches_out); + + // Output: 3 + echo count($matches_out[0]); + + // Output: Array("June 24", "August 13", "December 30") + print_r($matches_out[0]); + + // Output: Array("24", "13", "30") + print_r($matches_out[1]); +} +``` + + + +### preg_grep +```php +$arr = ["Jane", "jane", "Joan", "JANE"]; +$regex = "/Jane/"; + +// Output: Jane +echo preg_grep($regex, $arr); +``` + + +### preg_split {.col-span-2} +```php +$str = "Jane\tKate\nLucy Marion"; +$regex = "@\s@"; + +// Output: Array("Jane", "Kate", "Lucy", "Marion") +print_r(preg_split($regex, $str)); +``` + + +Regex in Java {.cols-3} +------------- + + +### Styles {.col-span-2} + +#### First way +```java +Pattern p = Pattern.compile(".s", Pattern.CASE_INSENSITIVE); +Matcher m = p.matcher("aS"); +boolean s1 = m.matches(); +System.out.println(s1); // Outputs: true +``` + +#### Second way +```java +boolean s2 = Pattern.compile("[0-9]+").matcher("123").matches(); +System.out.println(s2); // Outputs: true +``` + +#### Third way +```java +boolean s3 = Pattern.matches(".s", "XXXX"); +System.out.println(s3); // Outputs: false +``` + + +### Pattern Fields + +|----------------------|-----------------------------------------------| +| `CANON_EQ` | Canonical equivalence | +| `CASE_INSENSITIVE` | Case-insensitive matching | +| `COMMENTS` | Permits whitespace and comments | +| `DOTALL` | Dotall mode | +| `MULTILINE` | Multiline mode | +| `UNICODE_CASE` | Unicode-aware case folding | +| `UNIX_LINES` | Unix lines mode | + + + + + +### Methods + +#### Pattern +- Pattern compile(String regex [, int flags]) +- boolean matches([String regex, ] CharSequence input) +- String[] split(String regex [, int limit]) +- String quote(String s) + +#### Matcher +- int start([int group | String name]) +- int end([int group | String name]) +- boolean find([int start]) +- String group([int group | String name]) +- Matcher reset() + +#### String + +- boolean matches(String regex) +- String replaceAll(String regex, String replacement) +- String[] split(String regex[, int limit]) + +There are more methods ... + + + + +### Examples {.col-span-2} + +Replace sentence: +```java +String regex = "[A-Z\n]{5}$"; +String str = "I like APP\nLE"; + +Pattern p = Pattern.compile(regex, Pattern.MULTILINE); +Matcher m = p.matcher(str); + +// Outputs: I like Apple! +System.out.println(m.replaceAll("pple!")); +``` + +Array of all matches: +```java +String str = "She sells seashells by the Seashore"; +String regex = "\\w*se\\w*"; + +Pattern p = Pattern.compile(regex, Pattern.CASE_INSENSITIVE); +Matcher m = p.matcher(str); + +List matches = new ArrayList<>(); +while (m.find()) { + matches.add(m.group()); +} + +// Outputs: [sells, seashells, Seashore] +System.out.println(matches); +``` diff --git a/vim.md b/vim.md new file mode 100644 index 0000000..74c9ba0 --- /dev/null +++ b/vim.md @@ -0,0 +1,486 @@ +--- +title: Vim +date: 2020-11-25 18:28:43 +icon: icon-vim +background: bg-green-600 +tags: + - vi + - editor + - terminal + - text +categories: + - Toolkit +intro: | + [Vim](http://www.vim.org/) is a very efficient text editor. This reference was made for Vim 8.0. + For shortcut notation. +--- + +Getting started {.cols-3} +--------------- + +### Navigating {.row-span-3} + +| Shortcut | Description | +| --- | --- | +| `h` `j` `k` `l` | Arrow keys | +| `` _\|_ `` | Half-page up/down | +| `` _\|_ `` | Page up/down | +{.shortcuts} + +#### Words + +| Shortcut | Description | +| --- | --- | +| `b` _\|_ `w` | Previous/next word | +| `ge` _\|_ `e` | Previous/next end of word | +{.shortcuts} + +#### Line + +| Shortcut | Description | +| --- | --- | +| `0` _(zero)_ | Start of line | +| `^` | Start of line _(after whitespace)_ | +| `$` | End of line | +{.shortcuts} + +#### Character + +| Shortcut | Description | +| --- | --- | +| `fc` | Go forward to character `c` | +| `Fc` | Go backward to character `c` | +{.shortcuts} + +#### Document + +| Shortcut | Description | +| --- | --- | +| `gg` | First line | +| `G` | Last line | +| `:n` | Go to line `n` | +| `nG` | Go to line `n` | +{.shortcuts} + +#### Window + +| Shortcut | Description | +| --- | --- | +| `zz` | Center this line | +| `zt` | Top this line | +| `zb` | Bottom this line | +| `H` | Move to top of screen | +| `M` | Move to middle of screen | +| `L` | Move to bottom of screen | +{.shortcuts} + +#### Search + +| Shortcut | Description | +| --- | --- | +| `n` | Next matching search pattern | +| `N` | Previous match | +| `*` | Next whole word under cursor | +| `#` | Previous whole word under cursor | +{.shortcuts} + +#### Tab pages + +| Shortcut | Description | +| --- | --- | +| `:tabedit [file]` | Edit file in a new tab | +| `:tabfind [file]` | Open file if exists in new tab | +| `:tabclose` | Close current tab | +| `:tabs` | List all tabs | +| `:tabfirst` | Go to first tab | +| `:tablast` | Go to last tab | +| `:tabn ` | Go to next tab | +| `:tabp ` | Go to previous tab | + + +### Editing + +| Shortcut | Description | +| --- | --- | +| `a` | Append | +| `A` | Append from end of line | +| `i` | Insert | +| `o` | Next line | +| `O` | Previous line | + +| `s` | Delete char and insert | +| `S` | Delete line and insert | +| `C` | Delete until end of line and insert | + +| `r` | Replace one character | +| `R` | Enter Replace mode | + +| `u` | Undo changes | +| `` | Redo changes | +{.shortcuts} + + +### Exiting + +| Shortcut | Description | +| -------------- | -------------------------------- | +| `:qa` | Close all files | +| `:qa!` | Close all files, abandon changes | + +| `:w` | Save | +| `:wq` _\|_ `:x` | Save and close file | + +| `:q` | Close file | +| `:q!` | Close file, abandon changes | + +| `ZZ` | Save and quit | +| `ZQ` | Quit without checking changes | +{.shortcuts} + + +### Clipboard + +| Shortcut | Description | +| --- | --- | +| `x` | Delete character | + +| `dd` | Delete line _(Cut)_ | +| `yy` | Yank line _(Copy)_ | + +| `p` | Paste | +| `P` | Paste before | + +| `"*p` _\|_ `"+p` | Paste from system clipboard | +| `"*y` _\|_ `"+y` | Paste to system clipboard | +{.shortcuts} + +### Visual mode + +| Shortcut | Description | +| --- | --- | +| `v` | Enter visual mode | +| `V` | Enter visual line mode | +| `` | Enter visual block mode | +{.shortcuts} + + +#### In visual mode + +| Shortcut | Description | +| --- | --- | +| `d` _\|_ `x` | Delete selection | +| `s` | Replace selection | +| `y` | Yank selection _(Copy)_ | +{.shortcuts} + + +### Exiting insert mode + +| Shortcut | Description | +| --- | --- | +| `Esc` _\|_ `` | Exit insert mode | +| `` | Exit insert mode, and abort current command | +{.shortcuts} + +See [Operators](#operators) for other things you can do. + + + + + + + +Operators {.cols-3} +--------- + +### Usage {.secondary} + +Operators let you operate in a range of text (defined by *motion*). These are performed in normal mode. +| Shortcut | Description | +| --- | --- | +| `d` | `w` | +| Operator | Motion | + +### Operators list + +| Shortcut | Description | +| --- | --- | +| `d` | Delete | +| `y` | Yank _(copy)_ | +| `c` | Change _(delete then insert)_ | + +| `>` | Indent right | +| `<` | Indent left | +| `=` | Autoindent | + +| `g~` | Swap case | +| `gU` | Uppercase | +| `gu` | Lowercase | + +| `!` | Filter through external program | +{.shortcuts} + +See `:help operator` + +### Examples + +Combine operators with *motions* to use them. +{.setup} + +| Shortcut | Description | +| --- | --- | +| `d`_d_ | _(repeat the letter)_ Delete current line | +| `d`_w_ | Delete to next word | +| `d`_b_ | Delete to beginning of word | +| _2_`dd` | Delete 2 lines | +| `d`_ip_ | Delete a text object _(inside paragraph)_ | +| _(in visual mode)_ `d` | Delete selection | + +See `:help motion.txt` + +Text objects {.cols-3} +------------ + +### Usage {.secondary} + +Text objects let you operate (with an *operator*) in or around text blocks (*objects*). +{.setup} + +| Shortcut | Description | +| ----------- | --------- | +| `v` | `i` | `p` | +| Operator | [i]nside or [a]round | Text object | +{.css-breakdown} + +### Text objects {.row-span-2} + +| Shortcut | Description | +| --- | --- | +| `p` | Paragraph | +| `w` | Word | +| `s` | Sentence | + +| `[` `(` `{` `<` | A [], (), or {} block | +| `'` `"` \` | A quoted string | + +| `b` | A block [( | +| `B` | A block in [{ | +| `t` | A XML tag block | +{.shortcuts} + +### Examples {.row-span-2} + +| Shortcut | Description | +| --- | --- | +| `vip` | Select paragraph | +| `vipipipip` | Select more | + +| `yip` | Yank inner paragraph | +| `yap` | Yank paragraph (including newline) | + +| `dip` | Delete inner paragraph | +| `cip` | Change inner paragraph | +{.shortcuts} + +See [Operators](#operators) for other things you can do. + +### Diff + + +``` +vimdiff file1 file2 [file3] +``` + +See differences between files. + + +Misc {.cols-3} +---- + +### Folds {.row-span-3} + +| Shortcut | Description | +| --- | --- | +| `zo` _\|_ `zO` | Open | +| `zc` _\|_ `zC` | Close | +| `za` _\|_ `zA` | Toggle | + +| `zv` | Open folds for this line | + +| `zM` | Close all | +| `zR` | Open all | + +| `zm` | Fold more _(foldlevel += 1)_ | +| `zr` | Fold less _(foldlevel -= 1)_ | + +| `zx` | Update folds | +{.shortcuts} + +Uppercase ones are recursive (eg, `zO` is open recursively). + +### Navigation + +| Shortcut | Description | +| --- | --- | +| `%` | Nearest/matching `{[()]}` | +| `[(` `[{` `[<` | Previous `(` or `{` or `<` | +| `])` | Next | + +| `[m` | Previous method start | +| `[M` | Previous method end | +{.shortcuts} + + +### Case + +| Shortcut | Description | +| --- | --- | +| `~` | Toggle case (Case => cASE) | +| `gU` | Uppercase | +| `gu` | Lowercase | + +| `gUU` | Uppercase current line (also `gUgU`) | +| `guu` | Lowercase current line (also `gugu`) | +{.shortcuts} + +Do these in visual or normal mode. + + +### Counters + +| Shortcut | Description | +| --- | --- | +| `` | Increment number | +| `` | Decrement | +{.shortcuts} + +### Windows + +| Shortcut | Description | +| --- | --- | +| `z{height}` | Resize pane to `{height}` lines tall | + + +### Text alignment {.row-span-1} + + :center [width] + :right [width] + :left + +See `:help formatting` + + +### Calculator + +| Shortcut | Description | +| --- | --- | +| `=128/2` | Shows the result of the division : '64' | + +Do this in insert mode. + + +### Tags {.row-span-2 .col-span-2} + +| Shortcut | Description | +| --- | --- | +| `:tag Classname` | Jump to first definition of Classname | + +| `` | Jump to definition | +| `g]` | See all definitions | +| `` | Go back to last tag | +| ` ` | Back/forward | + +| `:tselect Classname` | Find definitions of Classname | +| `:tjump Classname` | Find definitions of Classname (auto-select 1st) | +{.shortcuts} + +### Exiting with an error + + :cq + :cquit + +Works like `:qa`, but throws an error. Great for aborting Git commands. + + +### Jumping + +| Shortcut | Description | +| --- | --- | +| `` | Go back to previous location | +| `` | Go forward | + +| `gf` | Go to file in cursor | +{.shortcuts} + +### Marks {.col-span-2 .row-span-2} + +| Shortcut | Description | +| --- | --- | +| \`^ | Last position of cursor in insert mode | +| \`. | Last change in current buffer | +| \`" | Last exited current buffer | +| \`0 | In last file edited | +| '' | Back to line in current buffer where jumped from | +| \`\` | Back to position in current buffer where jumped from | +| \`[ | To beginning of previously changed or yanked text | +| \`] | To end of previously changed or yanked text | +| \`< | To beginning of last visual selection | +| \`> | To end of last visual selection | + +| `ma` | Mark this cursor position as `a` | +| \`a | Jump to the cursor position `a` | +| `'a` | Jump to the beginning of the line with position `a` | +| d'a | Delete from current line to line of mark `a` | +| d\`a | Delete from current position to position of mark `a` | +| c'a | Change text from current line to line of `a` | +| y\`a | Yank text from current position to position of `a` | + +| `:marks` | List all current marks | +| `:delm a` | Delete mark `a` | +| `:delm a-d` | Delete marks `a`, `b`, `c`, `d` | +| `:delm abc` | Delete marks `a`, `b`, `c` | +{.shortcuts} + +### Misc + +| Shortcut | Description | +| --- | --- | +| `.` | Repeat last command | +| `]p` | Paste under the current indentation level | + +| `:set ff=unix` | Convert Windows line endings to Unix line endings | +{.shortcuts} + +### Command line + +| Shortcut | Description | +| --- | --- | +| `` | Insert current word into the command line | +| `"` | Paste from " register | +| `` | Auto-completion of path in insert mode | +{.shortcuts} + + + +### Spell checking {.col-span-3} + +| Shortcut | Description | +| --- | --- | +| `:set spell spelllang=en_us` | Turn on US English spell checking | +| `]s` | Move to next misspelled word after the cursor | +| `[s` | Move to previous misspelled word before the cursor | +| `z=` | Suggest spellings for the word under/after the cursor | +| `zg` | Add word to spell list | +| `zw` | Mark word as bad/mispelling | +| `zu` / `C-X (Insert Mode)` | Suggest words for bad word under cursor from spellfile | +{.shortcuts} + +See `:help spell` + + +Also see +-------- + +- [Vim cheatsheet](https://vim.rtorr.com/) _(vim.rotrr.com)_ +- [Vim documentation](http://vimdoc.sourceforge.net/htmldoc/) _(vimdoc.sourceforge.net)_ +- [Interactive Vim tutorial](http://openvim.com/) _(openvim.com)_