Cleanup: formatting update (2020-07-05) (#1496)
This commit is contained in:
parent
6b43bf97da
commit
aff701a600
97
brunch.md
97
brunch.md
|
@ -1,97 +0,0 @@
|
||||||
---
|
|
||||||
title: Brunch
|
|
||||||
category: JavaScript libraries
|
|
||||||
---
|
|
||||||
|
|
||||||
## Paths
|
|
||||||
|
|
||||||
/
|
|
||||||
app/
|
|
||||||
assets/
|
|
||||||
vendor/
|
|
||||||
public/
|
|
||||||
config.coffee
|
|
||||||
|
|
||||||
## Config
|
|
||||||
|
|
||||||
```js
|
|
||||||
module.exports = {
|
|
||||||
files: {
|
|
||||||
javascripts: { # or 'stylesheets' or 'templates'
|
|
||||||
order: {
|
|
||||||
before: [ 'normalize.css' ],
|
|
||||||
after: [ 'helpers.css' ],
|
|
||||||
|
|
||||||
joinTo: 'app.js',
|
|
||||||
joinTo: {
|
|
||||||
'js/app.js': /^app/,
|
|
||||||
'js/vendor.js': /^vendor/
|
|
||||||
},
|
|
||||||
pluginHelpers: 'js/vendor.js'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
paths: {
|
|
||||||
public: 'public', # where to compile
|
|
||||||
watched: ['app','test','vendor'], # what to monitor
|
|
||||||
}
|
|
||||||
|
|
||||||
modules: {
|
|
||||||
wrapper: 'amd',
|
|
||||||
definition: 'amd',
|
|
||||||
nameCleaner: (path) => path.replace(/^app\//, '')
|
|
||||||
}
|
|
||||||
|
|
||||||
npm: { styles, globals }
|
|
||||||
|
|
||||||
plugins: {
|
|
||||||
sass: { ... }
|
|
||||||
}
|
|
||||||
|
|
||||||
// brunch w --apply testing
|
|
||||||
// BRUNCH_ENV=testing brunch build
|
|
||||||
overrides: {
|
|
||||||
production: {
|
|
||||||
optimize: true,
|
|
||||||
sourceMaps: false,
|
|
||||||
plugins: { autoReload: { enabled: false } }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onCompile: (files, assets) => { ... }
|
|
||||||
```
|
|
||||||
|
|
||||||
## Plugins
|
|
||||||
|
|
||||||
plugins:
|
|
||||||
uglify:
|
|
||||||
mangle: true
|
|
||||||
compress:
|
|
||||||
global_defs:
|
|
||||||
DEBUG: false
|
|
||||||
|
|
||||||
## Extensions
|
|
||||||
|
|
||||||
Compile to CSS
|
|
||||||
|
|
||||||
* stylus-brunch
|
|
||||||
* less-brunch
|
|
||||||
* sass-brunch
|
|
||||||
|
|
||||||
Compile to HTML
|
|
||||||
|
|
||||||
* static-jade-brunch
|
|
||||||
|
|
||||||
Embedded templates
|
|
||||||
|
|
||||||
* emblem-brunch
|
|
||||||
|
|
||||||
Etc
|
|
||||||
|
|
||||||
* uglify-js-brunch
|
|
||||||
* jshint-brunch
|
|
||||||
* imageoptimizer-brunch
|
|
||||||
|
|
||||||
## References
|
|
||||||
|
|
||||||
* <https://github.com/brunch/brunch/blob/master/docs/config.md>
|
|
|
@ -1,50 +1,72 @@
|
||||||
---
|
---
|
||||||
title: C Preprocessor
|
title: C Preprocessor
|
||||||
category: C-like
|
category: C-like
|
||||||
|
layout: 2017/sheet
|
||||||
|
intro: |
|
||||||
|
Quick reference for the [C macro preprocessor](https://en.m.wikipedia.org/wiki/C_preprocessor), which can be used independent of C/C++.
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## Reference
|
||||||
|
{: .-three-column}
|
||||||
|
|
||||||
### Compiling
|
### Compiling
|
||||||
|
|
||||||
$ cpp -P file > outfile
|
```
|
||||||
|
$ cpp -P file > outfile
|
||||||
|
```
|
||||||
|
|
||||||
### Includes
|
### Includes
|
||||||
|
|
||||||
#include "file"
|
```
|
||||||
|
#include "file"
|
||||||
|
```
|
||||||
|
|
||||||
### Defines
|
### Defines
|
||||||
|
|
||||||
#define FOO
|
```
|
||||||
#define FOO "hello"
|
#define FOO
|
||||||
|
#define FOO "hello"
|
||||||
|
|
||||||
#undef FOO
|
#undef FOO
|
||||||
|
```
|
||||||
|
|
||||||
### If
|
### If
|
||||||
|
|
||||||
#ifdef DEBUG
|
```
|
||||||
console.log('hi');
|
#ifdef DEBUG
|
||||||
#elif defined VERBOSE
|
console.log('hi');
|
||||||
...
|
#elif defined VERBOSE
|
||||||
#else
|
...
|
||||||
...
|
#else
|
||||||
#endif
|
...
|
||||||
|
#endif
|
||||||
|
```
|
||||||
|
|
||||||
### Error
|
### Error
|
||||||
|
|
||||||
#if VERSION == 2.0
|
```
|
||||||
#error Unsupported
|
#if VERSION == 2.0
|
||||||
#warning Not really supported
|
#error Unsupported
|
||||||
#endif
|
#warning Not really supported
|
||||||
|
#endif
|
||||||
|
```
|
||||||
|
|
||||||
### Macro
|
### Macro
|
||||||
|
|
||||||
#define DEG(x) ((x) * 57.29)
|
```
|
||||||
|
#define DEG(x) ((x) * 57.29)
|
||||||
|
```
|
||||||
|
|
||||||
### Token concat
|
### Token concat
|
||||||
|
|
||||||
#define DST(name) name##_s name##_t
|
```
|
||||||
DST(object); #=> "object_s object_t;"
|
#define DST(name) name##_s name##_t
|
||||||
|
DST(object); #=> "object_s object_t;"
|
||||||
|
```
|
||||||
|
|
||||||
### file and line
|
### file and line
|
||||||
|
|
||||||
#define LOG(msg) console.log(__FILE__, __LINE__, msg)
|
```
|
||||||
#=> console.log("file.txt", 3, "hey")
|
#define LOG(msg) console.log(__FILE__, __LINE__, msg)
|
||||||
|
#=> console.log("file.txt", 3, "hey")
|
||||||
|
```
|
||||||
|
|
12
deku.md
12
deku.md
|
@ -1,9 +1,12 @@
|
||||||
---
|
---
|
||||||
title: Deku v2
|
title: Deku v2
|
||||||
category: JavaScript libraries
|
category: JavaScript libraries
|
||||||
|
layout: 2017/sheet
|
||||||
|
intro: |
|
||||||
|
Quick reference for [Deku](https://www.npmjs.com/package/deku), a minimal virtual DOM library.
|
||||||
---
|
---
|
||||||
|
|
||||||
## Components
|
### Components
|
||||||
|
|
||||||
```js
|
```js
|
||||||
/** @jsx element */
|
/** @jsx element */
|
||||||
|
@ -29,7 +32,7 @@ function onRemove ({ props, dispatch, path }) { ... }
|
||||||
export default { render, onCreate, onRemove }
|
export default { render, onCreate, onRemove }
|
||||||
```
|
```
|
||||||
|
|
||||||
## Rendering
|
### Rendering
|
||||||
|
|
||||||
```js
|
```js
|
||||||
import { createStore } from 'redux'
|
import { createStore } from 'redux'
|
||||||
|
@ -42,8 +45,5 @@ let store = createStore(reducer)
|
||||||
let render = createRenderer(document.body, store.dispatch)
|
let render = createRenderer(document.body, store.dispatch)
|
||||||
|
|
||||||
// Update the page and add redux state to the context
|
// Update the page and add redux state to the context
|
||||||
render(
|
render(<MyButton>Hello World!</MyButton>, store.getState())
|
||||||
<MyButton>Hello World!</MyButton>,
|
|
||||||
store.getState()
|
|
||||||
)
|
|
||||||
```
|
```
|
||||||
|
|
32
deku@1.md
32
deku@1.md
|
@ -1,36 +1,47 @@
|
||||||
---
|
---
|
||||||
title: Deku v1
|
title: Deku v1
|
||||||
category: JavaScript libraries
|
category: JavaScript libraries
|
||||||
|
layout: 2017/sheet
|
||||||
|
intro: |
|
||||||
|
Quick reference for [Deku](https://www.npmjs.com/package/deku), a minimal virtual DOM library. **Deprecated:** This is for Deku v1. See [deku](./deku) for a more updated cheatsheet.
|
||||||
---
|
---
|
||||||
|
|
||||||
This is for Deku v1. See [deku](./deku) for a more updated cheatsheet.
|
### Example
|
||||||
|
|
||||||
```js
|
```js
|
||||||
/** @jsx element */
|
/** @jsx element */
|
||||||
import element from 'virtual-element' // replacement for React.createElement
|
import element from 'virtual-element' // replacement for React.createElement
|
||||||
import {render, tree} from 'deku'
|
import { render, tree } from 'deku'
|
||||||
|
|
||||||
var app = <div class='my-app'>Hello World!</div>
|
var app = <div class='my-app'>Hello World!</div>
|
||||||
|
|
||||||
render(tree(app), document.body)
|
render(tree(app), document.body)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Components
|
### Components
|
||||||
|
|
||||||
```js
|
```js
|
||||||
Button = {
|
Button = {
|
||||||
render () { return <button>Submit</button> }
|
render() {
|
||||||
|
return <button>Submit</button>
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
App = {
|
App = {
|
||||||
render () { return <div><Button /></div> }
|
render() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Button />
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render(tree(<App />), document.body)
|
render(tree(<App />), document.body)
|
||||||
render(tree(element(App)), document.body)
|
render(tree(element(App)), document.body)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Component props/state
|
### Component props/state
|
||||||
|
|
||||||
```js
|
```js
|
||||||
App = {
|
App = {
|
||||||
|
@ -50,13 +61,14 @@ App = {
|
||||||
render(tree(<App />), document.body)
|
render(tree(<App />), document.body)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Events
|
### Events
|
||||||
|
|
||||||
```js
|
```js
|
||||||
<a onClick={onClick}>{props.text}</a>
|
<a onClick={onClick}>{props.text}</a>
|
||||||
```
|
```
|
||||||
|
|
||||||
## Magic virtual element
|
### Magic virtual element
|
||||||
|
|
||||||
Use [magic-virtual-element](https://github.com/dekujs/magic-virtual-element) to enable nice classnames.
|
Use [magic-virtual-element](https://github.com/dekujs/magic-virtual-element) to enable nice classnames.
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -64,7 +76,7 @@ import element from 'magic-virtual-element'
|
||||||
<div style={style} class={[ 'button', '-active' ]}>
|
<div style={style} class={[ 'button', '-active' ]}>
|
||||||
```
|
```
|
||||||
|
|
||||||
## Reference
|
### Reference
|
||||||
|
|
||||||
```
|
```
|
||||||
name = 'MyComponent'
|
name = 'MyComponent'
|
||||||
|
|
50
dom-range.md
50
dom-range.md
|
@ -1,17 +1,23 @@
|
||||||
---
|
---
|
||||||
title: DOM Range
|
title: DOM Range
|
||||||
category: JavaScript
|
category: JavaScript
|
||||||
|
layout: 2017/sheet
|
||||||
|
intro: |
|
||||||
|
Quick reference to the HTML [DOM createRange API](https://devdocs.io/dom/range).
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## Reference
|
||||||
|
{:.-three-column}
|
||||||
|
|
||||||
### Creating ranges
|
### Creating ranges
|
||||||
See <http://devdocs.io/dom/document/createrange>
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
var range = document.createRange()
|
var range = document.createRange()
|
||||||
```
|
```
|
||||||
|
|
||||||
|
See: <https://devdocs.io/dom/document/createrange>
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
See <http://devdocs.io/dom/range>
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
range
|
range
|
||||||
|
@ -27,41 +33,41 @@ range
|
||||||
.selectNodeContents(node)
|
.selectNodeContents(node)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
See: <https://devdocs.io/dom/range>
|
||||||
|
|
||||||
### Collapsing
|
### Collapsing
|
||||||
|
|
||||||
```js
|
```js
|
||||||
range
|
range.collapse() // to end (a single point)
|
||||||
.collapse() // to end (a single point)
|
range.collapse(true) // to start (a single point)
|
||||||
.collapse(true) // to start (a single point)
|
range.collapsed // true | false
|
||||||
.collapsed // true | false
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Operations
|
### Operations
|
||||||
|
|
||||||
```js
|
```js
|
||||||
range
|
range.cloneContents() // copy => DocumentFragment
|
||||||
.cloneContents() // copy => DocumentFragment
|
range.extractContents() // cut => DocumentFragment
|
||||||
.extractContents() // cut => DocumentFragment
|
range.deleteContents() // delete
|
||||||
.deleteContents() // delete
|
|
||||||
|
|
||||||
.insertNode(node)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Etc
|
```js
|
||||||
|
range.insertNode(node)
|
||||||
|
```
|
||||||
|
|
||||||
|
### String
|
||||||
|
|
||||||
```js
|
```js
|
||||||
range
|
range.toString()
|
||||||
.toString()
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Read-only attributes
|
### Read-only attributes
|
||||||
|
|
||||||
```js
|
```js
|
||||||
range
|
range.collapsed // => true/false
|
||||||
.collapsed // true/false
|
range.startContainer // => Node
|
||||||
.startContainer // Node
|
range.startOffset
|
||||||
.startOffset
|
range.endContainer // => Node
|
||||||
.endContainer // Node
|
range.endOffset
|
||||||
.endOffset
|
range.commonAncestorContainer // closest of start and end containers
|
||||||
.commonAncestorContainer // closest of start and end containers
|
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,50 +1,52 @@
|
||||||
---
|
---
|
||||||
title: DOM Selection
|
title: DOM Selection
|
||||||
category: JavaScript
|
category: JavaScript
|
||||||
|
layout: 2017/sheet
|
||||||
|
intro: |
|
||||||
|
Quick introduction to the HTML [DOM selection API](https://devdocs.io/dom/selection).
|
||||||
---
|
---
|
||||||
|
|
||||||
## Selection
|
## Reference
|
||||||
See <http://devdocs.io/dom/selection>
|
{: .-three-column}
|
||||||
|
|
||||||
|
### Selection
|
||||||
|
|
||||||
```js
|
```js
|
||||||
var selection = document.getSelection()
|
var sel = document.getSelection()
|
||||||
```
|
```
|
||||||
|
|
||||||
## Methods
|
See: <https://devdocs.io/dom/selection>
|
||||||
|
|
||||||
|
### Methods
|
||||||
|
|
||||||
```js
|
```js
|
||||||
selection
|
sel.removeAllRanges() // deselects
|
||||||
.removeAllRanges() // deselects
|
sel.addRange(range) // sets a selection
|
||||||
.addRange(range) // sets a selection
|
sel.removeRange(range) // remove a range
|
||||||
.removeRange(range) // remove a range
|
|
||||||
```
|
```
|
||||||
|
|
||||||
```js
|
```js
|
||||||
selection
|
sel.rangeCount
|
||||||
.rangeCount // ranges
|
sel.getRangeAt(0) // get the 0th range
|
||||||
.getRangeAt(0) // get the 0th range
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Collapsing
|
### Collapsing
|
||||||
|
|
||||||
```js
|
```js
|
||||||
selection
|
sel.collapse(parent, offset)
|
||||||
.collapse(parent, offset)
|
sel.collapseToEnd()
|
||||||
.collapseToEnd()
|
sel.collapseToStart()
|
||||||
.collapseToStart()
|
sel.isCollapsed
|
||||||
.isCollapsed
|
|
||||||
```
|
```
|
||||||
|
|
||||||
```js
|
```js
|
||||||
selection
|
sel.containsNode(node)
|
||||||
.containsNode(node)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Deleting
|
### Deleting
|
||||||
|
|
||||||
```js
|
```js
|
||||||
selection
|
sel.deleteFromDocument()
|
||||||
.deleteFromDocument()
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Events
|
### Events
|
||||||
|
|
67
ec2.md
67
ec2.md
|
@ -1,67 +0,0 @@
|
||||||
---
|
|
||||||
title: EC2 API tools
|
|
||||||
category: Devops
|
|
||||||
---
|
|
||||||
|
|
||||||
### Install
|
|
||||||
|
|
||||||
$ sudo apt-get install ec2-api-tools ec2-ami-tools
|
|
||||||
$ brew install ec2-api-tools ec2-ami-tools
|
|
||||||
|
|
||||||
### Pem files
|
|
||||||
|
|
||||||
$ brew info ec2-api-tools
|
|
||||||
|
|
||||||
* Before you can use these tools you must export some variables to your $SHELL
|
|
||||||
and download your X.509 certificate and private key from Amazon Web Services.
|
|
||||||
|
|
||||||
* Your certificate and private key are available at
|
|
||||||
[aws-portal.amazon.com](http://aws-portal.amazon.com/gp/aws/developer/account/index.html?action=access-key).
|
|
||||||
|
|
||||||
* Download two `.pem` files, one starting with `pk-`, and one starting with `cert-`.
|
|
||||||
You need to put both into a folder in your home directory, `~/.ec2`.
|
|
||||||
|
|
||||||
### Key pair
|
|
||||||
|
|
||||||
# To use public images (AMI's), you need an SSH keypair from EC2.
|
|
||||||
ec2-add-keypair my-keypair > ~/.ec2/my-keypair.pem
|
|
||||||
chmod 600 ec2-keypair.pem
|
|
||||||
|
|
||||||
### Start an instance
|
|
||||||
|
|
||||||
# Start an instance using a given AMI image:
|
|
||||||
# (Use the Ubuntu locator, or ec2-describe-images)
|
|
||||||
ec2-run-instances ami-xxxxxx -k ec2-keypair
|
|
||||||
|
|
||||||
# Open up ports (in the 'default' security group):
|
|
||||||
ec2-authorize default -p 22
|
|
||||||
ec2-authorize default -p 80
|
|
||||||
|
|
||||||
# Connect
|
|
||||||
ssh -i ~/.ec2/my-keypair.pem root@ec2-xxx.amazonaws.com
|
|
||||||
|
|
||||||
### Management
|
|
||||||
|
|
||||||
# Show running instances
|
|
||||||
ec2-describe-instances
|
|
||||||
|
|
||||||
# Kill an instance
|
|
||||||
ec2-terminate-instances i-yourinstance
|
|
||||||
|
|
||||||
### Misc
|
|
||||||
|
|
||||||
# Create a security group
|
|
||||||
ec2-add-group group_name -d "Description"
|
|
||||||
|
|
||||||
# Show images (AMI's) owned by amazon, or me
|
|
||||||
ec2-describe-images -o self -o amazon
|
|
||||||
|
|
||||||
### Ubuntu images
|
|
||||||
|
|
||||||
* [Ubuntu EC2 AMI locator](http://cloud-images.ubuntu.com/locator/ec2/)
|
|
||||||
|
|
||||||
### Change certificates
|
|
||||||
|
|
||||||
EC2_CERT_PATH="$HOME/.ec2"
|
|
||||||
export EC2_PRIVATE_KEY="$(/bin/ls $EC2_CERT_PATH/pk-*.pem | /usr/bin/head -1)"
|
|
||||||
export EC2_CERT="$(/bin/ls $EC2_CERT_PATH/cert-*.pem | /usr/bin/head -1)"
|
|
|
@ -1,65 +1,85 @@
|
||||||
---
|
---
|
||||||
title: Git extras
|
title: Git extras
|
||||||
category: Git
|
category: Git
|
||||||
|
layout: 2017/sheet
|
||||||
|
intro: |
|
||||||
|
Quick reference to some utilities in the [git-extras](https://github.com/tj/git-extras) utilities.
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## References
|
||||||
|
|
||||||
### Git-flow
|
### Git-flow
|
||||||
|
|
||||||
$ git feature myfeature
|
```sh
|
||||||
switched to branch 'feature/rofl'
|
$ git feature myfeature
|
||||||
|
switched to branch 'feature/rofl'
|
||||||
|
|
||||||
$ ...
|
$ ...
|
||||||
$ git checkout develop
|
$ git checkout develop
|
||||||
$ git feature finish myfeature
|
$ git feature finish myfeature
|
||||||
merging 'feature/rofl' into develop
|
merging 'feature/rofl' into develop
|
||||||
deleted branch 'feature/rofl'
|
deleted branch 'feature/rofl'
|
||||||
|
```
|
||||||
|
|
||||||
Also `git-bug` and `git-refactor`.
|
Also `git-bug` and `git-refactor`.
|
||||||
|
|
||||||
### Branches
|
### Branches
|
||||||
|
|
||||||
$ git delete-merged-branches
|
```sh
|
||||||
# hint: do `git remote prune origin` after
|
$ git delete-merged-branches
|
||||||
|
# hint: do `git remote prune origin` after
|
||||||
|
|
||||||
$ git create-branch development
|
$ git create-branch development
|
||||||
$ git delete-branch development
|
$ git delete-branch development
|
||||||
|
|
||||||
$ git fresh-branch gh-pages
|
$ git fresh-branch gh-pages
|
||||||
|
```
|
||||||
|
|
||||||
### Inspecting
|
### Inspecting
|
||||||
|
|
||||||
$ git summary # repo age, commits, active days, etc
|
```sh
|
||||||
$ git impact # impact graph
|
$ git summary # repo age, commits, active days, etc
|
||||||
$ git effort # commits per file
|
$ git impact # impact graph
|
||||||
|
$ git effort # commits per file
|
||||||
|
```
|
||||||
|
|
||||||
### Github
|
### Github
|
||||||
|
|
||||||
$ git fork strongloop/express
|
```sh
|
||||||
# sync your fork with the original repository:
|
$ git fork strongloop/express
|
||||||
$ git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
|
# sync your fork with the original repository:
|
||||||
$ git fetch upstream; git merge upstream/master
|
$ 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
|
```sh
|
||||||
$ git delete-tag v1.0.0
|
$ git release v1.0.0 # commit, tag, push-tags
|
||||||
|
$ git delete-tag v1.0.0
|
||||||
|
```
|
||||||
|
|
||||||
### Conveniences
|
### Conveniences
|
||||||
|
|
||||||
$ git ignore "*.log"
|
```sh
|
||||||
|
$ git ignore "*.log"
|
||||||
|
```
|
||||||
|
|
||||||
### Locking
|
### Locking
|
||||||
|
|
||||||
Assumes that changes will not be committed.
|
Assumes that changes will not be committed.
|
||||||
|
|
||||||
$ git lock config/database.yml
|
```sh
|
||||||
$ git unlock config/database.yml
|
$ git lock config/database.yml
|
||||||
|
$ git unlock config/database.yml
|
||||||
|
```
|
||||||
|
|
||||||
### Etc
|
### Etc
|
||||||
|
|
||||||
$ git obliterate secret.yml # remove all references to it
|
```sh
|
||||||
|
$ git obliterate secret.yml # remove all references to it
|
||||||
|
```
|
||||||
|
|
||||||
### References
|
### References
|
||||||
|
|
||||||
* https://github.com/visionmedia/git-extras
|
- https://github.com/visionmedia/git-extras
|
||||||
|
|
21
gmail.md
21
gmail.md
|
@ -1,21 +0,0 @@
|
||||||
---
|
|
||||||
title: Gmail
|
|
||||||
---
|
|
||||||
|
|
||||||
### IMAP
|
|
||||||
|
|
||||||
* `imap.gmail.com:993`
|
|
||||||
* SSL: yes
|
|
||||||
* Username: full `username@gmail.com`
|
|
||||||
|
|
||||||
### SMTP
|
|
||||||
|
|
||||||
* `smtp.gmail.com`
|
|
||||||
* SSL port: 465
|
|
||||||
* TLS/STARTTLS port: 587
|
|
||||||
* Use authentication: yes
|
|
||||||
|
|
||||||
### POP3
|
|
||||||
|
|
||||||
* `pop.gmail.com:995`
|
|
||||||
* SSL: yes
|
|
71
promise.md
71
promise.md
|
@ -1,59 +1,74 @@
|
||||||
---
|
---
|
||||||
title: Promises
|
title: Promises
|
||||||
category: JavaScript
|
category: JavaScript
|
||||||
|
intro: A quick reference to the [Promise API](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise).
|
||||||
---
|
---
|
||||||
|
|
||||||
Based on the [Promise API reference][promise] (mozilla.org).
|
## Reference
|
||||||
{:.brief-intro.center}
|
{:.-three-column}
|
||||||
|
|
||||||
[promise]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
|
|
||||||
|
|
||||||
### Creating promises
|
### Creating promises
|
||||||
|
|
||||||
```js
|
```js
|
||||||
new Promise(function (ok, err) {
|
new Promise((resolve, reject) => {
|
||||||
doStuff(function () {
|
doStuff(() => {
|
||||||
if (success) { ok(); }
|
if (success) {
|
||||||
else { err(); }
|
resolve('good')
|
||||||
});
|
} else {
|
||||||
|
reject(new Error('oops'))
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Use [new Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise#Contstructor) to create new promises.
|
||||||
|
|
||||||
### Consuming promises
|
### Consuming promises
|
||||||
|
|
||||||
```js
|
```js
|
||||||
promise
|
promise
|
||||||
.then(okFn, errFn)
|
.then((result) => {
|
||||||
.catch(errFn)
|
/* success */
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
/* failure */
|
||||||
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
[then()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then) runs a function when a promise resolves. [catch()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch) runs when a promise fails.
|
||||||
|
|
||||||
### Multiple promises
|
### Multiple promises
|
||||||
|
|
||||||
```js
|
```js
|
||||||
var promises = [
|
const promises = [promise1(), promise2() /* ... */]
|
||||||
promise1(), promise2(), ...
|
```
|
||||||
]
|
|
||||||
|
|
||||||
// succeeds when all succeed
|
```js
|
||||||
Promise.all(promises)
|
// Succeeds when all succeed
|
||||||
.then(function (results) {
|
Promise.all(promises).then((results) => {
|
||||||
});
|
/* ... */
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
// succeeds when one finishes first
|
```js
|
||||||
Promise.race(promises)
|
// Succeeds when one finishes first
|
||||||
.then(function (result) {
|
Promise.race(promises).then((result) => {
|
||||||
});
|
/* ... */
|
||||||
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### Converting other promises
|
### Converting other promises
|
||||||
|
|
||||||
```js
|
```js
|
||||||
return Promise.resolve("result");
|
return Promise.resolve('result')
|
||||||
return Promise.resolve(promise);
|
return Promise.resolve(promise)
|
||||||
return Promise.resolve(thenable);
|
return Promise.resolve(thenable)
|
||||||
|
|
||||||
return Promise.reject("reason");
|
return Promise.reject('reason')
|
||||||
|
|
||||||
Promise.resolve($.get('http://google.com'))
|
Promise.resolve(result).then(() => {
|
||||||
.then(...)
|
/* ... */
|
||||||
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
`Promise.resolve(val)` will return a promise that resolves to the value given to it.
|
||||||
|
|
42
ruby.md
42
ruby.md
|
@ -1,21 +1,31 @@
|
||||||
---
|
---
|
||||||
title: Ruby
|
title: Ruby
|
||||||
category: Ruby
|
category: Ruby
|
||||||
|
tags: [WIP]
|
||||||
|
layout: 2017/sheet
|
||||||
|
intro: |
|
||||||
|
Quick reference to some features of the Ruby programming language.
|
||||||
---
|
---
|
||||||
|
|
||||||
* `$!` - latest error message
|
### Reference
|
||||||
* `$@` - location of error
|
|
||||||
* `$_` - string last read by gets
|
{:.-one-column}
|
||||||
* `$.` - line number last read by interpreter
|
|
||||||
* `$&` - string last matched by regexp
|
| Code | Description |
|
||||||
* `$~` - the last regexp match, as an array of subexpressions
|
| ----------------------- | --------------------------------------------------------- |
|
||||||
* `$n` - the nth subexpression in the last match (same as `$~[n]`)
|
| `$!` | latest error message |
|
||||||
* `$=` - case-insensitivity flag
|
| `$@` | location of error |
|
||||||
* `$/` - input record separator
|
| `$_` | string last read by gets |
|
||||||
* `$\` - output record separator
|
| `$.` | line number last read by interpreter |
|
||||||
* `$0` - the name of the ruby script file
|
| `$&` | string last matched by regexp |
|
||||||
* `$*` (or `ARGV`) - the command line arguments
|
| `$~` | the last regexp match, as an array of subexpressions |
|
||||||
* `$$` - interpreter's process ID
|
| `$n` | the nth subexpression in the last match (same as `$~[n]`) |
|
||||||
* `$?` - exit status of last executed child process
|
| `$=` | case-insensitivity flag |
|
||||||
* `$-i` `$-l` `$-p` `$-v` - Command line switches
|
| `$/` | input record separator |
|
||||||
* `$-v` (or `$VERBOSE`) - verbose mode
|
| `$\` | output record separator |
|
||||||
|
| `$0` | the name of the ruby script file |
|
||||||
|
| `$*` (or `ARGV`) | the command line arguments |
|
||||||
|
| `$$` | interpreter's process ID |
|
||||||
|
| `$?` | exit status of last executed child process |
|
||||||
|
| `$-i` `$-l` `$-p` `$-v` | Command line switches |
|
||||||
|
| `$-v` (or `$VERBOSE`) | verbose mode |
|
||||||
|
|
135
travis.md
135
travis.md
|
@ -1,109 +1,114 @@
|
||||||
---
|
---
|
||||||
title: Travis.yml
|
title: Travis.yml
|
||||||
category: Devops
|
category: Devops
|
||||||
|
layout: 2017/sheet
|
||||||
|
prism_languages: [yaml]
|
||||||
|
intro: |
|
||||||
|
Quick reference for [Travis CI](https://travis-ci.org) yaml configuration. See [official documentation](https://docs.travis-ci.com/user/customizing-the-build/).
|
||||||
---
|
---
|
||||||
|
|
||||||
### Node
|
## Reference
|
||||||
|
{:.-three-column}
|
||||||
|
|
||||||
```yml
|
### Node.js
|
||||||
|
|
||||||
|
```yaml
|
||||||
language: node_js
|
language: node_js
|
||||||
node_js:
|
node_js:
|
||||||
- '4'
|
- '4'
|
||||||
```
|
```
|
||||||
|
|
||||||
* Provides: 0.10, 0.8, 0.6, 0.11 (latest dev)
|
Defaults install to `npm install`, and defaults test to `npm test`.
|
||||||
* Defaults install to `npm install`
|
|
||||||
* Defaults test to `npm test`
|
|
||||||
|
|
||||||
### Ruby
|
### Ruby
|
||||||
|
|
||||||
```yml
|
```yaml
|
||||||
language: ruby
|
language: ruby
|
||||||
rvm:
|
rvm:
|
||||||
- 2.0.0
|
- 2.0.0
|
||||||
- 1.9.3
|
- 1.9.3
|
||||||
- 1.8.7
|
- 1.8.7
|
||||||
- rbx-19mode
|
|
||||||
- jruby-19mode
|
|
||||||
- jruby-18mode
|
|
||||||
```
|
```
|
||||||
|
|
||||||
* Defaults install to `bundle install`
|
Defaults install to `bundle install`, defaults test to `rake`.
|
||||||
* Defaults test to `rake`
|
|
||||||
|
|
||||||
### Build lifecycle
|
### Build lifecycle
|
||||||
|
|
||||||
* `before_install`
|
| Lifecycle |
|
||||||
* `install`
|
| ---------------------------------- |
|
||||||
* `before_script`
|
| `before_install` |
|
||||||
* `script`
|
| `install` |
|
||||||
* `after_success` or `after_failure`
|
| --- |
|
||||||
* `after_script`
|
| `before_script` |
|
||||||
* OPTIONAL `before_deploy`
|
| `script` |
|
||||||
* OPTIONAL `deploy`
|
| --- |
|
||||||
* OPTIONAL `after_deploy`
|
| `after_success` or `after_failure` |
|
||||||
|
| `after_script` |
|
||||||
|
| --- |
|
||||||
|
| `before_deploy` (optional) |
|
||||||
|
| `deploy` (optional) |
|
||||||
|
| `after_deploy` (optional) |
|
||||||
|
|
||||||
### Branches
|
### Branches
|
||||||
|
|
||||||
branches:
|
```yaml
|
||||||
except: [".."]
|
branches:
|
||||||
only: ["master"]
|
except: ['..']
|
||||||
|
only: ['master']
|
||||||
|
```
|
||||||
|
|
||||||
### Environment vars
|
### Environment vars
|
||||||
|
|
||||||
env:
|
```yaml
|
||||||
- "rack=master"
|
env:
|
||||||
- "rack=1.3.4"
|
- 'rack=master'
|
||||||
|
- 'rack=1.3.4'
|
||||||
|
```
|
||||||
|
|
||||||
### Custom test command
|
### Custom test command
|
||||||
|
|
||||||
script: make test
|
```yaml
|
||||||
before_script: make pretest
|
script: make test
|
||||||
after_script: make clean
|
before_script: make pretest
|
||||||
|
after_script: make clean
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- make pretest1
|
- make pretest1
|
||||||
- make pretest2
|
- make pretest2
|
||||||
|
```
|
||||||
|
|
||||||
### Branches
|
### Branches
|
||||||
|
|
||||||
branches:
|
```yaml
|
||||||
except:
|
branches:
|
||||||
- legacy
|
except:
|
||||||
|
- legacy
|
||||||
|
|
||||||
only:
|
only:
|
||||||
- gh-pages
|
- gh-pages
|
||||||
- /^deploy/
|
- /^deploy/
|
||||||
|
```
|
||||||
|
|
||||||
### Apt packages
|
### Apt packages
|
||||||
|
|
||||||
before_install:
|
```yaml
|
||||||
- sudo apt-get update -q
|
before_install:
|
||||||
- sudo apt-get install gcc-4.8 -y
|
- sudo apt-get update -q
|
||||||
|
- sudo apt-get install gcc-4.8 -y
|
||||||
|
```
|
||||||
|
|
||||||
<https://docs.travis-ci.com/user/installing-dependencies/>
|
<https://docs.travis-ci.com/user/installing-dependencies/>
|
||||||
|
|
||||||
### Etc
|
### Etc
|
||||||
|
|
||||||
gemfile:
|
```yaml
|
||||||
- gemfiles/Gemfile.rails-2.3.x
|
gemfile:
|
||||||
- gemfiles/Gemfile.rails-3.0.x
|
- gemfiles/Gemfile.rails-2.3.x
|
||||||
|
- gemfiles/Gemfile.rails-3.0.x
|
||||||
### Notifications
|
```
|
||||||
|
|
||||||
notifications:
|
|
||||||
email:
|
|
||||||
- dropbox+travis@ricostacruz.com
|
|
||||||
|
|
||||||
email:
|
|
||||||
recipients:
|
|
||||||
- dropbox+travis@ricostacruz.com
|
|
||||||
on_success: <always|never|change> # default: change
|
|
||||||
on_failure: <always|never|change> # default: always
|
|
||||||
|
|
||||||
irc: "chat.freenode.net#travis"
|
|
||||||
|
|
||||||
### References
|
### References
|
||||||
|
|
||||||
* http://about.travis-ci.org/docs/user/build-configuration/
|
- http://about.travis-ci.org/docs/user/build-configuration/
|
||||||
* http://about.travis-ci.org/docs/user/languages/javascript-with-nodejs/
|
- http://about.travis-ci.org/docs/user/languages/javascript-with-nodejs/
|
||||||
* http://about.travis-ci.org/docs/user/languages/ruby/
|
- http://about.travis-ci.org/docs/user/languages/ruby/
|
||||||
|
|
Loading…
Reference in New Issue