Formatting: update formatting of 20+ files (#1490)
This commit is contained in:
parent
87ed01b739
commit
969967363f
63
ansi.md
63
ansi.md
|
@ -1,41 +1,52 @@
|
|||
---
|
||||
title: Ansi codes
|
||||
category: CLI
|
||||
layout: 2017/sheet
|
||||
intro: |
|
||||
Quick reference to ANSI color codes.
|
||||
---
|
||||
|
||||
Format
|
||||
### Format
|
||||
|
||||
\033[#m
|
||||
```
|
||||
\033[#m
|
||||
```
|
||||
|
||||
Where:
|
||||
### ANSI codes
|
||||
|
||||
0 clear
|
||||
1 bold
|
||||
4 underline
|
||||
5 blink
|
||||
```
|
||||
0 clear
|
||||
1 bold
|
||||
4 underline
|
||||
5 blink
|
||||
|
||||
30-37 fg color
|
||||
40-47 bg color
|
||||
30-37 fg color
|
||||
40-47 bg color
|
||||
|
||||
1K clear line (to beginning of line)
|
||||
2K clear line (entire line)
|
||||
2J clear screen
|
||||
0;0H move cursor to 0;0
|
||||
1K clear line (to beginning of line)
|
||||
2K clear line (entire line)
|
||||
2J clear screen
|
||||
0;0H move cursor to 0;0
|
||||
|
||||
1A move up 1 line
|
||||
1A move up 1 line
|
||||
```
|
||||
|
||||
Colors
|
||||
### Colors
|
||||
|
||||
0 black
|
||||
1 red
|
||||
2 green
|
||||
3 yellow
|
||||
4 blue
|
||||
5 magenta
|
||||
6 cyan
|
||||
7 white
|
||||
```
|
||||
0 black
|
||||
1 red
|
||||
2 green
|
||||
3 yellow
|
||||
4 blue
|
||||
5 magenta
|
||||
6 cyan
|
||||
7 white
|
||||
```
|
||||
|
||||
Stuff
|
||||
### Bash utilities
|
||||
|
||||
hide_cursor() { printf "\e[?25l"; }
|
||||
show_cursor() { printf "\e[?25h"; }
|
||||
```sh
|
||||
hide_cursor() { printf "\e[?25l"; }
|
||||
show_cursor() { printf "\e[?25h"; }
|
||||
```
|
||||
|
|
95
atom.md
95
atom.md
|
@ -5,49 +5,52 @@ layout: 2017/sheet
|
|||
updated: 2017-09-20
|
||||
---
|
||||
|
||||
Shortcuts
|
||||
---------
|
||||
## Shortcuts
|
||||
{: .-three-column}
|
||||
|
||||
### Tree
|
||||
|
||||
| Shortcut | Description |
|
||||
| --- | --- |
|
||||
| `⌘\` | Toggle tree |
|
||||
| `⌘⇧\` | Reveal current file |
|
||||
| Shortcut | Description |
|
||||
| -------- | ------------------- |
|
||||
| `⌘\` | Toggle tree |
|
||||
| `⌘⇧\` | Reveal current file |
|
||||
{: .-shortcuts}
|
||||
|
||||
### Comments
|
||||
|
||||
| Shortcut | Description |
|
||||
| --- | --- |
|
||||
| `⌘/` | Toggle comments |
|
||||
| Shortcut | Description |
|
||||
| -------- | --------------- |
|
||||
| `⌘/` | Toggle comments |
|
||||
{: .-shortcuts}
|
||||
|
||||
### View
|
||||
|
||||
| Shortcut | Description |
|
||||
| --- | --- |
|
||||
| Shortcut | Description |
|
||||
| -------- | ---------------------- |
|
||||
| `⌘k` `←` | Split pane to the left |
|
||||
| --- | --- |
|
||||
| `⌘⌥=` | Grow pane |
|
||||
| `⌘⌥-` | Shrink pane |
|
||||
| --- | --- |
|
||||
| `^⇧←` | Move tab to left |
|
||||
| --- | --- |
|
||||
| `⌘⌥=` | Grow pane |
|
||||
| `⌘⌥-` | Shrink pane |
|
||||
| --- | --- |
|
||||
| `^⇧←` | Move tab to left |
|
||||
{: .-shortcuts}
|
||||
|
||||
### Bracket matcher
|
||||
|
||||
| `^m` | Go to matching bracket |
|
||||
| `^]` | Remove brackets from selection |
|
||||
| `^⌘m` | Select inside brackets |
|
||||
| `⌥⌘.` | Close tag |
|
||||
| Shortcut | Description |
|
||||
| -------- | ------------------------------ |
|
||||
| `^m` | Go to matching bracket |
|
||||
| `^]` | Remove brackets from selection |
|
||||
| `^⌘m` | Select inside brackets |
|
||||
| `⌥⌘.` | Close tag |
|
||||
{: .-shortcuts}
|
||||
|
||||
### Symbols view
|
||||
|
||||
| `^⌥↓` | Jump to declaration under cursor |
|
||||
| `^⇧r` | Show tags |
|
||||
| Shortcut | Description |
|
||||
| -------- | -------------------------------- |
|
||||
| `^⌥↓` | Jump to declaration under cursor |
|
||||
| `^⇧r` | Show tags |
|
||||
{: .-shortcuts}
|
||||
|
||||
Symbols view enables Ctags support for Atom.
|
||||
|
@ -62,34 +65,34 @@ See: [Symbols view](https://atom.io/packages/symbols-view)
|
|||
|
||||
### Editing
|
||||
|
||||
| Shortcut | Description
|
||||
| --- | ---
|
||||
| `⌘d` | Select word
|
||||
| `⌘l` | Select line
|
||||
| --- | ---
|
||||
| `⌘↓` | Move line down
|
||||
| `⌘↑` | Move line up
|
||||
| --- | ---
|
||||
| `⌘⏎` | New line below
|
||||
| `⌘⇧⏎` | New line above
|
||||
| --- | ---
|
||||
| `⌘⇧k` | Delete line
|
||||
| `⌘⇧d` | Duplicate line
|
||||
| Shortcut | Description |
|
||||
| -------- | -------------- |
|
||||
| `⌘d` | Select word |
|
||||
| `⌘l` | Select line |
|
||||
| --- | --- |
|
||||
| `⌘↓` | Move line down |
|
||||
| `⌘↑` | Move line up |
|
||||
| --- | --- |
|
||||
| `⌘⏎` | New line below |
|
||||
| `⌘⇧⏎` | New line above |
|
||||
| --- | --- |
|
||||
| `⌘⇧k` | Delete line |
|
||||
| `⌘⇧d` | Duplicate line |
|
||||
{: .-shortcuts}
|
||||
|
||||
### Project
|
||||
|
||||
| Shortcut | Description
|
||||
| --- | ---
|
||||
| `⌘⇧p` | Command palette
|
||||
| `⌘⇧a` | Add project folder
|
||||
| --- | ---
|
||||
| `⌘n` | New file
|
||||
| `⌘⇧n` | New window
|
||||
| --- | ---
|
||||
| `⌘f` | Find in file
|
||||
| `⌘⇧f` | Find in project
|
||||
| `⌘t` | Search files in project
|
||||
| Shortcut | Description |
|
||||
| -------- | ----------------------- |
|
||||
| `⌘⇧p` | Command palette |
|
||||
| `⌘⇧a` | Add project folder |
|
||||
| --- | --- |
|
||||
| `⌘n` | New file |
|
||||
| `⌘⇧n` | New window |
|
||||
| --- | --- |
|
||||
| `⌘f` | Find in file |
|
||||
| `⌘⇧f` | Find in project |
|
||||
| `⌘t` | Search files in project |
|
||||
{: .-shortcuts}
|
||||
|
||||
## Notes
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
# bookshelf-contrib.Scopes
|
||||
#
|
||||
class Books
|
||||
scopes:
|
||||
published: (q) -> q.where(published: true)
|
||||
|
||||
Books.published().fetchAll()
|
||||
|
||||
|
||||
# bookshelf-contrib.QueryProxy
|
||||
#
|
||||
Books.query().where(published: true)
|
||||
Books.where(published: true)
|
||||
|
||||
# bookshelf-contrib.Migration
|
||||
class Migration
|
||||
up: ->
|
||||
down: ->
|
||||
|
||||
|
||||
|
39
cordova.md
39
cordova.md
|
@ -1,25 +1,34 @@
|
|||
---
|
||||
title: Cordova
|
||||
title: Apache Cordova
|
||||
layout: 2017/sheet
|
||||
intro: |
|
||||
A quick reference to common [Apache Cordova](https://cordova.apache.org/) commands.
|
||||
---
|
||||
|
||||
cordova plugin ls
|
||||
cordova plugin search facebook
|
||||
cordova plugin add com.phonegap.plugins.facebookconnect
|
||||
### Common commands
|
||||
|
||||
cordova platform add ios
|
||||
cordova platform ls
|
||||
cordova platform update ios
|
||||
cordova platform check
|
||||
```
|
||||
cordova plugin ls
|
||||
cordova plugin search facebook
|
||||
cordova plugin add com.phonegap.plugins.facebookconnect
|
||||
```
|
||||
|
||||
### Some plugins
|
||||
```
|
||||
cordova platform add ios
|
||||
cordova platform ls
|
||||
cordova platform update ios
|
||||
cordova platform check
|
||||
```
|
||||
|
||||
You'll likely need these:
|
||||
### Common plugins
|
||||
|
||||
* [org.apache.cordova.console](https://github.com/apache/cordova-plugin-console)
|
||||
* [org.apache.cordova.inappbrowser](https://github.com/apache/cordova-plugin-inappbrowser)
|
||||
* [org.apache.cordova.statusbar](https://github.com/apache/cordova-plugin-statusbar)
|
||||
* org.apache.cordova.splashscreen
|
||||
Some commonly-used plugins:
|
||||
|
||||
- [org.apache.cordova.console](https://github.com/apache/cordova-plugin-console)
|
||||
- [org.apache.cordova.inappbrowser](https://github.com/apache/cordova-plugin-inappbrowser)
|
||||
- [org.apache.cordova.statusbar](https://github.com/apache/cordova-plugin-statusbar)
|
||||
- org.apache.cordova.splashscreen
|
||||
|
||||
Also:
|
||||
|
||||
* com.phonegap.plugins.facebookconnect
|
||||
- com.phonegap.plugins.facebookconnect
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
---
|
||||
title: Cryptography
|
||||
---
|
||||
|
||||
* [PBKDF2](http://en.wikipedia.org/wiki/PBKDF2) - password-based key derivation
|
||||
function
|
||||
|
||||
* [HMAC](http://en.wikipedia.org/wiki/HMAC) - Hash-based message authentication
|
||||
code
|
24
freenode.md
24
freenode.md
|
@ -1,14 +1,26 @@
|
|||
---
|
||||
title: Freenode
|
||||
layout: 2017/sheet
|
||||
tags: [WIP]
|
||||
---
|
||||
|
||||
### irc.freenode.net
|
||||
### IRC server
|
||||
|
||||
/msg nickserv identify [nick] <password>
|
||||
/msg nickserv info <nick>
|
||||
```
|
||||
irc.freenode.net
|
||||
```
|
||||
|
||||
### NickServ commands
|
||||
|
||||
```
|
||||
/msg nickserv identify [nick] <password>
|
||||
/msg nickserv info <nick>
|
||||
```
|
||||
|
||||
### Add a nick
|
||||
|
||||
/nick newnick
|
||||
/msg nickserv identify <oldnick> <password>
|
||||
/msg nickserv group
|
||||
```
|
||||
/nick newnick
|
||||
/msg nickserv identify <oldnick> <password>
|
||||
/msg nickserv group
|
||||
```
|
||||
|
|
|
@ -1,12 +1,26 @@
|
|||
---
|
||||
title: Google Webfonts
|
||||
layout: 2017/sheet
|
||||
intro: |
|
||||
Short snippets on using [Google Webfonts](https://google.com/fonts) in a web page.
|
||||
---
|
||||
|
||||
### Link tag
|
||||
|
||||
<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
|
||||
<!-- prettier-ignore -->
|
||||
```html
|
||||
<link href="http://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet" type="text/css" />
|
||||
```
|
||||
|
||||
### CSS import
|
||||
|
||||
@import url(http://fonts.googleapis.com/css?family=Open+Sans);
|
||||
@import url(http://fonts.googleapis.com/css?family=Open+Sans:400,400italic|Montserrat:400,700);
|
||||
<!-- prettier-ignore -->
|
||||
```css
|
||||
/* One font */
|
||||
@import url('https://fonts.googleapis.com/css?family=Open+Sans:400,700');
|
||||
|
||||
/* Combining multiple fonts */
|
||||
@import url('https://fonts.googleapis.com/css?family=Open+Sans:400,400italic|Montserrat:400,700'');
|
||||
```
|
||||
|
||||
Great for using with [Codepen.io](https://codepen.io/) or similar websites!
|
||||
|
|
|
@ -1,31 +1,43 @@
|
|||
---
|
||||
title: Imagemagick
|
||||
layout: 2017/sheet
|
||||
intro: |
|
||||
A quick reference for common [Imagemagick](https://www.imagemagick.org) commands and switches.
|
||||
---
|
||||
|
||||
### Stuff
|
||||
### Common options
|
||||
|
||||
-resize 100x40
|
||||
-crop 40x30+10+10 # (width)x(height)+(x)+y
|
||||
-crop 40x30-10-10 # (width)x(height)+(x)+y
|
||||
-flip # vertical
|
||||
-flop # horizontal
|
||||
-transpose # flip vertical + rotate 90deg
|
||||
-transverse # flip horizontal + rotate 270deg
|
||||
-trim # trim image edges
|
||||
-rotate 90
|
||||
| Option | Description |
|
||||
| ------------------- | ------------------------------- |
|
||||
| `-resize 100x40` | Resize to a dimension |
|
||||
| `-crop 40x30+10+10` | (width)x(height)+(x)+y |
|
||||
| `-crop 40x30-10-10` | (width)x(height)+(x)+y |
|
||||
| `-flip` | Vertical |
|
||||
| `-flop` | Horizontal |
|
||||
| `-transpose` | Flip vertical + rotate 90deg |
|
||||
| `-transverse` | Flip horizontal + rotate 270deg |
|
||||
| `-trim` | Trim image edges |
|
||||
| `-rotate 90` | Rotate 90 degrees |
|
||||
|
||||
### Resize to fit
|
||||
|
||||
convert input.jpg -resize 80x80^ -gravity center -extent 80x80 icon.png
|
||||
```sh
|
||||
convert input.jpg -resize 80x80^ -gravity center -extent 80x80 icon.png
|
||||
```
|
||||
|
||||
### Convert all images to another format
|
||||
|
||||
mogrify -format jpg -quality 85 *.png
|
||||
```sh
|
||||
mogrify -format jpg -quality 85 *.png
|
||||
```
|
||||
|
||||
### Make a pdf
|
||||
|
||||
convert *.jpg hello.pdf
|
||||
```sh
|
||||
convert *.jpg hello.pdf
|
||||
```
|
||||
|
||||
### References
|
||||
|
||||
* http://www.noah.org/wiki/ImageMagick
|
||||
- <http://www.noah.org/wiki/ImageMagick>
|
||||
- <https://www.imagemagick.org/>
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
---
|
||||
title: jQuery CDN
|
||||
category: JavaScript libraries
|
||||
tags: [Archived]
|
||||
layout: 2017/sheet
|
||||
---
|
||||
|
||||
### Google jQuery
|
||||
|
||||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
|
||||
```html
|
||||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
|
||||
```
|
||||
|
|
|
@ -1,16 +1,25 @@
|
|||
---
|
||||
title: assert
|
||||
category: Node.js
|
||||
layout: 2017/sheet
|
||||
---
|
||||
|
||||
assert(val)
|
||||
assert.equal(actual, expected)
|
||||
assert.notEqual(a, e)
|
||||
### Assertions
|
||||
|
||||
assert.deepEqual(a, e)
|
||||
assert.notDeepEqual(a, e)
|
||||
```js
|
||||
assert(val)
|
||||
assert.equal(actual, expected)
|
||||
assert.notEqual(a, e)
|
||||
```
|
||||
|
||||
assert.throws(fn)
|
||||
```js
|
||||
assert.deepEqual(a, e)
|
||||
assert.notDeepEqual(a, e)
|
||||
```
|
||||
|
||||
```js
|
||||
assert.throws(fn)
|
||||
```
|
||||
|
||||
### References
|
||||
|
||||
|
|
|
@ -1,18 +1,33 @@
|
|||
---
|
||||
title: path
|
||||
title: Node.js path API
|
||||
category: Node.js
|
||||
layout: 2017/sheet
|
||||
intro: |
|
||||
Quick reference to the [Node.js path API](https://nodejs.org/api/path.html).
|
||||
---
|
||||
|
||||
fs.realpath('/etc/passwd', function(err, path) { /* "/private/etc/passwd" */
|
||||
});
|
||||
### Functions
|
||||
|
||||
dir = path.join('etc', 'passwd');
|
||||
dir = path.resolve('/etc', 'passwd', '..', 'var');
|
||||
```js
|
||||
const fs = require('fs')
|
||||
|
||||
path.dirname('/etc/passwd') //=> "/etc"
|
||||
path.basename('/etc/passwd') //=> "passwd"
|
||||
path.basename('/etc/rc.d', '.d') //=> "rc"
|
||||
fs.realpath('/etc/passwd', function (err, path) {
|
||||
path // => "/private/etc/passwd"
|
||||
})
|
||||
```
|
||||
|
||||
```js
|
||||
const path = require('path')
|
||||
dir = path.join('etc', 'passwd')
|
||||
dir = path.resolve('/etc', 'passwd', '..', 'var')
|
||||
```
|
||||
|
||||
```js
|
||||
path.dirname('/etc/passwd') // => "/etc"
|
||||
path.basename('/etc/passwd') // => "passwd"
|
||||
path.basename('/etc/rc.d', '.d') // => "rc"
|
||||
```
|
||||
|
||||
### References
|
||||
|
||||
- http://nodejs.org/api/path.html
|
||||
- https://nodejs.org/api/path.html
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
"devDependencies": {
|
||||
"@babel/core": "^7.10.2",
|
||||
"@babel/preset-env": "^7.10.2",
|
||||
"@rstacruz/prettier-plugin-markdown-code-fences": "^1.0.0",
|
||||
"jest": "26.0.1",
|
||||
"jest-html": "1.5.0",
|
||||
"netlify-plugin-minify-html": "^0.2.3",
|
||||
|
|
21
passenger.md
21
passenger.md
|
@ -1,12 +1,19 @@
|
|||
---
|
||||
title: Phusion Passenger
|
||||
tags: [WIP]
|
||||
layout: 2017/sheet
|
||||
---
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name www.yourhost.com;
|
||||
root /somewhere/public; # <--- be sure to point to 'public'!
|
||||
passenger_enabled on;
|
||||
autoindex on; # Show directory listings
|
||||
}
|
||||
### Enabling Phusion passenger
|
||||
|
||||
```
|
||||
server {
|
||||
listen 80;
|
||||
server_name www.yourhost.com;
|
||||
root /somewhere/public; # <--- be sure to point to 'public'!
|
||||
passenger_enabled on;
|
||||
autoindex on; # Show directory listings
|
||||
}
|
||||
```
|
||||
|
||||
This is an example nginx configuration.
|
||||
|
|
31
premailer.md
31
premailer.md
|
@ -1,13 +1,28 @@
|
|||
---
|
||||
title: Premailer
|
||||
layout: 2017/sheet
|
||||
tags: [WIP]
|
||||
intro: |
|
||||
[Premailer](https://github.com/premailer/premailer/) is a Ruby library that inlines CSS into HTML.
|
||||
---
|
||||
|
||||
### Custom CSS properties
|
||||
|
||||
-premailer-width
|
||||
Available on table, th and td elements
|
||||
-premailer-height
|
||||
Available on table, tr, th and td elements
|
||||
-premailer-cellpadding
|
||||
Available on table elements
|
||||
-premailer-cellspacing
|
||||
Available on table elements
|
||||
<!-- prettier-ignore -->
|
||||
```css
|
||||
table, th, td {
|
||||
/* Available on table, th and td elements */
|
||||
-premailer-width: 32px;
|
||||
}
|
||||
|
||||
table, tr, th, td {
|
||||
/* Available on table, tr, th and td elements */
|
||||
-premailer-height: 32px;
|
||||
}
|
||||
|
||||
table {
|
||||
/* Available on table elements */
|
||||
-premailer-cellpadding: 32px;
|
||||
-premailer-cellspacing: 32px;
|
||||
}
|
||||
```
|
||||
|
|
53
qunit.md
53
qunit.md
|
@ -1,32 +1,47 @@
|
|||
---
|
||||
title: Qunit
|
||||
category: JavaScript libraries
|
||||
layout: 2017/sheet
|
||||
intro: |
|
||||
A quick reference for the [QUnit](https://yarnpkg.com/package/qunit) testing library in JavaScript.
|
||||
---
|
||||
|
||||
QUnit.module('a');
|
||||
QUnit.test('ok', function (t) { ... });
|
||||
```js
|
||||
QUnit.module('a')
|
||||
QUnit.test('ok', function (t) {
|
||||
/* ... */
|
||||
})
|
||||
```
|
||||
|
||||
### Hooks
|
||||
|
||||
// each test
|
||||
QUnit.testStart(function)
|
||||
QUnit.testEnd(function)
|
||||
#### Each test
|
||||
|
||||
// each module
|
||||
QUnit.moduleStart(function)
|
||||
QUnit.moduleEnd(function)
|
||||
```js
|
||||
// each test
|
||||
QUnit.testStart(function)
|
||||
QUnit.testEnd(function)
|
||||
```
|
||||
|
||||
// all
|
||||
QUnit.begin(function)
|
||||
QUnit.done(function)
|
||||
```js
|
||||
// each module
|
||||
QUnit.moduleStart(function)
|
||||
QUnit.moduleEnd(function)
|
||||
```
|
||||
|
||||
```js
|
||||
// all
|
||||
QUnit.begin(function)
|
||||
QUnit.done(function)
|
||||
```
|
||||
|
||||
### Assertions
|
||||
|
||||
t.equal(actual, expected)
|
||||
t.deepEqual(actual, expected)
|
||||
t.strictEqual(actual, expected)
|
||||
t.propEqual(actual, expected)
|
||||
|
||||
t.notEqual
|
||||
|
||||
t.expect(amount)
|
||||
```js
|
||||
t.equal(actual, expected)
|
||||
t.deepEqual(actual, expected)
|
||||
t.strictEqual(actual, expected)
|
||||
t.propEqual(actual, expected)
|
||||
t.notEqual(actual, expected)
|
||||
t.expect(amount)
|
||||
```
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
---
|
||||
title: Rails gems
|
||||
category: Rails
|
||||
---
|
||||
|
||||
### Rico's preferred rails gems
|
||||
|
||||
Development:
|
||||
|
||||
gem 'spring' # code reloading
|
||||
gem 'letter_opener'
|
||||
gem 'better_errors'
|
||||
gem 'meta-tags'
|
||||
gem 'guard-rspec'
|
||||
|
||||
Prod:
|
||||
|
||||
gem 'kaminari' # pagination
|
||||
gem 'devise'
|
||||
gem 'meta-tags', require: 'meta_tags'
|
||||
gem 'friendly_id'
|
||||
gem 'bourbon'
|
||||
gem 'neat'
|
||||
gem 'turbolinks'
|
34
ruby21.md
34
ruby21.md
|
@ -1,25 +1,37 @@
|
|||
---
|
||||
title: Ruby 2.1
|
||||
category: Ruby
|
||||
layout: 2017/sheet
|
||||
tags: [Archived]
|
||||
intro: |
|
||||
Quick reference to the [new features in Ruby 2.1](https://www.ruby-lang.org/).
|
||||
---
|
||||
|
||||
### Named arguments with defaults
|
||||
|
||||
# length is required
|
||||
def pad(num, length:, char: "0")
|
||||
num.to_s.rjust(length, char)
|
||||
end
|
||||
```ruby
|
||||
# length is required
|
||||
def pad(num, length:, char: "0")
|
||||
num.to_s.rjust(length, char)
|
||||
end
|
||||
```
|
||||
|
||||
pad(42, length: 6) #=> "000042"
|
||||
pad(42) #=> #<ArgumentError: missing keyword: length>
|
||||
```ruby
|
||||
pad(42, length: 6) #=> "000042"
|
||||
pad(42) #=> #<ArgumentError: missing keyword: length>
|
||||
```
|
||||
|
||||
### Module.prepend
|
||||
|
||||
prepend(Module.new do
|
||||
define_method ...
|
||||
end)
|
||||
```ruby
|
||||
prepend(
|
||||
Module.new do
|
||||
define_method ...
|
||||
end
|
||||
)
|
||||
```
|
||||
|
||||
### References
|
||||
|
||||
* http://globaldev.co.uk/2013/03/ruby-2-0-0-in-detail
|
||||
* http://globaldev.co.uk/2014/05/ruby-2-1-in-detail
|
||||
- http://globaldev.co.uk/2013/03/ruby-2-0-0-in-detail
|
||||
- http://globaldev.co.uk/2014/05/ruby-2-1-in-detail
|
||||
|
|
43
rubygems.md
43
rubygems.md
|
@ -1,21 +1,40 @@
|
|||
---
|
||||
title: Rubygems
|
||||
category: Ruby
|
||||
layout: 2017/sheet
|
||||
intro: |
|
||||
A quick reference to common [rubygems](https://rubygems.org) CLI commands.
|
||||
---
|
||||
|
||||
gem build *.gemspec # Build a gem
|
||||
gem install *.gem # Install locally
|
||||
gem push *.gem # Upload to rubygems.org
|
||||
gem yank foogem -v 0.0.1 # Take it back
|
||||
### Building and publishing
|
||||
|
||||
gem owner foogem -a rico@ricostacruz.com
|
||||
```sh
|
||||
gem build *.gemspec # Build a gem
|
||||
gem install *.gem # Install locally
|
||||
gem push *.gem # Upload to rubygems.org
|
||||
gem yank foogem -v 0.0.1 # Take it back
|
||||
```
|
||||
|
||||
gem list # List local gems
|
||||
gem which rake # Point to where lib/rake.rb is
|
||||
gem search -r rails # [remote] Search for gems
|
||||
### Querying
|
||||
|
||||
# https://github.com/fnando/gem-open
|
||||
gem open foogem
|
||||
GEM_EDITOR="vim" gem open foogem
|
||||
```sh
|
||||
gem owner foogem -a rico@ricostacruz.com
|
||||
|
||||
cd $(basename `gem which rake`) # Go to a gem's path
|
||||
gem list # List local gems
|
||||
gem which rake # Point to where lib/rake.rb is
|
||||
gem search -r rails # [remote] Search for gems
|
||||
```
|
||||
|
||||
### Opening a gem
|
||||
|
||||
```sh
|
||||
# https://github.com/fnando/gem-open
|
||||
gem open foogem
|
||||
GEM_EDITOR="vim" gem open foogem
|
||||
```
|
||||
|
||||
### Changing to a directory
|
||||
|
||||
```sh
|
||||
cd $(basename `gem which rake`) # Go to a gem's path
|
||||
```
|
||||
|
|
25
siege.md
25
siege.md
|
@ -1,11 +1,20 @@
|
|||
---
|
||||
title: Siege
|
||||
category: Others
|
||||
layout: 2017/sheet
|
||||
intro: |
|
||||
[Siege](https://www.joedog.org/siege-home/) is an HTTP and HTTPS load testing tool.
|
||||
---
|
||||
|
||||
### Basic usage
|
||||
|
||||
```sh
|
||||
siege -b -c=10 -t=5m "http://..."
|
||||
```
|
||||
siege -b -c=10 -t=5m http://...
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
#### Repetitions
|
||||
|
||||
```
|
||||
-c, --concurrent=N
|
||||
|
@ -13,24 +22,28 @@ siege -b -c=10 -t=5m http://...
|
|||
-r, --reps=N
|
||||
```
|
||||
|
||||
#### Modes
|
||||
|
||||
```
|
||||
-i, --internet Hit URLs randomly
|
||||
-b, --benchmark No delay between requests
|
||||
```
|
||||
|
||||
### Configuration
|
||||
#### Configuration
|
||||
|
||||
```
|
||||
-f, --file=FILE load urls.txt
|
||||
-R, --rc=FILE load siegerc
|
||||
```
|
||||
|
||||
> Also see: [siegerc](https://gist.github.com/stansmet/3067988)
|
||||
|
||||
### Headers
|
||||
#### Headers
|
||||
|
||||
```
|
||||
-H, --header="Cookie: foo=bar"
|
||||
-A, --user-agent="Mozilla"
|
||||
-T, --content-type="text/html"
|
||||
```
|
||||
|
||||
### References
|
||||
|
||||
Also see: [siegerc](https://gist.github.com/stansmet/3067988)
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
---
|
||||
title: SimpleForm
|
||||
layout: 2017/sheet
|
||||
tags: [WIP]
|
||||
---
|
||||
|
||||
### Inputs
|
||||
|
||||
```ruby
|
||||
<%= f.input :email, required: false, autofocus: true %>
|
||||
<%= f.input :password, required: false %>
|
||||
|
@ -9,7 +13,8 @@ title: SimpleForm
|
|||
<%= f.button :submit, "Sign in" %>
|
||||
```
|
||||
|
||||
### Adding a wrapper
|
||||
|
||||
```ruby
|
||||
simple_form_for @x,
|
||||
wrapper: :small
|
||||
simple_form_for @x, wrapper: :small
|
||||
```
|
||||
|
|
|
@ -1,35 +1,54 @@
|
|||
---
|
||||
title: Spreadsheet functions
|
||||
tags: [WIP]
|
||||
layout: 2017/sheet
|
||||
---
|
||||
|
||||
### If
|
||||
|
||||
=IF(test, then, else)
|
||||
=IF(EQ(A1, "paid"), "true", "false")
|
||||
```
|
||||
=IF(test, then, else)
|
||||
=IF(EQ(A1, "paid"), "true", "false")
|
||||
```
|
||||
|
||||
### Comparators
|
||||
|
||||
=EQ(a,b) NE()
|
||||
=GT() GTE() LT() LTE()
|
||||
|
||||
```
|
||||
=EQ(a,b)
|
||||
=NE(a,b)
|
||||
=GT(a,b)
|
||||
=GTE(a,b)
|
||||
=LT(a,b)
|
||||
=LTE(a,b)
|
||||
```
|
||||
|
||||
### Math
|
||||
|
||||
=POW(2, 32) # 2^32
|
||||
=SIN() ACOS() etc
|
||||
=CEILING(n,sig,mode)
|
||||
=FLOOR(n,sig,mode)
|
||||
=INT(n)
|
||||
```
|
||||
=POW(2, 32) # 2^32
|
||||
=SIN() ACOS() etc
|
||||
=CEILING(n,sig,mode)
|
||||
=FLOOR(n,sig,mode)
|
||||
=INT(n)
|
||||
```
|
||||
|
||||
=SUM(range)
|
||||
```
|
||||
=SUM(range)
|
||||
```
|
||||
|
||||
=SUMIF(range, criteria, sum_range)
|
||||
=SUMIF(A1:A5, ">300", B1:B5) # if A# is >300, use B#
|
||||
```
|
||||
=SUMIF(range, criteria, sum_range)
|
||||
=SUMIF(A1:A5, ">300", B1:B5) # if A# is >300, use B#
|
||||
```
|
||||
|
||||
### Core
|
||||
|
||||
=TO_DATE(number)
|
||||
```
|
||||
=TO_DATE(number)
|
||||
```
|
||||
|
||||
### Vlook
|
||||
|
||||
=VLOOKUP(value, range, column_index)
|
||||
|
||||
```
|
||||
=VLOOKUP(value, range, column_index)
|
||||
```
|
||||
|
|
|
@ -54,14 +54,18 @@ category: Vim
|
|||
|
||||
### `:EasyAlign = dr` (delimiter_align right)
|
||||
|
||||
apple = 1
|
||||
banana += apple
|
||||
cake ||= banana
|
||||
```
|
||||
apple = 1
|
||||
banana += apple
|
||||
cake ||= banana
|
||||
```
|
||||
|
||||
### `:EasyAlign :` (for json or yaml)
|
||||
|
||||
url: jdbc:mysql://localhost/test
|
||||
database: test
|
||||
```
|
||||
url: jdbc:mysql://localhost/test
|
||||
database: test
|
||||
```
|
||||
|
||||
### `:EasyAlign *|` (markdown tables)
|
||||
|
||||
|
@ -71,10 +75,9 @@ category: Vim
|
|||
| `2` | on 2nd occurrence (and so on) |
|
||||
```
|
||||
|
||||
Interactive mode
|
||||
----------------
|
||||
## Interactive mode
|
||||
|
||||
| `{Visual}` `⏎` | activate for selection |
|
||||
| `{Visual}` `⏎` | activate for selection |
|
||||
| `ga` `{motion}` | activate for motion/text object |
|
||||
{:.greycode}
|
||||
|
||||
|
@ -82,19 +85,18 @@ Then press options (if available), then a delimiter.
|
|||
|
||||
### Interactive mode options
|
||||
|
||||
| `⏎` | Set `alignment` |
|
||||
| `⏎` | Set `alignment` |
|
||||
| `<ctrl-l>` `4 ⏎` | Set `left_margin` (to the left of the delimiter) |
|
||||
| `<ctrl-r>` `4 ⏎` | Set `right_margin` |
|
||||
| `↓` | no margin |
|
||||
| `<ctrl-r>` `4 ⏎` | Set `right_margin` |
|
||||
| `↓` | no margin |
|
||||
{:.greycode}
|
||||
|
||||
### Example
|
||||
|
||||
* `gaip` `<ctrl-l>` `8⏎` `=` - puts 8 spaces before the equal sign
|
||||
- `gaip` `<ctrl-l>` `8⏎` `=` - puts 8 spaces before the equal sign
|
||||
|
||||
Also see
|
||||
--------
|
||||
## Also see
|
||||
|
||||
* [vim-easy-align](https://github.com/junegunn/vim-easy-align)
|
||||
* [Examples](https://github.com/junegunn/vim-easy-align#examples)
|
||||
* [Alignment options](https://github.com/junegunn/vim-easy-align#alignment-options)
|
||||
- [vim-easy-align](https://github.com/junegunn/vim-easy-align)
|
||||
- [Examples](https://github.com/junegunn/vim-easy-align#examples)
|
||||
- [Alignment options](https://github.com/junegunn/vim-easy-align#alignment-options)
|
||||
|
|
32
weinre.md
32
weinre.md
|
@ -1,17 +1,35 @@
|
|||
---
|
||||
title: Weinre
|
||||
category: JavaScript libraries
|
||||
layout: 2017/sheet
|
||||
tags: [Archived]
|
||||
intro: |
|
||||
[weinre](https://www.npmjs.com/package/weinre) is a remote Web inspector. Note that it has been deprecated since 2016.
|
||||
---
|
||||
|
||||
* [Weinre](http://people.apache.org/~pmuellr/weinre/)
|
||||
### Usage
|
||||
|
||||
Install:
|
||||
#### Install:
|
||||
|
||||
$ npm install -g weinre
|
||||
```
|
||||
$ npm install -g weinre
|
||||
```
|
||||
|
||||
Start the server:
|
||||
#### Start the server:
|
||||
|
||||
$ weinre --boundHost 0.0.0.0
|
||||
$ open http://localhost:8080
|
||||
```
|
||||
$ weinre --boundHost 0.0.0.0
|
||||
$ open http://localhost:8080
|
||||
```
|
||||
|
||||
### HTML to inject
|
||||
|
||||
<!--prettier-ignore -->
|
||||
```html
|
||||
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.async=1;js.src='http://'+location.hostname+':8080/target/target-script-min.js#anonymous';fjs.parentNode.insertBefore(js,fjs);}}(document,'script','weinre');</script>
|
||||
```
|
||||
|
||||
### References
|
||||
|
||||
- [Weinre](http://people.apache.org/~pmuellr/weinre/)
|
||||
|
||||
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.async=1;js.src='http://'+location.hostname+':8080/target/target-script-min.js#anonymous';fjs.parentNode.insertBefore(js,fjs);}}(document,'script','weinre');</script>
|
||||
|
|
|
@ -1170,6 +1170,11 @@
|
|||
"@parcel/utils" "^1.11.0"
|
||||
physical-cpu-count "^2.0.0"
|
||||
|
||||
"@rstacruz/prettier-plugin-markdown-code-fences@^1.0.0":
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@rstacruz/prettier-plugin-markdown-code-fences/-/prettier-plugin-markdown-code-fences-1.0.0.tgz#b432eed2db4726abe2c3efaa75c12322976a8ab6"
|
||||
integrity sha512-p/P6BH6tGoCbgMemimUIXJSwi5enZ/HhLupATlPqJmjal00gociP1lbbUQEs97PWjLsgmY3kKu30yKzMSIs0mA==
|
||||
|
||||
"@sinonjs/commons@^1.7.0":
|
||||
version "1.8.0"
|
||||
resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.8.0.tgz#c8d68821a854c555bba172f3b06959a0039b236d"
|
||||
|
|
46
znc.md
46
znc.md
|
@ -1,32 +1,40 @@
|
|||
---
|
||||
title: ZNC bouncer
|
||||
layout: 2017/sheet
|
||||
intro: |
|
||||
A quick reference to the [ZNC](https://znc.bg) IRC bouncer's common commands.
|
||||
---
|
||||
|
||||
## Start
|
||||
|
||||
/msg *status addserver irc.undernet.org [6667]
|
||||
/msg *status connect
|
||||
```
|
||||
/msg *status addserver irc.undernet.org [6667]
|
||||
/msg *status connect
|
||||
|
||||
/msg *status loadmod webadmin
|
||||
/msg *status loadmod admin
|
||||
/msg *status loadmod away
|
||||
/msg *status loadmod awaynick
|
||||
/msg *status loadmod clientnotify # Notifies when another client logs
|
||||
/msg *status loadmod keepnick
|
||||
/msg *status loadmod kickrejoin
|
||||
/msg *status loadmod webadmin
|
||||
/msg *status loadmod admin
|
||||
/msg *status loadmod away
|
||||
/msg *status loadmod awaynick
|
||||
/msg *status loadmod clientnotify # Notifies when another client logs
|
||||
/msg *status loadmod keepnick
|
||||
/msg *status loadmod kickrejoin
|
||||
```
|
||||
|
||||
## Away
|
||||
|
||||
/msg *status loadmod away
|
||||
/msg *away away
|
||||
/msg *away back
|
||||
/msg *away show #=> Show messages
|
||||
/msg *away delete all
|
||||
```
|
||||
/msg *status loadmod away
|
||||
/msg *away away
|
||||
/msg *away back
|
||||
/msg *away show #=> Show messages
|
||||
/msg *away delete all
|
||||
```
|
||||
|
||||
## Watch
|
||||
|
||||
/msg *status loadmod watch
|
||||
/msg *watch list
|
||||
/msg *watch add * *watch *rico*
|
||||
/msg *watch add * *watch *%nick%*
|
||||
|
||||
```
|
||||
/msg *status loadmod watch
|
||||
/msg *watch list
|
||||
/msg *watch add * *watch *rico*
|
||||
/msg *watch add * *watch *%nick%*
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue