Skip to content

Instantly share code, notes, and snippets.

View borestad's full-sized avatar

Johan Borestad borestad

View GitHub Profile
@jesselawson
jesselawson / flush_block_list.sh
Created February 12, 2022 05:21
The last "Refresh my ipset drop list" script you'll ever need
#!/usr/bin/env bash
ipset -q flush ipsum
ipset -q create ipsum hash:net
for ip in $(curl --compressed https://raw.githubusercontent.com/stamparm/ipsum/master/ipsum.txt 2>/dev/null | grep -v "#" | grep -v -E "\s[1-2]$" | cut -f 1); do ipset add ipsum $ip; done
# Add any IPs here that may not be in the block list yet:
ipset add ipsum 110.169.9.43
@shawngmc
shawngmc / .aws-creds
Last active March 7, 2024 02:53
Caddy Example Files
[default]
aws_access_key_id=XXXXXXXXXXXXXXXXXXXX
aws_secret_access_key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
aws_region=us-east-1
@berkant
berkant / cloud-init.cfg
Last active April 26, 2024 17:58
Cloud-init config to set up my Ubuntu dev machine.
## template: jinja
#cloud-config
{% if v1.distro_release == 'focal' %}
users:
- name: berkant
shell: /usr/bin/bash
ssh_import_id: gh:berkant
sudo: ALL=(ALL:ALL) NOPASSWD:ALL
@eusonlito
eusonlito / README.md
Last active January 1, 2024 11:36
Strong iptables and ipset protection

Protect your server with a strong iptables rules and ipset lists.

1. Install ipset to manage ipstables lists

apt install ipset

2. Install iptables-persistent to preserve iptables rules on reboot

@kaichao
kaichao / log-http-headers.md
Last active May 26, 2024 17:41
nginx: Log complete request/response with all headers

1. switch nginx image to openresty/openresty

2. add the following to server/location (/etc/nginx/conf.d/default.conf)

   set $req_header "";
   set $resp_header "";
   header_filter_by_lua_block{ 
      local h = ngx.req.get_headers();
      for k, v in pairs(h) do
         ngx.var.req_header = ngx.var.req_header .. k.."="..v.." ";
@dustyfresh
dustyfresh / default.conf
Last active May 10, 2022 12:53
Hardened nginx config
# Security enhancements and custom Nginx server header
#
# Requirements:
# $ apt install nginx vim
# $ apt install libnginx-mod-http-headers-more-filter
# $ vim /etc/nginx/sites-enabled/default
#
# Further reading http://docs.hardentheworld.org/Applications/Nginx/
#
server {
@reitermarkus
reitermarkus / proxmox-setup.sh
Last active November 23, 2021 07:50
Proxmox Setup
set -euo pipefail
# Reduce backup IO.
sed -i -E 's/^\s*#?\s*(ionice:).*/\1 7/' /etc/vzdump.conf
sed -i -E 's/^\s*#?\s*(bwlimit:).*/\1 32768/' /etc/vzdump.conf
tee /etc/cron.hourly/xfs_fsr <<EOF
#!/bin/sh
xfs_fsr -t 600
@qzm
qzm / aria2.conf
Last active June 1, 2024 05:18
Best aria2 Config
### Basic ###
# The directory to store the downloaded file.
dir=${HOME}/Downloads
# Downloads the URIs listed in FILE.
input-file=${HOME}/.aria2/aria2.session
# Save error/unfinished downloads to FILE on exit.
save-session=${HOME}/.aria2/aria2.session
# Save error/unfinished downloads to a file specified by --save-session option every SEC seconds. If 0 is given, file will be saved only when aria2 exits. Default: 0
save-session-interval=60
# Set the maximum number of parallel downloads for every queue item. See also the --split option. Default: 5
@loilo
loilo / idb-backup-and-restore.md
Last active April 29, 2024 06:40
Back up and restore an IndexedDB database

Back up and restore an IndexedDB database

This gist is an ES module which provides functions to import and export data from an IndexedDB database as JSON. It's based on Justin Emery's indexeddb-export-import package, but applies some adjustments that reflect better on the current browser landscape (i.e. better developer ergonomics but no support for Internet Explorer).

Usage

For each of the provided functionalities, you need a connected IDBDatabase instance.

Export Data

import { idb } from 'some-database'