Skip to content

Instantly share code, notes, and snippets.

@j18e
j18e / yaml_parser.py
Created December 19, 2017 13:18
Yaml Parser for Bash
#!/usr/bin/env python3
"""Yaml Parser
Usage: yaml_parser.py [-f FILE] [KEYS]
Parses yaml file using provided keys in 'key.otherkey.anotherkey' format
If result is a datastructure, response comes in JSON
Arguments:
@j18e
j18e / render_jinja.py
Created December 19, 2017 21:09
Jinja Templating Script
#!/usr/bin/env python3
"""Usage: render_jinja.py <template_file> <parameters_file>
Parameters file must be yaml encoded. Use Jinja2 to reference in template.
Options: -h
"""
from docopt import docopt
from jinja2 import Environment, FileSystemLoader
@j18e
j18e / configmap.yml
Created December 20, 2017 14:44
Concourse on AWS Kubernetes Deployment with HTTPS endpoint
---
apiVersion: v1
kind: ConfigMap
metadata:
name: concourse-keys
data:
authorized_worker_keys: |+
ssh-rsa {{public_key_text}} worker-key
session_signing_key: |+
-----BEGIN RSA PRIVATE KEY-----
@j18e
j18e / ssh-port-forwarding
Last active January 8, 2018 15:23
SSH Port Forwarding
# $HOME/.ssh/config
Host example-forward
HostName bastion.example.com
ForwardAgent yes
ForwardX11 yes
LocalForward 9090 app-0.example.local:8080
# this allows you to run `ssh example-forward`
# you'll get an SSH session but more importantly,
@j18e
j18e / yamplate.py
Last active March 6, 2018 13:13
yamplate
from jinja2 import Environment, meta, StrictUndefined, exceptions
from yaml import load_all
def get_manifests(template_string, overrides):
config = get_config(template_string)
for k, v in overrides.items():
config['parms'][k] = v
rendered = render_jinja(template_string, config['parms'])
results = list(load_all(rendered))
try:
@j18e
j18e / config
Created July 22, 2018 08:46
Configure SSH Port Forwards
# in ~/.ssh/config
# run `ssh application-server` to use forward, then `curl localhost:8080`
Host application-server
HostName bastion.mycloud.app
User admin
ForwardAgent yes
ForwardX11 yes
LocalForward 8080 app-server-01.mycloud.local:80
@j18e
j18e / keymods.ahk
Created December 29, 2018 07:02
Auto hotkey config to remap ctrl and esc to caps lock, and to map alt+[]\ to vol up down and mute
; Volume control (turn master volume up and down with Ctrl-Alt-Up/Down and
; toggle mute with Ctrl-Alt-.)
!]::Send {Volume_Up}
![::Send {Volume_Down}
!\::Send {Volume_Mute}
g_LastCtrlKeyDownTime := 0
g_AbortSendEsc := false
g_ControlRepeatDetected := false
@j18e
j18e / karabiner.json
Last active January 30, 2019 13:27
App switching, Norwegian characters, ctrl/esc over caps, hyper using Karabiner elements on mac
{
"global": {
"check_for_updates_on_startup": false,
"show_in_menu_bar": false,
"show_profile_name_in_menu_bar": false
},
"profiles": [
{
"complex_modifications": {
"parameters": {
@j18e
j18e / docker-compose.yml
Last active January 17, 2023 01:19
Unifi controller behind Traefik reverse proxy in Docker
version: '3'
services:
unifi:
restart: always
hostname: unifi
container_name: "unifi"
image: linuxserver/unifi-controller
volumes: ["../data/unifi/:/config"]
environment:
TZ: "America/Seattle"
package main
import (
"fmt"
"io/ioutil"
"log"
"os"
"strings"
"sync"
"time"