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 / reset_git.sh
Created August 5, 2019 16:44
Reset a git repository (before commit)
# Reset git repository (before commit)
git reset HEAD \*
git checkout -- .
@wcarhart
wcarhart / deploy_django_to_heroku.sh
Last active August 6, 2019 10:25
How to deploy a Django application to Heroku
# How to deploy a Django application to Heroku with PostgreSQL
#========== Pre-requirements ==========#
### 1. make sure Heroku CLI is installed
### read more here: https://devcenter.heroku.com/articles/heroku-cli
### 2. use virtualenv to control python packages
### 3. replace 'projectname' with your project's name throughout this script
### 4. this script is for MacOS and Bash, but is very similar for Linux and other shells
#========== if you're lazy like me, make an alias ==========#
@wcarhart
wcarhart / new-net-nat.ps1
Created October 22, 2019 18:13
Add Network NAT for Hyper-V VM
# list all VMSwitches
Get-VMSwitch
# for each VMSwitch, do the following:
Remove-VMSwitch <VM_SWITCH_NAME>
# list all NetNATs
Get-NetNAT
# for each NetNAT, do the following:
@wcarhart
wcarhart / setup_networking.sh
Last active October 22, 2019 18:36
Setup networking for a CentOS VM (on Hyper-V)
# Start here: https://gist.github.com/wcarhart/48ce5d7e14a8172352db62af9705c183
# Edit the default network adapter settings
cd /etc/sysconfig/network-scripts/ifcfg-eth0
# IPADDR can be anything in our range
sed -i.bak -e 's/IPADDR = ".*"/IPADDR = "192.168.1.2"/'
# GATEWAY needs to match the gateway defined in Hyper-V
sed -i.bak -e 's/GATEWAY= ".*"/GATEWAY = "192.168.1.1"/'
# Configure DNS
@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
@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 / bash_tidbits.md
Last active May 19, 2024 11:18
Helpful Bash design patterns

Helpful Bash tidbits

@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 / 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