Skip to content

Instantly share code, notes, and snippets.

View dtiemann83's full-sized avatar

Dana Tiemann dtiemann83

View GitHub Profile
@dtiemann83
dtiemann83 / api-proxy.js
Created November 4, 2016 17:27
A quick bit of Node.JS/Express code to proxy a request to an API from a local URL, avoiding XSS and allowing safe injection of authentication params. Example includes HTTP Basic Authentication strategy. Requires 'request', 'underscore', and 'express'.
var request = require('request'), router = require('express').Router(),
url = require('url'), _ = require('underscore')
var config = {
api : {
url : {
protocol : "http",
hostname : "rest.myapi.com",
port : "8080"
},
@dtiemann83
dtiemann83 / gitautotag.sh
Last active September 17, 2024 02:19
A quick BASH script to automatically add a git tag by incrementing --major --minor --bug version, based on (most recent) previous tag.
#!/bin/bash
CURTAG=`git describe --abbrev=0 --tags`;
CURTAG="${CURTAG/v/}"
IFS='.' read -a vers <<< "$CURTAG"
MAJ=${vers[0]}
MIN=${vers[1]}
BUG=${vers[2]}
@dtiemann83
dtiemann83 / ssh_hosts.sh
Created February 23, 2018 19:14
Script to display all of the hostnames and addresses in your SSH config
#!/bin/bash
# Script to display all of the hostnames and addresses in your SSH config!
COLOR=$(tput setaf 2)
NCOL=$(tput sgr0)
hosts=``;
cat ~/.ssh/config | grep 'Host' | while read -r line ; do
nline=`echo $line | sed -e 's/[[:space:]]*Hostname[[:space:]]*//g' -e 's/[[:space:]]*Host[[:space:]]*//g' -e 's/[[:space:]]*$//g' -e 's/[[:space:]]/*/g'`
if ! [[ $line =~ ^Hostname ]]; then