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
### /etc/nginx/sites-available/default | |
server { | |
listen 80 default_server; | |
listen [::]:80 default_server; | |
root /var/www/html; | |
index index.html index.htm index.php; |
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
function dogBreeder(name,age){ | |
var tmpName=""; | |
if(name===undefined){ | |
tmpName="Steve"; | |
}else{ | |
if(typeof name ==="string"){name=name;} | |
else{tmpName="Steve";} | |
} | |
if(age===undefined){ |
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
//slice() does a pass by reference not value if the value it's passing is an object! | |
function copy(ary){ | |
//loop thru ary check typeof | |
//if object loop through, copy each value individually | |
var resultArray=[]; | |
for(var i=0;i<ary.length;i++){ | |
var tmpItem=copyIndefinite(ary[i]); | |
// console.log(tmpItem); | |
resultArray.push(tmpItem); |
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 myArray = [1, 2, 3, 4]; | |
reverse(myArray); | |
console.log(myArray) // [4, 3, 2, 1] | |
function reverse(arr){ | |
var cloneArray=arr.slice(); | |
var tmpArray=[]; | |
for(var i=0;i<arr.length;i++){ | |
tmpArray.push(cloneArray.pop()); | |
} |
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
function mySplice(arr,start,numEles){ | |
//remove item at 'start' | |
//remove numEles incl 'start' | |
//modify original array | |
//do not use splice | |
var tmpArray = []; | |
var modifiedElements=[]; | |
for(var i=0; i<arr.length;i++){ |
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 dolly = ["Dolly", "sheep", []]; | |
var dollyClone = cloneAnimal(dolly); | |
var dollyClone2 = cloneAnimal(dolly); | |
var dollyClone3 = cloneAnimal(dolly); | |
// The clone is of same species, with new name and no offspring | |
console.log(dollyClone) | |
console.log(dollyClone2)// ["DollyClone", "sheep", []] |
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
function partial(paramA, paramB){ | |
var resultA=paramA(paramB,0); | |
var resultB=paramB; | |
console.log(resultA, resultB); | |
var resultFunction=function(param){ | |
return resultA+param; | |
}; | |
return resultFunction; |
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
function genLoggers(arrayLength){ | |
var resultArray=[]; | |
for(var i=0;i<arrayLength;i++){ | |
resultArray.push( | |
functionMaker(i) | |
); | |
} | |
function functionMaker(arrayIndex){ | |
return 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
function timesTable(num){ | |
var timesTableNum=num; | |
return function(num){ | |
return num*timesTableNum; | |
} | |
} | |
// var ninesTable = timesTable(9); |
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 testOneMessage = "test failing"; | |
function testOne(testOneMessage) {//every param becomes a new var local | |
// Test One Restrictions: Do not declare any new variable with the var keyword | |
// Do not reassign testOneMessage | |
console.log("Test one: ", testOneMessage); | |
} | |
// Run test one | |
testOne("test succeeding"); |
NewerOlder