Skip to content

Instantly share code, notes, and snippets.

View wcarhart's full-sized avatar
🦉
Hoot hoot

Will Carhart wcarhart

🦉
Hoot hoot
View GitHub Profile
@wcarhart
wcarhart / links.txt
Last active January 24, 2024 23:07
Interesting software links
@wcarhart
wcarhart / knock.sh
Last active January 13, 2021 19:06
Setup and use port knocking
#!/bin/bash
# test port knocking using nmap
for port in 7151 10888 8899 ; do nmap -Pn --host_timeout 201 --max-retries 0 -p $port ipaddress ; done && ssh root@ipaddress
# test port knocking using knock
sudo apt-get update
sudo apt-get install knockd
knock ipaddress 7151 10888 8899 && ssh root@ipaddress
@wcarhart
wcarhart / bash_metaprogramming.sh
Created April 21, 2020 03:20
Bash metaprogramming
#!/bin/bash
# list all custom BASH functions
lsf() {
if [[ ! -d ~/.bash_functions ]] ; then
if [[ ! -f ~/.bashrc ]] ; then
echo "lsf: err: no such directory ~/.bash_functions, no such file ~/.bashrc"
return 1
fi
@wcarhart
wcarhart / remove_file.sh
Last active February 9, 2020 00:42
Completely remove a file from Git history
# Completely remove a file from git history
# Remove file from all commits
# $path_to_file supports wildcards: path/to/directory/*
git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch $path_to_file" HEAD
# Prune branch
git reflog expire --expire=now --all && git gc --prune=now --aggressive
# Rewrite history in remote
@wcarhart
wcarhart / Dockerfile
Created February 6, 2020 23:58
Run a Matlab script in a Docker container without rebuilding the image when the script updates (could be extended to any script)
FROM ubuntu:18.04
RUN apt-get update
RUN apt-get install -y octave
WORKDIR /
ENV SCRIPT=""
COPY octave_runner /
RUN chmod +x /octave_runner
@wcarhart
wcarhart / fix_virtualenv.sh
Last active February 6, 2020 23:50
How to install a Python package with setup.py + tox
#!/usr/bin/env bash
ENV_PATH="$(dirname "$(dirname "$(which pip)")")"
SYSTEM_VIRTUALENV="$(which -a virtualenv|tail -1)"
BAD_ENV_PATHS="/usr/local"
echo "Ensure the root of the broken virtualenv:"
echo " $ENV_PATH"
@wcarhart
wcarhart / bash_tidbits.md
Last active February 15, 2024 05:46
Helpful Bash design patterns

Helpful Bash tidbits

@wcarhart
wcarhart / setup_docker.sh
Created October 22, 2019 18:45
Setup Docker for a Centos VM (on Hyper-V)
# THIS IS FOR AN OLDER VERSION OF DOCKER
# if you're using a custom docker space on a mounted drive, ensure the drive mounted correctly
# determine where the mount is
df -h
# then, format the disk as necessary (may have to remove partition and remount)
fdisk /dev/sda # or /dev/sdb, etc.
p # print partitions
d # delete partition
@wcarhart
wcarhart / setup_python.sh
Last active October 22, 2019 19:51
Setup Python for a CentOS VM (on Hyper-V)
# you might need these, if they are not already installed:
yum install -y zlib
yum install -y zlib-devel
yum install -y opensll
yum install -y opensll-devel
# Install Python 3.6.8 (change version # as necessary)
cd /usr/src
yum install -y gcc
wget https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tar.xz