Skip to content

Instantly share code, notes, and snippets.

View JoshuaSchlichting's full-sized avatar

Joshua Schlichting JoshuaSchlichting

View GitHub Profile
#!/bin/bash
######## ######## ######## ######## ######## ######## ###########
### THIS BASH SCRIPT WILL COMPLETE DELETE *EVERY* OBJECT ####
### INCLUDING HIDDEN VERSIONS FROM AN S3 BUCKET!! ####
######## ######## ######## ######## ######## ######## ###########
BUCKET_NAME="$1"
if [[ -z "$BUCKET_NAME" ]]; then
@JoshuaSchlichting
JoshuaSchlichting / router.go
Created December 13, 2022 00:28
A basic HTTP router
package router
import (
"encoding/json"
"html/template"
"io/fs"
"net/http"
)
var commonMiddleware = []Middleware{}
@JoshuaSchlichting
JoshuaSchlichting / build.sh
Created November 13, 2022 00:10
A build script for Golang projects
"""
A build script for golang projects
"""
APP_NAME=<your app name here>
if [[ $(uname -m) == "x86_64" ]]; then
APP_ARCH=amd64
elif [[ $(uname -m) == "i686" ]]; then
APP_ARCH=386
elif [[ $(uname -m) == "arm64" ]]; then
@JoshuaSchlichting
JoshuaSchlichting / terraform_docker.sh
Last active August 12, 2022 21:29
A bash script for executing terraform within Docker.
#! /bin/bash
# This script is used to execute terraform commands in the current working directory, using Docker.
# USAGE: ./terraform_docker.sh <init, plan, apply, or any other valid terraform argument>
# NOTE: You will need to ensure this file is executable. You can do this by executing `chmod +x ./terraform_docker.sh`.
# !!!!!!!!!!!!!!!!! TERRAFORM CLOUD !!!!!!!!!!!!!!!!!
# NOTE: As written, this script assumes you have a credentials.tfrc.json file, which is
@JoshuaSchlichting
JoshuaSchlichting / vscode.settings.json
Last active June 8, 2022 20:36
My VSCode settings
{
"editor.inlineSuggest.enabled": true,
"github.copilot.enable": {
"*": true,
"yaml": true,
"plaintext": true,
"markdown": false
},
"json.schemas": [],
"workbench.colorTheme": "Ayu Light Bordered",
@JoshuaSchlichting
JoshuaSchlichting / stateless_tf_apply.py
Last active June 5, 2022 16:51
Stateless terraform apply
#! python
"""
This script is used to apply terraform changes to a given directory.
ANY STATE CHANGES STORED LOCALLY WILL BE LOST.
It is HIGHLY RECOMMENDED that you use this with a remote terraform backend.
Maintainer: Joshua Schlichting <[email protected]>
"""
@JoshuaSchlichting
JoshuaSchlichting / py.sh
Last active January 30, 2023 23:52
Interactive Python Docker container with Poetry installed
{
docker build -t pyshell . -f-<<EOF
FROM python:latest
RUN useradd -m -U -G staff -s /bin/bash devuser
USER devuser
WORKDIR /home/devuser
RUN mkdir /home/devuser/bin
ENV POETRY_HOME="/home/devuser/bin/poetry"
RUN curl -sSL https://install.python-poetry.org | python -
ENV PATH="/home/devuser/bin/poetry/bin:$PATH"
@JoshuaSchlichting
JoshuaSchlichting / nginx.conf
Last active June 2, 2022 16:21
NGINX with https and www redirects, and also with DoS protection
# 30 requests per minute limit for DDoS protection
limit_req_zone $binary_remote_addr zone=landing:20m rate=7000r/m;
server {
listen 443 ssl;
server_name yoursite.com;
ssl_certificate /etc/nginx/ssl/certificate.crt;
ssl_certificate_key /etc/nginx/ssl/private.key;
@JoshuaSchlichting
JoshuaSchlichting / fusuma_basic_setup.sh
Last active October 28, 2019 13:24
Install mac like gestures on Linux with Gnome
#!/bin/bash
# Tested on Ubuntu 19.10 with Gnome
# Hardware: HP Spectre x360 (13-AW0023DX)
gpasswd -a $USER input
apt install libinput-tools
apt install xdotool
apt install ruby
gem install fusuma
mkdir ~/.config/fusuma
cat << 'EOF' >> ~/.config/fusuma/config.yml
@JoshuaSchlichting
JoshuaSchlichting / securereader.py
Created April 1, 2019 17:40
Quickly read the attempted user names, and IP addresses, from /var/log/secure
file_rows = []
with open("/var/log/secure", 'r') as file:
for line in file.readlines():
file_rows.append(line)
filtered_rows = []
for row in file_rows:
if "Failed password for" in row:
filtered_rows.append(row)