Skip to content

Instantly share code, notes, and snippets.

View jmillerdesign's full-sized avatar

J. Miller jmillerdesign

View GitHub Profile
@JiveDig
JiveDig / functions.php
Last active December 1, 2022 21:24
Get the primary term of a post, by taxonomy. If Yoast Primary Term is used, return it, otherwise fallback to the first term.
<?php
/**
* Gets the primary term of a post, by taxonomy.
* If Yoast Primary Term is used, return it,
* otherwise fallback to the first term.
*
* @version 1.3.0
*
* @link https://gist.github.com/JiveDig/5d1518f370b1605ae9c753f564b20b7f
@davidsword
davidsword / wp-image-filters.php
Last active January 15, 2023 22:20
WordPress - All filters to modify an images URL (as far as I could find)
<?php
// Images in post galleries
add_filter( 'get_post_galleries', '_img_url_filter', PHP_INT_MAX );
add_filter( 'widget_media_image_instance', '_img_url_filter', PHP_INT_MAX );
// Core image retrieval
add_filter( 'image_downsize', '_img_url_filter', 10, 3 );
// Responsive image srcset substitution
@ReedD
ReedD / docker_to_host.sh
Created February 8, 2017 23:41
Let docker connect to host, output host ip.
#!/bin/bash
iptables -A INPUT -i docker0 -j ACCEPT
# Assumes host has `jq` installed
docker network inspect bridge | jq -r .[0].IPAM.Config[0].Gateway
@ReedD
ReedD / virtual.conf
Created November 9, 2016 17:40
Nginx Reverse Proxy
server {
listen 80;
server_name *.domain.tld;
merge_slashes off;
location / {
proxy_pass http://somealternatedomain.tld;
}
}
@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@ReedD
ReedD / log.js
Created November 10, 2015 18:05
Helpful node/javascript debug globals
Object.defineProperty(global, '__stack', {
get: function () {
var orig = Error.prepareStackTrace;
Error.prepareStackTrace = function(_, stack){ return stack; };
var err = new Error;
Error.captureStackTrace(err, arguments.callee);
var stack = err.stack;
Error.prepareStackTrace = orig;
return stack;
}
@lopezjurip
lopezjurip / README.md
Created September 26, 2015 12:13
OSX Homebrew: docker-machine setup

Prerequisites

Make sure you have installed Homebrew and (Homebrew-Cask)[http://caskroom.io/].

# Install Homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

# Install Homebrew-cask
brew install caskroom/cask/brew-cask
@greim
greim / reverse-proxy.md
Last active August 23, 2022 10:12
Using a Reverse Proxy for Rapid Prototyping

Using a Reverse Proxy for Rapid Prototyping

Note: This will be a contrived example, but hopefully illustrates some real-world trade-offs.

Example scenario: Suppose you're an independent web developer, and a client asks you to prototype a redesign of their website header. You'll be paid for your time, and if the client likes it, you'll be hired to do the full implementation. Your incentive is to show the client a quick, functional demo of the updated header. The problem is that quick and functional tend to be mutually-exclusive.

At One Extreme: Do It Fast

@ReedD
ReedD / EC2_mongodb.sh
Created June 9, 2015 16:11
EC2 MongoDB instance startup command
#!/bin/bash
# http://docs.mongodb.org/ecosystem/platforms/amazon-ec2/
# the following command is the updated version of the command
# used to setup the mongo instance along with the recommended
# EBS volumes
aws --profile <AWS_PROFILE> ec2 run-instances \
--image-id <CURRENT_AWS_LINUX_AMI> \
--instance-type <INSTANCE_TYPE> \
--security-group-ids <SECURITY_GROUP_ID> \
@terranware
terranware / snsToSlack.js
Last active March 7, 2024 14:47
AWS Lambda function to Slack Channel hookup
var https = require('https');
var util = require('util');
exports.handler = function(event, context) {
console.log(JSON.stringify(event, null, 2));
console.log('From SNS:', event.Records[0].Sns.Message);
var postData = {
"channel": "#aws-sns",
"username": "AWS SNS via Lamda :: DevQa Cloud",