Skip to content

Instantly share code, notes, and snippets.

View osadalakmal's full-sized avatar

Osada Lakmal Paranaliyanage osadalakmal

View GitHub Profile
#include <memory>
#include <thread>
#include <benchmark/benchmark.h>
void f1(bool shouldMallocInLoop)
{
auto n = 0;
void *c = nullptr;
for (int i = 0; i < 10; ++i) {
if (shouldMallocInLoop)
@osadalakmal
osadalakmal / docker-compose-6mach-consul-cluster.yml
Created June 1, 2017 13:32
Consul Cluster with 6 containers.
version: '2'
networks:
consul_net:
driver: bridge
ipam:
driver: default
config:
-
subnet: 172.16.238.0/24
@osadalakmal
osadalakmal / docker-compose.yml
Created May 15, 2017 08:05
docker compose file for bringing up a HA vault cluster with one active server and two standby servers.
version: '2'
networks:
consul_net:
driver: bridge
ipam:
driver: default
config:
-
subnet: 172.16.238.0/24
@osadalakmal
osadalakmal / minikube_proxy
Created April 26, 2017 01:49 — forked from mcastelino/minikube_proxy.md
HOWTO: minikube behind a proxy
https://github.com/kubernetes/minikube
To get it running behind the a proxy you need to setup things a bit differently from the documentation
1. Ensure that the proxy is passed into the VM that is created by minikube (this ensures that the docker daemon within the VM can get out to the internet)
minikube start --vm-driver="kvm" --docker-env="http_proxy=xxx" --docker-env="https_proxy=yyy" start
2. Get the IP that the VM gets
@osadalakmal
osadalakmal / docdist.cpp
Created June 23, 2013 20:15
Document Distance C++ version
#include <iostream>
#include <fstream>
#include <sstream>
#include <stdexcept>
#include <map>
#include <regex>
#include <set>
#include <cmath>
@osadalakmal
osadalakmal / docdist2.py
Created June 13, 2013 22:07
Document Distance Optimized
import cProfile
import re
import math
import string
import sys
def read_file(filename):
"""
Read the text file with the given filename;
return a list of the lines of text in the file.
@osadalakmal
osadalakmal / docdist1.py
Last active December 18, 2015 11:39
Document Distance calculator
# docdist1.py
# Author: Ronald L. Rivest
# Date Last Modified: February 14, 2007
# Changelog:
# Version 1:
# Initial version
#
# Usage:
# docdist1.py filename1 filename2
#
@osadalakmal
osadalakmal / elftagger-sample1
Created March 17, 2013 16:37
Sample use of elftagger
elf-tag $ readelf -p BuildTags a.out
readelf: Warning: Section 'BuildTags' was not dumped because it does not exist!
elf-tag $ ./tag.sh -u "osada" -g "git-describe-string" -v "0.02" a.out
elf-tag $ readelf -p BuildTags a.out.new
String dump of section 'BuildTags':
[ 0] BuildTags ver0.1
@osadalakmal
osadalakmal / elftagger.sh
Created March 17, 2013 16:29
A bash script for adding build tags to an ELF file
#!/bin/bash
date_format_str=""
git_describe=""
user_name=""
version_str=""
while getopts "d:g:u:v:h?" opt; do
case "$opt" in
d)
@osadalakmal
osadalakmal / elftagger.cpp
Created March 17, 2013 16:19
c++ program for adding build tag section to a elf file
#include <elfio/elfio.hpp>
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <iostream>
#include <time.h>
#include <string.h>
using namespace ELFIO;
static const char* xmlConfigFile = "buildtag.xml";