This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"maxerr" : 50, // {int} Maximum error before stopping | |
// Enforcing | |
"bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.) | |
"camelcase" : false, // true: Identifiers must be in camelCase | |
"curly" : true, // true: Require {} for every new block or scope | |
"eqeqeq" : true, // true: Require triple equals (===) for comparison | |
"forin" : true, // true: Require filtering for..in loops with obj.hasOwnProperty() | |
"immed" : false, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var myFunc = function(x){return x*2;}; | |
var num = 3; | |
var array = Array.apply(null, Array(num)).map(function(){return myFunc;}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var str = "This is a string.", | |
term = 'is', | |
reg = new RegExp(term, 'ig'); //remove the `i` if you need case-sensitivity | |
var count = str.match(reg).length; | |
console.log(count); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var getValueFromQueryString = function(url, key) { | |
return decodeURIComponent(new RegExp('[?|&]' + key + '=' + '([^&;]+?)(&|#|;|$)').exec(url) || [,""])[1].replace(/\+/g, '%20') || null; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var objectToQueryString = function(obj) { | |
var qs = _.reduce(obj, function(result, value, key) { | |
return (!_.isNull(value) && !_.isUndefined(value)) ? (result += key + '=' + value + '&') : result; | |
}, '').slice(0, -1); | |
return qs; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
//npm install gulp gulp-minify-css gulp-uglify gulp-clean gulp-cleanhtml gulp-jshint gulp-strip-debug gulp-zip --save-dev | |
var gulp = require('gulp'), | |
clean = require('gulp-clean'), | |
cleanhtml = require('gulp-cleanhtml'), | |
minifycss = require('gulp-minify-css'), | |
jshint = require('gulp-jshint'), | |
stripdebug = require('gulp-strip-debug'), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script> | |
window.addEventListener("offline", function(e) {alert("offline");}) | |
window.addEventListener("online", function(e) {alert("online");}) | |
</script> | |
</head> | |
<body> | |
</body> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm -g ls --depth=0 > ~/before.txt | |
npm -g update > /dev/null 2>&1 | |
npm -g ls --depth=0 > ~/after.txt | |
diff -as ~/before.txt ~/after.txt | |
rm ~/before.txt ~/after.txt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0 info it worked if it ends with ok | |
1 verbose cli [ '/opt/local/bin/node', '/opt/local/bin/npm', '-g', 'update' ] | |
2 info using [email protected] | |
3 info using [email protected] | |
4 verbose cache add [ 'express', '*' ] | |
5 verbose cache add name="express" spec="*" args=["express","*"] | |
6 verbose parsed url { protocol: null, | |
6 verbose parsed url slashes: null, | |
6 verbose parsed url auth: null, | |
6 verbose parsed url host: null, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Assuming you have the text © <span id="year"></span> in your footer --> | |
<!-- Without jQuery, add to bottom of page --> | |
<script>document.getElementById('year').textContent = (new Date()).getFullYear();</script> | |
<!-- If you're using jQuery, add this to $(document).ready() or $(function()) --> | |
$('#year').text((new Date()).getFullYear()); | |
<!-- One line in the HTML page --> | |
<footer>copyright © <script>document.write((new Date()).getFullYear());</script></footer> |