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 countElement(array, i, acc){ | |
if(!i) | |
i = 0; | |
if(!acc) | |
acc = {}; | |
if(array.length<=i) | |
return acc; | |
if(!acc[array[i]]) | |
acc[array[i]] = 0; | |
acc[array[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
{ | |
a: '0', | |
leaf1: { | |
a: '1', | |
leaf1: { | |
a: '2', | |
leaf1: { | |
a: '3', | |
} | |
}, |
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 printTree(n){ | |
if(n.leaf1) | |
printTree(n.leaf1); | |
if(n.leaf2) | |
printTree(n.leaf2); | |
if(n.a) | |
console.log(n.a); | |
} | |
printTree(n); // n คือ tree ตามด้านบน |
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 foo1(n){ | |
a = n*5; | |
return g(a); | |
} | |
function foo2(n){ | |
if(n == 10) | |
return f(5); | |
return g(n*5); | |
} |
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
// 'R' is red cube | |
// 'Y' is yellow cube | |
[ | |
['Y','Y','R'], | |
['Y','R'], | |
['R'], | |
['R'], | |
['Y','R'], | |
['Y','Y','R'] |
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
// 'R' is red cube | |
// 'Y' is yellow cube | |
var data = [ | |
['Y','Y','R'], | |
['Y','R'], | |
['R'], | |
['R'], | |
['Y','R'], | |
['Y','Y','R'] |
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
[ | |
[ 'R', 'R', 'R' ], | |
[ 'R', 'R' ], | |
[ 'R' ], | |
[ 'R' ], | |
[ 'R', 'R' ], | |
[ 'R', 'R', 'R' ] | |
] |
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
'use strict'; | |
const Hapi = require('hapi'); | |
// Create a server with a host and port | |
const server = new Hapi.Server(); | |
server.connection({ | |
host: 'localhost', | |
port: 3002 | |
}); |
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
{ | |
"data":[ | |
{ | |
"value":44 | |
}, | |
{ | |
"value":82 | |
}, | |
{ | |
"value":28 |
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
if (Meteor.isServer) { | |
REST2DDP.configs.push({ | |
name: 'sample', | |
collectionName: 'samples', | |
restUrl: 'http://localhost:3002/test', | |
jsonPath: '$.data.*', | |
pollInterval: 1, | |
}); | |
} |