Skip to content

Instantly share code, notes, and snippets.

View krishnan-mani's full-sized avatar
💭
lining up my magnum opus ;-)

Krishnan Mani krishnan-mani

💭
lining up my magnum opus ;-)
View GitHub Profile
@krishnan-mani
krishnan-mani / list_inactive_repos.rb
Created April 15, 2015 14:55
List inactive repositories for the organisation
require 'github_api'
require 'date'
puts 'You can obtain your access token from: https://github.com/settings/applications#personal-access-tokens'
puts 'Your Github.com access token:'
GITHUB_PERSONAL_ACCESS_TOKEN = gets.chomp
puts 'Your Github.com organisation:'
github_org = gets.chomp

#DevOps Tuesdays!

What?

  • Sign up to pair with Krishnan (and others) to work on real-world DevOps tasks one day of the week every week, and get going with specific knowledge, skills, and practice!

When?

  • Every Tuesday (or another day of the week in the event that holidays or vacation intervene). So there's always something happening every Tuesday, and some Tuesdays, you'll be knee-deep in it!

How?

  • We’ll pick people at random and let you know beforehand. No pre-requisites whatsoever!
require 'aws-sdk'
class MetricsWriter
def initialize(connection_info)
@client = Aws::DynamoDB::Client.new(connection_info)
ensure_tables
end
def ensure_tables
@krishnan-mani
krishnan-mani / gist:ee3c3e97b9ab3e685ac771818ec16f7e
Created November 8, 2016 12:00
elastic beanstalk deployment (from Jenkins)
#!/bin/bash -l
cd ${WORKSPACE}/api
virtualenv venv-api
source venv-api/bin/activate
pip install awsebcli
eb init -r ${AWS_REGION}
eb deploy
@krishnan-mani
krishnan-mani / gist:34df77be1277415edb8930f5a8f22352
Created August 2, 2017 11:47
S3-lifecycle-configuration-update
rules.append({
'NoncurrentVersionExpiration' : {
'NoncurrentDays' : XYZ
},
'Status' : 'Enabled',
'Prefix' : prefix})
@krishnan-mani
krishnan-mani / put_item_with_ttl.sh
Created January 29, 2018 02:14
Put an item in DynamoDB with a one day TTL
#!/usr/bin/env bash
set -euxo pipefail
TABLE_NAME="$1"
REGION="$2"
NOW_IN_MINUTES=$(date +%Y%m%dT%H%M%z)
EPOCH_TIME=$(date +%s)
ONE_DAY_LATER=$(($EPOCH_TIME+86400))
item={\"id\":{\"S\":\"$NOW_IN_MINUTES\"},\"expireAt\":{\"N\":\"$ONE_DAY_LATER\"},\"hostname\":{\"S\":\"$(hostname)\"}}
@krishnan-mani
krishnan-mani / describe-instances-then-stop-them.sh
Created February 22, 2018 10:45
Describe EC2 instances by filtering on tag values, then stop a list of instances by instance-id
$ aws ec2 describe-instances \
--filters "Name=tag:Name,Values=CodeDeployDemo" \
--query "Reservations[*].Instances[*].InstanceId" \
--output text
$ aws ec2 stop-instances --instance-ids i-abc17charsid01 i-def17charsid02 i-pqr17charsid-03