Skip to content

Instantly share code, notes, and snippets.

Jonathan Kosgei jonathan-kosgei

Block or report user

Report or block jonathan-kosgei

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View why-i'

I have been an aggressive Kubernetes evangelist over the last few years. It has been the hammer with which I have approached almost all my deployments, and the one tool I have mentioned (shoved down clients throats) in almost all my foremost communications with clients, and it was my go to choice when I was mocking my first startup (

A few weeks ago Docker 1.13 was released and I was tasked with replicating a client's Kubernetes deployment on Swarm, more specifically testing running compose on Swarm.

And it was a dream!

All our apps were already dockerised and all I had to do was make a few modificatons to an existing compose file that I had used for testing before prior said deployment on Kubernetes.

And, with the ease with which I was able to expose our endpoints, manage volumes, handle networking, deploy and tear down the setup. I in all honesty see no reason to not use Swarm. No mission-critical feature, or incredibly convenient really nice to have feature in Kubernetes that I'm go

jonathan-kosgei /
Last active Dec 6, 2019
Python Decorator to Time a Function
""" A simple decorator that times the duration of a function's execution. More info on Decorators at"""
import timeit
def timer(function):
def new_function():
start_time = timeit.default_timer()
elapsed = timeit.default_timer() - start_time
print('Function "{name}" took {time} seconds to complete.'.format(name=function.__name__, time=elapsed))
return new_function()
jonathan-kosgei /
Last active Dec 19, 2018
Deploy PHP site to AWS Elasticbeanstalk with Bitbucket Pipelines

ElasticBeanstalk on AWS

Getting Started

To deploy a new Magento store automatically via Bitbucket CI. Follow the following steps.

1. Set the following environment variables for the bitbucket repo with the magento store source code

jonathan-kosgei /
Created Apr 13, 2018
Get the size of any object in Python
import sys
def get_size(obj, seen=None):
"""Recursively finds size of objects"""
size = sys.getsizeof(obj)
if seen is None:
seen = set()
obj_id = id(obj)
if obj_id in seen:
return 0
jonathan-kosgei /
Created Apr 19, 2017
AWS Lambda backup EBS volumes with BOTO3
# Scheduling the above script hourly. Ensure you're properly authenticated via aws configure.
aws lambda create-function --function-name ebs-backup-worker \
--runtime python2.7 \
--role "arn for your lambda user's role" \
--handler lambda_handler \
--zip-file fileb:///

Keybase proof

I hereby claim:

  • I am jonathan-kosgei on github.
  • I am jkosgei ( on keybase.
  • I have a public key whose fingerprint is 4A3A EC85 E348 E5A8 4FD5 E82B 1C9F 43F8 656B 81FF

To claim this, I am signing this object:

jonathan-kosgei /
Created Oct 25, 2017
deploying to pypi
git push origin master
git tag 1.3 -m "desc"
git push --tags origin master
python sdist upload
jonathan-kosgei / stats.txt
Created Sep 8, 2017
API Stats for
View stats.txt
./hey -m GET -n 1000000 -more
Total: 476.9207 secs
Slowest: 5.0308 secs
Fastest: 0.0010 secs
Average: 0.0225 secs
Requests/sec: 2096.7846
Total data: 315238010 bytes
Size/request: 315 bytes
View container-logs.txt
ERROR: extension "pgcrypto" already exists
Buildfile: /opt/dspace/dspace/target/dspace-installer/build.xml
[mkdir] Created dir: /dspace/bin
[mkdir] Created dir: /dspace/config
[mkdir] Created dir: /dspace/lib
[mkdir] Created dir: /dspace/etc
[mkdir] Created dir: /dspace/webapps
[mkdir] Created dir: /dspace/triplestore

Getting Started

kubectl apply -f storageclass.yml
kubectl apply -f neo4j-service.yml
kubectl apply -f neo4j-statefulset.yml
You can’t perform that action at this time.