Skip to content

Instantly share code, notes, and snippets.

View patrobinson's full-sized avatar

Patrick Robinson patrobinson

View GitHub Profile
➜ ops git:(main) ✗ irb
irb(main):001:0> m1 = Hash.new { |h1, k1| h1[k1] = Hash.new { |h2, k2| h2[k2] = 0 } }
=> {}
irb(main):002:0> m2 = {}
=> {}
irb(main):003:0> m1 == m2
=> true
irb(main):004:0> m1[1][2] = 3
=> 3
irb(main):005:0> m2[1][2] = 3
@patrobinson
patrobinson / index.ts
Created May 7, 2020 10:08
Replicate unable to lookup VPC in CDK
import * as core from "@aws-cdk/core";
import * as ec2 from "@aws-cdk/aws-ec2";
export class MyStack extends core.Stack {
constructor(scope: core.Construct, id: string, props: core.StackProps) {
super(scope, id, props);
console.log(ec2.Vpc.fromLookup(this, "Vpc1", { isDefault: true }).vpcId);
}
}
@patrobinson
patrobinson / index.js
Created April 8, 2020 23:03
Replicate JS SDK hanging
const aws = require ('aws-sdk');
async function test() {
const s3 = new aws.S3({
apiVersion: '2006-03-01',
signatureVersion: 'v4',
httpOptions: {
connectionTimeout: 1000,
timeout: 1000
},
@patrobinson
patrobinson / test_elasticache_failover.rb
Created February 5, 2019 00:16
Test how long an ElastiCache Redis Failover takes before the app reconnects
require 'redis'
$redis = Redis.new({url: ENV['REDIS_HOST']})
puts $redis.connected?
failed = false
starting = nil
ending = nil
loop do
$redis.ping
@patrobinson
patrobinson / enumaws.rb
Created January 24, 2019 04:32
Rough AWS inventory tool
require 'aws-sdk-configservice'
require 'json'
require 'net/http'
module Enumaws
def self.run
uri = URI('https://raw.githubusercontent.com/aws/aws-sdk-ruby/master/apis/config/2014-11-12/api-2.json')
res = Net::HTTP.get_response(uri)
config_api_schema = JSON.load(res.body)
resource_types = config_api_schema["shapes"]["ResourceType"]["enum"]
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCxDRdSFtK4vLZqijBKZN9SrX4wVIARLEU3QikT5Tn34e34M5PBoK3L7im5vdwv9hJUmD/lBicznNONkGEbrF0U/ILy6qOAEUV0kuRrAbq7uTIvNdHK9jiMH2GDsNttkQA+O0y/lQrCtmD7/gPiN0w72Mql/d17QQ15uGTqYDMdzX4usTnUxlIqGgh+nuvjLnK5aUmiI/I0adAw9WCMW4mPh3xffAtq6maI/kQ9cr6iKXQO4IgRAxRhl3atLDrlVzNqwg4IoIPmWxss825fP72Vzshkod5oBvej+h+tbjRrvMsgd628R/IaKkTR+HimPM/hTPrNR2zEXAp/2UhJ400SxTZQ9eRb4O6ZA8ySVogFDm2tIWR8y2bCCSZIg5ksG9eS1XuH/vnPkvilzGhHWUaBVrxTo2gD0vuL6qX/Ncd+XHIe2qUw68CcSKPScziuJ4VFy3ehJh5AnmmjGb7dW1cCqm8LFCrEJdcUgKHgb42NRSM97GbxnxbRwHHo4EqEbUyhAD/tYApidOOn6BNwhnwbnrGtbHpD1MjVpOgW9dmGhSyKM6PhXEBAMZh0ZUjqgMkDCSy88ob3vmmoiMcYJYjYe5cDR9mv9da83a8ckyG8rZ6RZ1kvACo/1XDgFZ4b0qhvIyfpExAFRd0yCjjLgwHyX2kiQtMZiwRKix+iPiCWHQ== cardno:000606705651
@patrobinson
patrobinson / .bashrc
Last active July 11, 2021 23:03
aws vault bash profile
function aws-code() {
ykman oath -s bastion-account
}
function aws-vault-exec() {
local role_name=$1
export AWS_ACCOUNT=$role_name
shift
local command=$@
local extra_args=""
/* eslint-env es6 */
'use strict';
var assert = require('assert');
let harness = (req, res, callback, next) => {
try {
assert.equal(typeof callback, 'function');
} catch (E) {
return callback(E);
}
try {
@patrobinson
patrobinson / update_ddb_from_stream.py
Created February 20, 2018 02:44
(SO0037) - Real Time Insights on AWS Account Activity
#!/usr/bin/python
# -*- coding: utf-8 -*-
##############################################################################
# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. #
# #
# Licensed under the Amazon Software License (the 'License'). You may not #
# use this file except in compliance with the License. A copy of the #
# License is located at #
# #
INIT='eval $(docker-machine env docker5)'
PARSE = 'echo parse_url("http://google.com#@example.com/", PHP_URL_HOST);'
READ = 'echo readfile("http://google.com#@example.com/");'
versions = []
14.upto 25 do |i|
versions << "7.0.#{i}"