using mocha/chai/sinon for node.js unit-tests? check out my utility: mocha-stirrer to easily reuse test components and mock require dependencies
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
# $1=<new template component name> | |
# $2=<new template function name> | |
# expected file structure | |
# components | |
# / TemplateComponent | |
# / index.ts | |
# / TemplateComponent.tsx | |
# / TemplateComponent.test.tsx | |
# / TemplateComponent.module.scss | |
# / templateFunction.ts |
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
# update script to set variables or use parameters | |
username=<username here> | |
# remember to add token scope uploads:write | |
accessToken=<secret access token here> | |
# you can use "$1" for cli paramenter or however you please to set the path to file | |
pathToFile=</path/to/file here> | |
# to randomize id; change amount of characters after "head -c". This is mainly created for bash supported OS | |
export LC_CTYPE=C | |
randomId=$(head /dev/urandom | tr -dc a-z0-9 | head -c 6 ; echo '') |
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
// Cleaner implementation without Stacks, but using its concept | |
function main(arr) { | |
var solution = [], | |
balanced = true; | |
for (var i = 0; i < arr.length; i++){ | |
switch(arr[i]){ | |
case '{': | |
case '(': | |
case '[': |
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 reviewing the exercise again, I thought this revision is much cleaner and wanted to take out the extra function to not overcomplicate it | |
function flatten_array(input){ | |
var result = []; | |
for (var i = 0; i < input.length; i++){ | |
var flattened = input[i]; | |
result = result.concat(Array.isArray(flattened) ? flatten_array(flattened) : flattened); | |
} | |
return result; | |
} |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Soccer Test</title> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> | |
</head> | |
<body> | |
<div class="soccerBody container"> | |
<div class="row"> |
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
// Exercise a | |
var arrayofnums = [1,-5,4,-3,2]; | |
function max(array) { | |
var maxNumber = array[0]; | |
for(var i = 0; i < array.length; i++){ | |
if (array[i] > maxNumber){ | |
maxNumber = array[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
var prompt = require('prompt-sync')(); | |
function checkSpell(string1, string2) { | |
if (string1.toUpperCase().split("").sort().join("").trim() === string2.toUpperCase().split("").sort().join("").trim()) { | |
return "This is an anagram"; | |
} else { | |
// Just for humor's sake | |
return "In Trump's words: WRONG!"; | |
} |
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 arrays = [ | |
[9, 17, 0, 50], | |
[ 342, 689 ], | |
[ 43, 5, 12, 99 ], | |
[ 8, 4, 100 ], | |
[ 0, 1, 2, 3, 4, 5, 6, 7 ] | |
]; | |
function createHighestNumber(input, firstDigit, output){ | |
while (input.length > 0) { |