Skip to content

Instantly share code, notes, and snippets.

View varavut's full-sized avatar

Varavut Lormongkol varavut

View GitHub Profile
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]]++;
{
a: '0',
leaf1: {
a: '1',
leaf1: {
a: '2',
leaf1: {
a: '3',
}
},
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 ตามด้านบน
function foo1(n){
a = n*5;
return g(a);
}
function foo2(n){
if(n == 10)
return f(5);
return g(n*5);
}
// 'R' is red cube
// 'Y' is yellow cube
[
['Y','Y','R'],
['Y','R'],
['R'],
['R'],
['Y','R'],
['Y','Y','R']
// 'R' is red cube
// 'Y' is yellow cube
var data = [
['Y','Y','R'],
['Y','R'],
['R'],
['R'],
['Y','R'],
['Y','Y','R']
[
[ 'R', 'R', 'R' ],
[ 'R', 'R' ],
[ 'R' ],
[ 'R' ],
[ 'R', 'R' ],
[ 'R', 'R', 'R' ]
]
'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
});
{
"data":[
{
"value":44
},
{
"value":82
},
{
"value":28
if (Meteor.isServer) {
REST2DDP.configs.push({
name: 'sample',
collectionName: 'samples',
restUrl: 'http://localhost:3002/test',
jsonPath: '$.data.*',
pollInterval: 1,
});
}