Skip to content

Instantly share code, notes, and snippets.

View afreeland's full-sized avatar

Aaron Freeland afreeland

View GitHub Profile
@afreeland
afreeland / kubectl exec cmd multiple pods (envoy example)
Created July 25, 2022 17:08
Pipe `kubectl` pod names into `xargs` to invoke `curl` commands to update `envoy` debugging levels
kubectl -l{LABEL_SELECTOR} --no-headers -o custom-columns=":metadata.name" | xargs -I% kubectl exec % -- curl -X POST http://localhost:{ENVOY_ADMIN_PORT}/logging\?level\=debug
# List clusters
aws eks list-clusters
# You may need to target different profiles
AWS_PROFILE={account-profile-name-here} aws eks list-clusters
# Update kubeconfig with cluster info
aws eks update-kubeconfig --name {cluster-name-here}
@afreeland
afreeland / gist:f2e26e02a784e7cae66795a3281dbdb2
Created June 29, 2022 19:13
Git checkout pull requests
# git fetch {remote} pull/{PR#}/head && git checkout FETCH_HEAD
git fetch upstream pull/855/head && git checkout FETCH_HEAD
@afreeland
afreeland / WebhookVerification.js
Created August 6, 2020 18:51
Chargify webhook verification middleware
app.use("/chargify", (req, res, next) => {
// This request header contains the signature of the hmac sha 256 of the sites secret with the raw body of the request
const webhookSignature =
req.headers["x-chargify-webhook-signature-hmac-sha-256"];
try {
// Your secret shared site key that you got from Chargify earlier
// This is a SECRET and should be stored/retrieved in a safe manner, not source control (Kube Secret, etc.,)
const sharedKey = "b65ca1b9a6eaea838b7c536ca0ca5fe634214b5d";
// The first step is to create a sha256 of our shared site key
const hmac = crypto.createHmac("sha256", sharedKey);
@afreeland
afreeland / middleware.js
Last active August 7, 2020 13:08
Webhook middleware (Chargify)
const app = express();
function rawBodySaver(req, res, buf, encoding) {
if (buf && buf.length) {
req.rawBody = buf.toString(encoding || "utf8");
}
}
// For parsing application/json
app.use(express.json());
// For parsing application/x-www-form-urlencoded (which is the Content-Type from Chargify)
@afreeland
afreeland / Regex: Extract text from parenthesis
Created November 8, 2018 17:48
Extract text from parenthesis
\(([^)]+)\)
## regexr.com/42om5
@afreeland
afreeland / gist:7d85e483eb1795bb47af42f8a1115a4d
Last active March 13, 2019 09:44
Ingress TLS bare-metal Kubernetes
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/proxy-connect-timeout: "21600000"
nginx.ingress.kubernetes.io/proxy-read-timeout: "21600000"
nginx.ingress.kubernetes.io/proxy-send-timeout: "21600000"
nginx.ingress.kubernetes.io/rewrite-target: /
name: ds-ingress
namespace: default
@afreeland
afreeland / gist:ee525ba62bba605ad39088e667c13218
Created October 5, 2018 13:06
Ingress TLS secret Kubernetes bare-metal
apiVersion: v1
kind: Secret
metadata:
name: our-tls
namespace: default
type: kubernetes.io/tls
data:
tls.crt: abcde
tls.key: 12345
@afreeland
afreeland / recentQuery.js
Created May 1, 2018 20:02
React: Proper declaring enum type
import React, { Component } from 'react';
import { render } from 'react-dom';
const gql = require('graphql-tag');
import { graphql } from 'react-apollo';
import appRoot from 'app-root-path';
import store from '../../store.js';
const Recent_Query = gql(`
query recent_query($username: String! $type: recentTypess! ){
recent (username: $username type: $type){
import React, { Component } from 'react';
import { render } from 'react-dom';
const gql = require('graphql-tag');
import { graphql } from 'react-apollo';
import appRoot from 'app-root-path';
import store from '../../store.js';
const Recent_Query = gql(`
query recent_query($username: String! $type: String! ){
recent (username: $username type: $type){