Skip to content

Instantly share code, notes, and snippets.

View varavut's full-sized avatar

Varavut Lormongkol varavut

View GitHub Profile
<head>
<title>meteor-rest2ddp</title>
</head>
<body>
{{> hello}}
</body>
<template name="hello">
<ul>
if (Meteor.isClient) {
Samples = new Mongo.Collection('samples');
Template.hello.onCreated(function () {
var self = this;
self.autorun(function () {
self.subscribe('REST2DDP', 'sample');
});
});
if (Meteor.isClient) {
Samples = new Mongo.Collection('samples');
}
if (Meteor.isServer) {
REST2DDP.configs.push({
name: 'sample',
collectionName: 'samples',
restUrl: 'http://localhost:3002/test',
jsonPath: '$.data.*',
pollInterval: 1,
});
}
{
"data":[
{
"value":44
},
{
"value":82
},
{
"value":28
'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
});
[
[ 'R', 'R', 'R' ],
[ 'R', 'R' ],
[ 'R' ],
[ 'R' ],
[ 'R', 'R' ],
[ 'R', 'R', 'R' ]
]
// 'R' is red cube
// 'Y' is yellow cube
var data = [
['Y','Y','R'],
['Y','R'],
['R'],
['R'],
['Y','R'],
['Y','Y','R']
// 'R' is red cube
// 'Y' is yellow cube
[
['Y','Y','R'],
['Y','R'],
['R'],
['R'],
['Y','R'],
['Y','Y','R']
function foo1(n){
a = n*5;
return g(a);
}
function foo2(n){
if(n == 10)
return f(5);
return g(n*5);
}