Skip to content

Instantly share code, notes, and snippets.

View AliceWonderland's full-sized avatar
:octocat:

Alice Chuang AliceWonderland

:octocat:
View GitHub Profile
@AliceWonderland
AliceWonderland / default
Created December 14, 2017 19:41 — forked from yacafx/default
NGNIX configuration for run node app and php app the same same time
### /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;
@AliceWonderland
AliceWonderland / 9.1 Default Values.js
Created May 1, 2017 15:31 — forked from anonymous/9.1 Default Values.js
9.1 Default Values created by smillaraaq - https://repl.it/HMxp/4
function dogBreeder(name,age){
var tmpName="";
if(name===undefined){
tmpName="Steve";
}else{
if(typeof name ==="string"){name=name;}
else{tmpName="Steve";}
}
if(age===undefined){
@AliceWonderland
AliceWonderland / 8.4 Deeper Copy.js
Created April 18, 2017 07:29 — forked from anonymous/8.4 Deeper Copy.js
8.4 Deeper Copy created by smillaraaq - https://repl.it/HJll/15
//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);
@AliceWonderland
AliceWonderland / 8.3 Reverse Array.js
Created April 18, 2017 07:28 — forked from anonymous/8.3 Reverse Array.js
8.3 Reverse Array created by smillaraaq - https://repl.it/HJlK/4
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());
}
@AliceWonderland
AliceWonderland / 8.2 My Splice.js
Created April 18, 2017 07:28 — forked from anonymous/8.2 My Splice.js
8.2 My Splice created by smillaraaq - https://repl.it/HJLw/14
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++){
@AliceWonderland
AliceWonderland / 8.1 Clone Machine.js
Created April 18, 2017 07:28 — forked from anonymous/8.1 Clone Machine.js
8.1 Clone Machine created by smillaraaq - https://repl.it/HJMy/8
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", []]
@AliceWonderland
AliceWonderland / 7.6 Partial.js
Created April 18, 2017 07:27 — forked from anonymous/7.6 Partial.js
7.6 Partial created by smillaraaq - https://repl.it/HICV/7
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;
@AliceWonderland
AliceWonderland / 7.5 Logger Array.js
Created April 18, 2017 07:27 — forked from anonymous/7.5 Logger Array.js
7.5 Logger Array created by smillaraaq - https://repl.it/HHoC/3
function genLoggers(arrayLength){
var resultArray=[];
for(var i=0;i<arrayLength;i++){
resultArray.push(
functionMaker(i)
);
}
function functionMaker(arrayIndex){
return function(){
@AliceWonderland
AliceWonderland / 7.4 Times Tables.js
Created April 18, 2017 07:26 — forked from anonymous/7.4 Times Tables.js
7.4 Times Tables created by smillaraaq - https://repl.it/HHmm/6
function timesTable(num){
var timesTableNum=num;
return function(num){
return num*timesTableNum;
}
}
// var ninesTable = timesTable(9);
@AliceWonderland
AliceWonderland / 7.3 Scope Koans.js
Created April 18, 2017 07:26 — forked from anonymous/7.3 Scope Koans.js
7.3 Scope Koans created by smillaraaq - https://repl.it/HHlS/5
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");