Skip to content

Instantly share code, notes, and snippets.

View charithe's full-sized avatar

Charith Ellawala charithe

View GitHub Profile
@charithe
charithe / x_test.go
Created June 22, 2023 09:33
Viewing Cerbos test server logs
package x_test
import (
"context"
"testing"
"go.uber.org/zap"
"go.uber.org/zap/zaptest"
"github.com/cerbos/cerbos/client"
package mapbench
import (
"sync"
log "github.com/sirupsen/logrus"
)
type MapBench struct {
objects sync.Map
@charithe
charithe / grpc_test.go
Created October 27, 2018 11:49
Using Toxiproxy for resilliency tests
import (
"net"
"strconv"
"testing"
"time"
"github.com/Shopify/toxiproxy"
toxiclient "github.com/Shopify/toxiproxy/client"
)
@charithe
charithe / redis_test.go
Created October 27, 2018 11:21
Using Dockertest to launch Redis
import (
"net"
"testing"
"github.com/go-redis/redis"
"github.com/ory/dockertest"
)
func TestRedisStore(t *testing.T) {
addr, destroyFunc := startRedis(t)

Keybase proof

I hereby claim:

  • I am charithe on github.
  • I am charithe (https://keybase.io/charithe) on keybase.
  • I have a public key ASCum6rRJhYWxdWnYYXRfmrfD6a7-q3wBP80FSKiO5NaPgo

To claim this, I am signing this object:

@charithe
charithe / BuildEnvPlugin.scala
Created August 13, 2017 14:51
SBT Build Environment Dependent Docker Image
import BuildEnvPlugin.autoImport.BuildEnv
import com.sun.xml.internal.ws.api.config.management.policy.ManagementAssertion.Setting
import sbt.PluginTrigger.AllRequirements
import sbt.{AutoPlugin, Def, PluginTrigger, Plugins}
import sbtdocker.DockerPlugin
import sbt._
import sbt.Keys._
object BuildEnvPlugin extends AutoPlugin {
override def trigger: PluginTrigger = AllRequirements
@charithe
charithe / frequency.erl
Created April 14, 2017 11:39
Concurrent Programming in Erlang: Week 2
%% Based on code from
%% Erlang Programming
%% Francecso Cesarini and Simon Thompson
%% O'Reilly, 2008
%% http://oreilly.com/catalog/9780596518189/
%% http://www.erlangprogramming.org/
%% (c) Francesco Cesarini and Simon Thompson
-module(frequency).
-export([start/0,allocate/0,deallocate/1,stop/0,spawn_client/1]).
@charithe
charithe / frequency.erl
Created April 8, 2017 18:20
Concurrent Programming in Erlang: Week1
%% Based on code from
%% Erlang Programming
%% Francecso Cesarini and Simon Thompson
%% O'Reilly, 2008
%% http://oreilly.com/catalog/9780596518189/
%% http://www.erlangprogramming.org/
%% (c) Francesco Cesarini and Simon Thompson
-module(frequency).
-export([start/0,allocate/0,deallocate/1,stop/0]).
@charithe
charithe / client.go
Created March 26, 2017 16:28
GRPC Opentracing Interceptors
package otgrpc
import (
context "golang.org/x/net/context"
"github.com/opentracing/opentracing-go"
"github.com/opentracing/opentracing-go/ext"
"github.com/opentracing/opentracing-go/log"
"google.golang.org/grpc"
)
@charithe
charithe / index.erl
Created March 5, 2017 15:15
FutureLearn Erlang MOOC Week 2: Indexing a file
-module(index).
-export([do_index/1, show_file_contents/1]).
%% Main entrypoint
%% In the Erlang shell, execute: rp(index:do_index("path_to_file")).
%% Reads the contents of the file using the provided functions, builds up a map
%% of words to their locations, compresses the locations to ranges and returns a
%% list sorted in alphabetical order
do_index(Name) ->
Lines = get_file_contents(Name),