Skip to content

Instantly share code, notes, and snippets.

View kapilt's full-sized avatar
🌩️
🌩 📦 🔭 📻 🚀 🛰

Kapil Thangavelu kapilt

🌩️
🌩 📦 🔭 📻 🚀 🛰
View GitHub Profile
@kapilt
kapilt / developer-diff-notes.md
Last active December 6, 2016 19:15
exploring diffs

Three python diff libraries were evaluated for comparing resource revisions.

  • jsonpatch
  • dictdiffer
  • DeepDiff

Additional a consideration of rolling our own thats specific to custodian's needs.

jsonpatch

policies:
- name: aws-cloudtrail-not-enabled
resource: account
region: us-east-1
tags:
- level:high
description: |
Policy scans for accounts which do not have CloudTrails enabled in the current region
filters:
- type: check-cloudtrail
policies:
- name: all-lambdas
resource: lambda
- name: custodian-lambdas
resource: lambda
filters:
- type: value
key: FunctionName
value: "^custodian*"
policies:
- name: ec2-resizer
resource: ec2
filters:
- type: value
key: InstanceType
op: in
value:
- m4.10xlarge
- m4.4xlarge
from common import BaseTest
class UnitTest(BaseTest):
def test_ingress_remove(self):
# replay a recorded session
factory = self.replay_flight_data(
'test_security_group_ingress_filter')
# record a new session
#factory = self.record_flight_data(
- name: sg-fast-revert
resource: security-group
filters:
- GroupId: "sg-220123a1"
- type: diff
selector: date
selector_value: "2016/12/14 13:05Z"
actions:
- patch
- <<: *notify_action
@kapilt
kapilt / ppymemleak.py
Last active March 29, 2017 15:55
demonstrate memory leak issue with pypy and s3/boto using threads.
"""Pypy memory leak issue
this needs to process some large buckets to show the continual memory
accumulation. growth after 100 pages processed shows increase from 240mb rss
to 1221 mb rss.
interestingly playing around with chunk size shows dramatic effects on memory
growth rate.
"""
(require 'package) ;; You might already have this line
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/"))
(package-initialize) ;;
(global-font-lock-mode t)
(setq inhibit-startup-mesage t)
(setq make-backup-files nil)
(add-hook 'after-init-hook #'global-flycheck-mode)
@kapilt
kapilt / main.py
Created September 4, 2017 11:46
ratelimiter example
import boto3
import time
from botocore.session import Session as CoreSession
from botocore.hooks import HierarchicalEmitter
import traceback
import token_bucket
@kapilt
kapilt / test
Created January 16, 2018 12:19
test