Skip to content

Instantly share code, notes, and snippets.

View charithe's full-sized avatar

Charith Ellawala charithe

View GitHub Profile
@charithe
charithe / SSTableExport.java
Created December 28, 2012 11:59
Patches to Cassandra Tools
import static org.apache.cassandra.utils.ByteBufferUtil.bytesToHex;
import static org.apache.cassandra.utils.ByteBufferUtil.hexToBytes;
import org.apache.cassandra.config.CFMetaData;
import org.apache.cassandra.config.ConfigurationException;
import org.apache.cassandra.config.DatabaseDescriptor;
import org.apache.cassandra.config.Schema;
import org.apache.cassandra.db.ColumnFamily;
import org.apache.cassandra.db.CounterColumn;
import org.apache.cassandra.db.DecoratedKey;
@charithe
charithe / dnscrypt.service
Created June 8, 2013 17:14
systemd service definition for the dnscrypt-proxy. For more information, see my blog post at http://www.lucidelectricdreams.com/2013/06/setting-up-dnscrypt-on-fedora.html
[Unit]
Description=dnscrypt - Encrypted DNS service provided by OpenDNS
After=NetworkManager.service
[Service]
ExecStart=/usr/local/sbin/dnscrypt-proxy -u dnscrypt
ExecReload=/bin/kill -HUP $MAINPID
[Install]
WantedBy=basic.target
@charithe
charithe / TypesafeConfigMacros.scala
Created March 29, 2016 09:17
Scala macro for accessing Typesafe Config objects
import com.typesafe.config.Config
import scala.language.experimental.macros
import scala.reflect.macros.whitebox
import scala.reflect.runtime.universe._
object TypesafeConfigMacros {
def asImpl[T: c.WeakTypeTag](c: whitebox.Context)(key: c.Expr[String])(tag: c.Expr[WeakTypeTag[T]]): c.Expr[Option[T]] = {
@charithe
charithe / assignment.erl
Created February 25, 2017 19:47
FutureLearn Erlang MOOC: Assignment 1
-module(assignment).
-export([perimeter/1, area/1, enclose/1, bits/1]).
perimeter({circle, {_X, _Y}, R}) -> 2 * math:pi() * R;
perimeter({rectangle, {_X, _Y}, H, W}) -> 2 * (H + W);
%% A triangle is defined by its' three coordinates.
perimeter({triangle, {X1, Y1}, {X2, Y2}, {X3, Y3}}) ->
A = distance({X1, Y1}, {X2, Y2}),
@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 / 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 / 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

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 / 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)
@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"
)