Skip to content

Instantly share code, notes, and snippets.

Yusuke Sato sat0yu

Block or report user

Report or block sat0yu

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
@sat0yu
sat0yu / interceptor.go
Created Jul 7, 2019
sentry-raven-grpc/interceptor.go
View interceptor.go
// ErrorCapturer specifies the implementation of a method to capture the given error
type ErrorCapturer interface {
CaptureError(err error, tags map[string]string) string
}
// SentryRavenInterceptor creates an interceptor which catches the errors from each service method and reports them to Sentry
func SentryRavenInterceptor(ec ErrorCapturer) grpc.UnaryServerInterceptor {
return func(ctx context.Context, req interface{}, _info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
resp, err := handler(ctx, req)
if err != nil {
@sat0yu
sat0yu / minhash.go
Created Sep 15, 2019
A MinHash implementation in go
View minhash.go
package main
import (
"fmt"
"log"
"math/rand"
"time"
)
const DIM = 26 // |{'a', ..., 'z'}| = 26
@sat0yu
sat0yu / bloomfilter.go
Created Sep 23, 2019
A BloomFilter implementation
View bloomfilter.go
package main
import (
"bufio"
"crypto/md5"
"encoding/hex"
"fmt"
"math/big"
"os"
)
View active_record_with_connection_interceptor.rb
class ActiveRecordWithConnectionInterceptor < ::GRPC::ServerInterceptor
def request_response(**)
# ref: https://github.com/rails/rails/blob/5-2-stable/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb#L54-L56
::ActiveRecord::Base.connection_pool.with_connection do
yield
end
end
alias_method :server_streamer, :request_response
alias_method :client_streamer, :request_response
You can’t perform that action at this time.