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 ) |
View gist:481c713435985aa473f595cf1db40e09
aws cloudformation describe-stacks --stack-name STACKNAMEHERE --output=text|grep -i PARAMETERS | awk '{print "ParameterKey=" $2 ",ParameterValue=" $3 " \\"}' |
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)) |
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 { |
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) |
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> |
View vault_intermediate_ca_setup.sh
#!/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) |
View gist:c669c902c59d2dc33741d42b4e20fbf7
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] | |
) | |
View gist:945066c5d17ba504b1814bb312198384
[Unit] | |
Description=Var Lib Expansion Mount | |
[Mount] | |
What=/dev/disk/by-label/DOCKER | |
Where=/var/lib/docker | |
[Install] | |
RequiredBy = local-fs.target |
NewerOlder