Skip to content

Instantly share code, notes, and snippets.

View srkiNZ84's full-sized avatar

Srđan (Serge) Đukić srkiNZ84

View GitHub Profile
@srkiNZ84
srkiNZ84 / foobar.yaml
Last active February 10, 2020 02:46
Groovy test to check whether it does or does not interpert hash values
foo:
bar:
baz: something
anotherfoo:
secondbar: otherthing
@srkiNZ84
srkiNZ84 / test_db_latency.py
Created January 6, 2020 20:08
Simple Python script to test DB connection latency
#!/usr/bin/python3
# NOTE: If running on Ubuntu you need to install the "libmysqlclient-dev" package from apt and the "mysql" package through pip
# apt install libmysqlclient-dev
# pip3 install mysql
import MySQLdb
import time
NUM_ITERATIONS = 100
@srkiNZ84
srkiNZ84 / Dockerfile
Last active December 18, 2019 03:40
Python file to generate erally long log lines
FROM python:3
WORKDIR /usr/src/app
#COPY requirements.txt ./
#RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD [ "python", "./long_logger.py"]
@srkiNZ84
srkiNZ84 / generate_events.sh
Last active December 5, 2019 09:15
Eventstore event generation script
#!/bin/bash
sendToStream(){
local EVENT_UUID=`uuidgen`
echo "Sending $1 event with shared ID $2"
AUTH="-u admin:changeit"
curl $AUTH -i -d "{\"type\":\"$1\", \"foo$1\":\"we did a $1 kind of thing.\",\"id\":\"$2\"}" "http://127.0.0.1:2113/streams/$1-$2" -H "Content-Type:application/json" -H "ES-EventType: $1-event" -H "ES-EventId: $EVENT_UUID"
echo "Curl return value $?"
}
@srkiNZ84
srkiNZ84 / index.html
Last active September 30, 2019 10:14
Playing around with the Javascript crypto API's to see how they work
<html>
<head>
<script type="text/javascript" src="webcrypto.js"></script>
<title>Web Crypto Hello World</title>
</head>
<body>
<p>This is a super simple example of trying to get Web Cryptography working</p>
</body>
</html>
@srkiNZ84
srkiNZ84 / get_k8s_secret_plaintext.sh
Created September 15, 2019 23:25
Bash script/command to get a Secret and decode it
#!/bin/bash
# Usage: ./get_k8s_secret_plaintext SECRET_NAME SECRET_KEY
kubectl get secret $1 -o json | jq -r '.data[$2]' | base64 --decode
@srkiNZ84
srkiNZ84 / pyenhance_yaml.py
Last active August 8, 2019 11:11
Python script to take OpenAPI YAML definitions and enhance them with AWS API Gateway annotations with a view to auto-generating mocks
#!/Library/Frameworks/Python.framework/Versions/3.6/bin/python3
####!/usr/bin/python3
import os
import yaml
class APIGW():
def __init__(self, responses, passThroughBehavior, requestTemplates,
gwType):
@srkiNZ84
srkiNZ84 / blog.yml
Created April 4, 2019 10:18
Blog API Swagger definition
swagger: "2.0"
info:
description: "This is a blog API defined in swagger"
version: "1.0.0"
title: "Swagger blog API"
termsOfService: "http://blog.dukic.co.nz/terms"
contact:
email: "[email protected]"
license:
name: "AGPL 3.0"
@srkiNZ84
srkiNZ84 / test-xhr.html
Created February 19, 2019 00:47
Simple example of how to use XHR to call and enpoint
<html>
<head>
<title>Testing XHR</title>
</head>
<body>
<p>This is a test</p>
<br />
<div id="foobar"></div>
<script>
// Create the HTTP request
@srkiNZ84
srkiNZ84 / activemq_dlq.groovy
Last active June 20, 2019 23:23
Groovy script to connect to an ActiveMQ server and receive messages from the default Dead Letter Queue
#!/bin/groovy
// NOTE: The jar "activemq-all-5.15.8.jar" needs to be put under $HOME/.groovy/lib
// for this script to work
import javax.jms.*
import org.apache.activemq.*
def amqURL = "failover:tcp://localhost:61616"
println "Connecting to ActiveMQ at URL " + amqURL