Skip to content

Instantly share code, notes, and snippets.

View rotated8's full-sized avatar

Collin Brittle rotated8

  • Emory University
  • Atlanta, GA
View GitHub Profile
@rotated8
rotated8 / email.py
Last active March 1, 2022 08:29
Send emails through Gmail with Python. Send text messages using the SMS gateways. If you use Gmail's two-factor authentication, you'll need to set up an application specific password.
gmail_username = 'username@gmail.com'
recipients = 'recipient@example.com'
# https://en.wikipedia.org/wiki/List_of_SMS_gateways
# 10DigitNumber@text.att.net for AT&T
# 10DigitNumber@vtext.com for Verizon
from email.mime.text import MIMEText
msg = MIMEText('This is the body of the message.')
msg['Subject'] = 'Blank subject lines look like spam.'
msg['From'] = gmail_username
@rotated8
rotated8 / .vimrc
Created February 23, 2016 19:35
Highlight mixed and trailing whitespace
" Bad whitespace shows up in red.
highlight BadWhitespace ctermbg=1 guibg=Red
" This function will clear bad whitespace highlighting in help files.
" It is needed because Filetype events fire after BufEnter ones. See below.
function! IgnoreHelpFiles()
if &filetype ==? 'help'
call clearmatches()
endif
endfunction
" Match whenever we enter a buffer. (These happen in order)

Keybase proof

I hereby claim:

  • I am rotated8 on github.
  • I am rotated8 (https://keybase.io/rotated8) on keybase.
  • I have a public key ASDpj-G-2NBq9PodXpuW687eplx8AUXEzle110v33PN3Ogo

To claim this, I am signing this object:

@rotated8
rotated8 / to_json.py
Last active August 18, 2017 15:01
Convert CSV or Database data to JSON
import cx_Oracle as oracle
import argparse, csv, json, os, os.path
QUERY = 'SELECT * FROM ESDV.V_ETD_EMPE'
ROW_KEY = 'ETD Record Key'
def from_database(credentials):
data = {}
with oracle.connect(credentials) as conn:
cursor = conn.cursor()
@rotated8
rotated8 / .solr_wrapper
Last active September 25, 2018 17:00
Getting Started with Solr
# Which version of Solr to download. 6.6.2 is known good with Hyrax.
version: 6.6.2
# Download from Princeton, because their mirror is more stable than Apache's, and we have permission.
mirror_url: 'http://lib-solr-mirror.princeton.edu/dist/'
checksum: 'http://lib-solr-mirror.princeton.edu/dist/lucene/solr/6.6.2/solr-6.6.2.zip.sha1'
ignore_checksum: 'true'
# Where to download things.
download_dir: '/var/tmp'
# Where to put Solr. NOTE: This is relative to where you run solr_wrapper!
instance_dir: 'solr-dev'
@rotated8
rotated8 / tki-bash.sh
Last active July 30, 2019 16:26
TKI function for Bash prompt
# If AWS credentials have been updated in the last 12 hours, TKI is probably ok.
CHECK_TKI=false # Change to 'true' to enable the check.
function warn_tki {
if [[ -e "$HOME/.aws/credentials" && $CHECK_TKI == 'true' ]]; then
date_format="%Y%m%d%H%M%S" # Reduces time to a comparable number, not epoch dependant.
mod_time=$(date --reference="$HOME/.aws/credentials") # Time AWS creds were modified.
expire_time=$(date --date="$mod_time + 43200 seconds" +"$date_format") # Add 12 hours.
if [[ "$expire_time" -ge "$(date +$date_format)" ]]; then
echo -e '\033[0;32mTKI:✓ ' # Green
@rotated8
rotated8 / ssh-to-ec2-by-tag-name
Created July 24, 2019 15:38 — forked from SolomonHD/ssh-to-ec2-by-tag-name
Bash function for SSH into EC2 by Name Tag
<< ////
This function will ssh into a EC2 based on Name tags. You can ssh in via public or private IP This function requires awscli to work
There are several optional environment variables:
AWS_PROFILE = Control which profile is active with this variable, if this is unset the function will use AWS_DEFAULT_PROFILE instead
SSH_EC2_KEY_FILE = path to the key file for the user
SSH_EC2_USER = name of the user that logs in, if this variable is unset the value is ec2-user
To use this function do the following commands
(from command line)
@rotated8
rotated8 / stack.yml
Last active June 14, 2022 14:43
Docker Compose for Drupal
# Drupal with PostgreSQL
# Adapted from https://hub.docker.com/_/drupal/
#
# Access via "http://localhost:8080"
# (or "http://$(docker-machine ip):8080" if using docker-machine)
#
# Database type: PostgreSQL
# Database name: postgres
# Database username: postgres
# Database password: example
@rotated8
rotated8 / git-version.sh
Created May 23, 2023 20:13
Get the tag for a commit, or the branch@hash. Useful for showing a version.
#!/usr/bin/env bash
# Set repo_dir to folder this script lives in.
repo_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P)
if [[ $# -eq 1 && -n "$1" && -d "$1" ]]; then
# Script was called with an argument that is a path to a directory.
repo_dir="$1"
fi
# Get tags for HEAD.