Skip to content

Instantly share code, notes, and snippets.

View koop's full-sized avatar

Daryl Koopersmith koop

  • Stripe
  • San Francisco, CA
  • X @koop
View GitHub Profile
@koop
koop / ensure-cert-macos.sh
Created November 28, 2017 20:27
Ensures a certificate is in the macOS system keychain.
#!/bin/bash
# Usage
# $ ./install-cert-macos.sh "/path/to/cert"
CERT_PATH="$1"
# First, grab the SHA-1 from the provided SSL cert.
CERT_SHA1=$(openssl x509 -in "$CERT_PATH" -sha1 -noout -fingerprint | cut -d "=" -f2 | sed "s/://g")
# Next, grab the SHA-1s of any standard.dev certs in the keychain.
# Don't return an error code if nothing is found.
ENV_VARS=""
printenv | grep "^\([[:alnum:]]\|[[:punct:]]\)\+=" | sed 's/=.*$//g' | while read var; do
ENV_VARS+="$var=$(printenv $var)__IMPROMPTU__"
done
@koop
koop / gallery.js
Created December 3, 2012 01:46
Query all attachments uploaded to a post.
@koop
koop / esc_attrs.php
Created September 27, 2011 21:39
Generates a properly escaped HTML string based upon an array of HTML attributes.
<?php
function esc_attrs( $attrs ) {
$html = ' ';
$url_attrs = array( 'src', 'href', 'formaction', 'data', 'action', 'icon', 'manifest', 'poster' );
foreach ( $attrs as $key => $value ) {
// If an attribute starts with 'on', assume it's a javascript parameter
if ( 'on' == substr( $key, 0, 2 ) )