Skip to content

Instantly share code, notes, and snippets.

@2600box
2600box / gist:cfe0b82cb2d2af767dc2b2a13d1eca00
Created May 30, 2017 09:07 — forked from bobuss/gist:6515517
Tuning the Linux Kernel for many tcp connections

(from http://www.metabrew.com/article/a-million-user-comet-application-with-mochiweb-part-1)

Save yourself some time and tune the kernel tcp settings before testing with lots of connections, or your test will fail and you’ll see lots of Out of socket memory messages (and if you are masquerading, nf_conntrack: table full, dropping packet.)

Here are the sysctl settings I ended up with - YMMV, but these will probably do:

$ cat /etc/sysctl.conf
# General gigabit tuning:
net.core.rmem_max = 16777216
@2600box
2600box / org.nsa.pf.rules
Created June 1, 2017 04:48
OS X Firewall Packet Filter (pfctl): Killswitch + Protection
# Put this file in /etc/pf.anchors/
# Options
set block-policy drop
set fingerprints "/etc/pf.os"
set ruleset-optimization basic
set skip on lo0
# Interfaces
inet_define = "en0"
@2600box
2600box / ufw.md
Created October 10, 2017 07:04 — forked from kimus/ufw.md
NAT and FORWARD with Ubuntu’s ufw firewall

UFW

I use Ubuntu’s Uncomplicated firewall because it is available on Ubuntu and it's very simple.

Install UFW

if ufw is not installed by default be sure to install it first.

@2600box
2600box / setup_fulldisk_encryption_rpi.md
Created October 18, 2017 04:14 — forked from ammgws/setup_fulldisk_encryption_rpi.md
Notes on how to setup full disk encryption on an already setup Raspbian system

Setup full disk encryption using LVM on LUKS (single drive) with remote SSH for an already setup/running Raspbian stretch system. Using this guide there is no need to connect a screen or keyboard to the rpi at any stage since we will setup remote SSH at the same time (at present no other guides available tell you that this is possible).

1. Backup SD card

To be safe, backup SD card (using another computer is easiest in my case): sudo dd bs=4M if=/dev/<rpi_sdcard> | gzip > rpibackup.img.gz or use my fish shell function.

2. Install LUKS dependencies and reboot

@2600box
2600box / iTunes-now-playing-on-TouchBar.scpt
Created October 20, 2017 04:20 — forked from LucaTNT/iTunes-now-playing-on-TouchBar.scpt
his script can be used in conjunction with Better Touch Tool to display the currently playing track in iTunes on the MacBook Pro TouchBar. More info here: https://lucatnt.com/2017/02/display-the-currently-playing-track-in-itunesspotify-on-the-touch-bar
-- This script can be used in conjunction with Better Touch Tool to display the currently playing track on the MacBook Pro TouchBar
-- More info here: https://lucatnt.com/2017/02/display-the-currently-playing-track-in-itunesspotify-on-the-touch-bar
if application "iTunes" is running then
tell application "iTunes"
if player state is playing then
return (get artist of current track) & " - " & (get name of current track)
else
return ""
end if
@2600box
2600box / torrent-file-size.py
Last active April 25, 2019 02:58 — forked from DonnchaC/torrent-file-size.py
Get total file sizes of contents for a set of .torrent files
import os
import sys
import bencodepy
import humanize
import argparse
def total_size_files_torrent(file_name):
try:
parsed = bencodepy.decode_from_file(file_name)
@2600box
2600box / get torrent size
Created May 23, 2019 23:18 — forked from jcahill/get torrent size
parse data size from torrent file in bytes
head -1 example.torrent | grep -aoE '6:lengthi[0-9]+' | cut -di -f2 | awk '{s+=$1} END {print s}'
@2600box
2600box / LetsEncrypt_HTTPS_plex.MD
Created September 17, 2019 05:20 — forked from churro-s/LetsEncrypt_HTTPS_plex.MD
Setup Let's Encrypt certificate for use with Plex Media Server on Ubuntu
@2600box
2600box / snmp-tunnel.sh
Created September 18, 2019 01:44 — forked from n-st/snmp-tunnel.sh
Forward SNMP requests over a SSH connection (e.g. for use with Observium or other monitoring tools).
#!/bin/bash
# This script will make a local SNMP server accessible on a remote system by
# forwarding its UDP traffic over an SSH connection.
# To do this, the following port forwardings are applied (in this order):
# - local TCP port 42061 (arbitrary) to local UDP port 161 (SNMP)
# - remote TCP port 42061 to local TCP port 42061 (via SSH connection)
# - remote UDP port 42061 to remote TCP port 42061
@2600box
2600box / 1pass_dups.py
Created September 21, 2019 10:14 — forked from thehesiod/1pass_dups.py
1password duplicate remover (alpha, only run in debugger with breakpoints everywhere *g*)
#!/usr/bin/env python3
import json
import subprocess
import sys
from concurrent.futures import ThreadPoolExecutor
import html
import dictdiffer
import iso8601