Skip to content

Instantly share code, notes, and snippets.

View RiFi2k's full-sized avatar

Reilly Lowery RiFi2k

View GitHub Profile
@RiFi2k
RiFi2k / removeContent.js
Created June 21, 2019 18:04
Cloudflare Worker Function to find and replace content on a page
addEventListener("fetch", event => {
event.respondWith(handle(event.request))
})
async function handle(request) {
// Fetch from origin server.
let response = await fetch(request)
// Make sure we only modify text, not images.
let type = response.headers.get("Content-Type") || ""
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org
# WordPress Coding Standards
# http://make.wordpress.org/core/handbook/coding-standards/
root = true
[*]
charset = utf-8
@RiFi2k
RiFi2k / nginx.conf.j2
Last active April 7, 2021 22:50
Trellis nginx.conf file to include setting the real IP from Cloudflare if you use their DNS and SSL certs - https://github.com/roots/trellis/blob/master/roles/nginx/templates/nginx.conf.j2
# {{ ansible_managed }}
# nginx Configuration File
# http://wiki.nginx.org/Configuration
# Run as a less privileged user for security reasons.
user {{ nginx_user }};
# How many worker threads to run;
# "auto" sets it to the number of CPU cores available in the system, and
@RiFi2k
RiFi2k / fedora-proxy.md
Last active March 4, 2021 16:07
Instructions for setting up localhost proxy for most services on Fedora

Fedora 127.0.0.1 Proxy

DNF

sudo nano /etc/dnf/dnf.conf

Add proxy=socks5://127.0.0.1:8123

GIT

@RiFi2k
RiFi2k / sysctl.conf
Last active November 19, 2020 03:29
Trellis high traffic tuning and security sysctl settings
# Kernel sysctl configuration file for Linux
#
# This file should be saved as /etc/sysctl.conf and can be activated using the command:
# sysctl -e -p /etc/sysctl.conf
#
# For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and sysctl.conf(5) for more details.
# ----------
# Credits:
# https://klaver.it/linux/sysctl.conf
# http://whatizee.blogspot.com/2015/02/webserverftpserver-sysctlconf-parameter.html
#!/bin/bash
#
# TMBI Kubernetes E2E Test
#
# Author: Reilly Lowery <https://github.com/rifi2k>
# Copyright: 45AIR
# Permission to copy and modify is granted under the MIT license
#===============================================================================
set -eo pipefail
if ( class_exists( 'woocommerce' ) ) {
if ( is_wc_endpoint_url( 'order-pay' ) ) {
global $wp;
$order_id = $wp->query_vars['order-pay'];
$order_author_id = get_post_field( 'post_author', $order_id );
$current_user_id = get_current_user_id();
if ( $order_author_id !== $current_user_id ) {
// Do something here when user did not place the order.
// Redirect to homepage etc.
}
@RiFi2k
RiFi2k / iptables.sh
Last active January 18, 2020 20:04
iptables-persistent rules
#!/bin/bash
#!/bin/bash
# forget old rules
iptables -F
iptables -X
iptables -Z
# set default policy to drop
iptables -P INPUT DROP
@RiFi2k
RiFi2k / cloudSettings_public
Created October 6, 2019 01:52
Copy of my private cloudSettings gist I use to sync my VSCode configurations between work and home
{"lastUpload":"2019-10-06T01:41:34.820Z","extensionVersion":"v3.4.3"}
@RiFi2k
RiFi2k / iptables.openvpn
Last active July 18, 2019 22:32
Force all traffic through VPN tun, drop any traffic not headed through VPN to prevent DNS leaks. Assuming use of TUN-based routing and redirect-gateway OpenVPN client options.
# https://jamielinux.com/blog/force-all-network-traffic-through-openvpn-using-iptables/
# Force all traffic through VPN tun
*mangle
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
COMMIT