Skip to content

Instantly share code, notes, and snippets.

@t0mmyt
t0mmyt / delete_default_vpc.sh
Last active May 19, 2023 05:37
Delete Default VPCs in AWS
#!/bin/bash
set -euo pipefail
# Will only action if DRY_RUN=false
DRY_RUN=${DRY_RUN:=true}
# Will delete in the following regions
regions=(
ap-southeast-2
# ap-southeast-4
@t0mmyt
t0mmyt / abstract.cpp
Last active March 13, 2019 22:21
Notes on Polymorphism in C++
class Foo {
public:
// A purely virtual destructor will prevent this class being instantiated directly
virtual ~Foo() = 0;
};
class Bar: public Foo {
~Bar() override { };
};
@t0mmyt
t0mmyt / CustomPartitioner.java
Last active April 9, 2018 10:04
Custom Partitioner for specifying partition in key
import org.apache.kafka.clients.producer.Partitioner;
import org.apache.kafka.common.Cluster;
import org.apache.kafka.common.PartitionInfo;
import org.apache.kafka.common.utils.Utils;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ThreadLocalRandom;
@t0mmyt
t0mmyt / AesUniqueIv.java
Last active March 20, 2018 20:35
Java AES
package uk.tommyt.kafka.krypto;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.KeyGenerator;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
@t0mmyt
t0mmyt / checks.py
Last active November 21, 2017 14:12
Boto3 Check Framework
from utils import Checker, CheckError
from botocore.exceptions import ClientError
import requests
class AnonChecks(Checker):
def check_anonymous_http_get(self):
""" 1 """
r = requests.get("https://{}.s3.amazonaws.com/".format(self.bucket.name))
@t0mmyt
t0mmyt / gist:00b5026e74b6c24303caa5977f6f4f0e
Created November 1, 2017 18:43
Raspbeery Pi Stretch Headless
touch /boot/ssh
add `net.ifnames=0` to /boot/cmdline.txt
echo cat <<EOF > /etc/network/interfaces.d/eth0
auto eth0
iface eth0 inet static
address 172.16.1.20
netmask 255.255.255.0
gateway 172.16.1.1
@t0mmyt
t0mmyt / haproxy.cfg
Created July 19, 2017 13:21
HAProxy API Server
defaults
log global
timeout connect 5000
timeout client 50000
timeout server 50000
resolvers vpc
nameserver aws 172.18.0.2:53
hold valid 10s
@t0mmyt
t0mmyt / ELKK.txt
Last active July 17, 2017 15:08
X->Kafka->Logstash->Elasticsearch->Kibana
+-----------+
|Kinesis |-----\
+-----------+ ---------\ +-----------+
---------\ |Logstash | +-------------+
+-----------+ ------ +-----------+ |Elasticsearch| +-------------+
|Loglet |-\ |-----------| |Client | |Kibana |
+-----------+ -\ +--------------------+ -|-----------|---+-------------+---| |
-\ | | / |-----------| |-------------| +-------------+
+-----------+ --| |/ |-----------| +-------------+
|Fluentd |--------| Kafka / +-----------+ | \
kind: ConfigMap
apiVersion: v1
metadata:
name: sensu-server-conf
namespace: cloud
data:
redis.json: |
{
"redis": {
"host": "127.0.0.1",
@t0mmyt
t0mmyt / kube-dns-scale.yaml
Created February 27, 2017 14:21
DNS (auto)scaling for k8s
---
kind: ConfigMap
apiVersion: v1
metadata:
name: kube-dns-autoscaler
namespace: kube-system
data:
linear: |-
{
"coresPerReplica": 2,