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
// I was not expecting this. I changed a test using Node's assert.deepEqual() to | |
// Jest's toEqual(). | |
// Node's deepEqual(): | |
assert.deepEqual(transformed, plant); | |
// passed! | |
// Jest's toEqual(): | |
expect(transformed).toEqual(plant); | |
// Fails: |
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
// Which is faster depends on which version of Node you're using. | |
// See the bottom for the results. | |
const iterations = 1000000; | |
const arrayOfTen = [...Array(10).keys()]; | |
const arrayOfArrays = [...Array(10).keys()].map(() => arrayOfTen); | |
const NS_PER_SEC = 1e9; | |
function a() { | |
for (let i = 1; i < iterations; i++) { |
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
// After resetting the Master Combo Lock I was unable to unlock it. | |
// Assuming that I had been off on one or more on the new number/ | |
// letters I needed to generate all of the combinations so I could | |
// open it. | |
// This is an example of the combo I thought I set it to: | |
const combo = '0AT'; | |
// These are the numbers/letters available on the dial: | |
const letters = '0123456789ADEHJLNRST'; |
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
// I create a script to generate this groovy - i.e. did not write it by hand | |
mgmt = graph.openManagement(); | |
if(!mgmt.containsPropertyKey('TEXT_key_prop')){ | |
k = mgmt.makePropertyKey('TEXT_key_prop').dataType(String.class).cardinality(Cardinality.SINGLE).make(); | |
mgmt.buildIndex('TEXT_index_name', Vertex.class).addKey(k, Mapping.TEXT.asParameter()).buildMixedIndex('search'); | |
mgmt.commit(); | |
graph.addVertex('TEXT_key_prop', 'The quick brown fox JUMPS oVeR the lazy dog'); | |
graph.tx().commit(); |
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 obj = { | |
one: 'one', | |
two: 'two' | |
}; | |
// Forgot to add length after Object.keys(obj) | |
var isBig = Object.keys(obj) > 1; | |
console.log(isBig); | |
// false but should be true. |
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 async = require('async'); | |
var arr = [1,2,3,4]; | |
async.eachSeries(arr,function(item, cb){ | |
setTimeout(function() { | |
console.log('#1: ', item); | |
return cb(); | |
}, Math.random()*2000); | |
}, function(err){ |
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 async = require('async'); | |
var arr = [1,2,3,4]; | |
async.each(arr,function(item, cb){ | |
setTimeout(function() { | |
console.log('#1: ', item); | |
return cb(); | |
}, Math.random()*2000); | |
}, function(err){ |
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
0 info it worked if it ends with ok | |
1 verbose cli [ 'node', '/home/guy/local/bin/npm', 'publish' ] | |
2 info using [email protected] | |
3 info using [email protected] | |
4 verbose publish [ '.' ] | |
5 verbose cache add [ '.', null ] | |
6 verbose cache add spec="." args=[".",null] | |
7 verbose parsed spec { raw: '.', | |
7 verbose parsed spec scope: null, | |
7 verbose parsed spec name: null, |
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 vowels = ['a','e','i','o','u']; | |
var alphabet = 'bcdfghjklmnpqrstvwxyz'; | |
for(var a=0; a<alphabet.length; a++) { | |
for(var v1=0; v1<vowels.length; v1++) { | |
for(var b=0; b<alphabet.length; b++) { | |
for(var c=0; c<alphabet.length; c++) { | |
for(var v2=0; v2<vowels.length; v2++) { | |
for(var d=0; d<alphabet.length; d++) { | |
console.log(alphabet[a] + vowels[v1] + alphabet[b] + alphabet[c] + vowels[v2] + alphabet[d]); | |
} |
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
// Accepts a single paramater which is one or more emails separated | |
// by space,comma,semicolon,tab, or newline. | |
// Returns an array of tokens that should be emails | |
// Does not validate emails to see if they are well formed. | |
exports.parseEmails = function(emails) { | |
return emails.toLowerCase().split(/[\s,;\t\n]+/); | |
}; | |
NewerOlder