From 08c0092e7ab13758e756ba17d556bfd143452102 Mon Sep 17 00:00:00 2001 From: "Rico Sta. Cruz" Date: Mon, 14 Jul 2014 11:23:52 +0800 Subject: [PATCH] Update. --- browserify.md | 40 ++++++++++++++++++++++++++ jshint.md | 42 ++++++++++++++++++++------- layout-thrashing.md | 70 +++++++++++++++++++++++++++++++++++++++++++++ rest-api.md | 47 ++++++++++++++++++++++++++++++ 4 files changed, 188 insertions(+), 11 deletions(-) create mode 100644 browserify.md create mode 100644 layout-thrashing.md create mode 100644 rest-api.md diff --git a/browserify.md b/browserify.md new file mode 100644 index 000000000..f8cdd847c --- /dev/null +++ b/browserify.md @@ -0,0 +1,40 @@ +--- +title: Browserify +layout: default +--- + + + browserify input.js + -o output.js + -t coffeeify + -t [ coffeeify --extension coffee ] + --debug + +### Programmatic usage + + browserify = require('browserify') + browserify() + .add('main.js') + .bundle() + .transform(coffeeify) + .transform({extensions: '.coffee'}, coffeeify) + .pipe(process.stdout) + + browserify({}) + +### Tools + + * watchify (recompiles on demand) + * beefy (http server) + * debowerify + * es6ify (es6 to es5) + +Transforms + + * coffeeify + * ractify + * reactify + * brfs + * cssify + * https://github.com/substack/node-browserify/wiki/list-of-transforms + diff --git a/jshint.md b/jshint.md index 40eaf03b4..9ceed4d4d 100644 --- a/jshint.md +++ b/jshint.md @@ -3,12 +3,6 @@ title: Jshint layout: default --- -### Inline - - /* jshint undef: true */ - /* global jQuery */ - /* global -BAD_LIB */ - ### Relaxing /* jshint expr: true */ @@ -16,28 +10,54 @@ layout: default /* jshint loopfunc: true */ for (i=0; i<10; x++) { - (function(i) { - })(i); + (function(i) { ... })(i); } /* jshint sub: true */ process.env['name_here']; + /* jshint boss: true */ + if (m = str.match(/.../)) + + /* jshint asi: true */ + allow() + missing_semicolons() + + /* jshint evil: true */ + eval('...') + + /* jshint laxcomma: true */ + var one = 1 + , two = 2; + + /* jshint sub: true */ + person['name'] + + ### Enforcement - /* jshint es3: true (legacy IE compatibility) */ + /* jshint es3: true */ + // legacy IE compatibility a.default = function() { ... }; array = [ 1, 2, 3, ]; /* jshint white: true, indent: 4 */ - // check whitespace and indentation rules + /* jshint maxdepth: 2 */ + /* jshint maxparams: 3 */ + /* jshint maxstatements: 4 */ + /* jshint maxcomplexity: 5 */ + /* jshint maxlen: 80 */ ### Ignore /* jshint ignore:start */ /* jshint ignore:end */ -### Environments +### Globals + + /* jshint undef: true */ + /* global jQuery */ + /* global -BAD_LIB */ /* jshint browser: true */ window, document, ... /* jshint node: true */ module, exports, console, process, ... diff --git a/layout-thrashing.md b/layout-thrashing.md new file mode 100644 index 000000000..1ffe8986f --- /dev/null +++ b/layout-thrashing.md @@ -0,0 +1,70 @@ +--- +title: Layout thrashing +layout: default +--- + +### Things that cause invalidation + +Element + + clientHeight + clientLeft + clientTop + clientWidth + focus + getBoundingClientRect + getClientRects + innerText + offsetHeight + offsetLeft + offsetParent + offsetTop + offsetWidth + outerText + scrollByLines + scrollByPages + scrollHeight + scrollIntoView + scrollIntoViewIfNeeded + scrollLeft + scrollTop + scrollWidth + +MouseEvent + + layerX + layerY + offsetX + offsetY + +Window + + getComputedStyle + scrollBy + scrollTo + scrollX + scrollY + +Frame, Document & Image + + height + width + +jQuery + + $.fn.offset + $.fn.offsetParent + $.fn.position + $.fn.scrollLeft + $.fn.scrollTop + $.fn.css('...') + $.fn.text('...') + $(':hidden') + $(':contains') + +### Reference + + * http://www.kellegous.com/j/2013/01/26/layout-performance/ + * https://gist.github.com/desandro/4657744 + * + http://stackoverflow.com/questions/17199958/why-does-setting-textcontent-cause-layout-thrashing diff --git a/rest-api.md b/rest-api.md new file mode 100644 index 000000000..d5bfc0d0f --- /dev/null +++ b/rest-api.md @@ -0,0 +1,47 @@ +--- +title: RESTful API +layout: default +--- + +### Status codes + + * `200 OK` - successful get, patch (return a JSON object) + * `201 Created` - successful post (return a JSON object) + * `202 Accepted` - sucessful post, delete, path - async + * `204 No content` - successful delete + * `206 Partial content` - successful get - async + +### Error status + + * `401 Unauthorized` - not authenticated + * `406 Forbidden` - authenticated but no permissions + * `422 Unprocessable entity` - validation + +### Errors + + HTTP/1.1 401 Unauthorized + { + 'id': 'auth_failed', + 'message': "You're not logged in." + } + +### Versioning ([info](https://github.com/interagent/http-api-design#version-with-accepts-header)) + + GET /api/foo + Accept: application/json; version=1 + +### Authentication + + curl -is https://$TOKEN@api.service.com/ + +### Methods + + * `GET /articles/1` - read, returns *200* + * `PUT /articles/1` - edit (or path), returns *200* + * `DELETE /articles/1` - delete, returns *200* + * `POST /articles` - create, returns *201* + * `GET /articles` - list, returns *200* + +### References + + * https://github.com/interagent/http-api-design