Skip to content

Instantly share code, notes, and snippets.

View cfsghost's full-sized avatar

Fred Chien(錢逢祥) cfsghost

View GitHub Profile
@cfsghost
cfsghost / example1.js
Created September 26, 2017 22:31
Groa.js : Koa-like gRPC Middleware Framework - example1.js
const Groa = require('groa');
const app = new Groa();
// Add proto file
app.addProto(__dirname + '/example1.proto');
// Add middleware
app.use(async (ctx, next) => {
@cfsghost
cfsghost / example1.proto
Created September 26, 2017 22:18
Groa.js : Koa-like gRPC Middleware Framework - proto
syntax = "proto3";
package example.foo;
service Example1 {
rpc Ping(Ping) returns (Pong) {}
}
message Ping {
string content = 1;
@cfsghost
cfsghost / Installation.sh
Last active September 26, 2017 22:18
Groa.js : Koa-like gRPC Middleware Framework Installation
npm install groa --save
@andyburke
andyburke / facebook-photo-post-javascript.js
Created December 19, 2011 20:37
How to post a photo to Facebook from client-side Javascript
// This bit is important. It detects/adds XMLHttpRequest.sendAsBinary. Without this
// you cannot send image data as part of a multipart/form-data encoded request from
// Javascript. This implementation depends on Uint8Array, so if the browser doesn't
// support either XMLHttpRequest.sendAsBinary or Uint8Array, then you will need to
// find yet another way to implement this. (This is left as an exercise for the reader,
// but if you do it, please let me know and I'll integrate it.)
// from: http://stackoverflow.com/a/5303242/945521
if ( XMLHttpRequest.prototype.sendAsBinary === undefined ) {