Skip to content

Instantly share code, notes, and snippets.

View jmervine's full-sized avatar

Joshua Mervine jmervine

View GitHub Profile
@jmervine
jmervine / main.go
Last active July 1, 2021 03:38
Golang: Safely Split a string containing a shell command.
// safeSplit handles quoting well for commands for use with github.com/jmervine/exec/v2
//
// Examples:
// > safeSplit("/bin/bash bash -l -c 'echo \"foo bar bah bin\"'")
// => []string{"/bin/bash", "-l", "-c", "echo \"foo bar bah bin\""}
// > safeSplit("docker run --rm -it some/image bash -c \"npm test\"")
// => []string{"docker", "run", "--rm", "-it", "some/image", "bash", "-c", "npm test"}
//----
// package main
// import "github.com/jmervine/exec/v2"
@jmervine
jmervine / splunk.sh
Last active March 29, 2021 19:46
Simple script to start and seed a local splunk instances using Docker
#!/usr/bin/env bash
# Simple script to start and seed a local splunk instances using Docker
# Usage:
# $ bash splunk.sh [USERNAME] [HEC TOKEN]
PASSWORD="$1"
TOKEN="$2"
test -z "$PASSWORD" && PASSWORD=password
test -z "$TOKEN" && TOKEN=token
@jmervine
jmervine / gist:2079897
Created March 18, 2012 19:04
installing mysql on ubuntu using an aws instance
$ sudo apt-get install mysql-server mysql-client
... output omitted ...
$ sudo mysqladmin -u root -h localhost password 'password'
... output omitted ...
$ mysql -u root -p
... output omitted ...
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'your_host_name' IDENTIFIED BY "password";
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
@jmervine
jmervine / nginx.conf
Last active March 19, 2020 06:17
Nginx config to test regex.
# Usage:
#
# Start with:
#
# sudo /use/local/sbin/nginx -c /path/to/this/nginx.conf
#
# Tail logs:
#
# $ sudo tail -f /tmp/access.log /tmp/error.log /tmp/match.log
#
@jmervine
jmervine / Makefile
Last active February 20, 2020 11:30
Node.js forever Makefile tasks.
#
# Tasks
#
# - start :: starts application using forever
# - stop :: stops application using forever
# - restart :: restart application using forever
#
# This set's your local directory to to your NODE_PATH
NODE_EXEC = NODE_PATH=.:$(NODE_PATH)
@jmervine
jmervine / 1_http_hello.go
Last active November 22, 2019 13:16
Golang - Hello PATH HTTP Server Example
package main
import (
"fmt"
"log"
"net/http"
)
func Log(handler http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
@jmervine
jmervine / test-external-secrets.yaml
Last active April 18, 2019 18:17
godaddy external-secrets test
---
apiVersion: 'kubernetes-client.io/v1'
kind: ExternalSecret
metadata:
name: test-external-secrets
namespace: default
secretDescriptor:
backendType: secretsManager
data:
- key: /splunk/license
@jmervine
jmervine / purge.js
Last active March 6, 2019 19:41
MaxCDN purge script.
#!/usr/bin/env node
/***
* Setup:
*
* npm install maxcdn subarg async
*
***/
var MaxCDN, subarg, async;
try {
MaxCDN = require('maxcdn');
UPDATE_TYPE ?= sts
STS ?=
indexers: ## Select indexer as actionable StatefultSet
indexers:
$(eval STS := indexer)
@echo "Set indexer as actionable StatefulSet"
indexer: indexers