Skip to content

Instantly share code, notes, and snippets.

gistlyn

Block or report user

Report or block gistlyn

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@gistlyn
gistlyn / ss-utils.js
Last active Jan 23, 2020
rewrite ss-utils.js to minimize allocations in IE
View ss-utils.js
;(function (root, f) {
if (typeof exports === 'object' && typeof module === 'object')
module.exports = f(require("jquery"));
if (typeof define === "function" && define.amd)
define(["jquery"], f);
else if (typeof exports === "object")
f(require("jquery"));
else
f(root.jQuery);
})(this, function ($) {
@gistlyn
gistlyn / Configure.Grpc.cs
Last active Jan 6, 2020
Configure gRPC (requires .NET Core 3.1)
View Configure.Grpc.cs
using Microsoft.Extensions.DependencyInjection;
using ServiceStack;
namespace MyApp
{
public class ConfigureGrpc : IConfigureServices, IConfigureAppHost
{
public void Configure(IServiceCollection services)
{
services.AddServiceStackGrpc();
@gistlyn
gistlyn / index.js
Created Dec 31, 2019
Node.js Google protoc SSL GrpcServicesClient TodoWorld Example
View index.js
const { Hello } = require('./services_pb.js');
const { GrpcServicesClient } = require('./services_grpc_pb.js');
const grpc = require('grpc');
const { promisify } = require('util');
const fs = require('fs');
async function main() {
const client = new GrpcServicesClient('todoworld.servicestack.net:50051',
grpc.credentials.createSsl(fs.readFileSync('grpc.crt')));
@gistlyn
gistlyn / index.js
Created Dec 31, 2019
Node.js Google protoc insecure GrpcServicesClient TodoWorld Example
View index.js
const { Hello } = require('./services_pb.js');
const { GrpcServicesClient } = require('./services_grpc_pb.js');
const grpc = require('grpc');
const { promisify } = require('util');
async function main() {
const client = new GrpcServicesClient('todoworld.servicestack.net:5054',
grpc.credentials.createInsecure());
@gistlyn
gistlyn / main.php
Created Dec 31, 2019
PHP Google protoc SSL GrpcServicesClient TodoWorld Example
View main.php
<?php
require dirname(__FILE__).'/vendor/autoload.php';
@include_once dirname(__FILE__).'/GPBMetadata/Services.php';
@include_once dirname(__FILE__).'/TodoWorld/GrpcServicesClient.php';
@include_once dirname(__FILE__).'/TodoWorld/Hello.php';
@include_once dirname(__FILE__).'/TodoWorld/HelloResponse.php';
$client = new TodoWorld\GrpcServicesClient('todoworld.servicestack.net:50051', [
'credentials' => Grpc\ChannelCredentials::createSsl(file_get_contents('grpc.crt')),
@gistlyn
gistlyn / main.php
Created Dec 31, 2019
PHP Google protoc insecure GrpcServicesClient TodoWorld Example
View main.php
<?php
require dirname(__FILE__).'/vendor/autoload.php';
@include_once dirname(__FILE__).'/GPBMetadata/Services.php';
@include_once dirname(__FILE__).'/TodoWorld/GrpcServicesClient.php';
@include_once dirname(__FILE__).'/TodoWorld/Hello.php';
@include_once dirname(__FILE__).'/TodoWorld/HelloResponse.php';
$client = new TodoWorld\GrpcServicesClient('todoworld.servicestack.net:5054', [
'credentials' => Grpc\ChannelCredentials::createInsecure(),
@gistlyn
gistlyn / main.rb
Created Dec 31, 2019
Ruby Google protoc SSL GrpcServices Client TodoWorld Example
View main.rb
#!/usr/bin/env ruby
this_dir = File.expand_path(File.dirname(__FILE__))
lib_dir = File.join(this_dir, 'lib')
$LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
require 'grpc'
require 'services_pb'
require 'services_services_pb'
@gistlyn
gistlyn / main.rb
Created Dec 31, 2019
Ruby Google protoc insecure GrpcServices Client TodoWorld Example
View main.rb
#!/usr/bin/env ruby
this_dir = File.expand_path(File.dirname(__FILE__))
lib_dir = File.join(this_dir, 'lib')
$LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
require 'grpc'
require 'services_pb'
require 'services_services_pb'
@gistlyn
gistlyn / main.py
Created Dec 30, 2019
Python Google protoc SSL GrpcServicesClient TodoWorld Example
View main.py
import grpc
import services_pb2
import services_pb2_grpc
def run():
with open('grpc.crt', 'rb') as f:
credentials = grpc.ssl_channel_credentials(f.read())
with grpc.secure_channel('todoworld.servicestack.net:50051', credentials) as channel:
client = services_pb2_grpc.GrpcServicesStub(channel)
@gistlyn
gistlyn / main.py
Created Dec 30, 2019
Python Google protoc insecure GrpcServicesClient TodoWorld Example
View main.py
import grpc
import services_pb2
import services_pb2_grpc
def run():
with grpc.insecure_channel('todoworld.servicestack.net:5054') as channel:
client = services_pb2_grpc.GrpcServicesStub(channel)
response = client.GetHello(services_pb2.Hello(Name="gRPC Python"))
print(response.Result)
You can’t perform that action at this time.