Skip to content

Instantly share code, notes, and snippets.

View iolloyd's full-sized avatar
💭
Busy bee

Lloyd Moore iolloyd

💭
Busy bee
View GitHub Profile
@iolloyd
iolloyd / in.sh
Last active October 2, 2024 08:53
file_or_pipe
#!/bin/bash
# Function to process input (file or stdin)
process_input() {
while IFS= read -r line; do
# Perform any processing here
echo "$line"
done
}
@iolloyd
iolloyd / ssv.py
Created October 20, 2023 15:32
simple binary shapley values for data records against query output
import itertools
import math
def query_age(dataset):
"""
A query function that returns records with age less than 26.
"""
return [record for record in dataset if record['age'] < 26]
def query_trust(dataset):
@iolloyd
iolloyd / demo.tpl
Last active January 8, 2020 17:56
dynamic inventory from terraform
[kube-master]
${k8s_master_name}
@iolloyd
iolloyd / ec2_connect.sh
Last active August 1, 2019 11:06
AWS EC2 temporarily connect to an instance by id
#!/bin/sh
# Allows you to temporarily connect to an ec2 instance, using
# awscli to first push your own key to the instance, then using ssh
# to log in to the instance.
# Assumes a public key called ec2.pub and a private
# key called ec2.
# Usage ec2_connect.sh i-12345679abcdef <other-user> <other-file>
@iolloyd
iolloyd / golang.secure.small.Dockerfile
Created November 11, 2018 17:46
a super small secure docker container for golang binaries using Alpine and multi-stage builds
# The smallest starting point is the alpine image
FROM golang:alpine as builder
RUN apk update && apk add git && add ca-certificates
RUN adduser -D -g '' appuser
COPY . $GOPATH/src/mypackage/myapp/
WORKDIR $GOPATH/src/mypackage/myapp/
RUN go get -d -v
RUN CGO_ENABLE=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -ldflags="-w -s" -o /go/bin/hello
@iolloyd
iolloyd / kafka-zk.Dockerfile
Last active October 26, 2018 08:34
couples kafka and zookeeper together
FROM java:openjdk-8-jre
ENV DEBIAN_FRONTEND noninteractive
ENV SCALA_VERSION 2.11.12
ENV KAFKA_VERSION 2.0.0
ENV KAFKA_HOME /opt/kafka_"$SCALA_VERSION"-"$KAFKA_VERSION"
RUN apt-get update && \
apt-get install -y dnsutils supervisor wget zookeeper && \
rm -rf /var/lib/apt/lists/* && \
@iolloyd
iolloyd / booking.js
Created April 12, 2018 14:42
booking a resource
const flatten = arrays => [].concat.apply([], arrays);
const bookTime = (resource, time) => {
const newResource = resource.map(t => {
return (t.start < time.start && time.end < t.end)
? [{start: t.start, end: time.start}, {start: time.end, end: t.end}]
: t;
});
return flatten(newResource);
};
Verifying my Blockstack ID is secured with the address 1JEbu1eU9U7EUMQ1Q8VWeziA2fMcZcUi2B https://explorer.blockstack.org/address/1JEbu1eU9U7EUMQ1Q8VWeziA2fMcZcUi2B
@iolloyd
iolloyd / create_hash_and_salt.js
Created September 5, 2017 13:37
method to create hash and salt
import crypto from 'crypto'
import semver from 'semver'
const processVersion = '0.12.0';
const pbkdf2DigestSupport = semver.gte(process.version, processVersion);
const pbkdf2 = (pwd, salt, options, callback) => {
const { iterations, keylen, digestAlgorithm } = options;
if (pbkdf2DigestSupport) {
@iolloyd
iolloyd / about_working.md
Last active June 14, 2017 17:54
something about working for the man, for Pilar

From the unnatural sound from a modern thing,

a ring of a clock, a waking bot,

The dream through toil of a better day,

paid for with time and the daily grind

As slaves to a system of a fiat master