Skip to content

Instantly share code, notes, and snippets.

View geowa4's full-sized avatar
🏠
Working from home

George Adams geowa4

🏠
Working from home
View GitHub Profile
function FindProxyForURL(url, host) {
if(dnsDomainIs(host, "postman-echo.com")) {
return "PROXY squid.corp.redhat.com:3128";
}
return "DIRECT";
}
@geowa4
geowa4 / pi_ip.sh
Created May 4, 2020 01:46
Find my Raspberry Pis' IPs
# Ran on my Mac on WiFi
nmap -oG - -A -p22 "$(ipconfig getifaddr en0 | cut -d . -f 1-3).0/24" | grep Raspbian | cut -d ' ' -f 2
@geowa4
geowa4 / pstore2env.sh
Last active July 3, 2019 15:05
Shell script to convert AWS Parameter Store to env vars
#!/usr/bin/env bash
set \
-o nounset \
-o pipefail \
-o errexit
checkdep() {
cmd="$1"
if ! which "$1" > /dev/null;
then
@geowa4
geowa4 / sops.py
Created June 19, 2019 12:32
Ansible vars plugin to use Sops instead of Vault
import os
import subprocess
from ansible.errors import AnsibleParserError
from ansible.module_utils._text import to_native
from ansible.plugins.vars import BaseVarsPlugin
from ansible.inventory.host import Host
from ansible.inventory.group import Group
from ansible.utils.vars import combine_vars
from ansible.parsing.utils.yaml import from_yaml
@geowa4
geowa4 / confluence-to-pdf.js
Created January 3, 2019 03:12
Puppeteer to download Confluence PDF export
// PDF download hack taken from https://github.com/GoogleChrome/puppeteer/issues/610#issuecomment-340160025
const puppeteer = require("puppeteer");
const fs = require("fs");
(async () => {
const browser = await puppeteer.launch({ headless: true });
const page = await browser.newPage();
await page.goto(
"https://synopsys.atlassian.net/wiki/spaces/INTDOCS/pages/622678/Running+Black+Duck+Detect+with+Bamboo"
);
@geowa4
geowa4 / pairs.go
Created October 28, 2018 23:57
Find pairs that equal target
package main
//Given a list of numbers and a number k, return whether any two numbers from the list add up to k.
//For example, given [10, 15, 3, 7] and k of 17, return true since 10 + 7 is 17.
import (
"fmt"
"math/rand"
)
@geowa4
geowa4 / unival.go
Last active October 28, 2018 14:59
Unival Trees in Go
package main
//Given a tree, determine how many of its subtrees are inival trees.
//A unival tree is a tree where all nodes have the same value.
//An empty tree is a single unival tree.
//A tree with one node is a single unival tree.
//Assumptions
// - A tree whose value equals one of its children and the other child is nil is not a unival tree.
// - nil children do not contribute to the count of unival trees.
@geowa4
geowa4 / stairs.go
Created October 28, 2018 02:25
Stairs and step sizes in Go
package main
import "fmt"
//You're given a target number of steps and the avialable options for
//how many steps you can take at time. Find the number of options to get
//to the top.
//Assumptions
// - Can't make 0 steps since applying a step size of 0 at any point will yield infinite options.
@geowa4
geowa4 / main.go
Created October 26, 2018 01:39
Merge Sort in Go
package main
import (
"fmt"
"math/rand"
)
func fill(size int) []int {
slice := make([]int, 0, size)
for i := 0; i < size; i++ {
@geowa4
geowa4 / tour_of_go_web_crawler.go
Created September 2, 2018 03:05
My solution to the Tour of Go Web Crawler (Hint: read the sync package docs at https://golang.org/pkg/sync/.)
package main
import (
"fmt"
"sync"
)
type Fetcher interface {
// Fetch returns the body of URL and
// a slice of URLs found on that page.