diff --git a/Readme.md b/Readme.md index f822efab92..b0e366a951 100644 --- a/Readme.md +++ b/Readme.md @@ -38,5 +38,6 @@ title: React.js category: React layout: 2017/sheet # 'default' | '2017/sheet' ads: false # Add this to disable ads +updated: 201708 # To show in the updated list --- ``` diff --git a/_config.yml b/_config.yml index 0c69df5f21..691b32d85e 100644 --- a/_config.yml +++ b/_config.yml @@ -69,3 +69,5 @@ category_names: # https://help.github.com/articles/repository-metadata-on-github-pages/ repository: rstacruz/cheatsheets + +last_updated: 201708 diff --git a/_layouts/2017/home.html b/_layouts/2017/home.html index e35c5291dc..746d991e9c 100644 --- a/_layouts/2017/home.html +++ b/_layouts/2017/home.html @@ -30,6 +30,16 @@

{% endif %} {% endfor %} +

+ Recently updated +

+ + {% for page in site.pages %} + {% if page.updated >= site.last_updated %} + {% include 2017/pages-list-item.html page=page class='article item' %} + {% endif %} + {% endfor %} + {% for category in site.category_names %}

{{ category }} diff --git a/_layouts/redirect.html b/_layouts/redirect.html index 95df2f1e34..5aaedf9ec3 100644 --- a/_layouts/redirect.html +++ b/_layouts/redirect.html @@ -1,5 +1,5 @@ -{% assign target = {{ page.redirect.to | remove: '.html' | replace: 'cheatsheets/cheatsheets', 'cheatsheets' %} +{% assign target = page.redirect.to | remove: '.html' | replace: 'cheatsheets/cheatsheets', 'cheatsheets' %} Redirecting… diff --git a/bash.md b/bash.md index c2336c771a..acdf2f873c 100644 --- a/bash.md +++ b/bash.md @@ -3,9 +3,6 @@ title: Bash scripting category: CLI layout: 2017/sheet tags: [Featured] -redirect_from: - - /sh - - /sh.html --- Getting started diff --git a/cron.md b/cron.md index 452e744222..dc802a3a8a 100644 --- a/cron.md +++ b/cron.md @@ -2,6 +2,7 @@ title: Cron category: CLI layout: 2017/sheet +updated: 201708 --- ## Format diff --git a/elixir.md b/elixir.md index d833c7520b..2f34fc4d90 100644 --- a/elixir.md +++ b/elixir.md @@ -2,6 +2,8 @@ title: Elixir category: Elixir layout: 2017/sheet +tags: [New] +updated: 201708 --- ## Reference diff --git a/es2015.md b/es2015.md new file mode 100644 index 0000000000..9ed33e134c --- /dev/null +++ b/es2015.md @@ -0,0 +1,5 @@ +--- +title: ES2015 +category: JavaScript +redirect_to: /es6 +--- diff --git a/es2016.md b/es2016.md new file mode 100644 index 0000000000..0bf29b4bbf --- /dev/null +++ b/es2016.md @@ -0,0 +1,5 @@ +--- +title: ES2016 +category: JavaScript +redirect_to: /es6 +--- diff --git a/es2017.md b/es2017.md new file mode 100644 index 0000000000..6cd6e7bf34 --- /dev/null +++ b/es2017.md @@ -0,0 +1,5 @@ +--- +title: ES2017 +category: JavaScript +redirect_to: /es6 +--- diff --git a/es6.md b/es6.md index 4113952158..912e946cf5 100644 --- a/es6.md +++ b/es6.md @@ -1,8 +1,8 @@ --- -title: ES2015 +title: ES2015+ category: JavaScript layout: 2017/sheet -ads: true +tags: [Featured] --- ### Promises diff --git a/exunit.md b/exunit.md index 5a57e8ae26..74493000e6 100644 --- a/exunit.md +++ b/exunit.md @@ -2,6 +2,7 @@ title: ExUnit category: Elixir layout: 2017/sheet +updated: 201708 --- ### Test cases diff --git a/flow.md b/flow.md new file mode 100644 index 0000000000..757de04831 --- /dev/null +++ b/flow.md @@ -0,0 +1,201 @@ +--- +title: Flow +layout: 2017/sheet +updated: 201708 +--- + +### Simple failing example + +```js +/* @flow */ + +function foo(x) { return x * 10 } +foo('Hello, world!') +``` + +### Annotations + +```js +// Simple +function foo(x: string, y: number): string { ... } +``` + +```js +// Arrays +function total(numbers: Array) { ... } +``` + +### Primitives + +| Type | Description | +| --- | --- | +| `any` | | +| `boolean` | | +| `mixed` | | +| `number` | | +| `string` | | +| `void` | undefined | +| `null` | null (but not undefined) | +| --- | --- | +| `{a: Number}` | Object with a shape | +| `[any, number]` | Tuples (fixed-length arrays) | +| --- | --- | +| `Array` | | +| `Class` | | +| `Function` | | +| `Object` | | +| --- | --- | +| `?number` | Maybe (number, void, null) | +| `a | b` | Union types | + +### Dynamic keys + +```js +type Items = { + [key: string]: Item +} +``` + +See: [Dynamic object keys](https://flow.org/docs/objects.html#objects-as-maps) + +### Enums + +```js +type Suit = "Diamonds" | "Clubs" | "Hearts" | "Spades" + +const countries = { + US: "United States", + IT: "Italy", + FR: "France" +} + +type Country = $Keys +``` + +See: [Enums](https://flow.org/docs/utility-types.html#keyst) + +### Type aliases + +```js +type Tree = { + foo: string, + bar: number, + qux: (foo: string, bar: number) => boolean +} + +type Generic = { + foo: T +} +``` + +See: [Type aliases](https://flow.org/docs/quick-reference.html#type-aliases) + +### Generic classes + +```js +class GenericClass { + x: T + constructor (x: T) { ... } +} + +var n: GenericClass = new GenericClass(0) +``` + +See: [Generic classes](https://flow.org/docs/quick-reference.html#generics) + +### Interfaces + +```js +interface Jsonable { + toJSON(): string +} + +class Foo { + toJSON() { return '{}' } +} + +(new Foo: Jsonable) +``` + +See: [Interfaces](https://flow.org/docs/quick-reference.html#interfaces) + +### Functions + +```js +const callback: () => void = function () {} +``` + +```js +function filter ( + list: Array, + callback: (item: T) => boolean +): Array { + ··· +} +``` + +See: [Functions](https://flow.org/docs/functions.html) + +### Imports + +```js +import type { Person } from '../person' +import typeof Config from '../config' +``` + +```js +export type Person = { id: string } +``` + +### Comment syntax + +```js +/*:: + export type Foo = { ... } +*/ + +function add(n /*: number */) { ... } +``` + +### React + +```js +React$Element +``` + +```js +class Foo extends React.Component { + /*:: state: { open: boolean } */ + /*:: props: { open: boolean } */ +} +``` +## Examples + +### Examples + +```js +var myNumbers: Array = [42] +function foo(): any { return 42 } +var b: boolean = false +var b: ?boolean = false /* maybe */ +var b: string | boolean = false + +var a: Class = MyClass +var b: MyClass = new a() +``` + +### Function signature + +```js +var add: ((num1: number, num2: number) => number) = function (num1, num2) { + return num1 + num2 +} +``` + +You don't need to do this! It's inferred. This is better: + +```js +var add = function (num1: number, num2: number) { + return num1 + num2 +} +``` diff --git a/flowtype.md b/flowtype.md deleted file mode 100644 index 756396bfcc..0000000000 --- a/flowtype.md +++ /dev/null @@ -1,168 +0,0 @@ ---- -title: Flow ---- - -### Simple failing example - -```js -/* @flow */ - -function foo(x) { return x * 10; } -foo('Hello, world!'); -``` - -### Annotations - -```js -// Simple -function foo(x: string, y: number): string { ... } - -// Arrays -function total(numbers: Array) { ... } -``` - -### Primitives - -``` -any -boolean -mixed -number -string -void // undefined -null // null (but not undefined) - -?number // maybe (number | void | null) - -{a: Number} // object with a shape -[any, number] // tuples (fixed-length arrays) - -Array -Class -Function -Object -``` - -## [Dynamic object keys](https://flowtype.org/docs/objects.html#objects-as-maps) - -```js -type Items = { - [key: string]: Item -} -``` - -## [Enums](https://flowtype.org/docs/utility-types.html#keyst) - -```js -type Suit = "Diamonds" | "Clubs" | "Hearts" | "Spades" - -const countries = { - US: "United States", - IT: "Italy", - FR: "France" -} - -type Country = $Keys -``` - -## [Type aliases](https://flowtype.org/docs/quick-reference.html#type-aliases) - -```js -type Tree = { - foo: string, - bar: number, - qux: (foo: string, bar: number) => boolean -} - -type Generic = { - foo: T -} -``` - -## [Generic classes](https://flowtype.org/docs/quick-reference.html#generics) - -```js -class GenericClass { - x: T; - constructor (x: T) { ... } -} - -var n: GenericClass = new GenericClass(0) -``` - -## [Interfaces](https://flowtype.org/docs/quick-reference.html#interfaces) - -```js -interface Jsonable { - toJSON(): string -} - -class Foo { - toJSON() { return '{}' } -} - -(new Foo: Jsonable) -``` - -## [Functions](https://flowtype.org/docs/functions.html) - -```js -const callback: () => void = function () {} -``` - -```js -function filter (list: Array, callback: (item: T) => boolean): Array { -} -``` - -## Imports - -```js -import type { Person } from '../person' -import typeof Config from '../config' -``` - -```js -export type Person = { id: string } -``` - -## Examples - -```js -var myNumbers: Array = [42] -function foo(): any { return 42 } -var b: boolean = false -var b: ?boolean = false /* maybe */ -var b: string | boolean = false /* maybe */ - -var a: Class = MyClass -var b: MyClass = new a() - -// Function signature -var add: ((num1: number, num2: number) => number) = function(num1, num2) { - return num1 + num2; -}; -``` - -## Comment syntax - -```js -/*:: - export type Foo = { ... } -*/ - -function add(n /*: number */) { ... } -``` - -## React - -```js -React$Element -``` - -```js -class Foo extends React.Component { - /*:: state: { open: boolean } */ - /*:: props: { open: boolean } */ -} -``` diff --git a/homebrew.md b/homebrew.md index 151f618d79..219d996092 100644 --- a/homebrew.md +++ b/homebrew.md @@ -1,7 +1,6 @@ --- title: Homebrew layout: 2017/sheet -tags: [Featured] --- ### Commands diff --git a/html-meta.md b/html-meta.md index 7757f094ed..c999224825 100644 --- a/html-meta.md +++ b/html-meta.md @@ -1,7 +1,8 @@ --- -title: Meta tags +title: HTML meta tags category: HTML layout: 2017/sheet +updated: 201708 --- ### Meta tags diff --git a/sketch.md b/sketch.md index 69340d8ea3..5ea93028a8 100644 --- a/sketch.md +++ b/sketch.md @@ -2,6 +2,7 @@ title: Sketch category: Apps layout: 2017/sheet +updated: 201708 --- Shortcuts