Skip to content

Instantly share code, notes, and snippets.

View FreedomBen's full-sized avatar
💭
Currently setting my status

Ben Porter FreedomBen

💭
Currently setting my status
View GitHub Profile
@FreedomBen
FreedomBen / _etc_dnsmasq.conf
Last active April 10, 2021 16:10
Protectli Home Router setup for CentOS 8. / in filenames not allowed so substituted with _
# Initial from: https://wiki.archlinux.org/index.php/dnsmasq
# Some from: https://www.tecmint.com/setup-a-dns-dhcp-server-using-dnsmasq-on-centos-rhel/
#listen-address=::1,127.0.0.1,192.168.2.1
# Cloudflare
#server=1.1.1.1
#server=1.0.0.1
# Cloudflare family block malware
@FreedomBen
FreedomBen / check-endianness.sh
Last active February 20, 2021 19:01
Bash script to generate and compile a C program to check Endianness of your system. Cleans up after it is done
cat << EOF > check-endianness.c
#include <stdio.h>
int main() {
int n = 1;
// little endian if true
if(*(char *)&n == 1) {
printf("Little endian\n");
} else {
#include <stdio.h>
int main() {
int n = 1;
// little endian if true
if(*(char *)&n == 1) {
printf("Little endian\n");
} else {
printf("Big endian\n");
@FreedomBen
FreedomBen / firewall-cockpit.sh
Last active February 20, 2021 15:48
Firewall Cockpit to only Me
# Get your IP address from home or work: curl -s 'https://api.ipify.org'
# Replace with your IP. Can get it with the above command if you'd like
# This can also be a CIDR range if you own or trust a block
MY_IP=<ip>
firewall-cmd --zone-public --permanent --remove-service=cockpit
firewall-cmd --zone=public --permanent \
--add-rich-rule="rule family=\"ipv4\" source address=\"${MY_IP}\" port protocol=\"tcp\" port=\"9090\" accept"
firewall-cmd --reload
curl -k "https://basic-ocp-demo-basic-ocp-demo-project.apps.cluster1.example.com/healthz"
# or build the curl URL programmatically!
curl -k "https://$(oc get route basic-ocp-demo -o jsonpath="{.spec.host}")/healthz"

Quick Reference

  • Basic structure
    • oc [name]
    • There are some exceptions, like oc help or oc logs <pod> or oc exec
    • Most commands support oc <command> --help
  • Common resources (nouns)
    • Pods
    • Deployments
  • Services
@FreedomBen
FreedomBen / retrieved-deployment-basic-ocp-demo.yaml
Created January 8, 2021 02:16
Deployment read back from OpenShift API with `oc get deployment basic-ocp-demo -o yaml`
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "1"
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"apps/v1","kind":"Deployment","metadata":{"annotations":{},"labels":{"app":"basic-ocp-demo"},"name":"basic-ocp-demo","namespace":"basic-ocp-demo-project"},"spec":{"replicas":1,"selector":{"matchLabels":{"app":"basic-ocp-demo"}},"template":{"metadata":{"labels":{"app":"basic-ocp-demo"}},"spec":{"containers":[{"env":[{"name":"BASIC_OCP_DEMO_ENV","value":"master"}],"image":"quay.io/freedomben/basic-ocp-demo:latest","imagePullPolicy":"Always","name":"basic-ocp-demo","ports":[{"containerPort":4567,"protocol":"TCP"}],"readinessProbe":{"httpGet":{"path":"/healthz","port":4567,"scheme":"HTTP"},"initialDelaySeconds":5,"periodSeconds":1}}]}}}}
creationTimestamp: "2021-01-08T02:09:21Z"
generation: 1
labels:
@FreedomBen
FreedomBen / basic-ocp-demo.yaml
Last active January 8, 2021 02:43
Deployment YAML for the basic-ocp-demo application
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: basic-ocp-demo
name: basic-ocp-demo
spec:
replicas: 1
selector:
@FreedomBen
FreedomBen / .iex.exs
Created December 31, 2020 20:57
Part of my IEx config file
#
# This module defines some handy functions for use in iex
#
defmodule DebugTools do
@doc ~S"""
Cast all the params provided here into an Ecto.Changeset.
This defeats Ecto's whitelist approach so you should never use this in real code!
It's intended as a debug tool for use in tests of IEx sessions.
"""
sed -i -e '/printf.*TERMINATED/i \\tprintf(" HACKED! \\n");' 2048.c