Skip to content

Instantly share code, notes, and snippets.

View heph's full-sized avatar
:shipit:

Heph Adams heph

:shipit:
View GitHub Profile
@heph
heph / json2yml.rb
Created December 18, 2019 19:32
Converts a json file to yaml. Pretty sure I stole this from the travis-ci project.
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'json'
require 'yaml'
$stdout.puts YAML.dump(JSON.parse($stdin.read))
@heph
heph / yml2json.rb
Created December 18, 2019 19:30
Converts a yaml file to json with ruby. I'm pretty sure I stole this from the travis-ci project.
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'erb'
require 'json'
require 'yaml'
$stdout.puts JSON.pretty_generate(YAML.safe_load(ERB.new($stdin.read).result))
@heph
heph / boilerplate.sh
Created September 29, 2018 00:17
How I start all my shell scripts
#!/usr/bin/env bash
#
# Short header explaining what the script does
#
# exit on error, error on unbound variables, disable glob expansion, fail within pipes
set -eufo pipefail
[[ -n "${DEBUG:-}" ]] && set -x
: "${VAR_A=default_value_a}"
@heph
heph / chef_hostsfile.sh
Created September 2, 2018 00:11
Write chef node names and public ip addresses to /etc/hosts
#!/bin/bash
set -euo pipefail
HEADER='# All lines below managed by chef_hostfile.sh'
backup_hostsfile() {
sudo cp /etc/hosts{,.$(date +%s)}
}
@heph
heph / task_loader.sh
Created January 19, 2018 21:18
Bash - load and execute functions matching a pattern from include files Raw
for file in $(find ./tasks -type f -name '*.sh' | sort -n); do
current_functions="$(declare -F)"
echo "Sourcing task file: ${file}"
# shellcheck source=/dev/null
source "$file"
new_functions="$(diff <(echo "$current_functions") <($(declare -F))) | awk '$NF ~ /.*::main/ {print $NF}')" || true
for main in "$new_functions"; do
log debug "Executing function ${main} from ${file}:"
$main
done
services:
deck:
host: spinnaker.mydomain.com
baseUrl: ${services.default.protocol}://${services.deck.host}
gateUrl: ${services.deck.baseUrl}/gate
bakeryUrl: ${services.deck.baseUrl}/rosco
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default.conf
Listen 80
<IfModule ssl_module>
Listen 443
</IfModule>
<VirtualHost _default_:80>
DocumentRoot /opt/deck/html
ProxyPass "/gate" "http://localhost:8084" retry=0
ProxyPassReverse "/gate" "http://localhost:8084"
ProxyPass "/rosco" "http://localhost:8087" retry=0
ProxyPassReverse "/rosco" "http://localhost:8087"
<Directory "/opt/deck/html/">
@heph
heph / ohai-consul.rb
Created September 27, 2014 02:51
consul ohai plugin (only supports kv lookups at the moment)
require 'net/http'
require 'uri'
require 'base64'
require 'json'
Ohai.plugin(:Consul) do
provides 'consul'
##
# Insert a value into a hash with a '/' delimited path
@heph
heph / gist:8a6073a68cee61ac0d8f
Last active September 28, 2016 18:01
keybase.io identity proof
### Keybase proof
I hereby claim:
* I am heph on github.
* I am heph (https://keybase.io/heph) on keybase.
* I have a public key ASCr40PeHVymBfKyLcK5V_7j42sjUGTFIe8pAMYhaMkSYAo
To claim this, I am signing this object: