Skip to content

Instantly share code, notes, and snippets.

View ru-rocker's full-sized avatar

ru rocker ru-rocker

View GitHub Profile
@ru-rocker
ru-rocker / Vagrantfile
Created October 15, 2018 07:19
Sample of Vagrantfile for GO CD setup
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "centos/7"
config.vm.provider "virtualbox" do |vb|
# Customize the amount of memory on the VM:
@ru-rocker
ru-rocker / gist:a61162964aac135c83ccd4af9a77dd0e
Created December 1, 2017 16:07
How to find corrupted jar files in local repo
find ~/.m2/repository/ -name "*jar" | xargs -L 1 zip -T | grep error | grep invalid
@ru-rocker
ru-rocker / DoublyLinkedList.java
Last active May 29, 2017 08:17
Implementation of DoublyLinkedList algorithm
package com.rurocker.algo.ds;
/**
* DoublyLinkedList implementation
* Created by ricky on 5/29/17.
*/
public class DoublyLinkedList<E> {
private int size;
private Node<E> head;
@ru-rocker
ru-rocker / discovery.go
Last active April 15, 2017 14:45
Utility for consule service discovery
package lorem_consul
import (
consulsd "github.com/go-kit/kit/sd/consul"
"github.com/go-kit/kit/log"
"os"
"github.com/hashicorp/consul/api"
"github.com/go-kit/kit/sd"
"math/rand"
"strconv"
@ru-rocker
ru-rocker / instrument.go
Created April 1, 2017 14:53
metrics middleware
package lorem_metrics
import (
"github.com/go-kit/kit/metrics"
"time"
)
func Metrics(requestCount metrics.Counter,
requestLatency metrics.Histogram) ServiceMiddleware {
return func(next Service) Service {
@ru-rocker
ru-rocker / client_cmd_main.go
Last active February 20, 2017 10:30
lorem-grpc client command
package main
import (
"flag"
"time"
"log"
grpcClient "github.com/ru-rocker/gokit-playground/lorem-grpc/client"
"google.golang.org/grpc"
"golang.org/x/net/context"
"github.com/ru-rocker/gokit-playground/lorem-grpc"
@ru-rocker
ru-rocker / client.go
Created February 20, 2017 08:28
lorem-grpc client builder
package client
import (
"github.com/ru-rocker/gokit-playground/lorem-grpc"
"github.com/ru-rocker/gokit-playground/lorem-grpc/pb"
grpctransport "github.com/go-kit/kit/transport/grpc"
"google.golang.org/grpc"
)
// Return new lorem_grpc service
@ru-rocker
ru-rocker / server_grpc_main.go
Last active February 20, 2017 10:31
lorem-grpc server
package main
import (
"net"
"flag"
"github.com/ru-rocker/gokit-playground/lorem-grpc"
context "golang.org/x/net/context"
"google.golang.org/grpc"
"github.com/ru-rocker/gokit-playground/lorem-grpc/pb"
"os"
@ru-rocker
ru-rocker / transport.go
Created February 20, 2017 08:27
lorem-grpc trasport layer
package lorem_grpc
import (
"golang.org/x/net/context"
grpctransport "github.com/go-kit/kit/transport/grpc"
"github.com/ru-rocker/gokit-playground/lorem-grpc/pb"
)
type grpcServer struct {
lorem grpctransport.Handler
@ru-rocker
ru-rocker / model.go
Created February 20, 2017 08:27
lorem-grpc model layer
package lorem_grpc
import (
"context"
"github.com/ru-rocker/gokit-playground/lorem-grpc/pb"
)
//Encode and Decode Lorem Request
func EncodeGRPCLoremRequest(_ context.Context, r interface{}) (interface{}, error) {
req := r.(LoremRequest)