Skip to content

Instantly share code, notes, and snippets.

Jason Martin jhmartin

Block or report user

Report or block jhmartin

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:9e0f6670c1dde344a972e7f9c52309af
𝑸: How can I sort an inner array of an object? How can I sort all the arrays in a JSON entity? How can I modify a deeply nested array?
A: If the path to the inner entity is known, one can use |= as illustrated here:
{"array": [3,1,2] }
| .array |= sort
To sort all arrays in a JSON entity, no matter where they occur, one option is to use walk/1:
walk( if type == "array" then sort else . end )
jhmartin / gist:481c713435985aa473f595cf1db40e09
Last active Aug 7, 2019
Generate Cloudformation command from stack
View gist:481c713435985aa473f595cf1db40e09
aws cloudformation describe-stacks --stack-name STACKNAMEHERE --output=text|grep -i PARAMETERS | awk '{print "ParameterKey=" $2 ",ParameterValue=" $3 " \\"}'
jhmartin / createpoints.rb
Last active Aug 19, 2018
DNS LB Test compose
View createpoints.rb
#!/usr/bin/env ruby
# Input is an ip address. Map it to a position in a list.
linecount=0"\n").each do |a|
if (! indexes.has_key?(a))
jhmartin /
Created Jul 18, 2018
Davinci Resolve Close-Captions SRT to Youtube SRT converter
#!/usr/bin/perl -w
use strict;
while (<STDIN>) {
if (/^\s*$/) {
if (/^\d+$/) {
View gist:c2b3447f9ddbf7c972e5afd3d4853340
input {
lumberjack {
port => 5043
type => "squid"
ssl_certificate => "/home/ec2-user/logstash-forwarder/logstash-forwarder.crt"
ssl_key => "/home/ec2-user/logstash-forwarder/logstash-forwarder.key"
udp {
jhmartin / gist:d3f72246881a07c3d7efe0e14e8fd3c0
Last active Jul 5, 2018
Pull recent CW stats for pasting
View gist:d3f72246881a07c3d7efe0e14e8fd3c0
# Fetch 2-3 minutes in the past as current data isnt there yet
NOWDATE=$(date -v-2M -u +"%Y-%m-%dT%H:%M:%SZ")
LASTDATE=$(date -v-3M -u +"%Y-%m-%dT%H:%M:%SZ")
#-start-time 2014-04-08T23:18:00Z --end-time 2014-04-09T23:18:00Z --period 3600 --namespace AWS/EC2 --statistics Maximum --dimensions Name=InstanceId,Value=i-abcdef
export AWS_PROFILE=jmtdlcw
UTILSLATENCY=$(aws cloudwatch get-metric-statistics --start-time $LASTDATE --end-time $NOWDATE --metric-name Latency --period 60 --namespace AWS/ELB --statistic Average --dimensions Name=LoadBalancerName,Value=abc-prod-utilsapi|jq .Datapoints[0].Average)
jhmartin / nod10.xml
Created Nov 20, 2017
Zooz ZSE40 Openhab XML
View nod10.xml
#!/bin/bash -e
# Setup a Root CA in vault
# Generate and sign an Intermediate cert
# Requires:
# * A running vault server already initialzed and unsealed
# * Environment variable VAULT_TOKEN is set
# * vault cli (
# * httpie (
jhmartin / gist:c669c902c59d2dc33741d42b4e20fbf7
Created Jan 23, 2017
How to use cross-account roles in AWS RUby SDK
View gist:c669c902c59d2dc33741d42b4e20fbf7
require 'aws-sdk'
role_credentials =
role_arn: "arn:aws:iam::123:role/cross-account-role",
role_session_name: ENV['USER'],
serial_number: "arn:aws:iam::123:mfa/usernamehere",
token_code: ARGV[0]
View gist:945066c5d17ba504b1814bb312198384
Description=Var Lib Expansion Mount
RequiredBy =
You can’t perform that action at this time.