Skip to content

Instantly share code, notes, and snippets.

James Jackson jamesbjackson

Block or report user

Report or block jamesbjackson

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jamesbjackson
jamesbjackson / README.md
Created May 21, 2019
How to show current HTTP requests on any server
View README.md

How to show current HTTP requests on any server

via https://dev.to/codeenigma/how-to-show-current-http-requests-on-any-server-mmp

"If you’re ever need to see incoming HTTP requests, maybe to check incoming headers, you want to know what cookies are being set, or get some clues as to why things aren’t being cached, the following command might be helpful:"

sudo tcpdump -A -s 10240 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)' | egrep --line-buffered "........(GET |HTTP\/|POST |HEAD )|[A-Za-z0-9-]+: " | sed -r 's/........(GET |HTTP\/|POST |HEAD )/\n\1/g'

"It’s a bit of a mouthful, but it shows incoming HTTP requests direct from the network interface, and formats them in a readable way for humans. The nice thing is that you can then use grep with the output to show things like incoming cookies, or request headers. Probably more useful for monitoring requests than watching log files and guessing."

@jamesbjackson
jamesbjackson / Makefile
Created May 17, 2019 — forked from paulfurley/Makefile
Makefile for activating a virtualenv and installing requirements. Uses requirements-to-freeze.txt / requirements.txt pattern
View Makefile
# Put *unversioned* requirements in `requirements-to-freeze.txt` as described below.
# `requirements.txt` will be automatically generated from `pip freeze`
# https://www.kennethreitz.org/essays/a-better-pip-workflow
venv/bin/activate: requirements-to-freeze.txt
rm -rf venv/
test -f venv/bin/activate || virtualenv -p $(shell which python3) venv
. venv/bin/activate ;\
pip install -Ur requirements-to-freeze.txt ;\
pip freeze | sort > requirements.txt
@jamesbjackson
jamesbjackson / attributes.rb
Created Apr 23, 2019 — forked from lizthegrey/attributes.rb
Hardening SSH with 2fa
View attributes.rb
default['sshd']['sshd_config']['AuthenticationMethods'] = 'publickey,keyboard-interactive:pam'
default['sshd']['sshd_config']['ChallengeResponseAuthentication'] = 'yes'
default['sshd']['sshd_config']['PasswordAuthentication'] = 'no'
@jamesbjackson
jamesbjackson / Dockerfile
Created Apr 10, 2019 — forked from majodev/Dockerfile
netdata daemonset on kubernetes
View Dockerfile
FROM netdata/netdata:latest
MAINTAINER YOUR_EMAIL
# add netdata user to root group (access volumne mounts from host)
RUN apk --no-cache add shadow
RUN usermod -a -G root netdata
ENTRYPOINT ["/usr/sbin/run.sh"]
@jamesbjackson
jamesbjackson / get_sizes.sql
Created Feb 27, 2019 — forked from peterc/get_sizes.sql
Get the size of different tables and other relations in a PostgreSQL database
View get_sizes.sql
SELECT
schema_name, rel_name, table_size,
pg_size_pretty(table_size) AS size
FROM (
SELECT
nspname AS schema_name,
relname AS rel_name,
pg_table_size(pg_class.oid) AS table_size
FROM pg_class, pg_namespace
WHERE pg_class.relnamespace = pg_namespace.oid
View fpm-openssl.sh
#!/bin/bash
# fpm-openssl - @jbuchbinder
# Build script for recent openssl builds using FPM on EL7. Untar the release and run this script to build
# your RPM. Requires:
# - RPMS: ruby-devel make gcc rpm-build
# - GEMS: fpm
./config && make depend && make all && make install INSTALL_PREFIX=/tmp/openssl
fpm -s dir -t rpm -n openssl-recent \
View python_http_socket.py
import socket
import fcntl
import struct
import IN
import sys
interface_name = str(sys.argv[1])
print interface_name
def get_ip_address(ifname):
View https-server.txt
## On the server
# AWS EC2
SERVER_IP=$(curl http://169.254.169.254/latest/meta-data/public-ipv4)
# Digital Ocean
SERVER_IP=$(curl http://169.254.169.254/metadata/v1/interfaces/public/0/ipv4/address)
# Generate a self-signed server certificate
openssl genrsa -out server.key 4096
@jamesbjackson
jamesbjackson / web-servers.md
Created Dec 6, 2018 — forked from willurd/web-servers.md
Big list of http static server one-liners
View web-servers.md

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
View bash.generate.random.alphanumeric.string.sh
#!/bin/bash
# bash generate random alphanumeric string
#
# bash generate random 32 character alphanumeric string (upper and lowercase) and
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
# bash generate random 32 character alphanumeric string (lowercase only)
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1
You can’t perform that action at this time.