rtorrent: update

This commit is contained in:
Rico Sta. Cruz 2017-10-11 15:50:19 +08:00
parent da34aa0572
commit d1a7f94e64
No known key found for this signature in database
GPG Key ID: CAAD38AE2962619A
2 changed files with 139 additions and 70 deletions

View File

@ -1,82 +1,127 @@
---
title: Modella
category: JavaScript libraries
layout: 2017/sheet
prism_languages: [coffeescript]
intro: |
[Modella](https://www.npmjs.com/package/modella) allows you to create simple models in JavaScript. This is a guide on basic usage of Modella in CoffeeScript.
---
### Basic
### Defining models
User = Modella('User')
```coffeescript
User = Modella('User')
```
.attr('name')
.attr('email', { required: true })
.use(require('modella-validators')
```coffeescript
.attr('name')
.attr('email', { required: true })
.use(require('modella-validators'))
```
.validator (u) ->
u.error('username', 'is required') unless u.has('username')
```coffeescript
.validator (u) ->
u.error('username', 'is required') unless u.has('username')
```
### Instances
user
.name()
.name('John')
.set(name: 'John')
```coffeescript
user
.name()
.name('John')
.set(name: 'John')
```
.has('name') //=> true
.isNew()
.isValid()
```coffeescript
.has('name') # → true
.isNew()
.isValid()
```
.save (err) ->
.remove (err) ->
.removed
.model // === User
```coffeescript
.save (err) ->
.remove (err) ->
.removed
.model # === User
```
### Events
## Events
Model.emit('event', [data...])
record.emit('event', [data...])
### Emitting
```coffeescript
Model.emit('event', [data...])
record.emit('event', [data...])
```
### List of events
user
.on 'save', ->
.on 'create', ->
.on 'saving', (data, done) -> done()
```coffeescript
user
.on 'save', ->
.on 'create', ->
.on 'saving', (data, done) -> done()
```
.on 'remove', ->
.on 'removing', (data, done) -> done()
```coffeescript
.on 'remove', ->
.on 'removing', (data, done) -> done()
```
.on 'valid', ->
.on 'invalid', ->
```coffeescript
.on 'valid', ->
.on 'invalid', ->
```
.on 'change', ->
.on 'change email', ->
```coffeescript
.on 'change', ->
.on 'change email', ->
```
.on 'initializing', (instance, attrs) ->
.on 'initialize', ->
```coffeescript
.on 'initializing', (instance, attrs) ->
.on 'initialize', ->
```
.on 'error', -> failed to save model
```coffeescript
.on 'error', -> failed to save model
```
.on 'setting', (instance, attrs) -> # on Model#set()
.on 'attr', -> # new attr via Model.attr()
```coffeescript
.on 'setting', (instance, attrs) -> # on Model#set()
.on 'attr', -> # new attr via Model.attr()
```
## Misc
### Plugins
MyPlugin = ->
return (Model) ->
```coffeescript
MyPlugin = ->
return (Model) ->
```
Model.method = ...
Model.prototype.method = ...
Model.attr(...)
```coffeescript
Model.method = ...
Model.prototype.method = ...
Model.attr(...)
```
Model
```coffeescript
Model
```
### Memory
User
.all (err, users) ->
.find id, (err, user) ->
.remove ->
.save ->
.update ->
```coffeescript
User
.all (err, users) ->
.find id, (err, user) ->
```
```coffeescript
.remove ->
.save ->
.update ->
```

View File

@ -1,39 +1,63 @@
---
title: Rtorrent
category: CLI
layout: 2017/sheet
intro: |
[Rtorrent](https://rakshasa.github.io/rtorrent/) is a command-line torrent application. Here are some shortcut keys.
---
## Shortcuts
{: .-three-column}
### Global
^q Quit
| `^q` | Quit |
{: .-shortcuts}
### Main view
bksp Add torrent
-> View download
1 - 7 Change view
^S Start download
^D Stop download (or remove stopped)
^K Close a torrent
+ - Change priority
| Shortcut | Description |
| --- | --- |
| `bksp` | Add torrent |
| --- | --- |
| `->` | View download |
| --- | --- |
| `1` _-_ `7` | Change view |
| --- | --- |
| `^S` | Start download |
| `^D` | Stop download (or remove stopped) |
| `^K` | Close a torrent |
| --- | --- |
| `+` _/_ `-` | Change priority |
{: .-shortcuts}
### Throttling
a/s/d Increase the upload throttle by 1/5/50 KB
z/x/c Decrease the upload throttle by 1/5/50 KB
A/S/D Increase the download throttle by 1/5/50 KB
Z/X/C Decrease the download throttle by 1/5/50 KB
#### Upload
| `a` _/_ `s` _/_ `d` | Increase upload throttle by 1/5/50 KB |
| `z` _/_ `x` _/_ `c` | Decrease upload throttle by 1/5/50 KB |
{: .-shortcuts}
#### Download
| `A` _/_ `S` _/_ `D` | Increase download throttle by 1/5/50 KB |
| `Z` _/_ `X` _/_ `C` | Decrease download throttle by 1/5/50 KB |
{: .-shortcuts}
### Download view
1/2 Adjust max uploads
3/4 Adjust min peers
5/6 Adjust max peers
| `1` _/_ `2` | Adjust max uploads |
| `3` _/_ `4` | Adjust min peers |
| `5` _/_ `6` | Adjust max peers |
{: .-shortcuts}
### File list view
space Change priority
| `space` | Change priority |
{: .-shortcuts}
## Also see
- [Rtorrent website](https://rakshasa.github.io/rtorrent/) _(rakshasa.github.io)_
- [Rtorrent wiki](https://github.com/rakshasa/rtorrent/wiki) _(github.com)_