Skip to content

Instantly share code, notes, and snippets.

@Dreded
Dreded / remove_empty_folders.py
Last active December 1, 2017 05:55 — forked from jacobtomlinson/remove_empty_folders.py
Python Recursively Remove Empty Directories
#! /usr/bin/env python
'''
Module to remove empty folders recursively. Can be used as standalone script
or be imported into existing script.
'''
import os
import sys
@Dreded
Dreded / iptables.sh
Created December 20, 2022 20:24
iptables for deny all except SSH and 80/443( webserver )
# flush all current rules
sudo iptables -F
# allows all loopback (lo0) traffic and drop all traffic to 127/8 that doesn't use lo0
sudo iptables -A INPUT -i lo -j ACCEPT
sudo iptables -A INPUT ! -i lo -d 127.0.0.0/8 -j REJECT
# accepts all established inbound connections
sudo iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
@Dreded
Dreded / Git Hook.md
Last active December 21, 2022 22:45
Use Git Hooks to Publish via SSH to any SSH Client

Easily use git hooks to publish to a SSH server.

Instea of uploading to a middle man like github then doing a pull on your production or staging server you can use this trick to push directly to the production or staging server over SSH

These instructions will show how to use a git hook( in this case post-receive ) to do whatever is needed on the server(receiving) side.

This allows for high security(no middle men) and high flexibility as you can use Bash scripts to do whatever is required.

Prerequisit

  1. Know how to use GIT, Terminal etc.
  2. Have a local working-working copy ready
I want you to become my Expert Prompt Creator.
Your goal is to help me craft the best possible prompt for my needs.
The prompt you provide should be written from the perspective of me making
the request to ChatGPT. Consider in your prompt creation that this prompt will
be entered into an interface for GPT3, GPT4, or ChatGPT.
The process is as follows:
1. You will generate the following sections:
"
@Dreded
Dreded / bash_arg_parser.sh
Last active March 21, 2024 05:04
Bash argument parser
#!/usr/bin/env bash
# This is comment from here: https://stackoverflow.com/a/28466267
parseArgs() {
# just in case we call this twice make OPTIND local
local OPTIND OPT
die() { echo "$*" >&2; exit 2; } # complain to STDERR and exit with error
needs_arg() { if [ -z "$OPTARG" ]; then die "No arg for --$OPT option"; fi; }