Skip to content

Instantly share code, notes, and snippets.

@kpacha
kpacha / main.go
Last active July 17, 2018 16:15
Serve all the requests with a given distribution of response times and status codes
package main
import (
"flag"
"math/rand"
"net/http"
"sync"
"time"
"github.com/gin-gonic/gin"
gateway 10% 25% 50% 75% 90% 95% 99% min max avg
KrakenD 21.3 23.1 24.5 29.5 43.2 46.9 77.1 0.9 278.1 28.7
Vulcand 29.0 37.8 49.0 57.1 66.5 73.3 205.7 1.0 342.6 50.5
Kong 40.7 43.5 46.1 49.7 81.6 107.6 235.5 7.6 1597.8 56.9
Tyk 35.5 52.1 82.3 178.5 526.3 923.1 2105.4 1.2 5648.2 221.5
@kpacha
kpacha / dummy_service_discovery.py
Created May 30, 2015 18:19
Simple script for a naive service discovering system based on the serf member table
#! python
import json
import os
print "Parsing the members table"
# handle = os.popen("serf members -format=json")
handle = os.popen("cat serf_members_fake.json")
memberTable = json.load(handle)
products = {}
@kpacha
kpacha / install_scala.sh
Created April 10, 2015 17:46
Provision an up-to-date scala & sbt dev environment
#!/bin/bash
# don't forget to run it as root!!!
apt-get update
apt-get -y install unzip
apt-get -f -y install default-jdk openjdk-7-jdk
mkdir -p /opt
cd /opt
#! /bin/bash
export RUN_AS='ubuntu';
export INSTALL_DIR='/var/www/sentry';
HOSTNAME='http://mysentry.example.com'; # No trailing slash
DB_HOST='something.rds.amazonaws.com';
DB_PORT='5432';
DB_USER='sentry';
DB_NAME='sentry';
DB_PASSWORD='DB_PASSWORD';
@kpacha
kpacha / BoxMappedSudoku.scala
Last active August 29, 2015 14:08
Simple sudoku solvers based on scala streams
package sudoku
class BoxMappedSudoku {
val EmptyValue = '0'
val MaxValue = 9
val allValues = "123456789".toList
val indexes = (0 to 8).toList
val boxCoordinates = (0 to 2).toList
@kpacha
kpacha / fotonaut_yuicompressor-server
Created January 27, 2014 21:18
yuicompressor-server benchmark
$ ab -c 5 -n 100 -H "Content-Type:text/javascript; charset=utf-8" -p jquery.js -T "text/javascript" http://localhost:2013/
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient).....done
Server Software: Jetty(7.6.10.v20130312)
Server Hostname: localhost
@kpacha
kpacha / hash_benchmark
Created December 6, 2013 22:04
Simple php hashing benchmarking (based on a comment from http://www.php.net/manual/en/function.hash.php)
<?php
$totalIterations = 100000;
$data = "test";
$dataToHash = array();
echo "PHP Hash benchmark.\nCreating $totalIterations random strings.\n";
function generateRandomString(
$length = 20, $chars = '-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
)