Skip to content

Instantly share code, notes, and snippets.

@xcsrz
xcsrz / create-ssl-cert.sh
Last active October 28, 2015 23:19
This script creates the .key and .csr files using the bare minimum information. It's only argument is the domain name to be secured. Prepend "*." for wildcard domain certificates. Customize the DEFAULT_ORGNAME and DEFAULT_ORGCOUNTRY setting variables at the top before use. Environment variable overrides are ORGNAME and ORGCOUNTRY.
#!/bin/bash
DEFAULT_ORGNAME="xcsrz"
DEFAULT_ORGCOUNTRY="US"
if [ -t $1 ]; then
echo "you must provide a domain name (don't forget the asterisk if it's for a wildcard certificate"
echo ""
echo "Usage:"
echo " ${0} DOMAIN"
@xcsrz
xcsrz / server.go
Created January 2, 2016 07:12
A golang web server on a randomly (os) chosen port.
package main
import (
"fmt"
"github.com/skratchdot/open-golang/open"
"net"
"net/http"
)
func main() {
@xcsrz
xcsrz / whoiswatching.sh
Created November 7, 2016 19:42
Who can see/sniff your dns queries?
traceroute 8.8.8.8|awk -F[\(\)] '$2~/[0-9]/{print $2}'|while read i;do whois $i | awk -F ":\s*" '/^(OrgName|City|State|Country)/ {gsub(/^[ \t]+|[ \t]+$/, "", $2); printf $2" "}'; echo $i; done
@xcsrz
xcsrz / WriteChanCloser.go
Created January 5, 2017 17:42
Modeled after Golang's ioutil package's NopCloser method which wraps an io.Reader interface in an io.ReadCloser facade interface, this code takes an io.Writer and a nil channel and returns an io.WriteCloser interface. The example.go file demonstrates usage in an http.HandleFunc as a very over complicated counter using the worker-and-channel-over…
package main
import "io"
type writeChanCloser struct {
io.Writer
closeChan chan struct{}
}
func (wcc writeChanCloser) Close() error {
@xcsrz
xcsrz / center_text_on_image.py
Created March 8, 2017 00:17
Center text on an image with Python and OpenCV. Had to come up with it myself as no one was spelling this out anywhere (or google couldn't find it)
#!/usr/bin/env python
import numpy as np
import cv2
from time import sleep
# create blank image - y, x
img = np.zeros((600, 1000, 3), np.uint8)
# setup text
@xcsrz
xcsrz / emot.sh
Last active February 8, 2018 22:33
Terminal "utility" to copy ASCII emoji to the clipboard on OSX
#!/bin/bash
EMOTS=(
"¯\_(ツ)_/¯"
"༼ ༎ຶ ෴ ༎ຶ༽"
"「(°ヘ°)"
"(╯°□°)╯︵ ┻━┻"
"༼ つ ◕_◕ ༽つ"
"(✿◠‿◠)"
"¯(°_o)/¯"
@xcsrz
xcsrz / memcached-status.sh
Last active December 16, 2018 05:36
Grab stats from memcached
echo stats | nc 127.0.0.1 11211
@xcsrz
xcsrz / bump-to-even-numbers.sh
Last active December 16, 2018 05:36
Bash function to bump minor semantic version number by even numbers.
releaseBumpValue() {
semver="${1}"
local tifs=${IFS}
local IFS='.'
read -ra bits <<< "${semver}"
if [ $((bits[1]%2)) -eq 0 ]; then
echo 2
else
echo 1
fi
@xcsrz
xcsrz / sendgrid_keys.rb
Created December 7, 2018 22:47
Sendgrid's UI does not give you full control over API keys. This script does. Set two environment variables and you can view your keys, their scopes and add/remove scopes from any key. Simple utility but saves a lot of time and headache.
#!/usr/bin/env ruby
require 'base64'
require 'rest-client'
require 'json'
# https://stackoverflow.com/questions/38613941/sendgrid-error-access-forbidden-when-trying-to-get-user-profile-api
$base_endpiont = "https://api.sendgrid.com/v3/api_keys"
def usage
@xcsrz
xcsrz / clean-browser-session.sh
Created March 28, 2019 18:54
Run chrome completely separate from the standard as though it has never been run before on that computer, but skip the welcome wizard stuff.
#!/bin/bash
app="/Applications/Google Chrome.app"
dir=$(mktemp -d)
# echo $dir
touch "${dir}/First Run"
mkdir "${dir}/Default"
echo '{"browser":{"has_seen_welcome_page":true}}' > "${dir}/Default/Preferences"
exec "${app}/Contents/MacOS/Google Chrome" --bwsi --disable-signin-promo --bypass-app-banner-engagement-checks --no-managed-user-acknowledgment-check -no-first-run --user-data-dir=${dir} --system-developer-mode