This file contains 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 mergeUpdates(data) { | |
let output = {}; | |
Object.entries(data).forEach(function(entry) { | |
let key = entry[0]; | |
let value = entry[1]; | |
if (key.startsWith(fieldName + '.')) { | |
let column = key.split('.')[1]; | |
output[column] = value; | |
return |
This file contains 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
func Connect() error { | |
var nc *nats.Conn | |
// Connect to NATS | |
nc, err := nats.Connect(eb.host, | |
nats.PingInterval(10*time.Second), | |
nats.MaxPingsOutstanding(3), | |
nats.MaxReconnects(-1), |
This file contains 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
const Groa = require('groa'); | |
const Router = require('groa-router'); | |
const app = new Groa(); | |
const router = new Router(); | |
// Add proto file | |
app.addProto(__dirname + '/router.proto'); | |
// package: example.foo |
This file contains 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
syntax = "proto3"; | |
package example.foo; | |
service Example1 { | |
rpc Ping(Echo) returns (Echo) {} | |
rpc Echo(Echo) returns (Echo) {} | |
rpc Hello(Hello) returns (Hello) {} | |
} |
This file contains 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
const { Client } = require('groa'); | |
const main = async () => { | |
let client = new Client('0.0.0.0', 50051); | |
// Load definition file | |
await client.loadProto(__dirname + '/example1.proto'); | |
// Get specific service |
This file contains 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
const Groa = require('groa'); | |
const app = new Groa(); | |
// Add proto file | |
app.addProto(__dirname + '/example1.proto'); | |
// Add middleware | |
app.use(async (ctx, next) => { |
This file contains 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
syntax = "proto3"; | |
package example.foo; | |
service Example1 { | |
rpc Ping(Ping) returns (Pong) {} | |
} | |
message Ping { | |
string content = 1; |
This file contains 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
npm install groa --save |
This file contains 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
$ make test -f Makefile2 | |
> [email protected] postinstall /Users/fred/projects/koa-benchmark/koa2 | |
> babel koa2-async.js --out-file koa2-async-compile.js | |
prepare complete | |
benchmark koa-1 | |
1 middleware | |
6295.24 |
This file contains 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
/* | |
* 此範例 | |
* A2接Light Sensor v1.1 | |
* D4接Buzzer v1.2 | |
* analogPin=撈取A2 Sensor值 | |
* 計算方式 5v/1024每個刻度4.9mv左右 | |
* 實際量測過這顆sensor 輸出最高數值約為2.08v左右 | |
* 依照這個基準點算起來2.08v/4.9mv所以就會得到425左右的值輸入 | |
* 此範例程式將撈取到的值供Delay使用 | |
* 所以當沒有光線的時候Delay越少 |
NewerOlder