Skip to content

Instantly share code, notes, and snippets.

@south37
south37 / Servicex::Grpc::Server - servicex.rb
Last active June 8, 2020 12:34
Implementation of grpc-server command
require 'optparse'
require 'grpc/health/checker'
# NOTE: We must inject module-level logger.
# cf. https://github.com/grpc/grpc/blob/de893acb6aef88484a427e64b96727e4926fdcfd/src/ruby/lib/grpc/logconfig.rb#L43
# cf. https://github.com/grpc/grpc/blob/49be7a6667ee27be7be44c6307428ace9dbe373b/src/ruby/spec/spec_helper.rb#L42-L44
module GRPC
class << self
def logger
@logger ||= Servicex.logger
@south37
south37 / .stub_for - servicex.rb
Created March 12, 2020 02:25
.stub_for の実装
module Servicex::Grpc
class << self
# @example
# Servicex::Grpc.stub_for(UsersPb::UserService, UsersApi.base_url)
# @param service_class [Class<Grpc::GeneralService>]
# @param url [String]
# @yield [opts] To modify options for instantiating a Stub
# @yieldparam opts [Hash] Default options
def stub_for(service_class, url)
opts = {
@south37
south37 / resources.proto
Created September 4, 2018 06:41
.proto ファイルの内容を parse した情報を protoc-gen-json (https://github.com/sourcegraph/prototools/blob/master/README.json.md) で dump
syntax = "proto3";
package resources;
message User {
int32 id = 1;
Profile profile = 2;
}
message Profile {
int32 id = 1;
@south37
south37 / resources.proto
Last active September 1, 2018 17:45
.proto ファイルの内容を parse した情報を protoc-gen-reqdump (https://github.com/yugui/protoc-gen-reqdump) で dump
syntax = "proto3";
package resources;
message User {
int32 id = 1;
Profile profile = 2;
}
message Profile {
int32 id = 1;
@south37
south37 / json_parser.rs
Last active June 25, 2022 15:18
rust で combine を使って書いた json parser
// Rewrite code with `parser!` macro.
// Target: https://github.com/Marwes/combine/blob/f32fe7c135b8c3104843939b7b505f8b0ea4862e/benches/json.rs
#[macro_use]
extern crate combine;
use std::collections::hash_map::HashMap;
use combine::parser::char::{char, string, digit, spaces};
use combine::parser::choice::{choice, optional};
@south37
south37 / hello.c
Created January 25, 2018 07:46
hello
#include "stdio.h"
int main(int argc, char** argv) {
printf("Hello, World!\n");
return 0;
}
@south37
south37 / fib.c
Created January 25, 2018 06:42
fib
#include "stdlib.h"
#include "stdio.h"
int fib(int n) {
if (n == 0 || n == 1) {
return 1;
} else {
return fib(n - 1) + fib(n - 2);
}
}
@south37
south37 / heap.c
Last active January 25, 2018 06:00
heap
#include <stdio.h>
#include <stdlib.h>
#define MAX_N 100
typedef struct {
int nodes[MAX_N];
int size;
} Heap;
@south37
south37 / assert.rb
Last active December 9, 2017 08:10
## Definition of assert!
class AssertError < RuntimeError; end
def assert!(&block)
raise AssertError.new("Assertion failed!") if !block.call
rescue AssertError => e
print e
code = <<-CODE
require 'pry'
binding.pry
CODE
@south37
south37 / 00_timeline.md
Last active May 3, 2024 17:19
ISUCON Cheat Sheet