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
@jhmartin
jhmartin / gist:0e30486bded97d11dbe1aad729cbcce7
Created May 25, 2020
DigitalOcean monitoring installation w/chef
View gist:0e30486bded97d11dbe1aad729cbcce7
# Digital Ocean monitoring tool
yum_repository 'digitalocean-agent' do
description 'DigitalOcean Agent'
baseurl 'https://repos.insights.digitalocean.com/yum/do-agent/$basearch'
repo_gpgcheck false
enabled true
gpgkey 'https://repos.insights.digitalocean.com/sonar-agent.asc'
sslverify true
sslcacert '/etc/pki/tls/certs/ca-bundle.crt'
@jhmartin
jhmartin / gist:6db5b8b41d8ebc9de5e92479a76c4186
Created May 20, 2020
Cloud Custodian Date and Expiration Format
View gist:6db5b8b41d8ebc9de5e92479a76c4186
Cloud Custodian uses dateutil.parser to read dates, so date fields can be anything handled by this.
View gist:be44fb59133b145c147e7ee59bcf279e
Kernel warning that appears to be related to Trend Micro / Deep Security Agent (dsa_agent). Correlates to a mass failure of Amazon Linux 2 ECS tasks.
Linux xxx 4.14.173-137.229.amzn2.x86_64 #1 SMP Wed Apr 1 18:06:08 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
[ 641.849894] ------------[ cut here ]------------
[ 641.852726] WARNING: CPU: 10 PID: 5454 at lib/vsprintf.c:2119 vsnprintf+0x2c1/0x4d0
[ 641.857834] Modules linked in: veth xt_REDIRECT nf_nat_redirect xt_nat xt_tcpudp xfs bmhook(OE) tmhook(OE) dsa_filter(POE) dsa_filter_hook(OE) ipt_MASQUERADE nf_nat_masquerade_ipv4 nf_conntrack_netlink nfnetlink xfrm_user xfrm_algo iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 xt_addrtype iptable_filter xt_conntrack nf_nat nf_conntrack libcrc32c br_netfilter bridge stp llc overlay crc32_pclmul ghash_clmulni_intel pcbc aesni_intel aes_x86_64 crypto_simd mousedev evdev glue_helper psmouse cryptd button sunrpc binfmt_misc ena ip_tables x_tables ext4 crc16 mbcache jbd2 fscrypto nvme crc32c_intel nvme_core ipv6
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
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
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.
positioncount=0
linecount=0
indexes=Hash.new
STDIN.read.split("\n").each do |a|
a=a.chomp
if (! indexes.has_key?(a))
@jhmartin
jhmartin / davincisrt.pl
Created Jul 18, 2018
Davinci Resolve Close-Captions SRT to Youtube SRT converter
View davincisrt.pl
#!/usr/bin/perl -w
use strict;
while (<STDIN>) {
chomp;
if (/^\s*$/) {
next;
}
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
jhmartin / gist:d3f72246881a07c3d7efe0e14e8fd3c0
Last active Jul 5, 2018
Pull recent CW stats for pasting
View gist:d3f72246881a07c3d7efe0e14e8fd3c0
#!/bin/sh
# 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")
date
#-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
jhmartin / nod10.xml
Created Nov 20, 2017
Zooz ZSE40 Openhab XML
View nod10.xml
<node>
<deviceClass>
<basicDeviceClass>ROUTING_SLAVE</basicDeviceClass>
<genericDeviceClass>SENSOR_NOTIFICATION</genericDeviceClass>
<specificDeviceClass>NOTIFICATION_SENSOR</specificDeviceClass>
</deviceClass>
<homeId>0xd91cc41a</homeId>
<nodeId>10</nodeId>
<version>4</version>
<manufacturer>0x27a</manufacturer>
You can’t perform that action at this time.