This file contains 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 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
#!/bin/bash | |
# Locate the history file in your profile, and copy it to the same folder as this script. | |
# On Mac: ~/Library/Application\ Support/Google/Chrome/Default/History | |
# On Windows: C:\Users\YOUR USER NAME\AppData\Local\Google\Chrome\User Data\Default\History | |
sqlite3 History <<! | |
.headers on | |
.mode csv | |
.output out.csv |
This file contains 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 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
let foo = ({param1 = 1, param2 = 2, param3 = 3} = {}) => { | |
return (param1 + param2) / param3; | |
}; | |
console.log(foo()); //returns 1 | |
console.log(foo({param3: 1})); //returns 3 | |
console.log(foo({param1: 7, param2: 2})); //returns 3 | |
console.log(foo({param1: 6, param3: 2})); //returns 4 |
This file contains 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 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
const delay = ms => new Promise(resolve => setTimeout(resolve, ms)); | |
// Sample code using `delay` | |
const test = async () => { | |
const time = () => console.log((new Date).toLocaleTimeString()); | |
time(); | |
await delay(1000); | |
time(); | |
await delay(3000); | |
time(); |
This file contains 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 sqlite3 = require('sqlite3').verbose(); | |
var db = new sqlite3.Database('guy.sqlite'); //':memory:' | |
db.serialize(function() { | |
db.get("SELECT name FROM sqlite_master WHERE type='table' AND name='lorem'", function(error, row) { | |
if (row !== undefined) { | |
console.log("table exists. cleaning existing records"); | |
db.run("DELETE FROM lorem", function(error) { | |
if (error) | |
console.log(error); |
This file contains 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
let getJson = async url => { | |
try { | |
let response = await fetch(url); | |
let json = await response.json(); | |
return json; | |
} | |
catch(ex) { | |
//throw ex; //may want to handle externally | |
console.error(ex); | |
} |
This file contains 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
// Without line 9 hack, linting the file throws: 5:4 error should is defined but never used no-unused-vars | |
'use strict'; | |
var debug = require('debug')('test:myModel'); | |
var should = require('should'); | |
var security = require('../models/myModel'); | |
before((done) => { | |
should; //bypass ESLint no-unused-var error | |
done(); |
This file contains 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
let arr = [2, 3, 5, 2, 1, 3]; | |
arr = [...new Set(arr)]; //arr now contains [2, 3, 5, 1] |
NewerOlder