diff --git a/modella.md b/modella.md index 55ffba97b..44ab5a2f4 100644 --- a/modella.md +++ b/modella.md @@ -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 -> +``` diff --git a/rtorrent.md b/rtorrent.md index ce8123e4d..c45c2e6be 100644 --- a/rtorrent.md +++ b/rtorrent.md @@ -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)_