Merge branch 'master' into master
This commit is contained in:
commit
1d4e572260
|
@ -1,2 +1,24 @@
|
||||||
- name: Automatic rebase
|
# https://github.com/cirrus-actions/rebase
|
||||||
uses: cirrus-actions/rebase@1.2
|
on:
|
||||||
|
issue_comment:
|
||||||
|
types: [created]
|
||||||
|
|
||||||
|
name: Automatic rebase
|
||||||
|
jobs:
|
||||||
|
rebase:
|
||||||
|
name: Rebase
|
||||||
|
if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/rebase')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@master
|
||||||
|
- name: Automatic Rebase
|
||||||
|
uses: cirrus-actions/rebase@v1.2.0
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
# https://github.community/t5/GitHub-Actions/Workflow-is-failing-if-no-job-can-be-ran-due-to-condition/m-p/38186#M3250
|
||||||
|
always_job:
|
||||||
|
name: Aways run job
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Always run
|
||||||
|
run: echo "This job is used to prevent the workflow to fail when all other jobs are skipped."
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
image: gitpod/workspace-full
|
||||||
|
|
||||||
|
github:
|
||||||
|
# Prebuild the docker image for gitpod - https://www.gitpod.io/docs/46_prebuilds/
|
||||||
|
prebuilds:
|
||||||
|
# enable for the master/default branch
|
||||||
|
master: true
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- init: bundle install
|
|
@ -5,3 +5,10 @@ script:
|
||||||
- make -B _site
|
- make -B _site
|
||||||
- if ! make test; then make test-warning; exit 16; fi
|
- if ! make test; then make test-warning; exit 16; fi
|
||||||
cache: bundler
|
cache: bundler
|
||||||
|
notifications:
|
||||||
|
slack:
|
||||||
|
if: branch = master OR branch =~ ^.*slack.*$
|
||||||
|
rooms:
|
||||||
|
- secure: FN4trzyyUdtZ6DXj4G3A7YnhqkPyqi8jN9BIdA6S6D2eJEH1gPbZUfbqAW87LKckKZ9iYB5KDF5IuELhR3vv1DeHRqm3MKRU91JVBDT7EXbF86Z1J/JMJxNOcoWdCilcgpnm9NCkMAPFC9h6Y3txYhaLWLsnDaWlvehBsJg+Ql4=
|
||||||
|
on_success: change
|
||||||
|
on_failure: always
|
||||||
|
|
|
@ -1,5 +1,19 @@
|
||||||
# Developer notes
|
# Developer notes
|
||||||
|
|
||||||
|
## Gitpod
|
||||||
|
This repository supports contribution using [gitpod](https://gitpod.io) which is online IDE using [Theia](https://github.com/eclipse-theia/theia).
|
||||||
|
|
||||||
|
To open-up the environment simple natigate on https://gitpod.io/#https://github.com/rstacruz/cheatsheets
|
||||||
|
|
||||||
|
Or using a button:<br>
|
||||||
|
[](https://gitpod.io/#https://github.com/rstacruz/cheatsheets)
|
||||||
|
|
||||||
|
### Preview built website
|
||||||
|
To preview the website you need to first build it then you can navigate to file that you are trying to contribute and preview directly.
|
||||||
|
|
||||||
|
<img src='_docs/images/gitpod_preview_tut.png' width=828 height=459/>
|
||||||
|
|
||||||
|
|
||||||
## Starting a local instance
|
## Starting a local instance
|
||||||
|
|
||||||
This starts Jekyll and Webpack. This requires recent versions of [Node.js], [Yarn], [Ruby] and [Bundler] installed.
|
This starts Jekyll and Webpack. This requires recent versions of [Node.js], [Yarn], [Ruby] and [Bundler] installed.
|
||||||
|
|
|
@ -17,3 +17,5 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
See [CONTRIBUTING.md](CONTRIBUTING.md) for developer notes.
|
See [CONTRIBUTING.md](CONTRIBUTING.md) for developer notes.
|
||||||
|
|
||||||
|
[](https://gitpod.io/#https://github.com/rstacruz/cheatsheets)
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 504 KiB |
|
@ -33,7 +33,7 @@ Used by [Moment.js](http://momentjs.com/docs/#/displaying/) and [date-fns/format
|
||||||
| `YYYY` | `2013` | |
|
| `YYYY` | `2013` | |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| `M` | `1`..`12` _(Jan is 1)_ | **Month** |
|
| `M` | `1`..`12` _(Jan is 1)_ | **Month** |
|
||||||
| `Mo` | `1st`..`31st` | |
|
| `Mo` | `1st`..`12th` | |
|
||||||
| `MM` | `01`..`12` _(Jan is 1)_ | |
|
| `MM` | `01`..`12` _(Jan is 1)_ | |
|
||||||
| `MMM` | `Jan` | |
|
| `MMM` | `Jan` | |
|
||||||
| `MMMM` | `January` | |
|
| `MMMM` | `January` | |
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 26 KiB |
|
@ -37,6 +37,13 @@ brew install awscli
|
||||||
aws configure
|
aws configure
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Configuration profiles
|
||||||
|
|
||||||
|
```
|
||||||
|
aws configure --profile project1
|
||||||
|
aws configure --profile project2
|
||||||
|
```
|
||||||
|
|
||||||
## Elastic Beanstalk
|
## Elastic Beanstalk
|
||||||
|
|
||||||
### Configuration
|
### Configuration
|
||||||
|
|
38
bash.md
38
bash.md
|
@ -389,18 +389,6 @@ Note that `[[` is actually a command/program that returns either `0` (true) or `
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
|
|
||||||
```bash
|
|
||||||
if ping -c 1 google.com; then
|
|
||||||
echo "It appears you have a working internet connection"
|
|
||||||
fi
|
|
||||||
```
|
|
||||||
|
|
||||||
```bash
|
|
||||||
if grep -q 'foo' ~/.bash_history; then
|
|
||||||
echo "You appear to have typed 'foo' in the past"
|
|
||||||
fi
|
|
||||||
```
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# String
|
# String
|
||||||
if [[ -z "$string" ]]; then
|
if [[ -z "$string" ]]; then
|
||||||
|
@ -547,11 +535,11 @@ set -o nounset # Exposes unset variables
|
||||||
### Glob options
|
### Glob options
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
set -o nullglob # Non-matching globs are removed ('*.foo' => '')
|
shopt -s nullglob # Non-matching globs are removed ('*.foo' => '')
|
||||||
set -o failglob # Non-matching globs throw errors
|
shopt -s failglob # Non-matching globs throw errors
|
||||||
set -o nocaseglob # Case insensitive globs
|
shopt -s nocaseglob # Case insensitive globs
|
||||||
set -o globdots # Wildcards match dotfiles ("*.sh" => ".foo.sh")
|
shopt -s dotglob # Wildcards match dotfiles ("*.sh" => ".foo.sh")
|
||||||
set -o globstar # Allow ** for recursive matches ('lib/**/*.rb' => 'lib/a/b/c.rb')
|
shopt -s globstar # Allow ** for recursive matches ('lib/**/*.rb' => 'lib/a/b/c.rb')
|
||||||
```
|
```
|
||||||
|
|
||||||
Set `GLOBIGNORE` as a colon-separated list of patterns to be removed from glob
|
Set `GLOBIGNORE` as a colon-separated list of patterns to be removed from glob
|
||||||
|
@ -749,6 +737,22 @@ cd -
|
||||||
pwd # /home/user/foo
|
pwd # /home/user/foo
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Check for command's result
|
||||||
|
|
||||||
|
```bash
|
||||||
|
if ping -c 1 google.com; then
|
||||||
|
echo "It appears you have a working internet connection"
|
||||||
|
fi
|
||||||
|
```
|
||||||
|
|
||||||
|
### Grep check
|
||||||
|
|
||||||
|
```bash
|
||||||
|
if grep -q 'foo' ~/.bash_history; then
|
||||||
|
echo "You appear to have typed 'foo' in the past"
|
||||||
|
fi
|
||||||
|
```
|
||||||
|
|
||||||
## Also see
|
## Also see
|
||||||
{: .-one-column}
|
{: .-one-column}
|
||||||
|
|
||||||
|
|
|
@ -217,7 +217,7 @@ find('#x').fill_in('Street', with: 'Hello')
|
||||||
### Scripting
|
### Scripting
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
execute_script('$("input").trigger('change')')
|
execute_script('$("input").trigger("change")')
|
||||||
evaluate_script('window.ga')
|
evaluate_script('window.ga')
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
24
css.md
24
css.md
|
@ -13,6 +13,7 @@ keywords:
|
||||||
---
|
---
|
||||||
|
|
||||||
## Basics
|
## Basics
|
||||||
|
|
||||||
{: .-three-column}
|
{: .-three-column}
|
||||||
|
|
||||||
### Selectors
|
### Selectors
|
||||||
|
@ -22,10 +23,12 @@ keywords:
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
{: .-setup}
|
{: .-setup}
|
||||||
|
|
||||||
| Selector | Description |
|
| Selector | Description |
|
||||||
| ----------------- | ----------- |
|
| ----------------- | ------------ |
|
||||||
|
| `*` | All elements |
|
||||||
| `div` | Element |
|
| `div` | Element |
|
||||||
| `.class` | Class |
|
| `.class` | Class |
|
||||||
| `#id` | ID |
|
| `#id` | ID |
|
||||||
|
@ -40,6 +43,7 @@ keywords:
|
||||||
| `.parent > .child` | Direct descendant |
|
| `.parent > .child` | Direct descendant |
|
||||||
| `.child + .sibling` | Adjacent sibling |
|
| `.child + .sibling` | Adjacent sibling |
|
||||||
| `.child ~ .sibling` | Far sibling |
|
| `.child ~ .sibling` | Far sibling |
|
||||||
|
| `.class1.class2` | Have both classes |
|
||||||
|
|
||||||
### Attribute selectors
|
### Attribute selectors
|
||||||
|
|
||||||
|
@ -55,7 +59,7 @@ keywords:
|
||||||
### Pseudo-classes
|
### Pseudo-classes
|
||||||
|
|
||||||
| Selector | Description |
|
| Selector | Description |
|
||||||
| -------------------- | ------------------------ |
|
| -------------------- | ------------------------------------------ |
|
||||||
| `:target` | eg, `h2#foo:target` |
|
| `:target` | eg, `h2#foo:target` |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| `:disabled` | |
|
| `:disabled` | |
|
||||||
|
@ -69,6 +73,11 @@ keywords:
|
||||||
| `:nth-last-child(2)` | |
|
| `:nth-last-child(2)` | |
|
||||||
| `:nth-of-type(2)` | |
|
| `:nth-of-type(2)` | |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
|
| `:checked` | Checked inputs |
|
||||||
|
| `:disabled` | Disabled elements |
|
||||||
|
| `:default` | Default element in a group |
|
||||||
|
| --- | --- |
|
||||||
|
| `:empty` | Elements without children |
|
||||||
|
|
||||||
### Pseudo-class variations
|
### Pseudo-class variations
|
||||||
|
|
||||||
|
@ -83,9 +92,11 @@ keywords:
|
||||||
| `:last-child` |
|
| `:last-child` |
|
||||||
| `:nth-child(2)` |
|
| `:nth-child(2)` |
|
||||||
| `:only-child` |
|
| `:only-child` |
|
||||||
|
|
||||||
{: .-left-align}
|
{: .-left-align}
|
||||||
|
|
||||||
## Fonts
|
## Fonts
|
||||||
|
|
||||||
{: .-left-reference}
|
{: .-left-reference}
|
||||||
|
|
||||||
### Properties
|
### Properties
|
||||||
|
@ -103,15 +114,18 @@ keywords:
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| `text-align:` | `left` `right` `center` `justify` |
|
| `text-align:` | `left` `right` `center` `justify` |
|
||||||
| `text-transform:` | `capitalize` `uppercase` `lowercase` |
|
| `text-transform:` | `capitalize` `uppercase` `lowercase` |
|
||||||
|
|
||||||
{: .-key-values}
|
{: .-key-values}
|
||||||
|
|
||||||
### Shorthand
|
### Shorthand
|
||||||
|
|
||||||
{: .-prime}
|
{: .-prime}
|
||||||
|
|
||||||
| | style | weight | size (required) | | line-height | family |
|
| | style | weight | size (required) | | line-height | family |
|
||||||
| ------- | -------- | ------ | --------------- | --- | ----------- | ----------------- |
|
| ------- | -------- | ------ | --------------- | --- | ----------- | ----------------- |
|
||||||
| `font:` | `italic` | `400` | `14px` | `/` | `1.5` | `sans-serif` |
|
| `font:` | `italic` | `400` | `14px` | `/` | `1.5` | `sans-serif` |
|
||||||
| | style | weight | size (required) | | line-height | family (required) |
|
| | style | weight | size (required) | | line-height | family (required) |
|
||||||
|
|
||||||
{: .-css-breakdown}
|
{: .-css-breakdown}
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
|
@ -133,6 +147,7 @@ text-transform: lowercase; /* hello */
|
||||||
```
|
```
|
||||||
|
|
||||||
## Background
|
## Background
|
||||||
|
|
||||||
{: .-left-reference}
|
{: .-left-reference}
|
||||||
|
|
||||||
### Properties
|
### Properties
|
||||||
|
@ -148,6 +163,7 @@ text-transform: lowercase; /* hello */
|
||||||
| `background-clip:` | `border-box` `padding-box` `content-box` |
|
| `background-clip:` | `border-box` `padding-box` `content-box` |
|
||||||
| `background-repeat:` | `no-repeat` `repeat-x` `repeat-y` |
|
| `background-repeat:` | `no-repeat` `repeat-x` `repeat-y` |
|
||||||
| `background-attachment:` | `scroll` `fixed` `local` |
|
| `background-attachment:` | `scroll` `fixed` `local` |
|
||||||
|
|
||||||
{: .-key-values}
|
{: .-key-values}
|
||||||
|
|
||||||
### Shorthand
|
### Shorthand
|
||||||
|
@ -157,6 +173,7 @@ text-transform: lowercase; /* hello */
|
||||||
| `background:` | `#ff0` | `url(bg.jpg)` | `left` | `top` | `/` | `100px` `auto` | `no-repeat` | `fixed;` |
|
| `background:` | `#ff0` | `url(bg.jpg)` | `left` | `top` | `/` | `100px` `auto` | `no-repeat` | `fixed;` |
|
||||||
| `background:` | `#abc` | `url(bg.png)` | `center` | `center` | `/` | `cover` | `repeat-x` | `local;` |
|
| `background:` | `#abc` | `url(bg.png)` | `center` | `center` | `/` | `cover` | `repeat-x` | `local;` |
|
||||||
| | color | image | positionX | positionY | | size | repeat | attachment |
|
| | color | image | positionX | positionY | | size | repeat | attachment |
|
||||||
|
|
||||||
{: .-css-breakdown}
|
{: .-css-breakdown}
|
||||||
|
|
||||||
### Multiple backgrounds
|
### Multiple backgrounds
|
||||||
|
@ -167,6 +184,7 @@ background: linear-gradient(to bottom, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)),
|
||||||
```
|
```
|
||||||
|
|
||||||
## Animation
|
## Animation
|
||||||
|
|
||||||
{: .-left-reference}
|
{: .-left-reference}
|
||||||
|
|
||||||
### Properties
|
### Properties
|
||||||
|
@ -182,6 +200,7 @@ background: linear-gradient(to bottom, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)),
|
||||||
| `animation-direction:` | `normal` `reverse` `alternate` `alternate-reverse` |
|
| `animation-direction:` | `normal` `reverse` `alternate` `alternate-reverse` |
|
||||||
| `animation-fill-mode:` | `none` `forwards` `backwards` `both` `initial` `inherit` |
|
| `animation-fill-mode:` | `none` `forwards` `backwards` `both` `initial` `inherit` |
|
||||||
| `animation-play-state:` | `normal` `reverse` `alternate` `alternate-reverse` |
|
| `animation-play-state:` | `normal` `reverse` `alternate` `alternate-reverse` |
|
||||||
|
|
||||||
{: .-key-values}
|
{: .-key-values}
|
||||||
|
|
||||||
### Shorthand
|
### Shorthand
|
||||||
|
@ -190,6 +209,7 @@ background: linear-gradient(to bottom, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)),
|
||||||
| ------------ | -------- | -------- | --------------- | ------- | ---------- | ------------------- | --------- | ---------- |
|
| ------------ | -------- | -------- | --------------- | ------- | ---------- | ------------------- | --------- | ---------- |
|
||||||
| `animation:` | `bounce` | `300ms` | `linear` | `100ms` | `infinite` | `alternate-reverse` | `both` | `reverse` |
|
| `animation:` | `bounce` | `300ms` | `linear` | `100ms` | `infinite` | `alternate-reverse` | `both` | `reverse` |
|
||||||
| | name | duration | timing-function | delay | count | direction | fill-mode | play-state |
|
| | name | duration | timing-function | delay | count | direction | fill-mode | play-state |
|
||||||
|
|
||||||
{: .-css-breakdown}
|
{: .-css-breakdown}
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
|
|
|
@ -54,6 +54,8 @@ docker-compose down
|
||||||
web:
|
web:
|
||||||
# build from Dockerfile
|
# build from Dockerfile
|
||||||
build: .
|
build: .
|
||||||
|
args: # Add build arguments
|
||||||
|
APP_HOME: app
|
||||||
```
|
```
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
|
@ -77,7 +79,7 @@ web:
|
||||||
```yaml
|
```yaml
|
||||||
ports:
|
ports:
|
||||||
- "3000"
|
- "3000"
|
||||||
- "8000:80" # guest:host
|
- "8000:80" # host:container
|
||||||
```
|
```
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
|
|
|
@ -24,6 +24,11 @@ docker run [options] IMAGE
|
||||||
# see `docker create` for options
|
# see `docker create` for options
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
|
||||||
|
```
|
||||||
|
$ docker run -it debian:buster /bin/bash
|
||||||
|
```
|
||||||
Run a command in an `image`.
|
Run a command in an `image`.
|
||||||
|
|
||||||
Manage containers
|
Manage containers
|
||||||
|
|
|
@ -22,6 +22,11 @@ ENV APP_HOME /myapp
|
||||||
RUN mkdir $APP_HOME
|
RUN mkdir $APP_HOME
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```docker
|
||||||
|
ARG APP_HOME=""
|
||||||
|
RUN mkdir $APP_HOME
|
||||||
|
```
|
||||||
|
|
||||||
### Initialization
|
### Initialization
|
||||||
|
|
||||||
```docker
|
```docker
|
||||||
|
|
|
@ -88,7 +88,7 @@ expect(wrap.state('show')).toEqual(true)
|
||||||
```
|
```
|
||||||
|
|
||||||
```js
|
```js
|
||||||
expect('name' in wrap.props()).toEqual(true)
|
expect('name' in wrap.props()).toEqual('Moe')
|
||||||
expect('show' in wrap.state()).toEqual(true)
|
expect('show' in wrap.state()).toEqual(true)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
2
es6.md
2
es6.md
|
@ -415,7 +415,7 @@ numbers.map(n => n * 2)
|
||||||
// Same as: numbers.map(function (n) { return n * 2 })
|
// Same as: numbers.map(function (n) { return n * 2 })
|
||||||
numbers.map(n => ({
|
numbers.map(n => ({
|
||||||
result: n * 2
|
result: n * 2
|
||||||
})
|
}))
|
||||||
// Implicitly returning objects requires parentheses around the object
|
// Implicitly returning objects requires parentheses around the object
|
||||||
```
|
```
|
||||||
{: data-line="1,4,5,6"}
|
{: data-line="1,4,5,6"}
|
||||||
|
|
19
find.md
19
find.md
|
@ -2,6 +2,7 @@
|
||||||
title: Find
|
title: Find
|
||||||
category: CLI
|
category: CLI
|
||||||
layout: 2017/sheet
|
layout: 2017/sheet
|
||||||
|
updated: 2019-10-01
|
||||||
---
|
---
|
||||||
|
|
||||||
### Usage
|
### Usage
|
||||||
|
@ -48,6 +49,20 @@ find <path> <conditions> <actions>
|
||||||
-newerXt "1 hour ago" # [t]imestamp
|
-newerXt "1 hour ago" # [t]imestamp
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Access time conditions
|
||||||
|
|
||||||
|
```bash
|
||||||
|
-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 a 0)
|
||||||
|
-ctime -6h30m # File status changed within the last 6 hours and 30 minutes
|
||||||
|
-mtime +1w # Last modified more than 1 week ago
|
||||||
|
```
|
||||||
|
|
||||||
|
These conditions only work in MacOS and BSD-like systems (no GNU/Linux support).
|
||||||
|
|
||||||
### Condition flow
|
### Condition flow
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
@ -73,3 +88,7 @@ find . -name '*.jpg' -exec rm {} \;
|
||||||
```bash
|
```bash
|
||||||
find . -newerBt "24 hours ago"
|
find . -newerBt "24 hours ago"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
find . -type f -mtime +29 # find files modified more than 30 days ago
|
||||||
|
```
|
||||||
|
|
14
go.md
14
go.md
|
@ -422,10 +422,24 @@ func main() {
|
||||||
fmt.Println("Working...")
|
fmt.Println("Working...")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
{: data-line="2,3,4"}
|
{: data-line="2,3,4"}
|
||||||
|
|
||||||
Lambdas are better suited for defer blocks.
|
Lambdas are better suited for defer blocks.
|
||||||
|
|
||||||
|
```go
|
||||||
|
func main() {
|
||||||
|
var d = int64(0)
|
||||||
|
defer func(d *int64) {
|
||||||
|
fmt.Printf("& %v Unix Sec\n", *d)
|
||||||
|
}(&d)
|
||||||
|
fmt.Print("Done ")
|
||||||
|
d = time.Now().Unix()
|
||||||
|
}
|
||||||
|
```
|
||||||
|
{: data-line="3,4,5"}
|
||||||
|
The defer func uses current value of d, unless we use a pointer to get final value at end of main.
|
||||||
|
|
||||||
## Structs
|
## Structs
|
||||||
{: .-three-column}
|
{: .-three-column}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ category: CLI
|
||||||
| `brew update` | Update brew and cask |
|
| `brew update` | Update brew and cask |
|
||||||
| `brew list` | List installed |
|
| `brew list` | List installed |
|
||||||
| `brew outdated` | What's due for upgrades? |
|
| `brew outdated` | What's due for upgrades? |
|
||||||
|
| `brew doctor` | Diagnose brew issues |
|
||||||
|
|
||||||
### Brew Cask commands
|
### Brew Cask commands
|
||||||
|
|
||||||
|
@ -50,5 +51,4 @@ Cask commands are used for interacting with graphical applications.
|
||||||
|
|
||||||
* [Homebrew homepage](https://brew.sh/) _brew.sh_
|
* [Homebrew homepage](https://brew.sh/) _brew.sh_
|
||||||
* [Homebrew docs](https://docs.brew.sh) _docs.brew.sh_
|
* [Homebrew docs](https://docs.brew.sh) _docs.brew.sh_
|
||||||
* [Homebrew Cask](https://caskroom.github.io/) _caskroom.github.io_
|
|
||||||
{: .-also-see}
|
{: .-also-see}
|
||||||
|
|
2
jsdoc.md
2
jsdoc.md
|
@ -31,7 +31,7 @@ See: <http://usejsdoc.org/index.html>
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| `@param {string=} n` | Optional |
|
| `@param {string=} n` | Optional |
|
||||||
| `@param {string} [n]` | Optional |
|
| `@param {string} [n]` | Optional |
|
||||||
| `@param {(string\|number)} n`| Multiple types |
|
| `@param {(string|number)} n` | Multiple types |
|
||||||
| `@param {*} n` | Any type |
|
| `@param {*} n` | Any type |
|
||||||
| `@param {...string} n` | Repeatable arguments |
|
| `@param {...string} n` | Repeatable arguments |
|
||||||
| `@param {string} [n="hi"]` | Optional with default |
|
| `@param {string} [n="hi"]` | Optional with default |
|
||||||
|
|
2
lua.md
2
lua.md
|
@ -61,7 +61,7 @@ title: Lua
|
||||||
|
|
||||||
if condition then
|
if condition then
|
||||||
print("yes")
|
print("yes")
|
||||||
elsif condition then
|
elseif condition then
|
||||||
print("maybe")
|
print("maybe")
|
||||||
else
|
else
|
||||||
print("no")
|
print("no")
|
||||||
|
|
11
npm.md
11
npm.md
|
@ -12,11 +12,13 @@ updated: 2017-10-27
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| `npm i` | Alias for `npm install` |
|
| `npm i` | Alias for `npm install` |
|
||||||
| `npm install` | Install everything in package.json |
|
| `npm install` | Install everything in package.json |
|
||||||
|
| `npm install --production` | Install everything in package.json, except devDependecies |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| `npm install lodash` | Install a package |
|
| `npm install lodash` | Install a package |
|
||||||
| `npm install --save-dev lodash` | Install as devDependency |
|
| `npm install --save-dev lodash` | Install as devDependency |
|
||||||
| `npm install --save-exact lodash` | Install with exact |
|
| `npm install --save-exact lodash` | Install with exact |
|
||||||
|
|
||||||
|
|
||||||
`--save` is the default as of npm@5. Previously, using `npm install` without `--save` doesn't update package.json.
|
`--save` is the default as of npm@5. Previously, using `npm install` without `--save` doesn't update package.json.
|
||||||
|
|
||||||
### Install names
|
### Install names
|
||||||
|
@ -39,6 +41,15 @@ updated: 2017-10-27
|
||||||
| `npm i ./archive.tgz` | Tarball |
|
| `npm i ./archive.tgz` | Tarball |
|
||||||
| `npm i https://site.com/archive.tgz` | Tarball via HTTP |
|
| `npm i https://site.com/archive.tgz` | Tarball via HTTP |
|
||||||
|
|
||||||
|
### Listing
|
||||||
|
|
||||||
|
| Command | Description |
|
||||||
|
| --- | --- |
|
||||||
|
| `npm list` | Lists the installed versions of all dependencies in this software |
|
||||||
|
| `npm list -g --depth 0` | Lists the installed versions of all globally installed packages |
|
||||||
|
| `npm view` | Lists the latest versions of all dependencies in this software |
|
||||||
|
| `npm outdated` | Lists only the dependencies in this software which are outdated |
|
||||||
|
|
||||||
### Updating
|
### Updating
|
||||||
|
|
||||||
| Command | Description |
|
| Command | Description |
|
||||||
|
|
42
python.md
42
python.md
|
@ -58,6 +58,7 @@ category: Python
|
||||||
string.replace("-", " ")
|
string.replace("-", " ")
|
||||||
",".join(list)
|
",".join(list)
|
||||||
"hi {0}".format('j')
|
"hi {0}".format('j')
|
||||||
|
"hi {name}" # same as "hi {}".format('name')
|
||||||
str.find(",")
|
str.find(",")
|
||||||
str.index(",") # same, but raises IndexError
|
str.index(",") # same, but raises IndexError
|
||||||
str.count(",")
|
str.count(",")
|
||||||
|
@ -101,3 +102,44 @@ category: Python
|
||||||
expr.match(...)
|
expr.match(...)
|
||||||
expr.sub(...)
|
expr.sub(...)
|
||||||
|
|
||||||
|
## File manipulation
|
||||||
|
|
||||||
|
### Reading
|
||||||
|
|
||||||
|
```py
|
||||||
|
file = open("hello.txt", "r") # open in read mode 'r'
|
||||||
|
file.close()
|
||||||
|
|
||||||
|
print(file.read()) # read the file
|
||||||
|
print fh.readline() # Reading line by line
|
||||||
|
```
|
||||||
|
|
||||||
|
### Writing (overwrite)
|
||||||
|
|
||||||
|
```py
|
||||||
|
file = open("hello.txt", "w") # open in write mode 'w'
|
||||||
|
write("Hello World")
|
||||||
|
|
||||||
|
text_lines = ["First line", "Second line", "Last line"]
|
||||||
|
file.writelines(text_lines)
|
||||||
|
|
||||||
|
file.close()
|
||||||
|
```
|
||||||
|
|
||||||
|
### Writing (append)
|
||||||
|
|
||||||
|
```py
|
||||||
|
file = open("Hello.txt", "a") # open in append mode
|
||||||
|
write("Hello World again")
|
||||||
|
file.close()
|
||||||
|
```
|
||||||
|
|
||||||
|
### Context manager
|
||||||
|
|
||||||
|
```py
|
||||||
|
with open("welcome.txt", "r") as file:
|
||||||
|
# 'file' refers directly to the "welcome.txt"
|
||||||
|
data = file.read()
|
||||||
|
```
|
||||||
|
|
||||||
|
It closes the file automatically, no need for `file.close()`.
|
||||||
|
|
|
@ -247,11 +247,11 @@ Associations
|
||||||
belongs_to :parent, :foreign_key => 'parent_id' class_name: 'Folder'
|
belongs_to :parent, :foreign_key => 'parent_id' class_name: 'Folder'
|
||||||
has_many :folders, :foreign_key => 'parent_id', class_name: 'Folder'
|
has_many :folders, :foreign_key => 'parent_id', class_name: 'Folder'
|
||||||
|
|
||||||
has_many :comments, :order => "posted_on"
|
has_many :comments, -> { order('posted_on DESC') }
|
||||||
has_many :comments, :include => :author
|
has_many :comments, :include => :author
|
||||||
has_many :people, :class_name => "Person"
|
has_many :people, :class_name => "Person"
|
||||||
has_many :people, :conditions => "deleted = 0"
|
has_many :people, :conditions => "deleted = 0"
|
||||||
has_many :tracks, :order => "position"
|
has_many :tracks, -> { order(:position) }
|
||||||
has_many :comments, :dependent => :nullify
|
has_many :comments, :dependent => :nullify
|
||||||
has_many :comments, :dependent => :destroy
|
has_many :comments, :dependent => :destroy
|
||||||
has_many :tags, :as => :taggable
|
has_many :tags, :as => :taggable
|
||||||
|
|
145
react.md
145
react.md
|
@ -312,6 +312,151 @@ Called when parents change properties and `.setState()`. These are not called fo
|
||||||
|
|
||||||
See: [Component specs](http://facebook.github.io/react/docs/component-specs.html#updating-componentwillreceiveprops)
|
See: [Component specs](http://facebook.github.io/react/docs/component-specs.html#updating-componentwillreceiveprops)
|
||||||
|
|
||||||
|
Hooks (New)
|
||||||
|
-----------
|
||||||
|
{: .-two-column}
|
||||||
|
|
||||||
|
### State Hook
|
||||||
|
|
||||||
|
```jsx
|
||||||
|
import React, { useState } from 'react';
|
||||||
|
|
||||||
|
function Example() {
|
||||||
|
// Declare a new state variable, which we'll call "count"
|
||||||
|
const [count, setCount] = useState(0);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<p>You clicked {count} times</p>
|
||||||
|
<button onClick={() => setCount(count + 1)}>
|
||||||
|
Click me
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
{: data-line="5,10"}
|
||||||
|
|
||||||
|
Hooks are a new addition in React 16.8.
|
||||||
|
|
||||||
|
See: [Hooks at a Glance](https://reactjs.org/docs/hooks-overview.html)
|
||||||
|
|
||||||
|
### Declaring multiple state variables
|
||||||
|
|
||||||
|
```jsx
|
||||||
|
function ExampleWithManyStates() {
|
||||||
|
// Declare multiple state variables!
|
||||||
|
const [age, setAge] = useState(42);
|
||||||
|
const [fruit, setFruit] = useState('banana');
|
||||||
|
const [todos, setTodos] = useState([{ text: 'Learn Hooks' }]);
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Effect hook
|
||||||
|
|
||||||
|
```jsx
|
||||||
|
import React, { useState, useEffect } from 'react';
|
||||||
|
|
||||||
|
function Example() {
|
||||||
|
const [count, setCount] = useState(0);
|
||||||
|
|
||||||
|
// Similar to componentDidMount and componentDidUpdate:
|
||||||
|
useEffect(() => {
|
||||||
|
// Update the document title using the browser API
|
||||||
|
document.title = `You clicked ${count} times`;
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<p>You clicked {count} times</p>
|
||||||
|
<button onClick={() => setCount(count + 1)}>
|
||||||
|
Click me
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
{: data-line="6,7,8,9,10"}
|
||||||
|
|
||||||
|
If you’re familiar with React class lifecycle methods, you can think of `useEffect` Hook as `componentDidMount`, `componentDidUpdate`, and `componentWillUnmount` combined.
|
||||||
|
|
||||||
|
By default, React runs the effects after every render — including the first render.
|
||||||
|
|
||||||
|
### Building your own hooks
|
||||||
|
|
||||||
|
#### Define FriendStatus
|
||||||
|
```jsx
|
||||||
|
import React, { useState, useEffect } from 'react';
|
||||||
|
|
||||||
|
function FriendStatus(props) {
|
||||||
|
const [isOnline, setIsOnline] = useState(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
function handleStatusChange(status) {
|
||||||
|
setIsOnline(status.isOnline);
|
||||||
|
}
|
||||||
|
|
||||||
|
ChatAPI.subscribeToFriendStatus(props.friend.id, handleStatusChange);
|
||||||
|
return () => {
|
||||||
|
ChatAPI.unsubscribeFromFriendStatus(props.friend.id, handleStatusChange);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
if (isOnline === null) {
|
||||||
|
return 'Loading...';
|
||||||
|
}
|
||||||
|
return isOnline ? 'Online' : 'Offline';
|
||||||
|
}
|
||||||
|
```
|
||||||
|
{: data-line="11,12,13,14"}
|
||||||
|
|
||||||
|
Effects may also optionally specify how to “clean up” after them by returning a function.
|
||||||
|
|
||||||
|
#### Use FriendStatus
|
||||||
|
|
||||||
|
```jsx
|
||||||
|
function FriendStatus(props) {
|
||||||
|
const isOnline = useFriendStatus(props.friend.id);
|
||||||
|
|
||||||
|
if (isOnline === null) {
|
||||||
|
return 'Loading...';
|
||||||
|
}
|
||||||
|
return isOnline ? 'Online' : 'Offline';
|
||||||
|
}
|
||||||
|
```
|
||||||
|
{: data-line="2"}
|
||||||
|
|
||||||
|
See: [Building Your Own Hooks](https://reactjs.org/docs/hooks-custom.html)
|
||||||
|
|
||||||
|
### Hooks API Reference
|
||||||
|
|
||||||
|
Also see: [Hooks FAQ](https://reactjs.org/docs/hooks-faq.html)
|
||||||
|
|
||||||
|
#### Basic Hooks
|
||||||
|
|
||||||
|
| Hook | Description |
|
||||||
|
| ---------------------------- | ----------------------------------------- |
|
||||||
|
| `useState`_(initialState)_ | |
|
||||||
|
| `useEffect`_(() => { ... })_ | |
|
||||||
|
| `useContext`_(MyContext)_ | value returned from `React.createContext` |
|
||||||
|
|
||||||
|
Full details: [Basic Hooks](https://reactjs.org/docs/hooks-reference.html#basic-hooks)
|
||||||
|
|
||||||
|
#### Additional Hooks
|
||||||
|
|
||||||
|
| Hook | Description |
|
||||||
|
| -------------------------------------------- | ---------------------------------------------------------------------------- |
|
||||||
|
| `useReducer`_(reducer, initialArg, init)_ | |
|
||||||
|
| `useCallback`_(() => { ... })_ | |
|
||||||
|
| `useMemo`_(() => { ... })_ | |
|
||||||
|
| `useRef`_(initialValue)_ | |
|
||||||
|
| `useImperativeHandle`_(ref, () => { ... })_ | |
|
||||||
|
| `useLayoutEffect` | identical to `useEffect`, but it fires synchronously after all DOM mutations |
|
||||||
|
| `useDebugValue`_(value)_ | display a label for custom hooks in React DevTools |
|
||||||
|
|
||||||
|
Full details: [Additional Hooks](https://reactjs.org/docs/hooks-reference.html#additional-hooks)
|
||||||
|
|
||||||
DOM nodes
|
DOM nodes
|
||||||
---------
|
---------
|
||||||
{: .-two-column}
|
{: .-two-column}
|
||||||
|
|
12
regexp.md
12
regexp.md
|
@ -6,17 +6,19 @@ weight: -1
|
||||||
authors:
|
authors:
|
||||||
- github: rizqyhi
|
- github: rizqyhi
|
||||||
- github: kolapsys
|
- github: kolapsys
|
||||||
updated: 2019-10-24
|
- github: samtrion
|
||||||
|
updated: 2019-11-14
|
||||||
description: |
|
description: |
|
||||||
Basic cheatsheets for regular expression
|
Basic cheatsheets for regular expression
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## RegExp
|
||||||
{: .-three-column}
|
{: .-three-column}
|
||||||
|
|
||||||
### Character classes
|
### Character classes
|
||||||
|
|
||||||
| Pattern | Description |
|
| Pattern | Description |
|
||||||
| ------- | ------------------------------ |
|
| -------- | ------------------------------------ |
|
||||||
| `.` | Any character, except newline |
|
| `.` | Any character, except newline |
|
||||||
| `\w` | Word |
|
| `\w` | Word |
|
||||||
| `\d` | Digit |
|
| `\d` | Digit |
|
||||||
|
@ -27,6 +29,7 @@ description: |
|
||||||
| `[abc]` | Any of a, b, or c |
|
| `[abc]` | Any of a, b, or c |
|
||||||
| `[a-e]` | Characters between `a` and `e` |
|
| `[a-e]` | Characters between `a` and `e` |
|
||||||
| `[1-9]` | Digit between `1` and `9` |
|
| `[1-9]` | Digit between `1` and `9` |
|
||||||
|
| `[^abc]` | Any character except `a`, `b` or `c` |
|
||||||
|
|
||||||
### Anchors
|
### Anchors
|
||||||
|
|
||||||
|
@ -55,8 +58,11 @@ description: |
|
||||||
### Groups
|
### Groups
|
||||||
|
|
||||||
| Pattern | Description |
|
| Pattern | Description |
|
||||||
| ------- | ------------- |
|
| --------- | ------------------------------ |
|
||||||
| `(abc)` | Capture group |
|
| `(abc)` | Capture group |
|
||||||
|
| `(a|b)` | Match `a` or `b` |
|
||||||
|
| `(?:abc)` | Match `abc`, but don't capture |
|
||||||
|
|
||||||
|
|
||||||
### Quantifiers
|
### Quantifiers
|
||||||
|
|
||||||
|
|
|
@ -125,7 +125,7 @@ this.options = { ...this.options, show: true }
|
||||||
|
|
||||||
Mutable operations such as `push()` won't work. You'll need to assign a new copy.
|
Mutable operations such as `push()` won't work. You'll need to assign a new copy.
|
||||||
|
|
||||||
See: [Updating arrays](https://stenciljs.com/docs/handling-arrays)
|
See: [Updating arrays](https://stenciljs.com/docs/reactive-data/#updating-arrays)
|
||||||
|
|
||||||
## Slots
|
## Slots
|
||||||
|
|
||||||
|
|
|
@ -1,35 +1,61 @@
|
||||||
---
|
---
|
||||||
title: Superagent
|
title: Superagent
|
||||||
category: JavaScript libraries
|
category: JavaScript libraries
|
||||||
|
updated: 2018-04-21
|
||||||
|
prism_languages: [javascript]
|
||||||
|
tags:
|
||||||
|
- WIP
|
||||||
---
|
---
|
||||||
|
|
||||||
### Result
|
### Response object
|
||||||
|
```javascript
|
||||||
|
res: {
|
||||||
|
// The HTTP Status Code (see: httpstatuses.com for definitions on HTTP status codes)
|
||||||
|
status: 202,
|
||||||
|
// True when res.status is 2xx
|
||||||
|
ok: true,
|
||||||
|
// True when res.status is 4xx or 5xx
|
||||||
|
error: false,
|
||||||
|
// True when res.status is 4xx
|
||||||
|
clientError: false,
|
||||||
|
// True when res.status is 5xx
|
||||||
|
serverError: false,
|
||||||
|
|
||||||
result == {
|
// True when res.status == 202
|
||||||
ok: true
|
accepted: true,
|
||||||
error: false
|
// True when res.status == 204 || res.status == 1223
|
||||||
|
noContent: false,
|
||||||
|
// True when res.status == 400
|
||||||
|
badRequest: false,
|
||||||
|
// True when res.status == 401
|
||||||
|
unauthorized: false,
|
||||||
|
// True when res.status == 406
|
||||||
|
notAcceptable: false,
|
||||||
|
// True when res.status == 404
|
||||||
|
notFound: false,
|
||||||
|
// True when res.status == 403
|
||||||
|
forbidden: false,
|
||||||
|
|
||||||
// Response
|
// Unparsed response text
|
||||||
body: null
|
text: '{"user":{"username":"JohnDoe","role":"admin"}}'
|
||||||
text: "<!doctype html>..."
|
|
||||||
|
|
||||||
// Headers
|
// Parsed response text (only if response is 'application/json' or 'application/x-www-form-urlencoded'
|
||||||
status: 200
|
body: {
|
||||||
type: "text/html"
|
// Example of parsed object from res.text
|
||||||
charset: "UTF-8"
|
user: {
|
||||||
|
username: 'JohnDoe',
|
||||||
|
role: 'admin'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The content-type (parsed from headers)
|
||||||
|
type: 'application/json'
|
||||||
|
// The charset (parsed from headers)
|
||||||
|
charset: 'UTF-8'
|
||||||
|
// Header object with each header field as a property
|
||||||
headers: {
|
headers: {
|
||||||
'cache-control': 'public',
|
'content-type': 'application/json; charset=UTF-8',
|
||||||
'content-type': 'text/html; charset=UTF-8'
|
...
|
||||||
}
|
}
|
||||||
|
|
||||||
accepted: false
|
|
||||||
|
|
||||||
// specific errors
|
|
||||||
badRequest: false
|
|
||||||
clientError: false
|
|
||||||
forbidden: false
|
|
||||||
notFound: false
|
|
||||||
noContent: false
|
|
||||||
notAcceptable: false
|
|
||||||
unauthorized: false
|
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
4
tmux.md
4
tmux.md
|
@ -44,8 +44,8 @@ category: CLI
|
||||||
|
|
||||||
### Panes
|
### Panes
|
||||||
|
|
||||||
C-b v # vert
|
C-b % # vert
|
||||||
C-b n # horiz
|
C-b " # horiz
|
||||||
C-b hkjl # navigation
|
C-b hkjl # navigation
|
||||||
C-b HJKL # resize
|
C-b HJKL # resize
|
||||||
C-b o # next window
|
C-b o # next window
|
||||||
|
|
1
vim.md
1
vim.md
|
@ -78,6 +78,7 @@ Getting started
|
||||||
| Shortcut | Description |
|
| Shortcut | Description |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| `zz` | Center this line |
|
| `zz` | Center this line |
|
||||||
|
| `zt` | Top this line |
|
||||||
| `H` | Move to top of screen |
|
| `H` | Move to top of screen |
|
||||||
| `M` | Move to middle of screen |
|
| `M` | Move to middle of screen |
|
||||||
| `L` | Move to bottom of screen |
|
| `L` | Move to bottom of screen |
|
||||||
|
|
9
vue.md
9
vue.md
|
@ -1,6 +1,11 @@
|
||||||
---
|
---
|
||||||
title: Vue
|
title: Vue.js
|
||||||
category: JavaScript libraries
|
category: JavaScript
|
||||||
|
layout: 2017/sheet
|
||||||
|
updated: 2019-11-22
|
||||||
|
weight: -10
|
||||||
|
intro: |
|
||||||
|
[Vue.js](https://vuejs.org/) is an open-source Model–view–viewmodel JavaScript framework for building user interfaces and single-page applications.
|
||||||
---
|
---
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
Loading…
Reference in New Issue