This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
𝑸: 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 ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aws cloudformation describe-stacks --stack-name STACKNAMEHERE --output=text|grep -i PARAMETERS | awk '{print "ParameterKey=" $2 ",ParameterValue=" $3 " \\"}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
use strict; | |
while (<STDIN>) { | |
chomp; | |
if (/^\s*$/) { | |
next; | |
} | |
if (/^\d+$/) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 (https://www.vaultproject.io) | |
# * httpie (https://github.com/jkbrzt/httpie) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'aws-sdk' | |
role_credentials = Aws::AssumeRoleCredentials.new( | |
client: Aws::STS::Client.new(), | |
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] | |
) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Var Lib Expansion Mount | |
[Mount] | |
What=/dev/disk/by-label/DOCKER | |
Where=/var/lib/docker | |
[Install] | |
RequiredBy = local-fs.target |