Skip to content

Instantly share code, notes, and snippets.

Avatar

Joshua Mervine jmervine

View GitHub Profile
@jmervine
jmervine / cert_convert.sh
Created Nov 17, 2014
openssl: convert cert from p7b to crt (or cer)
View cert_convert.sh
openssl pkcs7 -print_certs -in old.p7b -out new.crt
# openssl pkcs7 -print_certs -in old.p7b -out new.cer
View sri.go
package sri
import (
"crypto/sha256"
"encoding/base64"
"fmt"
"io/ioutil"
)
func Generate256(file string) (string, error) {
@jmervine
jmervine / gist:2079897
Created Mar 18, 2012
installing mysql on ubuntu using an aws instance
View gist:2079897
$ 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 Mar 19, 2020
Nginx config to test regex.
View nginx.conf
# 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 Feb 20, 2020
Node.js forever Makefile tasks.
View Makefile
#
# 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 Nov 22, 2019
Golang - Hello PATH HTTP Server Example
View 1_http_hello.go
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 / 01_nginx.conf
Last active Oct 22, 2019
Nginx Based A/B testing.
View 01_nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include /home/t/nginx/conf/mime.types;
default_type application/octet-stream;
@jmervine
jmervine / main.go
Last active Jul 13, 2019
Golang: Safely Split a string containing a shell command.
View main.go
// 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 / golang-crosscompile-build.bash
Last active Apr 29, 2019
Scripts to setup golang cross-compiling and build an application on all setup platforms. Tested on: Linux 3.8.0-36-generic #52~precise1-Ubuntu SMP x86_64
View golang-crosscompile-build.bash
#!/bin/bash
#
# usage: ./golang-crosscompile-build.bash /path/to/target.go
# argument handling
test "$1" && target="$1" # .go file to build
if ! test "$target"
then
echo "target file required"
You can’t perform that action at this time.