This commit is contained in:
Rico Sta. Cruz 2014-04-01 15:59:39 +08:00
parent 3022606545
commit 0afa45b3c2
6 changed files with 93 additions and 16 deletions

View File

@ -36,6 +36,7 @@ layout: default
ffmpeg -i input.mov -vcodec h264 -acodec aac -strict -2 output.mp4
ffmpeg -i input.mov -vcodec libvpx -acodec libvorbis output.webm
# -acodec null
<video width="320" height="240" controls>
<source src="movie.mp4"></source>

27
js-appcache.md Normal file
View File

@ -0,0 +1,27 @@
---
title: applicationCache
layout: default
---
### applicationCache checking
if (window.applicationCache){
// "Naturally" reload when an update is available
var reload = false;
window.applicationCache.addEventListener('updateready', function(){
if (window.applicationCache.status == window.applicationCache.UPDATEREADY){
window.applicationCache.swapCache();
reload = true;
}
}, false);
setInterval(function(){
try { // There's nothing to update for first-time load, browser freaks out :/
window.applicationCache.update();
} catch (e){}
}, 1000*60*60); // Every hour
}
### Reference
* https://developer.mozilla.org/en-US/docs/HTML/Using_the_application_cache

View File

@ -1,28 +1,27 @@
---
title: Setting up jscoverage
title: jscoverage
layout: default
---
### Install
npm i --save-dev jscoverage
npm install --save-dev jscoverage
### Ignore output
echo coverage.html >> .gitignore
### package.json
Set up the `coverage` task so you can do `npm run coverage` later.
The `coverage` task injects your source files (`lib`) with jscoverage hooks, runs `mocha -R html-cov`, then restores later.
"coverage": "./node_modules/.bin/jscoverage YOURFILE.js && env COVERAGE=true ./node_modules/.bin/mocha -R html-cov > coverage.html; rm YOURFILE-cov.js",
### test/setup.js
Instead of requiring `YOURFILE.js`, use `-cov.js` when it's necessary. It's
preferred to do this in the test files (rather than the main entry points) so
not to mess with browserify.
var cov = (!! process.env.COVERAGE);
global.Mylib = require(cov ? 'mylib' : 'mylib-cov');
"coverage": "./node_modules/.bin/jscoverage lib && (mv lib lib~; mv lib-cov lib; ./node_modules/.bin/mocha -R html-cov > coverage.html; mv -f lib~ lib)"
### Run
npm run coverage
open coverage.html
### Caveats
If you're using jsdom, be sure to expose the `window._$jscoverage` variable into the `global` scope.

View File

@ -5,8 +5,35 @@ layout: default
### Relaxing
// expr: true
production && a = b;
/* expr: true */
production && minify = true;
/* loopfunc: true */
for (i=0; i<10; x++) {
(function(i) {
})(i);
}
/* sub: true */
process.env['name_here'];
### Enforcement
/* es3: true (legacy IE compatibility) */
a.default = function() { ... };
array = [ 1, 2, 3, ];
### Environments
browser /* window, document, ... */
node /* module, exports, console, process, ... */
jquery /* jQuery, $ */
### Also see
* www.jshint.com/docs/options/
* https://gist.github.com/haschek/2595796

2
sh.md
View File

@ -171,7 +171,7 @@ Misc crap
set -o nullglob # Non-matching globs are removed ('*.foo' => '')
set -o failglob # Non-matching globs throw errors
set -o nocaseglob # Case insensitive globs
set -o dotglob # Wildcards match dotfiles ("*.sh" => ".foo.sh")
set -o globdots # Wildcards match dotfiles ("*.sh" => ".foo.sh")
set -o globstar # Allow ** for recursive matches ('lib/**/*.rb' => 'lib/a/b/c.rb')
set GLOBIGNORE as a colon-separated list of patterns to be removed from glob

View File

@ -21,4 +21,27 @@ layout: default
filename: '[name].js'
/* also: [id] [hash] */
chunkFilename: "[id].chunk.js"
libraryTarget: 'var' | 'this' | 'commonjs' | 'commonjs2' | 'amd' | 'umd'
}
### Module
module: {
loaders: [ ... ]
preLoaders: [ ... ]
postLoaders: [ ... ]
}
### Resolve
resolve: {
alias: {
'xyz': './foo.js'
}
modulesDirectories: [
'node_modules',
'web_modules' ]
}
}