Skip to content

Instantly share code, notes, and snippets.

@daemonfire300
daemonfire300 / pingpong.sh
Last active March 20, 2025 10:13
Pod Ping Pong
#!/bin/sh
NS=$1
# Delete existing pods and services if they exist
kubectl -n $NS delete pod pod1 pod2 --ignore-not-found
kubectl -n $NS delete service pod1-svc pod2-svc --ignore-not-found
# Create services
kubectl -n $NS create service clusterip pod1-svc --tcp=8080:8080 --dry-run=client -o yaml | kubectl set selector --local -f - 'run=pod1' -o yaml | kubectl -n $NS apply -f -
kubectl -n $NS create service clusterip pod2-svc --tcp=8080:8080 --dry-run=client -o yaml | kubectl set selector --local -f - 'run=pod2' -o yaml | kubectl -n $NS apply -f -
@daemonfire300
daemonfire300 / example.py
Created February 27, 2025 15:17
Minio STS Sample in Python without RoleArn
import requests
def make_post_request(base_url, action, duration_seconds, web_identity_token, version):
# Define the URL and query parameters
url = base_url
params = {
"Action": action,
"DurationSeconds": duration_seconds,
"WebIdentityToken": web_identity_token,
"Version": version
awk '/-----BEGIN CERTIFICATE-----/{f++}{print > "cert" f ".pem"}' yourfile.pem && for cert in cert*.pem; do kubectl create secret tls $(basename $cert .pem) --cert=$cert --dry-run=client -o yaml | kubectl apply -f -; done
@daemonfire300
daemonfire300 / adm_mut_pol.yaml
Created February 18, 2025 16:13
example-admission-policy
apiVersion: admissionregistration.k8s.io/v1alpha1
kind: MutatingAdmissionPolicy
metadata:
name: "modify-init-container-security-context"
spec:
matchConstraints:
resourceRules:
- apiGroups: ["apps"]
apiVersions: ["v1"]
operations: ["CREATE", "UPDATE"]
apiVersion: projectcalico.org/v3
kind: NetworkPolicy
metadata:
name: allow-same-namespace-communication
namespace: my-namespace
spec:
selector: app == 'myapp' # Applies to pods with the label `app=myapp`
types:
- Ingress
- Egress
@daemonfire300
daemonfire300 / minio.yaml
Created February 4, 2025 15:52
Example Minio Tenant
apiVersion: v1
kind: Secret
metadata:
name: storage-configuration
namespace: minio-tenant
stringData:
config.env: |-
export MINIO_ROOT_USER="minio"
export MINIO_ROOT_PASSWORD="minio123"
export MINIO_STORAGE_CLASS_STANDARD="EC:2"
@daemonfire300
daemonfire300 / email.exs
Created October 13, 2016 12:07
Simple shot at implementing an email validator for use with `Ecto.Changeset`
defmodule YourApp.Validators.Email do
use Ecto.Changeset
@mail_regex ~r/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/
# ensure that the email looks valid
def validate_email(changeset, field) do
changeset
|> validate_format(field, @mail_regex)
end
end
CREATE CONSTRAINT ON (l:Location) ASSERT l.locationid IS UNIQUE;
CREATE INDEX ON :Location(locationid);
USING PERIODIC COMMIT 5000
LOAD CSV WITH HEADERS FROM 'file:///wln_label-type.txt.csv' AS line WITH line
MERGE (location:Location {locationid: toInt(line.locationid)} )
RETURN COUNT(location);
@daemonfire300
daemonfire300 / txt_to_neoscv.py
Last active June 8, 2016 21:11
Little Helper Script to convert CSV files for neo4j
# -*- coding: utf-8 -*-
"""
Created on Wed May 25 11:26:57 2016
@author: julius
"""
import getopt, sys
defmodule ListAndRecursion do
def all?([head | tail], filter) do
if filter.(head) == true do
pall?(tail, filter, true)
else
false
end
end
defp pall?([head | tail], filter, _previous) do
if filter.(head) == true do