Merge branch 'master' into patch-1
This commit is contained in:
commit
0b74fe127d
|
@ -27,7 +27,7 @@ First time setup:
|
||||||
docker-compose build
|
docker-compose build
|
||||||
|
|
||||||
# First-time setup
|
# First-time setup
|
||||||
docker-compose run --rm web bundle install
|
docker-compose run --rm web bundle install && yarn
|
||||||
```
|
```
|
||||||
|
|
||||||
Starting the server:
|
Starting the server:
|
||||||
|
|
|
@ -3,12 +3,15 @@ names:
|
||||||
- Analytics
|
- Analytics
|
||||||
- Ansible
|
- Ansible
|
||||||
- Apps
|
- Apps
|
||||||
|
- C-like
|
||||||
- CLI
|
- CLI
|
||||||
- CSS
|
- CSS
|
||||||
|
- Databases
|
||||||
- Devops
|
- Devops
|
||||||
- Elixir
|
- Elixir
|
||||||
- Git
|
- Git
|
||||||
- HTML
|
- HTML
|
||||||
|
- Java & JVM
|
||||||
- JavaScript
|
- JavaScript
|
||||||
- JavaScript libraries
|
- JavaScript libraries
|
||||||
- Jekyll
|
- Jekyll
|
||||||
|
@ -16,6 +19,8 @@ names:
|
||||||
- Markup
|
- Markup
|
||||||
- macOS
|
- macOS
|
||||||
- Node.js
|
- Node.js
|
||||||
|
- PHP
|
||||||
|
- Python
|
||||||
- Rails
|
- Rails
|
||||||
- React
|
- React
|
||||||
- Ruby
|
- Ruby
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<p class='blurb'>
|
<p class='blurb'>
|
||||||
<strong><a href="{{ base }}">{{ site.title }}</a></strong> is a collection of cheatsheets I've written over the years.
|
<strong><a href="{{ base }}">{{ site.title }}</a></strong> is a collection of cheatsheets I've written over the years.
|
||||||
Suggestions and corrections? <a href='https://github.com/rstacruz/cheatsheets/issues'>Send them in</a>.
|
Suggestions and corrections? <a href='https://github.com/rstacruz/cheatsheets/issues/907'>Send them in</a>.
|
||||||
<i class='fleuron'></i>
|
<i class='fleuron'></i>
|
||||||
I'm <a href="http://ricostacruz.com">Rico Sta. Cruz</a>.
|
I'm <a href="http://ricostacruz.com">Rico Sta. Cruz</a>.
|
||||||
Check out my <a href="http://ricostacruz.com/til">Today I learned blog</a> for more.
|
Check out my <a href="http://ricostacruz.com/til">Today I learned blog</a> for more.
|
||||||
|
|
|
@ -77,7 +77,7 @@
|
||||||
<div class='message item missing-message'>
|
<div class='message item missing-message'>
|
||||||
<h3>See something missing?</h3>
|
<h3>See something missing?</h3>
|
||||||
<p>
|
<p>
|
||||||
<a class='push-button' href='{{ site.github.repository_url }}/issues/new?title=Cheatsheet%20request:%20APP_NAME_HERE'>Request cheatsheet</a>
|
<a class='push-button' href='{{ site.github.repository_url }}/issues/907'>Request cheatsheet</a>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
---
|
---
|
||||||
title: Analytics libraries
|
title: Analytics libraries
|
||||||
layout: 2017/sheet
|
layout: 2017/sheet
|
||||||
|
category: Analytics
|
||||||
---
|
---
|
||||||
|
|
||||||
### Mixpanel
|
### Mixpanel
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -15,6 +15,7 @@ aws ec2 start-instances --instance-ids i-12345678c
|
||||||
|
|
||||||
```
|
```
|
||||||
aws s3 ls s3://mybucket
|
aws s3 ls s3://mybucket
|
||||||
|
aws s3 rm s3://mybucket/folder --recursive
|
||||||
aws s3 cp myfolder s3://mybucket/folder --recursive
|
aws s3 cp myfolder s3://mybucket/folder --recursive
|
||||||
aws s3 sync myfolder s3://mybucket/folder --exclude *.tmp
|
aws s3 sync myfolder s3://mybucket/folder --exclude *.tmp
|
||||||
```
|
```
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
title: Backbone.js
|
title: Backbone.js
|
||||||
layout: 2017/sheet
|
layout: 2017/sheet
|
||||||
updated: 2017-09-04
|
updated: 2017-09-04
|
||||||
|
category: JavaScript libraries
|
||||||
---
|
---
|
||||||
|
|
||||||
### Binding events
|
### Binding events
|
||||||
|
|
29
bash.md
29
bash.md
|
@ -3,7 +3,7 @@ title: Bash scripting
|
||||||
category: CLI
|
category: CLI
|
||||||
layout: 2017/sheet
|
layout: 2017/sheet
|
||||||
tags: [Featured]
|
tags: [Featured]
|
||||||
updated: 2017-08-26
|
updated: 2018-11-19
|
||||||
keywords:
|
keywords:
|
||||||
- Variables
|
- Variables
|
||||||
- Functions
|
- Functions
|
||||||
|
@ -154,8 +154,8 @@ echo ${STR:-5:5} # "world"
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
SRC="/path/to/foo.cpp"
|
SRC="/path/to/foo.cpp"
|
||||||
BASE=${STR##*/} #=> "foo.cpp" (basepath)
|
BASE=${SRC##*/} #=> "foo.cpp" (basepath)
|
||||||
DIR=${SRC%$BASE} #=> "/path/to" (dirpath)
|
DIR=${SRC%$BASE} #=> "/path/to/" (dirpath)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Substitution
|
### Substitution
|
||||||
|
@ -325,6 +325,8 @@ Note that `[[` is actually a command/program that returns either `0` (true) or `
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| `[[ -z STRING ]]` | Empty string |
|
| `[[ -z STRING ]]` | Empty string |
|
||||||
| `[[ -n STRING ]]` | Not empty string |
|
| `[[ -n STRING ]]` | Not empty string |
|
||||||
|
| `[[ STRING == STRING ]]` | Equal |
|
||||||
|
| `[[ STRING != STRING ]]` | Not Equal |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| `[[ NUM -eq NUM ]]` | Equal |
|
| `[[ NUM -eq NUM ]]` | Equal |
|
||||||
| `[[ NUM -ne NUM ]]` | Not equal |
|
| `[[ NUM -ne NUM ]]` | Not equal |
|
||||||
|
@ -392,6 +394,11 @@ if [[ X ]] && [[ Y ]]; then
|
||||||
fi
|
fi
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Equal
|
||||||
|
if [[ "$A" == "$B" ]]
|
||||||
|
```
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Regex
|
# Regex
|
||||||
if [[ "A" =~ "." ]]
|
if [[ "A" =~ "." ]]
|
||||||
|
@ -439,6 +446,7 @@ echo ${Fruits[@]:3:2} # Range (from position 3, length 2)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
Fruits=("${Fruits[@]}" "Watermelon") # Push
|
Fruits=("${Fruits[@]}" "Watermelon") # Push
|
||||||
|
Fruits+=('Watermelon') # Also Push
|
||||||
Fruits=( ${Fruits[@]/Ap*/} ) # Remove by regex match
|
Fruits=( ${Fruits[@]/Ap*/} ) # Remove by regex match
|
||||||
unset Fruits[2] # Remove one item
|
unset Fruits[2] # Remove one item
|
||||||
Fruits=("${Fruits[@]}") # Duplicate
|
Fruits=("${Fruits[@]}") # Duplicate
|
||||||
|
@ -497,6 +505,7 @@ History
|
||||||
|
|
||||||
### Operations
|
### Operations
|
||||||
|
|
||||||
|
| `!!` | Execute last command again |
|
||||||
| `!!:s/<FROM>/<TO>/` | Replace first occurrence of `<FROM>` to `<TO>` in most recent command |
|
| `!!:s/<FROM>/<TO>/` | Replace first occurrence of `<FROM>` to `<TO>` in most recent command |
|
||||||
| `!!:gs/<FROM>/<TO>/` | Replace all occurrences of `<FROM>` to `<TO>` in most recent command |
|
| `!!:gs/<FROM>/<TO>/` | Replace all occurrences of `<FROM>` to `<TO>` in most recent command |
|
||||||
| `!$:t` | Expand only basename from last parameter of most recent command |
|
| `!$:t` | Expand only basename from last parameter of most recent command |
|
||||||
|
@ -506,7 +515,9 @@ History
|
||||||
|
|
||||||
### Slices
|
### Slices
|
||||||
|
|
||||||
| `!!:n` | Expand only `n`th token from most recent command (command is `0`; first param is `1`) |
|
| `!!:n` | Expand only `n`th token from most recent command (command is `0`; first argument is `1`) |
|
||||||
|
| `!^` | Expand first argument from most recent command |
|
||||||
|
| `!$` | Expand last token from most recent command |
|
||||||
| `!!:n-m` | Expand range of tokens from most recent command |
|
| `!!:n-m` | Expand range of tokens from most recent command |
|
||||||
| `!!:n-$` | Expand `n`th token to last from most recent command |
|
| `!!:n-$` | Expand `n`th token to last from most recent command |
|
||||||
|
|
||||||
|
@ -651,6 +662,16 @@ read -n 1 ans # Just one character
|
||||||
|
|
||||||
See [Special parameters](http://wiki.bash-hackers.org/syntax/shellvars#special_parameters_and_shell_variables).
|
See [Special parameters](http://wiki.bash-hackers.org/syntax/shellvars#special_parameters_and_shell_variables).
|
||||||
|
|
||||||
|
### Go to previous directory
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pwd # /home/user/foo
|
||||||
|
cd bar/
|
||||||
|
pwd # /home/user/foo/bar
|
||||||
|
cd -
|
||||||
|
pwd # /home/user/foo
|
||||||
|
```
|
||||||
|
|
||||||
## Also see
|
## Also see
|
||||||
{: .-one-column}
|
{: .-one-column}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ title: Bootstrap
|
||||||
layout: 2017/sheet
|
layout: 2017/sheet
|
||||||
prism_languages: [scss, haml, html]
|
prism_languages: [scss, haml, html]
|
||||||
weight: -1
|
weight: -1
|
||||||
|
category: CSS
|
||||||
description: |
|
description: |
|
||||||
.container .row .col-md-6, @screen-sm-min, .form-control, grids, .modal-content, tooltips, and other Bootstrap CSS examples.
|
.container .row .col-md-6, @screen-sm-min, .form-control, grids, .modal-content, tooltips, and other Bootstrap CSS examples.
|
||||||
---
|
---
|
||||||
|
|
22
bulma.md
22
bulma.md
|
@ -1,9 +1,10 @@
|
||||||
---
|
---
|
||||||
title: Bulma
|
title: Bulma
|
||||||
|
category: CSS
|
||||||
layout: 2017/sheet
|
layout: 2017/sheet
|
||||||
prism_languages: [css, html]
|
prism_languages: [css, html]
|
||||||
weight: -1
|
weight: -1
|
||||||
updated: 2018-03-06
|
updated: 2018-11-19
|
||||||
authors:
|
authors:
|
||||||
- github: benolot
|
- github: benolot
|
||||||
description: |
|
description: |
|
||||||
|
@ -61,7 +62,6 @@ The following classes modify the **state**.
|
||||||
.is-loading
|
.is-loading
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### Typography Helpers
|
### Typography Helpers
|
||||||
|
|
||||||
The following classes modify the **font-size**
|
The following classes modify the **font-size**
|
||||||
|
@ -92,3 +92,21 @@ The following classes **transform** the text
|
||||||
| `.is-capitalized` | Transforms the **first character** of each word to **uppercase** |
|
| `.is-capitalized` | Transforms the **first character** of each word to **uppercase** |
|
||||||
| `.is-lowercase` | Transforms **all** characters to **lowercase** |
|
| `.is-lowercase` | Transforms **all** characters to **lowercase** |
|
||||||
| `.is-uppercase` | Transforms **all** characters to **uppercase** |
|
| `.is-uppercase` | Transforms **all** characters to **uppercase** |
|
||||||
|
|
||||||
|
### WYSIWYG Content
|
||||||
|
|
||||||
|
```html
|
||||||
|
<div class="content">
|
||||||
|
<!-- start WYSIWYG contents -->
|
||||||
|
<h1>Heading</h1>
|
||||||
|
<p>Paragraph</p>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>Item 1</li>
|
||||||
|
<li>Item 2</li>
|
||||||
|
</ul>
|
||||||
|
<!-- end WYSIWYG contents -->
|
||||||
|
</div>
|
||||||
|
```
|
||||||
|
|
||||||
|
To provide default stylings for commonly generated WYSIWYG contents, use the `.content` class.
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
---
|
---
|
||||||
title: C Preprocessor
|
title: C Preprocessor
|
||||||
|
category: C-like
|
||||||
---
|
---
|
||||||
|
|
||||||
### Compiling
|
### Compiling
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
---
|
---
|
||||||
title: CircleCI
|
title: CircleCI
|
||||||
|
category: Devops
|
||||||
---
|
---
|
||||||
|
|
||||||
## circle.yml
|
## circle.yml
|
||||||
|
|
|
@ -30,6 +30,7 @@ All composer commands, depending on your install, may need to use `php composer.
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| `composer update laravel` | Update a certain package |
|
| `composer update laravel` | Update a certain package |
|
||||||
| `composer update vendor/*`| Update all packages in a folder |
|
| `composer update vendor/*`| Update all packages in a folder |
|
||||||
|
| `composer update --lock` | Update lock file hash without updating any packages |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,4 +46,4 @@ All composer commands, depending on your install, may need to use `php composer.
|
||||||
|
|
||||||
| Command | Description |
|
| Command | Description |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| `composer remove laravel` | Remove new package to composer.json and uninstall it |
|
| `composer remove laravel` | Remove new package from composer.json and uninstall it |
|
||||||
|
|
|
@ -0,0 +1,195 @@
|
||||||
|
---
|
||||||
|
title: C# 7
|
||||||
|
category: C-like
|
||||||
|
updated: 2018-12-06
|
||||||
|
layout: 2017/sheet
|
||||||
|
prism_languages: [csharp]
|
||||||
|
description: |
|
||||||
|
A quick overview of C# 7
|
||||||
|
---
|
||||||
|
|
||||||
|
### Out Variables
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
public void PrintCoordinates(Point p)
|
||||||
|
{
|
||||||
|
p.GetCoordinates(out int x, out int y);
|
||||||
|
WriteLine($"({x}, {y})");
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
`out` is used to declare a variable at the point where it is passed as an argument.
|
||||||
|
|
||||||
|
### Pattern Matching
|
||||||
|
|
||||||
|
#### Is-expressions with patterns
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
public void PrintStars(object o)
|
||||||
|
{
|
||||||
|
if (o is null) return; // constant pattern "null"
|
||||||
|
if (!(o is int i)) return; // type pattern "int i"
|
||||||
|
WriteLine(new string('*', i));
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Switch statements with patterns
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
switch(shape)
|
||||||
|
{
|
||||||
|
case Circle c:
|
||||||
|
WriteLine($"circle with radius {c.Radius}");
|
||||||
|
break;
|
||||||
|
case Rectangle s when (s.Length == s.Height):
|
||||||
|
WriteLine($"{s.Length} x {s.Height} square");
|
||||||
|
break;
|
||||||
|
case Rectangle r:
|
||||||
|
WriteLine($"{r.Length} x {r.Height} rectangle");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
WriteLine("<unknown shape>");
|
||||||
|
break;
|
||||||
|
case null:
|
||||||
|
throw new ArgumentNullException(nameof(shape));
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Tuples
|
||||||
|
|
||||||
|
#### Tuple type
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
(string, string, string) LookupName(long id) // tuple return type
|
||||||
|
{
|
||||||
|
... // retrieve first, middle and last from data storage
|
||||||
|
return (first, middle, last); // tuple literal
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
var names = LookupName(id);
|
||||||
|
WriteLine($"found {names.Item1} {names.Item3}.");
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Tuple elements with name
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
(string first, string middle, string last) LookupName(long id) // tuple elements have names
|
||||||
|
```
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
var names = LookupName(id);
|
||||||
|
WriteLine($"found {names.first} {names.last}.");
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Tuple Literals
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
return (first: first, middle: middle, last: last); // named tuple elements in a literal
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Tuple Deconstruction
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
(var first, var middle, var last) = LookupName(id1);
|
||||||
|
WriteLine($"found {first} {last}.");
|
||||||
|
```
|
||||||
|
or
|
||||||
|
```csharp
|
||||||
|
var (first, middle, last) = LookupName(id1); // var outside
|
||||||
|
```
|
||||||
|
or
|
||||||
|
```csharp
|
||||||
|
(first, middle, last) = LookupName(id2); // assign onto existing variables
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Local Functions
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
public int Fibonacci(int x)
|
||||||
|
{
|
||||||
|
if (x < 0) throw new ArgumentException("Less negativity please!", nameof(x));
|
||||||
|
return Fib(x).current;
|
||||||
|
|
||||||
|
(int current, int previous) Fib(int i)
|
||||||
|
{
|
||||||
|
if (i == 0) return (1, 0);
|
||||||
|
var (p, pp) = Fib(i - 1);
|
||||||
|
return (p + pp, p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Literal Improvements
|
||||||
|
|
||||||
|
#### Digit Separator inside numbers literals
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
var d = 123_456;
|
||||||
|
var x = 0xAB_CD_EF;
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Binary Literals
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
var b = 0b1010_1011_1100_1101_1110_1111;
|
||||||
|
```
|
||||||
|
|
||||||
|
### Ref Returns and Locals
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
public ref int Find(int number, int[] numbers)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < numbers.Length; i++)
|
||||||
|
{
|
||||||
|
if (numbers[i] == number)
|
||||||
|
{
|
||||||
|
return ref numbers[i]; // return the storage location, not the value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new IndexOutOfRangeException($"{nameof(number)} not found");
|
||||||
|
}
|
||||||
|
|
||||||
|
int[] array = { 1, 15, -39, 0, 7, 14, -12 };
|
||||||
|
ref int place = ref Find(7, array); // aliases 7's place in the array
|
||||||
|
place = 9; // replaces 7 with 9 in the array
|
||||||
|
WriteLine(array[4]); // prints 9
|
||||||
|
```
|
||||||
|
|
||||||
|
### More Expression Bodied Members
|
||||||
|
|
||||||
|
C# 7.0 adds accessors, constructors and finalizers to the list of things that can have expression bodies:
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
class Person
|
||||||
|
{
|
||||||
|
private static ConcurrentDictionary<int, string> names = new ConcurrentDictionary<int, string>();
|
||||||
|
private int id = GetId();
|
||||||
|
|
||||||
|
public Person(string name) => names.TryAdd(id, name); // constructors
|
||||||
|
~Person() => names.TryRemove(id, out *); // destructors
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get => names[id]; // getters
|
||||||
|
set => names[id] = value; // setters
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Throw Expressions
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
class Person
|
||||||
|
{
|
||||||
|
public string Name { get; }
|
||||||
|
public Person(string name) => Name = name ?? throw new ArgumentNullException(name);
|
||||||
|
public string GetFirstName()
|
||||||
|
{
|
||||||
|
var parts = Name.Split(" ");
|
||||||
|
return (parts.Length > 0) ? parts[0] : throw new InvalidOperationException("No name!");
|
||||||
|
}
|
||||||
|
public string GetLastName() => throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
```
|
|
@ -0,0 +1,255 @@
|
||||||
|
---
|
||||||
|
title: CSS Grid
|
||||||
|
category: CSS
|
||||||
|
updated: 2018-12-06
|
||||||
|
layout: 2017/sheet
|
||||||
|
prism_languages: [css]
|
||||||
|
---
|
||||||
|
|
||||||
|
### Container
|
||||||
|
|
||||||
|
```css
|
||||||
|
.grid-container {
|
||||||
|
```
|
||||||
|
{: .-setup}
|
||||||
|
|
||||||
|
```css
|
||||||
|
/* Display properties */
|
||||||
|
display: grid;
|
||||||
|
display: inline-grid;
|
||||||
|
display: subgrid;
|
||||||
|
```
|
||||||
|
|
||||||
|
```css
|
||||||
|
/* Columns and rows */
|
||||||
|
grid-template-columns: 1rem 2rem 1rem; /* Measurement units */
|
||||||
|
grid-template-columns: 25% 50% 25%; /* Percentage units */
|
||||||
|
grid-template-columns: 1rem auto 1rem 2fr; /* Fill remaining widths with auto or fr units */
|
||||||
|
grid-template-columns: repeat(12, 1fr); /* Repeat columns without needing to write them */
|
||||||
|
|
||||||
|
grid-template-rows: 1rem 10% auto repeat(5, 10px); /* Mix any group, same rules work for rows */
|
||||||
|
```
|
||||||
|
|
||||||
|
```css
|
||||||
|
/* Automatic columns and rows */
|
||||||
|
|
||||||
|
grid-auto-columns: 10px; /* No matter how many columns of content end up in the grid, each column will be this same width */
|
||||||
|
grid-auto-rows: 1rem; /* No matter how many rows of content end up in the grid, each row will be this same height */
|
||||||
|
```
|
||||||
|
|
||||||
|
```css
|
||||||
|
/* Areas */
|
||||||
|
grid-tamplate-areas:
|
||||||
|
"header header"
|
||||||
|
"main aside"
|
||||||
|
"footer footer"; /* Grid-style */
|
||||||
|
|
||||||
|
grid-template-areas: "header header" "main aside" "footer footer"; /* Inline-style */
|
||||||
|
```
|
||||||
|
|
||||||
|
```css
|
||||||
|
/* Template shorthand */
|
||||||
|
grid-template:
|
||||||
|
"header header" auto
|
||||||
|
"main aside" 100vh
|
||||||
|
"footer footer" 10rem
|
||||||
|
/ 80% 20%;
|
||||||
|
|
||||||
|
/* The above is the same as below long-hand */
|
||||||
|
grid-template-columns: 80% 20%;
|
||||||
|
grid-template-rows: auto 100vh 10rem;
|
||||||
|
grid-tamplate-areas:
|
||||||
|
"header header"
|
||||||
|
"main aside"
|
||||||
|
"footer footer";
|
||||||
|
```
|
||||||
|
|
||||||
|
```css
|
||||||
|
/* Gaps */
|
||||||
|
grid-row-gap: 1rem;
|
||||||
|
grid-column-gap: 0.5rem; /* Define values separately */
|
||||||
|
|
||||||
|
grid-gap: 1rem 0.5rem; /* Short-hand for row / column */
|
||||||
|
grid-gap: 1rem; /* Gap in both dimensions */
|
||||||
|
```
|
||||||
|
|
||||||
|
```css
|
||||||
|
/* Item justification (horizontal or column alignment) */
|
||||||
|
justify-items: start; /* Align items to the left */
|
||||||
|
justify-items: center; /* Align items centered within its column */
|
||||||
|
justify-items: end; /* Align items to the right */
|
||||||
|
justify-items: stretch; /* (default) Fills available area (horizontally) */
|
||||||
|
```
|
||||||
|
|
||||||
|
```css
|
||||||
|
/* Item alignment (vertical or row alignment) */
|
||||||
|
align-items: start; /* Align items to the top */
|
||||||
|
align-items: center; /* Align items centered within its row */
|
||||||
|
align-items: end; /* Align items to the bottom */
|
||||||
|
align-items: stretch; /* (default) Fills available area (vertically) */
|
||||||
|
```
|
||||||
|
|
||||||
|
```css
|
||||||
|
/* Place item shorthand */
|
||||||
|
place-items: start stretch;
|
||||||
|
|
||||||
|
/* The above is the same as below long-hand */
|
||||||
|
align-items: start;
|
||||||
|
justify-items: stretch;
|
||||||
|
```
|
||||||
|
|
||||||
|
```css
|
||||||
|
/* Content justification (horizontal or column alignment) */
|
||||||
|
justify-content: start; /* Align content to the left */
|
||||||
|
justify-content: center; /* Align content centered horizontally within the grid */
|
||||||
|
justify-content: end; /* Align content to the right */
|
||||||
|
justify-content: stretch; /* (default) Fills available area (horizontally) */
|
||||||
|
|
||||||
|
justify-content: space-around; /* Chooses a space for both sides of the columns like a left and right margin */
|
||||||
|
justify-content: space-between; /* Chooses a space to go between columns, no margins on outside of content */
|
||||||
|
justify-content: space-evenly; /* Chooses a space that goes between all columns and edges consistently */
|
||||||
|
```
|
||||||
|
|
||||||
|
```css
|
||||||
|
/* Content alignment (horizontal or column alignment) */
|
||||||
|
align-content: start; /* Align content to the top */
|
||||||
|
align-content: center; /* Align content centered vertically within the grid */
|
||||||
|
align-content: end; /* Align content to the bottom */
|
||||||
|
align-content: stretch; /* (default) Fills available area (vertically) */
|
||||||
|
|
||||||
|
align-content: space-around; /* Chooses a space for the top and bottom of the rows like a top and bottom margin */
|
||||||
|
align-content: space-between; /* Chooses a space to go between rows, no margins on outside of content */
|
||||||
|
align-content: space-evenly; /* Chooses a space that goes between all rows and edges consistently */
|
||||||
|
```
|
||||||
|
|
||||||
|
```css
|
||||||
|
/* Place item shorthand */
|
||||||
|
place-content: center start;
|
||||||
|
|
||||||
|
/* The above is the same as below long-hand */
|
||||||
|
align-content: center;
|
||||||
|
justify-content: start;
|
||||||
|
```
|
||||||
|
|
||||||
|
```css
|
||||||
|
/* Automatic grid positioning */
|
||||||
|
|
||||||
|
grid-auto-flow: row; /* Left-to-right rows, then top-to-bottom*/
|
||||||
|
grid-auto-flow: column; /* Top-to-bottom columns, then left-to-right */
|
||||||
|
grid-auto-flow: dense; /* Responds with best-guess on left-to-right, top-to-bottom order with advanced layouts */
|
||||||
|
```
|
||||||
|
|
||||||
|
```css
|
||||||
|
/* There is one final shorthand for all container properties in one */
|
||||||
|
|
||||||
|
/* Explicit grid columns, rows, and areas */
|
||||||
|
grid:
|
||||||
|
"header header" auto
|
||||||
|
"main aside" 100vh
|
||||||
|
"footer footer" 10rem
|
||||||
|
/ 80% 20%; /* You can include a template as the only value, which is equivalent to below */
|
||||||
|
grid-template:
|
||||||
|
"header header" auto
|
||||||
|
"main aside" 100vh
|
||||||
|
"footer footer" 10rem
|
||||||
|
/ 80% 20%; /* Which is again equivalent to below */
|
||||||
|
grid-template-columns: 80% 20%;
|
||||||
|
grid-template-rows: auto 100vh 10rem;
|
||||||
|
grid-tamplate-areas:
|
||||||
|
"header header"
|
||||||
|
"main aside"
|
||||||
|
"footer footer";
|
||||||
|
|
||||||
|
/* Automatic grid flows */
|
||||||
|
grid: 1rem / auto-flow dense 1fr; /* You can include rows, a flow, and automatic columns, which is equivalent to below */
|
||||||
|
grid-template-rows: 1rem;
|
||||||
|
grid-auto-flow: dense;
|
||||||
|
grid-auto-columns: 1fr;
|
||||||
|
|
||||||
|
grid: auto-flow dense 1rem / repeat(10, 10%); /* Conversely, you can do the same thing with automatic rows, and defined columns */
|
||||||
|
grid-auto-flow: dense;
|
||||||
|
grid-auto-rows: 1rem;
|
||||||
|
grid-template-columns: repeat(10, 10%);
|
||||||
|
```
|
||||||
|
|
||||||
|
```css
|
||||||
|
}
|
||||||
|
```
|
||||||
|
{: .-setup}
|
||||||
|
|
||||||
|
### Child
|
||||||
|
|
||||||
|
```css
|
||||||
|
.grid-child {
|
||||||
|
```
|
||||||
|
{: .-setup}
|
||||||
|
|
||||||
|
```css
|
||||||
|
/* Column position */
|
||||||
|
grid-column-start: 1;
|
||||||
|
grid-column-end: 2;
|
||||||
|
|
||||||
|
grid-column: 1 / 2; /* Short hand */
|
||||||
|
grid-column: 1 / span 2; /* Span 2 columns without explicitly defining an endpoint */
|
||||||
|
grid-column: 1; /* Start in and occupy a single column */
|
||||||
|
```
|
||||||
|
|
||||||
|
```css
|
||||||
|
/* Row position */
|
||||||
|
grid-row-start: 2;
|
||||||
|
grid-row-end: 4;
|
||||||
|
|
||||||
|
grid-row: 2 / 4; /* Short hand */
|
||||||
|
grid-row: 2 / span 3;/* Span 3 rows without explicitly defining an endpoint */
|
||||||
|
grid-row: 1; /* Start in and occupy a single row */
|
||||||
|
```
|
||||||
|
|
||||||
|
```css
|
||||||
|
/* Area positioning */
|
||||||
|
grid-area: header; /* You can use a named grid area from the container */
|
||||||
|
|
||||||
|
grid-area: 2 / 1 / 4 / 2; /* Or you can use positioning. This is equivalent to... */
|
||||||
|
grid-row-start: 2;
|
||||||
|
grid-column-start: 1;
|
||||||
|
grid-row-end: 4;
|
||||||
|
grid-column-end: 2;
|
||||||
|
```
|
||||||
|
|
||||||
|
```css
|
||||||
|
/* Self justification (horizontal or column alignment) */
|
||||||
|
justify-self: start; /* Align item to the left */
|
||||||
|
justify-self: center; /* Align item centered within its column */
|
||||||
|
justify-self: end; /* Align item to the right */
|
||||||
|
justify-self: stretch; /* (default) Fills available area (horizontally) */
|
||||||
|
```
|
||||||
|
|
||||||
|
```css
|
||||||
|
/* Self alignment (vertical or row alignment) */
|
||||||
|
align-self: start; /* Align item to the top */
|
||||||
|
align-self: center; /* Align item centered within its row */
|
||||||
|
align-self: end; /* Align item to the bottom */
|
||||||
|
align-self: stretch; /* (default) Fills available area (vertically) */
|
||||||
|
```
|
||||||
|
|
||||||
|
```css
|
||||||
|
/* Placement shorthand */
|
||||||
|
place-self: start stretch;
|
||||||
|
|
||||||
|
/* The above is the same as below long-hand */
|
||||||
|
align-self: start;
|
||||||
|
justify-self: stretch;
|
||||||
|
```
|
||||||
|
|
||||||
|
```css
|
||||||
|
}
|
||||||
|
```
|
||||||
|
{: .-setup}
|
||||||
|
|
||||||
|
|
||||||
|
## References
|
||||||
|
{: .-one-column}
|
||||||
|
|
||||||
|
* [GRID: A simple visual cheatsheet](http://grid.malven.co/)
|
||||||
|
* [CSS Tricks: A Complete Guide to Grid](https://css-tricks.com/snippets/css/complete-guide-grid/)
|
||||||
|
* [Browser support](https://caniuse.com/#feat=css-grid)
|
||||||
|
|
29
css.md
29
css.md
|
@ -170,23 +170,25 @@ background: linear-gradient(to bottom, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)),
|
||||||
|
|
||||||
### Properties
|
### Properties
|
||||||
|
|
||||||
| Property | Value |
|
| Property | Value |
|
||||||
| ---------------------------- | -------------------------------------------------- |
|
| ---------------------------- | -------------------------------------------------------- |
|
||||||
| `animation:` | _(shorthand)_ |
|
| `animation:` | _(shorthand)_ |
|
||||||
| `animation-name:` | `<name>` |
|
| `animation-name:` | `<name>` |
|
||||||
| `animation-delay:` | `<time>ms` |
|
| `animation-duration:` | `<time>ms` |
|
||||||
| `animation-duration:` | `<time>ms` |
|
| `animation-timing-function:` | `ease` `linear` `ease-in` `ease-out` `ease-in-out` |
|
||||||
| `animation-direction:` | `normal` `reverse` `alternate` `alternate-reverse` |
|
| `animation-delay:` | `<time>ms` |
|
||||||
| `animation-iteration-count:` | `infinite` `<number>` |
|
| `animation-iteration-count:` | `infinite` `<number>` |
|
||||||
| `animation-timing-function:` | `ease` `linear` `ease-in` `ease-out` `ease-in-out` |
|
| `animation-direction:` | `normal` `reverse` `alternate` `alternate-reverse` |
|
||||||
|
| `animation-fill-mode:` | `none` `forwards` `backwards` `both` `initial` `inherit` |
|
||||||
|
| `animation-play-state:` | `normal` `reverse` `alternate` `alternate-reverse` |
|
||||||
{: .-key-values}
|
{: .-key-values}
|
||||||
|
|
||||||
### Shorthand
|
### Shorthand
|
||||||
|
|
||||||
| | name | duration | timing-function | delay | count | direction |
|
| | name | duration | timing-function | delay | count | direction | fill-mode | play-state |
|
||||||
| ------------ | -------- | -------- | --------------- | ------- | ---------- | ------------------- |
|
| ------------ | -------- | -------- | --------------- | ------- | ---------- | ------------------- | --------- | ---------- |
|
||||||
| `animation:` | `bounce` | `300ms` | `linear` | `100ms` | `infinite` | `alternate-reverse` |
|
| `animation:` | `bounce` | `300ms` | `linear` | `100ms` | `infinite` | `alternate-reverse` | `both` | `reverse` |
|
||||||
| | name | duration | timing-function | delay | count | direction |
|
| | name | duration | timing-function | delay | count | direction | fill-mode | play-state |
|
||||||
{: .-css-breakdown}
|
{: .-css-breakdown}
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
|
@ -195,6 +197,7 @@ background: linear-gradient(to bottom, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)),
|
||||||
animation: bounce 300ms linear 0s infinite normal;
|
animation: bounce 300ms linear 0s infinite normal;
|
||||||
animation: bounce 300ms linear infinite;
|
animation: bounce 300ms linear infinite;
|
||||||
animation: bounce 300ms linear infinite alternate-reverse;
|
animation: bounce 300ms linear infinite alternate-reverse;
|
||||||
|
animation: bounce 300ms linear 2s infinite alternate-reverse forwards normal;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Event
|
### Event
|
||||||
|
|
2
curl.md
2
curl.md
|
@ -17,6 +17,7 @@ updated: 2017-09-20
|
||||||
```bash
|
```bash
|
||||||
-v # --verbose
|
-v # --verbose
|
||||||
-vv # Even more verbose
|
-vv # Even more verbose
|
||||||
|
-s # --silent
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
@ -27,6 +28,7 @@ updated: 2017-09-20
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
-X POST # --request
|
-X POST # --request
|
||||||
|
-L # follow link if page redirects
|
||||||
```
|
```
|
||||||
|
|
||||||
### Data
|
### Data
|
||||||
|
|
|
@ -196,3 +196,21 @@ services:
|
||||||
extra_hosts:
|
extra_hosts:
|
||||||
- "somehost:192.168.1.100"
|
- "somehost:192.168.1.100"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Network
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# creates a custom network called `frontend`
|
||||||
|
networks:
|
||||||
|
frontend:
|
||||||
|
```
|
||||||
|
|
||||||
|
### External network
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# join a pre-existing network
|
||||||
|
networks:
|
||||||
|
default:
|
||||||
|
external:
|
||||||
|
name: frontend
|
||||||
|
```
|
||||||
|
|
|
@ -4,6 +4,7 @@ layout: 2017/sheet
|
||||||
prism_languages: [ini]
|
prism_languages: [ini]
|
||||||
weight: -1
|
weight: -1
|
||||||
updated: 2017-09-04
|
updated: 2017-09-04
|
||||||
|
category: Apps
|
||||||
---
|
---
|
||||||
|
|
||||||
### Short example
|
### Short example
|
||||||
|
|
1
emacs.md
1
emacs.md
|
@ -1,5 +1,6 @@
|
||||||
---
|
---
|
||||||
title: Emacs
|
title: Emacs
|
||||||
|
category: CLI
|
||||||
---
|
---
|
||||||
|
|
||||||
### Movements
|
### Movements
|
||||||
|
|
|
@ -0,0 +1,178 @@
|
||||||
|
---
|
||||||
|
title: Emmet
|
||||||
|
category: Markup
|
||||||
|
layout: 2017/sheet
|
||||||
|
prism_languages: [html, css]
|
||||||
|
updated: 2018-11-10
|
||||||
|
intro: |
|
||||||
|
Emmet is a markup language for expanding CSS rules into HTML
|
||||||
|
---
|
||||||
|
|
||||||
|
### Child: >
|
||||||
|
|
||||||
|
```css
|
||||||
|
nav>ul>li
|
||||||
|
```
|
||||||
|
Expands to
|
||||||
|
```html
|
||||||
|
<nav>
|
||||||
|
<ul>
|
||||||
|
<li></li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Sibling: +
|
||||||
|
|
||||||
|
```css
|
||||||
|
section>p+p+p
|
||||||
|
```
|
||||||
|
Expands to
|
||||||
|
```html
|
||||||
|
<section>
|
||||||
|
<p></p>
|
||||||
|
<p></p>
|
||||||
|
<p></p>
|
||||||
|
</section>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Climb Up: ^
|
||||||
|
|
||||||
|
```css
|
||||||
|
section>header>h1^footer
|
||||||
|
```
|
||||||
|
Expands to
|
||||||
|
```html
|
||||||
|
<section>
|
||||||
|
<header>
|
||||||
|
<h1></h1>
|
||||||
|
</header>
|
||||||
|
<footer></footer>
|
||||||
|
</section>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Grouping: ()
|
||||||
|
|
||||||
|
```css
|
||||||
|
section>(header>nav>ul>li)+footer>p
|
||||||
|
```
|
||||||
|
Expands to
|
||||||
|
```html
|
||||||
|
<section>
|
||||||
|
<header>
|
||||||
|
<nav>
|
||||||
|
<ul>
|
||||||
|
<li></li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
<footer>
|
||||||
|
<p></p>
|
||||||
|
</footer>
|
||||||
|
</section>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Multiplication: \*
|
||||||
|
|
||||||
|
```css
|
||||||
|
ul>li*3
|
||||||
|
```
|
||||||
|
Expands to
|
||||||
|
```html
|
||||||
|
<ul>
|
||||||
|
<li></li>
|
||||||
|
<li></li>
|
||||||
|
<li></li>
|
||||||
|
</ul>
|
||||||
|
```
|
||||||
|
|
||||||
|
### IDs and Classes: . #
|
||||||
|
|
||||||
|
```css
|
||||||
|
ul.menu>li.menu__item+li#id_item+li.menu__item#id_2
|
||||||
|
```
|
||||||
|
Expands to
|
||||||
|
```html
|
||||||
|
<ul>
|
||||||
|
<li class="menu__item"></li>
|
||||||
|
<li id="id_item"></li>
|
||||||
|
<li class="menu__item" id="id_2"></li>
|
||||||
|
</ul>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Numbering: $
|
||||||
|
|
||||||
|
```css
|
||||||
|
ul>li.item$*3
|
||||||
|
ul>li.item$$*3
|
||||||
|
ul>li.item$@-*3
|
||||||
|
ul>li.item$@3*5
|
||||||
|
```
|
||||||
|
Expands to
|
||||||
|
```html
|
||||||
|
<ul>
|
||||||
|
<li class="item1"></li>
|
||||||
|
<li class="item2"></li>
|
||||||
|
<li class="item3"></li>
|
||||||
|
</ul>
|
||||||
|
<ul>
|
||||||
|
<li class="item01"></li>
|
||||||
|
<li class="item02"></li>
|
||||||
|
<li class="item03"></li>
|
||||||
|
</ul>
|
||||||
|
<ul>
|
||||||
|
<li class="item3"></li>
|
||||||
|
<li class="item2"></li>
|
||||||
|
<li class="item1"></li>
|
||||||
|
</ul>
|
||||||
|
<ul>
|
||||||
|
<li class="item3"></li>
|
||||||
|
<li class="item4"></li>
|
||||||
|
<li class="item5"></li>
|
||||||
|
</ul>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Attributes: []
|
||||||
|
|
||||||
|
```css
|
||||||
|
input[type="text"]
|
||||||
|
div[data-attr="test"]
|
||||||
|
```
|
||||||
|
Expands to
|
||||||
|
```html
|
||||||
|
<input type="text" />
|
||||||
|
<div data-attr="test"></div>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Text: {}
|
||||||
|
|
||||||
|
```css
|
||||||
|
p{Lorem ipsum}
|
||||||
|
```
|
||||||
|
Expands to
|
||||||
|
```html
|
||||||
|
<p>Lorem ipsum</p>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Implicit tags
|
||||||
|
|
||||||
|
```css
|
||||||
|
.default-block
|
||||||
|
em>.default-inline
|
||||||
|
ul>.default-list
|
||||||
|
table>.default-table-row>.default-table-column
|
||||||
|
```
|
||||||
|
Expands to
|
||||||
|
```html
|
||||||
|
<div class="default-block"></div>
|
||||||
|
<em><span class="default-inline"></span></em>
|
||||||
|
<ul>
|
||||||
|
<li class="default-list"></li>
|
||||||
|
</ul>
|
||||||
|
<table>
|
||||||
|
<tr class="default-table-row">
|
||||||
|
<td class="default-table-column"></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
```
|
|
@ -2,7 +2,7 @@
|
||||||
title: Enzyme
|
title: Enzyme
|
||||||
category: React
|
category: React
|
||||||
layout: 2017/sheet
|
layout: 2017/sheet
|
||||||
updated: 2017-10-12
|
updated: 2018-04-27
|
||||||
tags: [Featured]
|
tags: [Featured]
|
||||||
weight: -1
|
weight: -1
|
||||||
keywords:
|
keywords:
|
||||||
|
@ -248,7 +248,7 @@ wrap.context() // get full context
|
||||||
|
|
||||||
```js
|
```js
|
||||||
wrap.state('key') // → any
|
wrap.state('key') // → any
|
||||||
wrap.props('key') // → any
|
wrap.prop('key') // → any
|
||||||
wrap.context('key') // → any
|
wrap.context('key') // → any
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: ES2018
|
||||||
|
category: JavaScript
|
||||||
|
redirect_to: /es6
|
||||||
|
---
|
51
es6.md
51
es6.md
|
@ -6,7 +6,7 @@ tags: [Featured]
|
||||||
updated: 2017-10-21
|
updated: 2017-10-21
|
||||||
weight: -10
|
weight: -10
|
||||||
intro: |
|
intro: |
|
||||||
A quick overview of new JavaScript features in ES2015, ES2016, ES2017 and beyond.
|
A quick overview of new JavaScript features in ES2015, ES2016, ES2017, ES2018 and beyond.
|
||||||
---
|
---
|
||||||
|
|
||||||
### Block scoping
|
### Block scoping
|
||||||
|
@ -69,6 +69,9 @@ See: [Binary and octal literals](https://babeljs.io/learn-es2015/#binary-and-oct
|
||||||
"hello".repeat(3)
|
"hello".repeat(3)
|
||||||
"hello".includes("ll")
|
"hello".includes("ll")
|
||||||
"hello".startsWith("he")
|
"hello".startsWith("he")
|
||||||
|
"hello".padStart(8) // " hello"
|
||||||
|
"hello".padEnd(8) // "hello "
|
||||||
|
"hello".padEnd(8, '!') // hello!!!
|
||||||
"\u1E9B\u0323".normalize("NFC")
|
"\u1E9B\u0323".normalize("NFC")
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -154,6 +157,20 @@ promise
|
||||||
```
|
```
|
||||||
{: data-line="2,3"}
|
{: data-line="2,3"}
|
||||||
|
|
||||||
|
|
||||||
|
### Using promises with finally
|
||||||
|
|
||||||
|
```js
|
||||||
|
promise
|
||||||
|
.then((result) => { ··· })
|
||||||
|
.catch((error) => { ··· })
|
||||||
|
.finally(() => { // logic independent of success/error })
|
||||||
|
```
|
||||||
|
{: data-line="4"}
|
||||||
|
|
||||||
|
The handler is called when the promise is fulfilled or rejected.
|
||||||
|
|
||||||
|
|
||||||
### Promise functions
|
### Promise functions
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
@ -273,6 +290,17 @@ for (let {title, artist} of songs) {
|
||||||
|
|
||||||
The assignment expressions work in loops, too.
|
The assignment expressions work in loops, too.
|
||||||
|
|
||||||
|
|
||||||
|
### Object destructuring
|
||||||
|
|
||||||
|
```js
|
||||||
|
const { id, ...detail } = song;
|
||||||
|
```
|
||||||
|
{: data-line="1"}
|
||||||
|
|
||||||
|
Extract some keys individually and remaining keys in the object using rest (...) operator
|
||||||
|
|
||||||
|
|
||||||
Spread
|
Spread
|
||||||
------
|
------
|
||||||
|
|
||||||
|
@ -385,8 +413,12 @@ readFile('text.txt', (err, data) => {
|
||||||
numbers.map(n => n * 2)
|
numbers.map(n => n * 2)
|
||||||
// No curly braces = implicit return
|
// No curly braces = implicit return
|
||||||
// Same as: numbers.map(function (n) { return n * 2 })
|
// Same as: numbers.map(function (n) { return n * 2 })
|
||||||
|
numbers.map(n => ({
|
||||||
|
result: n * 2
|
||||||
|
})
|
||||||
|
// Implicitly returning objects requires parentheses around the object
|
||||||
```
|
```
|
||||||
{: data-line="1"}
|
{: data-line="1,4,5,6"}
|
||||||
|
|
||||||
Like functions but with `this` preserved.
|
Like functions but with `this` preserved.
|
||||||
See: [Fat arrows](https://babeljs.io/learn-es2015/#arrows-and-lexical-this)
|
See: [Fat arrows](https://babeljs.io/learn-es2015/#arrows-and-lexical-this)
|
||||||
|
@ -446,6 +478,21 @@ let handlers = {
|
||||||
|
|
||||||
See: [Object literal enhancements](https://babeljs.io/learn-es2015/#enhanced-object-literals)
|
See: [Object literal enhancements](https://babeljs.io/learn-es2015/#enhanced-object-literals)
|
||||||
|
|
||||||
|
|
||||||
|
### Extract values
|
||||||
|
|
||||||
|
```js
|
||||||
|
const fatherJS = { age: 57, name: "Brendan Eich" }
|
||||||
|
|
||||||
|
Object.values(fatherJS)
|
||||||
|
// [57, "Brendan Eich"]
|
||||||
|
Object.entries(fatherJS)
|
||||||
|
// [["age", 57], ["name", "Brendan Eich"]]
|
||||||
|
```
|
||||||
|
|
||||||
|
{: data-line="3,5"}
|
||||||
|
|
||||||
|
|
||||||
Modules
|
Modules
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
|
16
exunit.md
16
exunit.md
|
@ -85,12 +85,18 @@ end
|
||||||
|
|
||||||
|
|
||||||
```elixir
|
```elixir
|
||||||
describe "a block" do
|
defp my_hook(_context) do
|
||||||
setup [:my_hook]
|
# Invoked in every block in "a block"
|
||||||
|
{:ok, name: "John", age: 54}
|
||||||
end
|
end
|
||||||
|
|
||||||
defp my_hook(context) do
|
describe "a block" do
|
||||||
# Invoked in every block in "a block"
|
setup [:my_hook]
|
||||||
|
|
||||||
|
test "John's age", context do
|
||||||
|
assert context[:name] == "John"
|
||||||
|
assert context[:age] == 54
|
||||||
|
end
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -98,4 +104,4 @@ end
|
||||||
## Also see
|
## Also see
|
||||||
{: .-one-column}
|
{: .-one-column}
|
||||||
|
|
||||||
- <http://devdocs.io/elixir/ex_unit/exunit#configure/1>
|
* [ExUnit Docs](http://devdocs.io/elixir/ex_unit/exunit#configure/1)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
title: Factory Girl
|
title: Factory Girl
|
||||||
category: JavaScript libraries
|
category: Ruby libraries
|
||||||
redirect_to: /factory_bot
|
redirect_to: /factory_bot
|
||||||
---
|
---
|
||||||
|
|
8
find.md
8
find.md
|
@ -33,6 +33,14 @@ find <path> <conditions> <actions>
|
||||||
-regex PATTERN
|
-regex PATTERN
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
-size 8 # Exactly 8 512-bit blocks
|
||||||
|
-size -128c # Smaller than 128 bytes
|
||||||
|
-size 1440k # Exactly 1440KiB
|
||||||
|
-size +10M # Larger than 10MiB
|
||||||
|
-size +2G # Larger than 2GiB
|
||||||
|
```
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
-newer file.txt
|
-newer file.txt
|
||||||
-newerm file.txt # modified newer than file.txt
|
-newerm file.txt # modified newer than file.txt
|
||||||
|
|
2
flow.md
2
flow.md
|
@ -133,7 +133,7 @@ type Album = {
|
||||||
```js
|
```js
|
||||||
const a: Album = { } // ✓ OK
|
const a: Album = { } // ✓ OK
|
||||||
a.name = 'Blue' // ✓ OK
|
a.name = 'Blue' // ✓ OK
|
||||||
a.name = null // ✓ Error
|
a.name = null // ✗ Error
|
||||||
a.name = undefined // ✓ OK
|
a.name = undefined // ✓ OK
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -34,27 +34,31 @@ Also `git-bug` and `git-refactor`.
|
||||||
|
|
||||||
### Github
|
### Github
|
||||||
|
|
||||||
$ git fork strongloop/express
|
$ git fork strongloop/express
|
||||||
|
# sync your fork with the original repository:
|
||||||
|
$ git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
|
||||||
|
$ git fetch upstream; git merge upstream/master
|
||||||
|
|
||||||
|
|
||||||
### Tags
|
### Tags
|
||||||
|
|
||||||
$ git release v1.0.0 # commit, tag, push-tags
|
$ git release v1.0.0 # commit, tag, push-tags
|
||||||
$ git delete-tag v1.0.0
|
$ git delete-tag v1.0.0
|
||||||
|
|
||||||
### Conveniences
|
### Conveniences
|
||||||
|
|
||||||
$ git ignore "*.log"
|
$ git ignore "*.log"
|
||||||
|
|
||||||
### Locking
|
### Locking
|
||||||
|
|
||||||
Assumes that changes will not be committed.
|
Assumes that changes will not be committed.
|
||||||
|
|
||||||
$ git lock config/database.yml
|
$ git lock config/database.yml
|
||||||
$ git unlock config/database.yml
|
$ git unlock config/database.yml
|
||||||
|
|
||||||
### Etc
|
### Etc
|
||||||
|
|
||||||
$ git obliterate secret.yml # remove all references to it
|
$ git obliterate secret.yml # remove all references to it
|
||||||
|
|
||||||
### References
|
### References
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ See the next tables on format variables.
|
||||||
| `%f` | commit subject, filename style |
|
| `%f` | commit subject, filename style |
|
||||||
| `%b` | commit body |
|
| `%b` | commit body |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| `%cd` | ref names |
|
| `%d` | ref names |
|
||||||
| `%e` | encoding |
|
| `%e` | encoding |
|
||||||
|
|
||||||
## Author and committer
|
## Author and committer
|
||||||
|
|
|
@ -28,6 +28,9 @@ category: Git
|
||||||
# delete remote branch
|
# delete remote branch
|
||||||
git push origin :$branchname
|
git push origin :$branchname
|
||||||
|
|
||||||
|
# go back to previous branch
|
||||||
|
git checkout -
|
||||||
|
|
||||||
## Collaboration
|
## Collaboration
|
||||||
|
|
||||||
# Rebase your changes on top of the remote master
|
# Rebase your changes on top of the remote master
|
||||||
|
@ -86,7 +89,7 @@ Misc
|
||||||
|
|
||||||
git rebase 76acada^
|
git rebase 76acada^
|
||||||
|
|
||||||
## Misc
|
### Misc
|
||||||
|
|
||||||
# get current sha1 (?)
|
# get current sha1 (?)
|
||||||
git show-ref HEAD -s
|
git show-ref HEAD -s
|
||||||
|
@ -133,3 +136,13 @@ Misc
|
||||||
git log --grep="fixes things" # search in commit messages
|
git log --grep="fixes things" # search in commit messages
|
||||||
git log -S"window.alert" # search in code
|
git log -S"window.alert" # search in code
|
||||||
git log -G"foo.*" # search in code (regex)
|
git log -G"foo.*" # search in code (regex)
|
||||||
|
|
||||||
|
## GPG Signing
|
||||||
|
|
||||||
|
git config set user.signingkey <GPG KEY ID> # Sets GPG key to use for signing
|
||||||
|
|
||||||
|
git commit -m "Implement feature Y" --gpg-sign # Or -S, GPG signs commit
|
||||||
|
|
||||||
|
git config set commit.gpgsign true # Sign commits by default
|
||||||
|
git commit -m "Implement feature Y" --no-gpg-sign # Do not sign
|
||||||
|
|
||||||
|
|
24
go.md
24
go.md
|
@ -4,6 +4,7 @@ layout: 2017/sheet
|
||||||
prism_languages: [go, bash]
|
prism_languages: [go, bash]
|
||||||
weight: -3
|
weight: -3
|
||||||
tags: [Featured]
|
tags: [Featured]
|
||||||
|
category: C-like
|
||||||
updated: 2017-09-15
|
updated: 2017-09-15
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -198,6 +199,27 @@ switch day {
|
||||||
|
|
||||||
See: [Switch](https://github.com/golang/go/wiki/Switch)
|
See: [Switch](https://github.com/golang/go/wiki/Switch)
|
||||||
|
|
||||||
|
### For loop
|
||||||
|
|
||||||
|
```go
|
||||||
|
for count := 0; count <= 10; count++ {
|
||||||
|
fmt.Println("My counter is at", count)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
See: [For loops](https://tour.golang.org/flowcontrol/1)
|
||||||
|
|
||||||
|
### For-Range loop
|
||||||
|
|
||||||
|
```go
|
||||||
|
entry := []string{"Jack","John","Jones"}
|
||||||
|
for i, val := range entry {
|
||||||
|
fmt.Printf("At position %d, the character %s is present\n", i, val)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
See: [For-Range loops](https://gobyexample.com/range)
|
||||||
|
|
||||||
## Functions
|
## Functions
|
||||||
{: .-three-column}
|
{: .-three-column}
|
||||||
|
|
||||||
|
@ -485,7 +507,7 @@ See: [Methods](https://tour.golang.org/methods/1)
|
||||||
```go
|
```go
|
||||||
func (v *Vertex) Scale(f float64) {
|
func (v *Vertex) Scale(f float64) {
|
||||||
v.X = v.X * f
|
v.X = v.X * f
|
||||||
v.y = v.Y * f
|
v.Y = v.Y * f
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
{: data-line="1"}
|
{: data-line="1"}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
title: GraphQL
|
title: GraphQL
|
||||||
layout: 2017/sheet
|
layout: 2017/sheet
|
||||||
updated: 2017-09-23
|
updated: 2017-09-23
|
||||||
|
category: Databases
|
||||||
---
|
---
|
||||||
|
|
||||||
## Intro
|
## Intro
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
---
|
||||||
|
title: Haml
|
||||||
|
category: Markup
|
||||||
|
layout: 2017/sheet
|
||||||
|
prism_languages: [haml]
|
||||||
|
---
|
||||||
|
|
||||||
|
### Doctype
|
||||||
|
|
||||||
|
```haml
|
||||||
|
!!! 5
|
||||||
|
```
|
||||||
|
|
||||||
|
### Tags
|
||||||
|
|
||||||
|
```haml
|
||||||
|
%html
|
||||||
|
%head
|
||||||
|
%title
|
||||||
|
%body
|
||||||
|
%h1 Hello World
|
||||||
|
%br/
|
||||||
|
```
|
||||||
|
|
||||||
|
### Classes and ID's
|
||||||
|
|
||||||
|
```haml
|
||||||
|
%p.class-example
|
||||||
|
.no-tag-defaults-to-div
|
||||||
|
%div#butItCanBeIncluded
|
||||||
|
```
|
||||||
|
|
||||||
|
### Inline Attributes
|
||||||
|
|
||||||
|
Either hash syntax works
|
||||||
|
|
||||||
|
```haml
|
||||||
|
%meta{ name: "viewport", content: "width=device-width, initial-scale=1.0" }
|
||||||
|
%input{ :type => "text", :required => true }
|
||||||
|
```
|
||||||
|
|
||||||
|
### Ruby
|
||||||
|
|
||||||
|
```haml
|
||||||
|
-# This is a comment
|
||||||
|
-# Anything starting with a hyphen signals to Haml that Ruby is coming
|
||||||
|
- @arr = [1, 2, 3]
|
||||||
|
- @str = "test"
|
||||||
|
-# Equal signals output
|
||||||
|
= render partial: "shared/header"
|
||||||
|
= yield
|
||||||
|
= link_to page_url
|
||||||
|
```
|
|
@ -2,6 +2,7 @@
|
||||||
title: Homebrew
|
title: Homebrew
|
||||||
layout: 2017/sheet
|
layout: 2017/sheet
|
||||||
weight: -3
|
weight: -3
|
||||||
|
category: CLI
|
||||||
---
|
---
|
||||||
|
|
||||||
### Commands
|
### Commands
|
||||||
|
|
|
@ -47,6 +47,7 @@ Print options:
|
||||||
# h: response headers
|
# h: response headers
|
||||||
# b: response body
|
# b: response body
|
||||||
--pretty=none # all | colors | format
|
--pretty=none # all | colors | format
|
||||||
|
--json | -j # Response is serialized as a JSON object.
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Authentication
|
#### Authentication
|
||||||
|
|
|
@ -139,7 +139,7 @@ Markup
|
||||||
{% for post in site.posts %}
|
{% for post in site.posts %}
|
||||||
<a href="{{ post.url }}">
|
<a href="{{ post.url }}">
|
||||||
<h2>{{ post.title }}</h2>
|
<h2>{{ post.title }}</h2>
|
||||||
<p>{{ post.date | date_to_string }}</h2>
|
<p>{{ post.date | date_to_string }}</p>
|
||||||
</a>
|
</a>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
```
|
```
|
||||||
|
|
7
knex.md
7
knex.md
|
@ -2,6 +2,7 @@
|
||||||
title: Knex
|
title: Knex
|
||||||
layout: 2017/sheet
|
layout: 2017/sheet
|
||||||
updated: 2017-09-23
|
updated: 2017-09-23
|
||||||
|
category: Databases
|
||||||
intro: |
|
intro: |
|
||||||
[Knex](http://knexjs.org/) is an SQL query builder for Node.js.
|
[Knex](http://knexjs.org/) is an SQL query builder for Node.js.
|
||||||
This guide targets v0.13.0.
|
This guide targets v0.13.0.
|
||||||
|
@ -43,7 +44,7 @@ knex('users')
|
||||||
```
|
```
|
||||||
{: data-line="2"}
|
{: data-line="2"}
|
||||||
|
|
||||||
See: [Select](#elect-1)
|
See: [Select](#select-1)
|
||||||
|
|
||||||
### Insert
|
### Insert
|
||||||
|
|
||||||
|
@ -475,7 +476,7 @@ See: [Delete](http://knexjs.org/#Builder-del)
|
||||||
|
|
||||||
### Setting up
|
### Setting up
|
||||||
|
|
||||||
#### Creates knexfile.js
|
#### Create knexfile.js
|
||||||
|
|
||||||
```
|
```
|
||||||
./node_modules/.bin/knex init
|
./node_modules/.bin/knex init
|
||||||
|
@ -485,6 +486,7 @@ See: [Delete](http://knexjs.org/#Builder-del)
|
||||||
|
|
||||||
```
|
```
|
||||||
knex migrate:make migration_name
|
knex migrate:make migration_name
|
||||||
|
knex migrate:make migration_name --env production
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Run migrations
|
#### Run migrations
|
||||||
|
@ -498,6 +500,7 @@ knex migrate:latest --env production
|
||||||
|
|
||||||
```
|
```
|
||||||
knex migrate:rollback
|
knex migrate:rollback
|
||||||
|
knex migrate:rollback --env production
|
||||||
```
|
```
|
||||||
|
|
||||||
See: [Migrations](http://knexjs.org/#Migrations)
|
See: [Migrations](http://knexjs.org/#Migrations)
|
||||||
|
|
|
@ -0,0 +1,402 @@
|
||||||
|
---
|
||||||
|
title: Kotlin
|
||||||
|
layout: 2017/sheet
|
||||||
|
updated: 2018-12-06
|
||||||
|
category: Java & JVM
|
||||||
|
prism_languages: [kotlin]
|
||||||
|
intro: |
|
||||||
|
[Kotlin](http://kotlinlang.org/) is a statically typed programming language for modern multiplatform applications.
|
||||||
|
---
|
||||||
|
|
||||||
|
Variables
|
||||||
|
---------
|
||||||
|
{: .-three-column}
|
||||||
|
|
||||||
|
### Mutability
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
var mutableString: String = "Adam"
|
||||||
|
val immutableString: String = "Adam"
|
||||||
|
val inferredString = "Adam"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Strings
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
val name = "Adam"
|
||||||
|
val greeting = "Hello, " + name
|
||||||
|
val greetingTemplate = "Hello, $name"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Numbers
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
val intNum = 10
|
||||||
|
val doubleNum = 10.0
|
||||||
|
val longNum = 10L
|
||||||
|
val floatNum = 10.0F
|
||||||
|
```
|
||||||
|
|
||||||
|
### Booleans
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
val trueBoolean = true
|
||||||
|
val falseBoolean = false
|
||||||
|
val andCondition = trueBoolean && falseBoolean
|
||||||
|
val orCondition = trueBoolean || falseBoolean
|
||||||
|
```
|
||||||
|
|
||||||
|
### Static Fields
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
class Person {
|
||||||
|
companion object {
|
||||||
|
val NAME_KEY = "name_key"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val key = Person.NAME_KEY
|
||||||
|
```
|
||||||
|
|
||||||
|
Null Safety
|
||||||
|
-----------
|
||||||
|
{: .-two-column}
|
||||||
|
|
||||||
|
### Nullable properties
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
val cannotBeNull: String = null // Invalid
|
||||||
|
val canBeNull: String? = null // Valid
|
||||||
|
|
||||||
|
val cannotBeNull: Int = null // Invalid
|
||||||
|
val canBeNull: Int? = null // Valid
|
||||||
|
```
|
||||||
|
|
||||||
|
### Checking for null
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
val name: String? = "Adam"
|
||||||
|
|
||||||
|
if (name != null && name.length > 0) {
|
||||||
|
print("String length is ${name.length}")
|
||||||
|
} else {
|
||||||
|
print("String is empty.")
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Safe Operator
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
val nullableStringLength: Int? = nullableString?.length
|
||||||
|
val nullableDepartmentHead: String? = person?.department?.head?.name
|
||||||
|
```
|
||||||
|
|
||||||
|
### Elvis Operator
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
val nonNullStringLength: Int = nullableString?.length ?: 0
|
||||||
|
val nonNullDepartmentHead: String = person?.department?.head?.name ?: ""
|
||||||
|
val nonNullDepartmentHead: String = person?.department?.head?.name.orEmpty()
|
||||||
|
```
|
||||||
|
|
||||||
|
### Safe Casts
|
||||||
|
```kotlin
|
||||||
|
// Will not throw ClassCastException
|
||||||
|
val nullableCar: Car? = (input as? Car)
|
||||||
|
```
|
||||||
|
|
||||||
|
Collections
|
||||||
|
-----------
|
||||||
|
{: .-two-column}
|
||||||
|
|
||||||
|
### Creation
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
val numArray = arrayOf(1, 2, 3)
|
||||||
|
val numList = listOf(1, 2, 3)
|
||||||
|
val mutableNumList = mutableListOf(1, 2, 3)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Accessing
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
val firstItem = numList[0]
|
||||||
|
val firstItem = numList.first()
|
||||||
|
val firstItem = numList.firstOrNull()
|
||||||
|
```
|
||||||
|
|
||||||
|
### Maps
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
val faceCards = mutableMapOf("Jack" to 11, "Queen" to 12, "King" to 13)
|
||||||
|
val jackValue = faceCards["Jack"] // 11
|
||||||
|
faceCards["Ace"] = 1
|
||||||
|
```
|
||||||
|
|
||||||
|
### Mutability
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
val immutableList = listOf(1, 2, 3)
|
||||||
|
val mutableList = immutableList.toMutableList()
|
||||||
|
|
||||||
|
val immutableMap = mapOf("Jack" to 11, "Queen" to 12, "King" to 13)
|
||||||
|
val mutableMap = immutableMap.toMutableMap()
|
||||||
|
```
|
||||||
|
|
||||||
|
### Iterating
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
for (item in myList) {
|
||||||
|
print(item)
|
||||||
|
}
|
||||||
|
|
||||||
|
myList.forEach {
|
||||||
|
print(it)
|
||||||
|
}
|
||||||
|
|
||||||
|
myList.forEachIndexed { index, item ->
|
||||||
|
print("Item at $index is: $item")
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Filtering & Searching
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
val evenNumbers = numList.filter { it % 2 == 0 }
|
||||||
|
val containsEven = numList.any { it % 2 == 0 }
|
||||||
|
val containsNoEvens = numList.none { it % 2 == 0 }
|
||||||
|
val containsNoEvens = numList.all { it % 2 == 1 }
|
||||||
|
val firstEvenNumber: Int = numList.first { it % 2 == 0 }
|
||||||
|
val firstEvenOrNull: Int? = numList.firstOrNull { it % 2 == 0 }
|
||||||
|
```
|
||||||
|
|
||||||
|
Note: `it` is the [implicit name for a single parameter](https://kotlinlang.org/docs/reference/lambdas.html#it-implicit-name-of-a-single-parameter).
|
||||||
|
|
||||||
|
Functions
|
||||||
|
---------
|
||||||
|
{: .-two-column}
|
||||||
|
|
||||||
|
### Parameters & Return Types
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
fun printName() {
|
||||||
|
print("Adam")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun printName(person: Person) {
|
||||||
|
print(person.name)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getGreeting(person: Person): String {
|
||||||
|
return "Hello, ${person.name}"
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getGreeting(person: Person): String = "Hello, ${person.name}"
|
||||||
|
fun getGreeting(person: Person) = "Hello, ${person.name}"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Higher Order Functions
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
fun callbackIfTrue(condition: Boolean, callback: () -> Unit) {
|
||||||
|
if (condition) {
|
||||||
|
callback()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
callbackIfTrue(someBoolean) {
|
||||||
|
print("Condition was true")
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Extension Functions
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
fun Int.timesTwo(): Int {
|
||||||
|
return this * 2
|
||||||
|
}
|
||||||
|
|
||||||
|
val four = 2.timesTwo()
|
||||||
|
```
|
||||||
|
|
||||||
|
### Default Parameters
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
fun getGreeting(person: Person, intro: String = "Hello,") {
|
||||||
|
return "$intro ${person.name}"
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns "Hello, Adam"
|
||||||
|
val hello = getGreeting(Person("Adam"))
|
||||||
|
|
||||||
|
// Returns "Welcome, Adam"
|
||||||
|
val welcome = getGreeting(Person("Adam"), "Welcome,")
|
||||||
|
```
|
||||||
|
|
||||||
|
### Named Parameters
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
class Person(val name: String = "", age: Int = 0)
|
||||||
|
|
||||||
|
// All valid
|
||||||
|
val person = Person()
|
||||||
|
val person = Person("Adam", 100)
|
||||||
|
val person = Person(name = "Adam", age = 100)
|
||||||
|
val person = Person(age = 100)
|
||||||
|
val person = Person(age = 100, name = "Adam")
|
||||||
|
```
|
||||||
|
|
||||||
|
### Static Functions
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
class Fragment(val args: Bundle) {
|
||||||
|
companion object {
|
||||||
|
fun newInstance(args: Bundle): Fragment {
|
||||||
|
return Fragment(args)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val fragment = Fragment.newInstance(args)
|
||||||
|
```
|
||||||
|
|
||||||
|
* [Companion Objects](https://kotlinlang.org/docs/reference/object-declarations.html#companion-objects)
|
||||||
|
|
||||||
|
Classes
|
||||||
|
-------
|
||||||
|
{: .-two-column}
|
||||||
|
|
||||||
|
### Primary Constructor
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
class Person(val name: String, val age: Int)
|
||||||
|
val adam = Person("Adam", 100)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Secondary Constructors
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
class Person(val name: String) {
|
||||||
|
private var age: Int? = null
|
||||||
|
|
||||||
|
constructor(name: String, age: Int) : this(name) {
|
||||||
|
this.age = age
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Above can be replaced with default params
|
||||||
|
class Person(val name: String, val age: Int? = null)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Inheritance & Implementation
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
open class Vehicle
|
||||||
|
class Car : Vehicle()
|
||||||
|
|
||||||
|
interface Runner {
|
||||||
|
fun run()
|
||||||
|
}
|
||||||
|
|
||||||
|
class Machine : Runner {
|
||||||
|
override fun run() {
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Control Flow
|
||||||
|
------------
|
||||||
|
{: .-two-column}
|
||||||
|
|
||||||
|
### If Statements
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
if (someBoolean) {
|
||||||
|
doThing()
|
||||||
|
} else {
|
||||||
|
doOtherThing()
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### For Loops
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
for (i in 0..10) { } // 1 - 10
|
||||||
|
for (i in 0 until 10) // 1 - 9
|
||||||
|
(0..10).forEach { }
|
||||||
|
for (i in 0 until 10 step 2) // 0, 2, 4, 6, 8
|
||||||
|
```
|
||||||
|
|
||||||
|
### When Statements
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
when (direction) {
|
||||||
|
NORTH -> {
|
||||||
|
print("North")
|
||||||
|
}
|
||||||
|
SOUTH -> print("South")
|
||||||
|
EAST, WEST -> print("East or West")
|
||||||
|
"N/A" -> print("Unavailable")
|
||||||
|
else -> print("Invalid Direction")
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### While Loops
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
while (x > 0) {
|
||||||
|
x--
|
||||||
|
}
|
||||||
|
|
||||||
|
do {
|
||||||
|
x--
|
||||||
|
} while (x > 0)
|
||||||
|
```
|
||||||
|
|
||||||
|
Destructuring Declarations
|
||||||
|
--------------------------
|
||||||
|
{: .-two-column}
|
||||||
|
|
||||||
|
### Objects & Lists
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
val person = Person("Adam", 100)
|
||||||
|
val (name, age) = person
|
||||||
|
|
||||||
|
val pair = Pair(1, 2)
|
||||||
|
val (first, second) = pair
|
||||||
|
|
||||||
|
val coordinates = arrayOf(1, 2, 3)
|
||||||
|
val (x, y, z) = coordinates
|
||||||
|
```
|
||||||
|
|
||||||
|
### ComponentN Functions
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
class Person(val name: String, val age: Int) {
|
||||||
|
operator fun component1(): String {
|
||||||
|
return name
|
||||||
|
}
|
||||||
|
|
||||||
|
operator fun component2(): Int {
|
||||||
|
return age
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
References
|
||||||
|
----------
|
||||||
|
{: .-one-column}
|
||||||
|
|
||||||
|
* [Defining Variables](https://kotlinlang.org/docs/reference/basic-syntax.html#defining-variables) _(kotlinlang.org)_
|
||||||
|
* [Strings Documentation](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) _(kotlinlang.org)_
|
||||||
|
* [String Templates](https://kotlinlang.org/docs/reference/basic-types.html#string-templates) _(kotlinlang.org)_
|
||||||
|
* [Basic Types](https://kotlinlang.org/docs/reference/basic-types.html) _(kotlinlang.org)_
|
||||||
|
* [Companion Objects](https://kotlinlang.org/docs/reference/object-declarations.html#companion-objects) _(kotlinlang.org)_
|
||||||
|
* [Null Safety](https://kotlinlang.org/docs/reference/null-safety.html) _(kotlinlang.org)_
|
||||||
|
* [Collections Overview](https://kotlinlang.org/docs/reference/collections.html) _(kotlinlang.org)_
|
||||||
|
* [Collections Documentation](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/index.html) _(kotlinlang.org)_
|
||||||
|
* [Functions Documentation](https://kotlinlang.org/docs/reference/functions.html) _(kotlinlang.org)_
|
||||||
|
* [Classes Documentation](https://kotlinlang.org/docs/reference/classes.html) _(kotlinlang.org)_
|
||||||
|
* [Destructuring Declarations](https://kotlinlang.org/docs/reference/multi-declarations.html) _(kotlinlang.org)_
|
2
lua.md
2
lua.md
|
@ -32,7 +32,7 @@ title: Lua
|
||||||
|
|
||||||
-- Remember, arrays are also tables
|
-- Remember, arrays are also tables
|
||||||
array = { "a", "b", "c", "d" }
|
array = { "a", "b", "c", "d" }
|
||||||
print(array[2]) -- "b" (zero-indexed)
|
print(array[2]) -- "b" (one-indexed)
|
||||||
print(#array) -- 4 (length)
|
print(#array) -- 4 (length)
|
||||||
|
|
||||||
## Loops
|
## Loops
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
---
|
---
|
||||||
title: Makefile
|
title: Makefile
|
||||||
hljs_languages: [makefile]
|
prism_languages: [makefile]
|
||||||
layout: 2017/sheet
|
layout: 2017/sheet
|
||||||
|
category: CLI
|
||||||
---
|
---
|
||||||
|
|
||||||
## Var assignment
|
## Var assignment
|
||||||
|
|
27
markdown.md
27
markdown.md
|
@ -14,6 +14,7 @@ weight: -1
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
# h1
|
# h1
|
||||||
|
## h2
|
||||||
### h3
|
### h3
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -43,6 +44,18 @@ __bold__
|
||||||
`code`
|
`code`
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Lists
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
* Item 1
|
||||||
|
* Item 2
|
||||||
|
```
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
- Item 1
|
||||||
|
- Item 2
|
||||||
|
```
|
||||||
|
|
||||||
### Links
|
### Links
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
|
@ -109,3 +122,17 @@ codeFences.withLanguage()
|
||||||
```markdown
|
```markdown
|
||||||
****
|
****
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Tables
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
| Column 1 Heading | Column 2 Heading |
|
||||||
|
| ---------------- | ---------------- |
|
||||||
|
| Some content | Other content |
|
||||||
|
```
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
Column 1 Heading | Column 2 Heading
|
||||||
|
--- | ---
|
||||||
|
Some content | Other content
|
||||||
|
```
|
||||||
|
|
21
moment.md
21
moment.md
|
@ -9,19 +9,20 @@ tags: [Featurable]
|
||||||
### Parsing
|
### Parsing
|
||||||
|
|
||||||
```js
|
```js
|
||||||
m = moment("2013-03-01", "YYYY-MM-DD")
|
m = moment('2013-03-01', 'YYYY-MM-DD')
|
||||||
```
|
```
|
||||||
|
|
||||||
This parses the given date using the given format. Returns a moment object.
|
This parses the given date using the given format. Returns a moment object.
|
||||||
|
|
||||||
### Formatting
|
### Formatting
|
||||||
|
|
||||||
```js
|
```js
|
||||||
m
|
m
|
||||||
.format()
|
.format()
|
||||||
.format('dddd')
|
.format('dddd')
|
||||||
.format("MMM Do YY") // → "Sep 2nd 07"
|
.format('MMM Do YY') // → "Sep 2nd 07"
|
||||||
.fromNow() // → "31 minutes ago"
|
.fromNow() // → "31 minutes ago"
|
||||||
.calendar() // → "Last Friday at 9:32PM"
|
.calendar() // → "Last Friday at 9:32PM"
|
||||||
```
|
```
|
||||||
|
|
||||||
### Add
|
### Add
|
||||||
|
@ -56,6 +57,12 @@ See [datetime](./datetime) for more.
|
||||||
|
|
||||||
## References
|
## References
|
||||||
|
|
||||||
* [Datetime cheatsheet](./datetime) _(devhints.io)_
|
### Alternatives
|
||||||
* [Moment website](http://momentjs.com/) _(momentjs.com)_
|
|
||||||
* [Moment docs](http://momentjs.com/docs/) _(momentjs.com)_
|
* [You don't need Moment.js](https://github.com/you-dont-need/You-Dont-Need-Momentjs) _(github.com)_
|
||||||
|
|
||||||
|
### Also see
|
||||||
|
|
||||||
|
* [Datetime cheatsheet](./datetime) _(devhints.io)_
|
||||||
|
* [Moment website](http://momentjs.com/) _(momentjs.com)_
|
||||||
|
* [Moment docs](http://momentjs.com/docs/) _(momentjs.com)_
|
||||||
|
|
|
@ -0,0 +1,163 @@
|
||||||
|
---
|
||||||
|
title: MySql
|
||||||
|
category: Databases
|
||||||
|
---
|
||||||
|
### Create / Delete Database
|
||||||
|
CREATE DATABASE dbNameYouWant
|
||||||
|
CREATE DATABASE dbNameYouWant CHARACTER SET utf8
|
||||||
|
DROP DATABASE dbNameYouWant
|
||||||
|
ALTER DATABASE dbNameYouWant CHARACTER SET utf8
|
||||||
|
|
||||||
|
### Backup Database to SQL File
|
||||||
|
mysqldump -u Username -p dbNameYouWant > databasename_backup.sql
|
||||||
|
|
||||||
|
### Restore from backup SQL File
|
||||||
|
mysql - u Username -p dbNameYouWant < databasename_backup.sql
|
||||||
|
|
||||||
|
### Repair Tables After Unclean Shutdown
|
||||||
|
mysqlcheck --all-databases
|
||||||
|
mysqlcheck --all-databases --fast
|
||||||
|
### Browsing
|
||||||
|
SHOW DATABASES
|
||||||
|
SHOW TABLES
|
||||||
|
SHOW FIELDS FROM table / DESCRIBE table
|
||||||
|
SHOW CREATE TABLE table
|
||||||
|
SHOW PROCESSLIST
|
||||||
|
KILL process_number
|
||||||
|
|
||||||
|
### Select
|
||||||
|
SELECT * FROM table
|
||||||
|
SELECT * FROM table1, table2, ...
|
||||||
|
SELECT field1, field2, ... FROM table1, table2, ...
|
||||||
|
SELECT ... FROM ... WHERE condition
|
||||||
|
SELECT ... FROM ... WHERE condition GROUPBY field
|
||||||
|
SELECT ... FROM ... WHERE condition GROUPBY field HAVING condition2
|
||||||
|
SELECT ... FROM ... WHERE condition ORDER BY field1, field2
|
||||||
|
SELECT ... FROM ... WHERE condition ORDER BY field1, field2 DESC
|
||||||
|
SELECT ... FROM ... WHERE condition LIMIT 10
|
||||||
|
SELECT DISTINCT field1 FROM ...
|
||||||
|
SELECT DISTINCT field1, field2 FROM ...
|
||||||
|
|
||||||
|
### Select - Join
|
||||||
|
SELECT ... FROM t1 JOIN t2 ON t1.id1 = t2.id2 WHERE condition
|
||||||
|
SELECT ... FROM t1 LEFT JOIN t2 ON t1.id1 = t2.id2 WHERE condition
|
||||||
|
SELECT ... FROM t1 JOIN (t2 JOIN t3 ON ...) ON ...
|
||||||
|
|
||||||
|
### Conditions
|
||||||
|
field1 = value1
|
||||||
|
field1 <> value1
|
||||||
|
field1 LIKE 'value _ %'
|
||||||
|
field1 IS NULL
|
||||||
|
field1 IS NOT NULL
|
||||||
|
field1 IS IN (value1, value2)
|
||||||
|
field1 IS NOT IN (value1, value2)
|
||||||
|
condition1 AND condition2
|
||||||
|
condition1 OR condition2
|
||||||
|
|
||||||
|
### Insert
|
||||||
|
INSERT INTO table1 (field1, field2, ...) VALUES (value1, value2, ...)
|
||||||
|
|
||||||
|
### Delete
|
||||||
|
DELETE FROM table1 / TRUNCATE table1
|
||||||
|
DELETE FROM table1 WHERE condition
|
||||||
|
DELETE FROM table1, table2 FROM table1, table2 WHERE table1.id1 =
|
||||||
|
table2.id2 AND condition
|
||||||
|
|
||||||
|
### Update
|
||||||
|
|
||||||
|
UPDATE table1 SET field1=new_value1 WHERE condition
|
||||||
|
UPDATE table1, table2 SET field1=new_value1, field2=new_value2, ... WHERE
|
||||||
|
table1.id1 = table2.id2 AND condition
|
||||||
|
|
||||||
|
### Create / Delete / Modify Table
|
||||||
|
|
||||||
|
*Create*
|
||||||
|
CREATE TABLE table (field1 type1, field2 type2, ...)
|
||||||
|
CREATE TABLE table (field1 type1, field2 type2, ..., INDEX (field))
|
||||||
|
CREATE TABLE table (field1 type1, field2 type2, ..., PRIMARY KEY (field1))
|
||||||
|
CREATE TABLE table (field1 type1, field2 type2, ..., PRIMARY KEY (field1,
|
||||||
|
field2))
|
||||||
|
|
||||||
|
CREATE TABLE table1 (fk_field1 type1, field2 type2, ...,
|
||||||
|
FOREIGN KEY (fk_field1) REFERENCES table2 (t2_fieldA))
|
||||||
|
[ON UPDATE|ON DELETE] [CASCADE|SET NULL]
|
||||||
|
|
||||||
|
CREATE TABLE table1 (fk_field1 type1, fk_field2 type2, ...,
|
||||||
|
FOREIGN KEY (fk_field1, fk_field2) REFERENCES table2 (t2_fieldA, t2_fieldB))
|
||||||
|
|
||||||
|
CREATE TABLE table IF NOT EXISTS (...)
|
||||||
|
|
||||||
|
CREATE TEMPORARY TABLE table (...)
|
||||||
|
|
||||||
|
*Drop*
|
||||||
|
DROP TABLE table
|
||||||
|
DROP TABLE IF EXISTS table
|
||||||
|
DROP TABLE table1, table2, ...
|
||||||
|
|
||||||
|
*Alter*
|
||||||
|
ALTER TABLE table MODIFY field1 type1
|
||||||
|
ALTER TABLE table MODIFY field1 type1 NOT NULL ...
|
||||||
|
ALTER TABLE table CHANGE old_name_field1 new_name_field1 type1
|
||||||
|
ALTER TABLE table CHANGE old_name_field1 new_name_field1 type1 NOT NULL ...
|
||||||
|
ALTER TABLE table ALTER field1 SET DEFAULT ...
|
||||||
|
ALTER TABLE table ALTER field1 DROP DEFAULT
|
||||||
|
ALTER TABLE table ADD new_name_field1 type1
|
||||||
|
ALTER TABLE table ADD new_name_field1 type1 FIRST
|
||||||
|
ALTER TABLE table ADD new_name_field1 type1 AFTER another_field
|
||||||
|
ALTER TABLE table DROP field1
|
||||||
|
ALTER TABLE table ADD INDEX (field);
|
||||||
|
|
||||||
|
*Change field order*
|
||||||
|
ALTER TABLE table MODIFY field1 type1 FIRST
|
||||||
|
ALTER TABLE table MODIFY field1 type1 AFTER another_field
|
||||||
|
ALTER TABLE table CHANGE old_name_field1 new_name_field1 type1 FIRST
|
||||||
|
ALTER TABLE table CHANGE old_name_field1 new_name_field1 type1 AFTER
|
||||||
|
another_field
|
||||||
|
|
||||||
|
### Keys
|
||||||
|
CREATE TABLE table (..., PRIMARY KEY (field1, field2))
|
||||||
|
CREATE TABLE table (..., FOREIGN KEY (field1, field2) REFERENCES table2
|
||||||
|
(t2_field1, t2_field2))
|
||||||
|
|
||||||
|
|
||||||
|
### Users and Privileges
|
||||||
|
GRANT ALL PRIVILEGES ON base.* TO 'user'@'localhost' IDENTIFIED BY 'password';
|
||||||
|
GRANT SELECT, INSERT, DELETE ON base.* TO 'user'@'localhost' IDENTIFIED BY 'password';
|
||||||
|
REVOKE ALL PRIVILEGES ON base.* FROM 'user'@'host'; -- one permission only
|
||||||
|
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user'@'host'; -- all permissions
|
||||||
|
|
||||||
|
SET PASSWORD = PASSWORD('new_pass')
|
||||||
|
SET PASSWORD FOR 'user'@'host' = PASSWORD('new_pass')
|
||||||
|
SET PASSWORD = OLD_PASSWORD('new_pass')
|
||||||
|
|
||||||
|
DROP USER 'user'@'host'
|
||||||
|
host ‘%’ indicates any host.
|
||||||
|
|
||||||
|
|
||||||
|
### Main Data Types
|
||||||
|
TINYINT (1o: -217+128) SMALLINT (2o: +-65 000)
|
||||||
|
MEDIUMINT (3o: +-16 000 000) INT (4o: +- 2 000 000 000)
|
||||||
|
BIGINT (8o: +-9.10^18)
|
||||||
|
|
||||||
|
Precise interval: -(2^(8*N-1)) -> (2^8*N)-1
|
||||||
|
/!\ INT(2) = "2 digits displayed" -- NOT "number with 2 digits max"
|
||||||
|
|
||||||
|
FLOAT(M,D) DOUBLE(M,D) FLOAT(D=0->53)
|
||||||
|
/!\ 8,3 -> 12345,678 -- NOT 12345678,123!
|
||||||
|
|
||||||
|
TIME (HH:MM) YEAR (AAAA) DATE (AAAA-MM-JJ) DATETIME (AAAA-MM-JJ HH:MM; années 1000->9999)
|
||||||
|
TIMESTAMP (like DATETIME, but 1970->2038, compatible with Unix)
|
||||||
|
|
||||||
|
VARCHAR (single-line; explicit size) TEXT (multi-lines; max size=65535) BLOB (binary; max size=65535)
|
||||||
|
Variants for TEXT&BLOB: TINY (max=255) MEDIUM (max=~16000) LONG (max=4Go)
|
||||||
|
Ex: VARCHAR(32), TINYTEXT, LONGBLOB, MEDIUMTEXT
|
||||||
|
|
||||||
|
ENUM ('value1', 'value2', ...) -- (default NULL, or '' if NOT NULL)
|
||||||
|
|
||||||
|
### Reset Root Password
|
||||||
|
$ /etc/init.d/mysql stop
|
||||||
|
$ mysqld_safe --skip-grant-tables
|
||||||
|
$ mysql # on another terminal
|
||||||
|
mysql> UPDATE mysql.user SET password=PASSWORD('new_pass') WHERE user='root';
|
||||||
|
## Switch back to the mysqld_safe terminal and kill the process using Control + \
|
||||||
|
$ /etc/init.d/mysql start</code>
|
1
osx.md
1
osx.md
|
@ -1,6 +1,7 @@
|
||||||
---
|
---
|
||||||
title: OS X
|
title: OS X
|
||||||
layout: 2017/sheet
|
layout: 2017/sheet
|
||||||
|
category: macOS
|
||||||
---
|
---
|
||||||
|
|
||||||
### Locations of startup items
|
### Locations of startup items
|
||||||
|
|
|
@ -3,6 +3,7 @@ title: Parsley.js
|
||||||
updated: 2017-10-19
|
updated: 2017-10-19
|
||||||
weight: -1
|
weight: -1
|
||||||
layout: 2017/sheet
|
layout: 2017/sheet
|
||||||
|
category: JavaScript libraries
|
||||||
keywords:
|
keywords:
|
||||||
- "data-parsley-validate"
|
- "data-parsley-validate"
|
||||||
- "$('#form').parsley()"
|
- "$('#form').parsley()"
|
||||||
|
|
|
@ -14,26 +14,22 @@ intro: |
|
||||||
```html
|
```html
|
||||||
<script src="https://cdn.polyfill.io/v2/polyfill.min.js"></script>
|
<script src="https://cdn.polyfill.io/v2/polyfill.min.js"></script>
|
||||||
```
|
```
|
||||||
|
|
||||||
{: .-wrap}
|
{: .-wrap}
|
||||||
|
|
||||||
This is the default script for Polyfill.io.
|
This is the default script for Polyfill.io.
|
||||||
|
|
||||||
### References
|
### References
|
||||||
|
|
||||||
- [API example](https://polyfill.io/v2/docs/api) _(polyfill.io)_
|
* [API example](https://polyfill.io/v2/docs/api) _(polyfill.io)_
|
||||||
- [List of features](https://polyfill.io/v2/docs/features) _(polyfill.io)_
|
* [List of features](https://polyfill.io/v2/docs/features) _(polyfill.io)_
|
||||||
|
|
||||||
## Optimized
|
## Optimized
|
||||||
|
|
||||||
### For modern browsers
|
### For modern browsers
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<script>(function(d,s){
|
<script>if(!(window.Promise&&[].includes&&Object.assign&&window.Map)){document.write('<script src="https://cdn.polyfill.io/v2/polyfill.min.js"></scr'+'ipt>')}</script>
|
||||||
if(window.Promise&&[].includes&&Object.assign&&window.Map)return;
|
|
||||||
var sc=d.getElementsByTagName(s)[0],js=d.createElement(s);
|
|
||||||
js.src='https://cdn.polyfill.io/v2/polyfill.min.js';
|
|
||||||
sc.parentNode.insertBefore(js, sc);
|
|
||||||
}(document,'script'))</script>
|
|
||||||
```
|
```
|
||||||
|
|
||||||
This only includes polyfill.io when necessary, skipping it for modern browsers for faster load times.
|
This only includes polyfill.io when necessary, skipping it for modern browsers for faster load times.
|
||||||
|
@ -41,13 +37,7 @@ This only includes polyfill.io when necessary, skipping it for modern browsers f
|
||||||
### Extra features
|
### Extra features
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<script>(function(d,s){
|
<script>if(!(window.fetch&&window.Promise&&[].includes&&Object.assign&&window.Map)){document.write('<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=default,fetch"></scr'+'ipt>')}</script>
|
||||||
if(window.fetch&&window.Promise&&[].includes&&Object.assign&&window.Map)return;
|
|
||||||
var sc=d.getElementsByTagName(s)[0],js=d.createElement(s);
|
|
||||||
js.src='https://cdn.polyfill.io/v2/polyfill.min.js?features=default,fetch';
|
|
||||||
sc.parentNode.insertBefore(js, sc);
|
|
||||||
}(document,'script'))</script>
|
|
||||||
```
|
```
|
||||||
{: data-line="2,4"}
|
|
||||||
|
|
||||||
This is the same as the previous, but also adds a polyfill for `window.fetch()`. We add a `window.fetch` check and loads the additional `fetch` feature.
|
This is the same as the previous, but also adds a polyfill for `window.fetch()`. We add a `window.fetch` check and loads the additional `fetch` feature.
|
||||||
|
|
|
@ -3,6 +3,7 @@ title: PostgreSQL JSON
|
||||||
layout: 2017/sheet
|
layout: 2017/sheet
|
||||||
prism_languages: [sql]
|
prism_languages: [sql]
|
||||||
updated: 2017-09-22
|
updated: 2017-09-22
|
||||||
|
category: Databases
|
||||||
---
|
---
|
||||||
|
|
||||||
## Operators
|
## Operators
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
---
|
---
|
||||||
title: PostgreSQL
|
title: PostgreSQL
|
||||||
|
category: Databases
|
||||||
---
|
---
|
||||||
|
|
||||||
Replace anything within `<placeholder>` accordingly
|
Replace anything within `<placeholder>` accordingly
|
||||||
|
|
18
python.md
18
python.md
|
@ -1,5 +1,6 @@
|
||||||
---
|
---
|
||||||
title: Python
|
title: Python
|
||||||
|
category: Python
|
||||||
---
|
---
|
||||||
|
|
||||||
### Lists
|
### Lists
|
||||||
|
@ -15,19 +16,19 @@ title: Python
|
||||||
|
|
||||||
list.append(item)
|
list.append(item)
|
||||||
list.extend(another_list)
|
list.extend(another_list)
|
||||||
list.insert(0, item)
|
list.insert(index, item)
|
||||||
list.pop() # returns and removes last element from the list
|
list.pop() # returns and removes last element from the list
|
||||||
list.remove(i)
|
list.pop(i) # returns and removes i-th element from the list
|
||||||
|
list.remove(i) # removes the first item from the list whose value is i
|
||||||
list1 + list2 # combine two list
|
list1 + list2 # combine two list
|
||||||
set(list) # remove duplicate elements from a list
|
set(list) # remove duplicate elements from a list
|
||||||
|
|
||||||
list.reverse()
|
list.reverse() # reverses the elements of the list in-place
|
||||||
list.count(item)
|
list.count(item)
|
||||||
sum(list)
|
sum(list)
|
||||||
|
|
||||||
|
zip(list1, list2) # returns list of tuples with n-th element of both list1 and list2
|
||||||
list.sort() # sorts in-place, returns None
|
list.sort() # sorts in-place, returns None
|
||||||
|
|
||||||
zip(list1, list2)
|
|
||||||
sorted(list) # returns sorted copy of list
|
sorted(list) # returns sorted copy of list
|
||||||
",".join(list) # returns a string with list elements seperated by comma
|
",".join(list) # returns a string with list elements seperated by comma
|
||||||
|
|
||||||
|
@ -43,9 +44,11 @@ title: Python
|
||||||
### Iteration
|
### Iteration
|
||||||
|
|
||||||
for item in ["a", "b", "c"]:
|
for item in ["a", "b", "c"]:
|
||||||
for i in range(4): # 0 to 3
|
for i in range(4): # 0 to 3
|
||||||
for i in range(4, 8): # 4 to 7
|
for i in range(4, 8): # 4 to 7
|
||||||
|
for i in range(1, 9, 2): # 1, 3, 5, 7
|
||||||
for key, val in dict.items():
|
for key, val in dict.items():
|
||||||
|
for index, item in enumerate(list):
|
||||||
|
|
||||||
### [String](https://docs.python.org/2/library/stdtypes.html#string-methods)
|
### [String](https://docs.python.org/2/library/stdtypes.html#string-methods)
|
||||||
|
|
||||||
|
@ -76,6 +79,7 @@ title: Python
|
||||||
float(str)
|
float(str)
|
||||||
str(int)
|
str(int)
|
||||||
str(float)
|
str(float)
|
||||||
|
'string'.encode()
|
||||||
|
|
||||||
### Comprehensions
|
### Comprehensions
|
||||||
|
|
||||||
|
|
102
react.md
102
react.md
|
@ -4,7 +4,7 @@ category: React
|
||||||
layout: 2017/sheet
|
layout: 2017/sheet
|
||||||
ads: true
|
ads: true
|
||||||
tags: [Featured]
|
tags: [Featured]
|
||||||
updated: 2017-10-10
|
updated: 2018-10-04
|
||||||
weight: -10
|
weight: -10
|
||||||
keywords:
|
keywords:
|
||||||
- React.Component
|
- React.Component
|
||||||
|
@ -48,20 +48,36 @@ ReactDOM.render(<Hello name='John' />, el)
|
||||||
|
|
||||||
Use the [React.js jsfiddle](http://jsfiddle.net/reactjs/69z2wepo/) to start hacking. (or the unofficial [jsbin](http://jsbin.com/yafixat/edit?js,output))
|
Use the [React.js jsfiddle](http://jsfiddle.net/reactjs/69z2wepo/) to start hacking. (or the unofficial [jsbin](http://jsbin.com/yafixat/edit?js,output))
|
||||||
|
|
||||||
|
### Import multiple exports
|
||||||
|
{: .-prime}
|
||||||
|
|
||||||
|
```jsx
|
||||||
|
import React, {Component} from 'react'
|
||||||
|
import ReactDOM from 'react-dom'
|
||||||
|
```
|
||||||
|
{: .-setup}
|
||||||
|
|
||||||
|
```jsx
|
||||||
|
class Hello extends Component {
|
||||||
|
...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### Properties
|
### Properties
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<Video fullscreen={true} />
|
<Video fullscreen={true} autoplay={false} />
|
||||||
```
|
```
|
||||||
{: .-setup}
|
{: .-setup}
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
render () {
|
render () {
|
||||||
this.props.fullscreen
|
this.props.fullscreen
|
||||||
|
const { fullscreen, autoplay } = this.props
|
||||||
···
|
···
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
{: data-line="2"}
|
{: data-line="2,3"}
|
||||||
|
|
||||||
Use `this.props` to access properties passed to the component.
|
Use `this.props` to access properties passed to the component.
|
||||||
|
|
||||||
|
@ -72,7 +88,7 @@ See: [Properties](https://reactjs.org/docs/tutorial.html#using-props)
|
||||||
```jsx
|
```jsx
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
this.state = {}
|
this.state = { username: undefined }
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -83,19 +99,30 @@ this.setState({ username: 'rstacruz' })
|
||||||
```jsx
|
```jsx
|
||||||
render () {
|
render () {
|
||||||
this.state.username
|
this.state.username
|
||||||
|
const { username } = this.state
|
||||||
···
|
···
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
{: data-line="2"}
|
{: data-line="2,3"}
|
||||||
|
|
||||||
Use states (`this.state`) to manage dynamic data.
|
Use states (`this.state`) to manage dynamic data.
|
||||||
|
|
||||||
|
With [Babel](https://babeljs.io/) you can use [proposal-class-fields](https://github.com/tc39/proposal-class-fields) and get rid of constructor
|
||||||
|
|
||||||
|
```jsx
|
||||||
|
class Hello extends Component {
|
||||||
|
state = { username: undefined };
|
||||||
|
...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
See: [States](https://reactjs.org/docs/tutorial.html#reactive-state)
|
See: [States](https://reactjs.org/docs/tutorial.html#reactive-state)
|
||||||
|
|
||||||
|
|
||||||
### Nesting
|
### Nesting
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
class Info extends React.Component {
|
class Info extends Component {
|
||||||
render () {
|
render () {
|
||||||
const { avatar, username } = this.props
|
const { avatar, username } = this.props
|
||||||
|
|
||||||
|
@ -109,15 +136,20 @@ class Info extends React.Component {
|
||||||
As of React v16.2.0, fragments can be used to return multiple children without adding extra wrapping nodes to the DOM.
|
As of React v16.2.0, fragments can be used to return multiple children without adding extra wrapping nodes to the DOM.
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
class Info extends React.Component {
|
import React, {
|
||||||
|
Component,
|
||||||
|
Fragment
|
||||||
|
} from 'react'
|
||||||
|
|
||||||
|
class Info extends Component {
|
||||||
render () {
|
render () {
|
||||||
const { avatar, username } = this.props
|
const { avatar, username } = this.props
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<Fragment>
|
||||||
<UserAvatar src={avatar} />
|
<UserAvatar src={avatar} />
|
||||||
<UserProfile username={username} />
|
<UserProfile username={username} />
|
||||||
</React.Fragment>
|
</Fragment>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,7 +172,7 @@ See: [Composing Components](https://reactjs.org/docs/components-and-props.html#c
|
||||||
{: data-line="2"}
|
{: data-line="2"}
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
class AlertBox extends React.Component {
|
class AlertBox extends Component {
|
||||||
render () {
|
render () {
|
||||||
return <div className='alert-box'>
|
return <div className='alert-box'>
|
||||||
{this.props.children}
|
{this.props.children}
|
||||||
|
@ -169,7 +201,7 @@ See: [defaultProps](https://reactjs.org/docs/react-component.html#defaultprops)
|
||||||
### Setting default state
|
### Setting default state
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
class Hello extends React.Component {
|
class Hello extends Component {
|
||||||
constructor (props) {
|
constructor (props) {
|
||||||
super(props)
|
super(props)
|
||||||
this.state = { visible: true }
|
this.state = { visible: true }
|
||||||
|
@ -180,13 +212,24 @@ class Hello extends React.Component {
|
||||||
|
|
||||||
Set the default state in the `constructor()`.
|
Set the default state in the `constructor()`.
|
||||||
|
|
||||||
|
And without constructor using [Babel](https://babeljs.io/) with [proposal-class-fields](https://github.com/tc39/proposal-class-fields).
|
||||||
|
|
||||||
|
```jsx
|
||||||
|
class Hello extends Component {
|
||||||
|
state = { visible: true }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
{: data-line="2"}
|
||||||
|
|
||||||
See: [Setting the default state](https://reactjs.org/docs/react-without-es6.html#setting-the-initial-state)
|
See: [Setting the default state](https://reactjs.org/docs/react-without-es6.html#setting-the-initial-state)
|
||||||
|
|
||||||
Other components
|
Other components
|
||||||
----------------
|
----------------
|
||||||
{: .-three-column}
|
{: .-three-column}
|
||||||
|
|
||||||
### Function components
|
### Functional components
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
function MyComponent ({ name }) {
|
function MyComponent ({ name }) {
|
||||||
|
@ -204,11 +247,13 @@ See: [Function and Class Components](https://reactjs.org/docs/components-and-pro
|
||||||
### Pure components
|
### Pure components
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
class MessageBox extends React.PureComponent {
|
import React, {PureComponent} from 'react'
|
||||||
|
|
||||||
|
class MessageBox extends PureComponent {
|
||||||
···
|
···
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
{: data-line="1"}
|
{: data-line="3"}
|
||||||
|
|
||||||
Performance-optimized version of `React.Component`. Doesn't rerender if props/state hasn't changed.
|
Performance-optimized version of `React.Component`. Doesn't rerender if props/state hasn't changed.
|
||||||
|
|
||||||
|
@ -222,6 +267,7 @@ this.forceUpdate()
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
this.setState({ ... })
|
this.setState({ ... })
|
||||||
|
this.setState(state => { ... })
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
|
@ -257,9 +303,8 @@ Add DOM event handlers, timers (etc) on `componentDidMount()`, then remove them
|
||||||
|
|
||||||
| Method | Description |
|
| Method | Description |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| `componentWillReceiveProps` *(newProps)* | Use `setState()` here |
|
| `componentDidUpdate` *(prevProps, prevState, snapshot)* | Use `setState()` here, but remember to compare props |
|
||||||
| `shouldComponentUpdate` *(newProps, newState)* | Skips `render()` if returns false |
|
| `shouldComponentUpdate` *(newProps, newState)* | Skips `render()` if returns false |
|
||||||
| `componentWillUpdate` *(newProps, newState)* | Can't use `setState()` here |
|
|
||||||
| `render()` | Render |
|
| `render()` | Render |
|
||||||
| `componentDidUpdate` *(prevProps, prevState)* | Operate on the DOM here |
|
| `componentDidUpdate` *(prevProps, prevState)* | Operate on the DOM here |
|
||||||
|
|
||||||
|
@ -274,7 +319,7 @@ DOM nodes
|
||||||
### References
|
### References
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
class MyComponent extends React.Component {
|
class MyComponent extends Component {
|
||||||
render () {
|
render () {
|
||||||
return <div>
|
return <div>
|
||||||
<input ref={el => this.input = el} />
|
<input ref={el => this.input = el} />
|
||||||
|
@ -295,7 +340,7 @@ See: [Refs and the DOM](https://reactjs.org/docs/refs-and-the-dom.html)
|
||||||
### DOM Events
|
### DOM Events
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
class MyComponent extends React.Component {
|
class MyComponent extends Component {
|
||||||
render () {
|
render () {
|
||||||
<input type="text"
|
<input type="text"
|
||||||
value={this.state.value}
|
value={this.state.value}
|
||||||
|
@ -323,7 +368,7 @@ See: [Events](https://reactjs.org/docs/events.html)
|
||||||
{: .-setup}
|
{: .-setup}
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
class VideoPlayer extends React.Component {
|
class VideoPlayer extends Component {
|
||||||
render () {
|
render () {
|
||||||
return <VideoEmbed {...this.props} />
|
return <VideoEmbed {...this.props} />
|
||||||
}
|
}
|
||||||
|
@ -363,7 +408,7 @@ JSX patterns
|
||||||
### Style shorthand
|
### Style shorthand
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
var style = { height: 10 }
|
const style = { height: 10 }
|
||||||
return <div style={style}></div>
|
return <div style={style}></div>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -385,7 +430,7 @@ See: [Dangerously set innerHTML](https://reactjs.org/tips/dangerously-set-inner-
|
||||||
### Lists
|
### Lists
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
class TodoList extends React.Component {
|
class TodoList extends Component {
|
||||||
render () {
|
render () {
|
||||||
const { items } = this.props
|
const { items } = this.props
|
||||||
|
|
||||||
|
@ -403,19 +448,20 @@ Always supply a `key` property.
|
||||||
### Conditionals
|
### Conditionals
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
<div>
|
<Fragment>
|
||||||
{showMyComponent
|
{showMyComponent
|
||||||
? <MyComponent />
|
? <MyComponent />
|
||||||
: <OtherComponent />}
|
: <OtherComponent />}
|
||||||
</div>
|
</Fragment>
|
||||||
```
|
```
|
||||||
|
|
||||||
### Short-circuit evaluation
|
### Short-circuit evaluation
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
<div>
|
<Fragment>
|
||||||
{showPopup && <Popup />}
|
{showPopup && <Popup />}
|
||||||
</div>
|
...
|
||||||
|
</Fragment>
|
||||||
```
|
```
|
||||||
|
|
||||||
New features
|
New features
|
||||||
|
@ -444,10 +490,10 @@ render () {
|
||||||
render () {
|
render () {
|
||||||
// Fragments don't require keys!
|
// Fragments don't require keys!
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<Fragment>
|
||||||
<li>First item</li>
|
<li>First item</li>
|
||||||
<li>Second item</li>
|
<li>Second item</li>
|
||||||
</React.Fragment>
|
</Fragment>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -471,7 +517,7 @@ See: [Fragments and strings](https://reactjs.org/blog/2017/09/26/react-v16.0.htm
|
||||||
### Errors
|
### Errors
|
||||||
|
|
||||||
```js
|
```js
|
||||||
class MyComponent extends React.Component {
|
class MyComponent extends Component {
|
||||||
···
|
···
|
||||||
componentDidCatch (error, info) {
|
componentDidCatch (error, info) {
|
||||||
this.setState({ error })
|
this.setState({ error })
|
||||||
|
|
61
regexp.md
61
regexp.md
|
@ -1,12 +1,59 @@
|
||||||
---
|
---
|
||||||
title: Regexp
|
title: regexp
|
||||||
|
category: Others
|
||||||
|
layout: 2017/sheet
|
||||||
|
weight: -1
|
||||||
|
authors:
|
||||||
|
- github: rizqyhi
|
||||||
|
updated: 2018-10-26
|
||||||
|
description: |
|
||||||
|
Basic cheatsheets for regular expression
|
||||||
---
|
---
|
||||||
|
|
||||||
(?P<named_match>...)
|
### Character Classes
|
||||||
(?:invisible group)
|
|
||||||
|
|
||||||
(?!negative look-ahead)
|
| Pattern | Description |
|
||||||
(?=positive look-ahead)
|
| --- | --- |
|
||||||
(?<!negative look-behind)
|
| `.` | Any character, except newline |
|
||||||
(?<=positive look-behind)
|
| `\w` | Word |
|
||||||
|
| `\d` | Digit |
|
||||||
|
| `\s` | Whitespace |
|
||||||
|
| `\W` | Not word |
|
||||||
|
| `\d` | Not digit |
|
||||||
|
| `\S` | Not whitespace |
|
||||||
|
| `[abc]` | Any of a, b, or c |
|
||||||
|
| `[a-e]` | Characters between `a` and `e` |
|
||||||
|
| `[1-9]` | Digit between `1` and `9` |
|
||||||
|
|
||||||
|
### Anchors
|
||||||
|
|
||||||
|
| Pattern | Description |
|
||||||
|
| --- | --- |
|
||||||
|
| `^abc` | Start with `abc` |
|
||||||
|
| `abc$` | End with `abc` |
|
||||||
|
|
||||||
|
### Escaped Characters
|
||||||
|
|
||||||
|
| Pattern | Description |
|
||||||
|
| --- | --- |
|
||||||
|
| `\. \* \\` | Escape special character used by regex |
|
||||||
|
| `\t` | Tab |
|
||||||
|
| `\n` | Newline |
|
||||||
|
| `\r` | Carriage return |
|
||||||
|
|
||||||
|
### Groups
|
||||||
|
|
||||||
|
| Pattern | Description |
|
||||||
|
| --- | --- |
|
||||||
|
| `(abc)` | Capture group |
|
||||||
|
|
||||||
|
### Quantifiers
|
||||||
|
|
||||||
|
| Pattern | Description |
|
||||||
|
| --- | --- |
|
||||||
|
| `a*` | Match 0 or more |
|
||||||
|
| `a+` | Match 1 or more |
|
||||||
|
| `a?` | Match 0 or 1 |
|
||||||
|
| `a{5}` | Match exactly 5 |
|
||||||
|
| `a{3,}` | Match 3 or more |
|
||||||
|
| `a{1,3}` | Match between 1 and 3 |
|
||||||
|
|
7
rsync.md
7
rsync.md
|
@ -9,7 +9,10 @@ weight: -1
|
||||||
{: .-prime}
|
{: .-prime}
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
# syncing folder src into dest:
|
||||||
rsync -avz ./src /dest
|
rsync -avz ./src /dest
|
||||||
|
# syncing the content of src into dest:
|
||||||
|
rsync -avz ./src/ /dest
|
||||||
```
|
```
|
||||||
|
|
||||||
### OSX
|
### OSX
|
||||||
|
@ -25,6 +28,7 @@ rsync -avz ./src /dest
|
||||||
```bash
|
```bash
|
||||||
-z, --compress
|
-z, --compress
|
||||||
-n, --dry-run
|
-n, --dry-run
|
||||||
|
--partial # allows resuming of aborted syncs
|
||||||
```
|
```
|
||||||
|
|
||||||
### Display options
|
### Display options
|
||||||
|
@ -34,6 +38,7 @@ rsync -avz ./src /dest
|
||||||
-v, --verbose
|
-v, --verbose
|
||||||
-h, --human-readable
|
-h, --human-readable
|
||||||
--progress
|
--progress
|
||||||
|
-P # same as --partial --progress
|
||||||
```
|
```
|
||||||
|
|
||||||
### Skipping options
|
### Skipping options
|
||||||
|
@ -61,7 +66,7 @@ rsync -avz ./src /dest
|
||||||
```bash
|
```bash
|
||||||
--exclude-from=FILE
|
--exclude-from=FILE
|
||||||
--include-from=FILE
|
--include-from=FILE
|
||||||
--files-from=FILE # read list of filenames from FILe
|
--files-from=FILE # read list of filenames from FILE
|
||||||
```
|
```
|
||||||
|
|
||||||
### Archive options
|
### Archive options
|
||||||
|
|
37
sass.md
37
sass.md
|
@ -66,7 +66,7 @@ h1 {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Mixin properties
|
#### with parameters
|
||||||
|
|
||||||
```scss
|
```scss
|
||||||
@mixin font-size($n) {
|
@mixin font-size($n) {
|
||||||
|
@ -80,6 +80,39 @@ body {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### with default values
|
||||||
|
|
||||||
|
```scss
|
||||||
|
@mixin pad($n: 10px) {
|
||||||
|
padding: $n;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
```scss
|
||||||
|
body {
|
||||||
|
@include pad(15px);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### with a default variable
|
||||||
|
|
||||||
|
```scss
|
||||||
|
// Set a default value
|
||||||
|
$default-padding: 10px;
|
||||||
|
```
|
||||||
|
|
||||||
|
```scss
|
||||||
|
@mixin pad($n: $default-padding) {
|
||||||
|
padding: $n;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
```scss
|
||||||
|
body {
|
||||||
|
@include pad(15px);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### Extend
|
### Extend
|
||||||
|
|
||||||
```scss
|
```scss
|
||||||
|
@ -133,7 +166,7 @@ grayscale($color)
|
||||||
|
|
||||||
```scss
|
```scss
|
||||||
adjust-hue($color, 15deg)
|
adjust-hue($color, 15deg)
|
||||||
compliment($color) // like adjust-hue(_, 180deg)
|
complement($color) // like adjust-hue(_, 180deg)
|
||||||
invert($color)
|
invert($color)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
title: Semver
|
title: Semver
|
||||||
layout: 2017/sheet
|
layout: 2017/sheet
|
||||||
updated: 2018-01-15
|
updated: 2018-08-23
|
||||||
weight: -3
|
weight: -3
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -93,4 +93,4 @@ When the left is partial (eg, `1.2`), missing pieces are assumed to be `0` (eg,
|
||||||
{: .-one-column}
|
{: .-one-column}
|
||||||
|
|
||||||
* <http://semver.org/>
|
* <http://semver.org/>
|
||||||
* <https://www.npmjs.org/doc/misc/semver.html>
|
* <https://docs.npmjs.com/misc/semver>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
---
|
---
|
||||||
title: SQL joins
|
title: SQL joins
|
||||||
layout: 2017/sheet
|
layout: 2017/sheet
|
||||||
|
category: Databases
|
||||||
updated: 2017-10-30
|
updated: 2017-10-30
|
||||||
weight: -1
|
weight: -1
|
||||||
---
|
---
|
||||||
|
|
1
tig.md
1
tig.md
|
@ -42,6 +42,7 @@ You can substitute `git log` → `tig`.
|
||||||
| `m` | Main view |
|
| `m` | Main view |
|
||||||
| `s` | Status |
|
| `s` | Status |
|
||||||
| `t` | Tree (files) |
|
| `t` | Tree (files) |
|
||||||
|
| `y` | Stash view |
|
||||||
| `g` | Grep |
|
| `g` | Grep |
|
||||||
| `h` | Help |
|
| `h` | Help |
|
||||||
{: .-shortcuts}
|
{: .-shortcuts}
|
||||||
|
|
19
tmux.md
19
tmux.md
|
@ -1,5 +1,6 @@
|
||||||
---
|
---
|
||||||
title: tmux
|
title: tmux
|
||||||
|
category: CLI
|
||||||
---
|
---
|
||||||
|
|
||||||
### Commands
|
### Commands
|
||||||
|
@ -8,7 +9,23 @@ title: tmux
|
||||||
-u # UTF8 mode
|
-u # UTF8 mode
|
||||||
-S ~/.tmux.socket
|
-S ~/.tmux.socket
|
||||||
|
|
||||||
$ tmux attach
|
#### Sessions
|
||||||
|
|
||||||
|
$ tmux new
|
||||||
|
$ tmux new -s session_name
|
||||||
|
|
||||||
|
$ tmux attach # Default session
|
||||||
|
$ tmux attach -s session_name
|
||||||
|
|
||||||
|
$ tmux switch -t session_name
|
||||||
|
|
||||||
|
$ tmux ls # List sessions
|
||||||
|
|
||||||
|
$ tmux detach
|
||||||
|
|
||||||
|
#### Windows
|
||||||
|
|
||||||
|
$ tmux new-window
|
||||||
|
|
||||||
### Help
|
### Help
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
---
|
---
|
||||||
title: Travis.yml
|
title: Travis.yml
|
||||||
|
category: Devops
|
||||||
---
|
---
|
||||||
|
|
||||||
### Node
|
### Node
|
||||||
|
|
1
umdjs.md
1
umdjs.md
|
@ -1,5 +1,6 @@
|
||||||
---
|
---
|
||||||
title: Universal JS module loader
|
title: Universal JS module loader
|
||||||
|
category: JavaScript libraries
|
||||||
---
|
---
|
||||||
|
|
||||||
### [With dependency](https://github.com/umdjs/umd/blob/master/amdWebGlobal.js)
|
### [With dependency](https://github.com/umdjs/umd/blob/master/amdWebGlobal.js)
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
---
|
||||||
|
title: Vimdiff
|
||||||
|
category: Vim
|
||||||
|
layout: 2017/sheet
|
||||||
|
updated: 2017-08-26
|
||||||
|
weight: -10
|
||||||
|
intro: |
|
||||||
|
[Vim](http://www.vim.org/) is a very efficient text editor. This reference was made for Vim 8.0.
|
||||||
|
---
|
||||||
|
|
||||||
|
Getting started
|
||||||
|
---------------
|
||||||
|
{: .-three-column}
|
||||||
|
|
||||||
|
### Navigating
|
||||||
|
{: .-prime}
|
||||||
|
|
||||||
|
| Shortcut | Description |
|
||||||
|
| --- | --- |
|
||||||
|
| `]c` | Next difference |
|
||||||
|
| `[c` | Previous difference |
|
||||||
|
{: .-shortcuts}
|
||||||
|
|
||||||
|
### Editing
|
||||||
|
|
||||||
|
| Shortcut | Description |
|
||||||
|
| --- | --- |
|
||||||
|
| `do` | Diff Obtain! <br>Pull the changes to the current file. |
|
||||||
|
| `dp` | Diff Put! <br>Push the changes to the other file. |
|
||||||
|
| --- | --- |
|
||||||
|
| `:diffupdate` | Re-scan the files for differences. |
|
||||||
|
| `ZQ` | Quit without checking changes |
|
||||||
|
{: .-shortcuts}
|
||||||
|
|
||||||
|
### Folds
|
||||||
|
|
||||||
|
| Shortcut | Description |
|
||||||
|
| --- | --- |
|
||||||
|
| `zo` _/_ `zO` | Open |
|
||||||
|
| `zc` _/_ `zC` | Close |
|
||||||
|
| `za` _/_ `zA` | Toggle |
|
||||||
|
| --- | --- |
|
||||||
|
| `zv` | Open folds for this line |
|
||||||
|
| --- | --- |
|
||||||
|
| `zM` | Close all |
|
||||||
|
| `zR` | Open all |
|
||||||
|
| --- | --- |
|
||||||
|
| `zm` | Fold more _(foldlevel += 1)_ |
|
||||||
|
| `zr` | Fold less _(foldlevel -= 1)_ |
|
||||||
|
| --- | --- |
|
||||||
|
| `zx` | Update folds |
|
||||||
|
{: .-shortcuts}
|
||||||
|
|
||||||
|
|
||||||
|
Also see
|
||||||
|
--------
|
||||||
|
|
||||||
|
- [Vim cheatsheet](https://vim.rtorr.com/) _(vim.rotrr.com)_
|
||||||
|
- [Vim documentation](http://vimdoc.sourceforge.net/htmldoc/) _(vimdoc.sourceforge.net)_
|
||||||
|
- [Interactive Vim tutorial](http://openvim.com/) _(openvim.com)_
|
115
vim.md
115
vim.md
|
@ -3,10 +3,11 @@ title: Vim
|
||||||
category: Vim
|
category: Vim
|
||||||
layout: 2017/sheet
|
layout: 2017/sheet
|
||||||
tags: [Featured]
|
tags: [Featured]
|
||||||
updated: 2017-08-26
|
updated: 2018-09-11
|
||||||
weight: -10
|
weight: -10
|
||||||
intro: |
|
intro: |
|
||||||
[Vim](http://www.vim.org/) is a very efficient text editor. This reference was made for Vim 8.0.
|
[Vim](http://www.vim.org/) is a very efficient text editor. This reference was made for Vim 8.0.
|
||||||
|
For shortcut notation, see `:help key-notation`.
|
||||||
---
|
---
|
||||||
|
|
||||||
Getting started
|
Getting started
|
||||||
|
@ -33,14 +34,18 @@ Getting started
|
||||||
|
|
||||||
### Navigating
|
### Navigating
|
||||||
|
|
||||||
| `h` `j` `k` `l` | Arrow keys |
|
| Shortcut | Description |
|
||||||
| `<C-U>` _/_ `<C-D>` | Page up/page down |
|
| --- | --- |
|
||||||
|
| `h` `j` `k` `l` | Arrow keys |
|
||||||
|
| `<C-U>` _/_ `<C-D>` | Page up/page down |
|
||||||
{: .-shortcuts}
|
{: .-shortcuts}
|
||||||
|
|
||||||
#### Words
|
#### Words
|
||||||
|
|
||||||
| `b` _/_ `w` | Previous/next word |
|
| Shortcut | Description |
|
||||||
| `e` _/_ `ge` | Previous/next end of word |
|
| --- | --- |
|
||||||
|
| `b` _/_ `w` | Previous/next word |
|
||||||
|
| `e` _/_ `ge` | Previous/next end of word |
|
||||||
{: .-shortcuts}
|
{: .-shortcuts}
|
||||||
|
|
||||||
#### Line
|
#### Line
|
||||||
|
@ -78,6 +83,18 @@ Getting started
|
||||||
| `L` | Move to bottom of screen |
|
| `L` | Move to bottom of screen |
|
||||||
{: .-shortcuts}
|
{: .-shortcuts}
|
||||||
|
|
||||||
|
#### Tab pages
|
||||||
|
|
||||||
|
| Shortcut | Description |
|
||||||
|
| --- | --- |
|
||||||
|
| `:tabedit [file]` | Edit file in a new tab |
|
||||||
|
| `:tabfind [file]` | Open file if exists in new tab |
|
||||||
|
| `:tabclose` | Close current tab |
|
||||||
|
| `:tabs` | List all tabs |
|
||||||
|
| `:tabfirst` | Go to first tab |
|
||||||
|
| `:tablast` | Go to last tab |
|
||||||
|
| `:tabn ` | Go to next tab |
|
||||||
|
| `:tabp ` | Go to previous tab |
|
||||||
|
|
||||||
### Editing
|
### Editing
|
||||||
|
|
||||||
|
@ -94,14 +111,17 @@ Getting started
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| `r` | Replace one character |
|
| `r` | Replace one character |
|
||||||
| `R` | Enter Replace mode |
|
| `R` | Enter Replace mode |
|
||||||
|
| --- | --- |
|
||||||
|
| `u` | Undo changes |
|
||||||
|
| `<C-R>` | Redo changes |
|
||||||
{: .-shortcuts}
|
{: .-shortcuts}
|
||||||
|
|
||||||
### Exiting insert mode
|
### Exiting insert mode
|
||||||
|
|
||||||
| Shortcut | Description |
|
| Shortcut | Description |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| `Esc` _/_ `<C-[>` | Exit insert mode |
|
| `Esc` _/_ `<C-[>` | Exit insert mode |
|
||||||
| `<C-C>` | Exit insert mode, and abort current command |
|
| `<C-C>` | Exit insert mode, and abort current command |
|
||||||
{: .-shortcuts}
|
{: .-shortcuts}
|
||||||
|
|
||||||
### Clipboard
|
### Clipboard
|
||||||
|
@ -119,13 +139,17 @@ Getting started
|
||||||
|
|
||||||
### Visual mode
|
### Visual mode
|
||||||
|
|
||||||
| `v` | Enter visual mode |
|
| Shortcut | Description |
|
||||||
| `V` | Enter visual line mode |
|
| --- | --- |
|
||||||
| `<C-V>` | Enter visual block mode |
|
| `v` | Enter visual mode |
|
||||||
|
| `V` | Enter visual line mode |
|
||||||
|
| `<C-V>` | Enter visual block mode |
|
||||||
{: .-shortcuts}
|
{: .-shortcuts}
|
||||||
|
|
||||||
#### In visual mode
|
#### In visual mode
|
||||||
|
|
||||||
|
| Shortcut | Description |
|
||||||
|
| --- | --- |
|
||||||
| `d` _/_ `x` | Delete selection |
|
| `d` _/_ `x` | Delete selection |
|
||||||
| `s` | Replace selection |
|
| `s` | Replace selection |
|
||||||
| `y` | Yank selection _(Copy)_ |
|
| `y` | Yank selection _(Copy)_ |
|
||||||
|
@ -229,6 +253,13 @@ Text objects let you operate (with an *operator*) in or around text blocks (*obj
|
||||||
|
|
||||||
See [Operators](#operators) for other things you can do.
|
See [Operators](#operators) for other things you can do.
|
||||||
|
|
||||||
|
### Diff
|
||||||
|
|
||||||
|
| Shortcut | Description |
|
||||||
|
| --- | --- |
|
||||||
|
| `gvimdiff file1 file2 [file3]` | See differencies between files, in HMI |
|
||||||
|
|
||||||
|
|
||||||
Misc
|
Misc
|
||||||
----
|
----
|
||||||
|
|
||||||
|
@ -257,27 +288,29 @@ Uppercase ones are recursive (eg, `zO` is open recursively).
|
||||||
|
|
||||||
| Shortcut | Description |
|
| Shortcut | Description |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| `[(` `[{` `[<` | previous `(` or `{` or `<` |
|
| `[(` `[{` `[<` | Previous `(` or `{` or `<` |
|
||||||
| `])` | next |
|
| `])` | Next |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| `[m` | previous method start |
|
| `[m` | Previous method start |
|
||||||
| `[M` | previous method end |
|
| `[M` | Previous method end |
|
||||||
{: .-shortcuts}
|
{: .-shortcuts}
|
||||||
|
|
||||||
### Jumping
|
### Jumping
|
||||||
|
|
||||||
| Shortcut | Description |
|
| Shortcut | Description |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| `<C-O>` | Go back to previous location |
|
| `<C-O>` | Go back to previous location |
|
||||||
| `<C-I>` | Go forward |
|
| `<C-I>` | Go forward |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| `gf` | go to file in cursor |
|
| `gf` | Go to file in cursor |
|
||||||
{: .-shortcuts}
|
{: .-shortcuts}
|
||||||
|
|
||||||
### Counters
|
### Counters
|
||||||
|
|
||||||
| `<C-A>` | increment number |
|
| Shortcut | Description |
|
||||||
| `<C-X>` | decrement |
|
| --- | --- |
|
||||||
|
| `<C-A>` | Increment number |
|
||||||
|
| `<C-X>` | Decrement |
|
||||||
{: .-shortcuts}
|
{: .-shortcuts}
|
||||||
|
|
||||||
### Windows
|
### Windows
|
||||||
|
@ -303,12 +336,12 @@ Uppercase ones are recursive (eg, `zO` is open recursively).
|
||||||
|
|
||||||
| Shortcut | Description |
|
| Shortcut | Description |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| `~` | toggle case (Case => cASE) |
|
| `~` | Toggle case (Case => cASE) |
|
||||||
| `gU` | uppercase |
|
| `gU` | Uppercase |
|
||||||
| `gu` | lowercase |
|
| `gu` | Lowercase |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| `gUU` | uppercase current line (also `gUgU`) |
|
| `gUU` | Uppercase current line (also `gUgU`) |
|
||||||
| `guu` | lowercase current line (also `gugu`) |
|
| `guu` | Lowercase current line (also `gugu`) |
|
||||||
{: .-shortcuts}
|
{: .-shortcuts}
|
||||||
|
|
||||||
Do these in visual or normal mode.
|
Do these in visual or normal mode.
|
||||||
|
@ -330,16 +363,17 @@ Do these in visual or normal mode.
|
||||||
|
|
||||||
| Shortcut | Description |
|
| Shortcut | Description |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| `.` | repeat last command |
|
| `.` | Repeat last command |
|
||||||
| `]p` | paste under the current indentation level |
|
| `]p` | Paste under the current indentation level |
|
||||||
{: .-shortcuts}
|
{: .-shortcuts}
|
||||||
|
|
||||||
### Command line
|
### Command line
|
||||||
|
|
||||||
| Shortcut | Description |
|
| Shortcut | Description |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| `<C-R><C-W>` | insert current word into the command line |
|
| `<C-R><C-W>` | Insert current word into the command line |
|
||||||
| `<C-R>"` | paste from " register |
|
| `<C-R>"` | Paste from " register |
|
||||||
|
| `<C-X><C-F>` | Auto-completion of path in insert mode |
|
||||||
{: .-shortcuts}
|
{: .-shortcuts}
|
||||||
|
|
||||||
### Text alignment
|
### Text alignment
|
||||||
|
@ -352,7 +386,9 @@ See `:help formatting`
|
||||||
|
|
||||||
### Calculator
|
### Calculator
|
||||||
|
|
||||||
<C-R>=128/2
|
| Shortcut | Description |
|
||||||
|
| --- | --- |
|
||||||
|
| `<C-R>=128/2` | Shows the result of the division : '64' |
|
||||||
|
|
||||||
Do this in insert mode.
|
Do this in insert mode.
|
||||||
|
|
||||||
|
@ -363,6 +399,23 @@ Do this in insert mode.
|
||||||
|
|
||||||
Works like `:qa`, but throws an error. Great for aborting Git commands.
|
Works like `:qa`, but throws an error. Great for aborting Git commands.
|
||||||
|
|
||||||
|
|
||||||
|
### Spell checking
|
||||||
|
|
||||||
|
| Shortcut | Description |
|
||||||
|
| --- | --- |
|
||||||
|
| `:set spell spelllang=en_us` | Turn on US English spell checking |
|
||||||
|
| `]s` | Move to next misspelled word after the cursor |
|
||||||
|
| `[s` | Move to previous misspelled word before the cursor |
|
||||||
|
| `z=` | Suggest spellings for the word under/after the cursor |
|
||||||
|
| `zg` | Add word to spell list |
|
||||||
|
| `zw` | Mark word as bad/mispelling |
|
||||||
|
| `zu` / `C-X (Insert Mode)` | Suggest words for bad word under cursor from spellfile |
|
||||||
|
{: .-shortcuts}
|
||||||
|
|
||||||
|
See `:help spell`
|
||||||
|
|
||||||
|
|
||||||
Also see
|
Also see
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
|
69
wip/php.md
69
wip/php.md
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
title: PHP
|
title: PHP
|
||||||
category: Other
|
category: PHP
|
||||||
layout: 2017/sheet
|
layout: 2017/sheet
|
||||||
prism_languages: [php]
|
prism_languages: [php]
|
||||||
---
|
---
|
||||||
|
@ -28,12 +28,22 @@ See: [PHP tags](http://php.net/manual/en/language.basic-syntax.phptags.php)
|
||||||
```php
|
```php
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$fruits = array(
|
$fruitsArray = array(
|
||||||
"apple" => 20,
|
"apple" => 20,
|
||||||
"banana" => 30
|
"banana" => 30
|
||||||
)
|
);
|
||||||
|
echo $fruitsArray['banana'];
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Or cast as object
|
||||||
|
|
||||||
|
```php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$fruitsObject = (object) $fruits;
|
||||||
|
echo $fruitsObject->banana;
|
||||||
|
```
|
||||||
|
|
||||||
### Inspecting objects
|
### Inspecting objects
|
||||||
|
|
||||||
```php
|
```php
|
||||||
|
@ -44,3 +54,56 @@ var_dump($object)
|
||||||
Prints the contents of a variable for inspection.
|
Prints the contents of a variable for inspection.
|
||||||
|
|
||||||
See: [var_dump](http://php.net/var_dump)
|
See: [var_dump](http://php.net/var_dump)
|
||||||
|
|
||||||
|
### Classes
|
||||||
|
|
||||||
|
```php
|
||||||
|
class Person {
|
||||||
|
public $name = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$person = new Person();
|
||||||
|
$person->name = 'bob';
|
||||||
|
|
||||||
|
echo $person->name;
|
||||||
|
```
|
||||||
|
|
||||||
|
### Getters and setters
|
||||||
|
|
||||||
|
```php
|
||||||
|
class Person
|
||||||
|
{
|
||||||
|
public $name = '';
|
||||||
|
|
||||||
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setName($name)
|
||||||
|
{
|
||||||
|
$this->name = $name;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$person = new Person();
|
||||||
|
$person->setName('bob');
|
||||||
|
|
||||||
|
echo $person->getName();
|
||||||
|
```
|
||||||
|
|
||||||
|
### isset vs empty
|
||||||
|
```php
|
||||||
|
|
||||||
|
$options = [
|
||||||
|
'key' => 'value',
|
||||||
|
'blank' => '',
|
||||||
|
'nothing' => null,
|
||||||
|
];
|
||||||
|
|
||||||
|
var_dump(isset($options['key']), empty($options['key'])); // true, false
|
||||||
|
var_dump(isset($options['blank']), empty($options['blank'])); // true, true
|
||||||
|
var_dump(isset($options['nothing']), empty($options['nothing'])); // false, true
|
||||||
|
|
||||||
|
```
|
||||||
|
|
1
yarn.md
1
yarn.md
|
@ -16,6 +16,7 @@ tags: [Featurable]
|
||||||
| `npm install gulp --save` | `yarn add gulp` |
|
| `npm install gulp --save` | `yarn add gulp` |
|
||||||
| `npm install gulp --save-dev --save-exact` | `yarn add gulp --dev --exact` |
|
| `npm install gulp --save-dev --save-exact` | `yarn add gulp --dev --exact` |
|
||||||
| `npm install -g gulp` | `yarn global add gulp` |
|
| `npm install -g gulp` | `yarn global add gulp` |
|
||||||
|
| `npm update` | `yarn upgrade` |
|
||||||
| `./node_modules/.bin/gulp` | `yarn run gulp` |
|
| `./node_modules/.bin/gulp` | `yarn run gulp` |
|
||||||
{: .-left-align.-headers}
|
{: .-left-align.-headers}
|
||||||
|
|
||||||
|
|
8
zsh.md
8
zsh.md
|
@ -27,6 +27,14 @@ layout: 2017/sheet
|
||||||
chsh -s `which zsh`
|
chsh -s `which zsh`
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Process Substitution
|
||||||
|
|
||||||
|
| Expression | Example | Description
|
||||||
|
| --- | --- | ---
|
||||||
|
| `<(COMMAND)` | `grep "needle" <(curl "https://haystack.io")` | Replace argument with _named pipe/FIFO_ (read-only) with command output
|
||||||
|
| `=(COMMAND)` | `vim =(curl "https://haystack.io")` | Replace argument with _file_ (writable) containing command output
|
||||||
|
{: .-headers}
|
||||||
|
|
||||||
### Also see
|
### Also see
|
||||||
|
|
||||||
- [Bash cheatsheet](./bash)
|
- [Bash cheatsheet](./bash)
|
||||||
|
|
Loading…
Reference in New Issue