Skip to content

Instantly share code, notes, and snippets.

DaisukeMiyamoto /
Created Sep 12, 2018
AWS Boto3 Assume Role example
import boto3
from boto3.session import Session
def assume_role(arn, session_name):
"""aws sts assume-role --role-arn arn:aws:iam::00000000000000:role/example-role --role-session-name example-role"""
client = boto3.client('sts')
account_id = client.get_caller_identity()["Account"]
lukeplausin /
Last active Jul 27, 2021
AWS, JQ and bash command cheat sheet. How to query, cut and munge things in JSON generally.
# Count total EBS based storage in AWS
aws ec2 describe-volumes | jq "[.Volumes[].Size] | add"
# Count total EBS storage with a tag filter
aws ec2 describe-volumes --filters "Name=tag:Name,Values=CloudEndure Volume qjenc" | jq "[.Volumes[].Size] | add"
# Describe instances concisely
aws ec2 describe-instances | jq '[.Reservations | .[] | .Instances | .[] | {InstanceId: .InstanceId, State: .State, SubnetId: .SubnetId, VpcId: .VpcId, Name: (.Tags[]|select(.Key=="Name")|.Value)}]'
# Wait until $instance_id is running and then immediately stop it again
aws ec2 wait instance-running --instance-id $instance_id && aws ec2 stop-instances --instance-id $instance_id
# Get 10th instance in the account
fffaraz / dns.c
Created May 29, 2016
DNS Query Code in C with linux sockets
View dns.c
//DNS Query Program on Linux
//Author : Silver Moon (
//Dated : 29/4/2009
//Header Files
#include<stdio.h> //printf
#include<string.h> //strlen
#include<stdlib.h> //malloc
#include<sys/socket.h> //you know what this is for
#include<arpa/inet.h> //inet_addr , inet_ntoa , ntohs etc
pgporada /
Last active Feb 15, 2021
Upgrade Kernel on Centos7 via ELRepo
Install the ELRepo and GPG key
rpm --import
yum install -y
Enable kernel updates from elrepo
yum-config-manager --enable elrepo-kernel
untergeek / ls-es-template-20150831.json
Created Aug 31, 2015
Logstash -> Elasticsearch Template 2015-08-31
View ls-es-template-20150831.json
"template" : "logstash-*",
"settings" : {
"index.refresh_interval" : "5s"
"mappings" : {
"_default_" : {
"_all" : {"enabled" : true, "omit_norms" : true},
"dynamic_templates" : [ {
"message_field" : {
human39 / gist:8b80d51a75c99e64eb42
Last active Oct 17, 2019
Logstash split field solution.
View gist:8b80d51a75c99e64eb42
Problem: We have a log line that includes a perl class that we want to log the class
and method in their respected fields. An example class and method in perl:
In this example, "bark" is the method. "Animal::Dog" is the class.
After some searching and hacking, I found a solution that works with Logstash 1.4.2
Assume the input is "Animal::Dog::bark".
DavidWittman /
Created Sep 11, 2014
Issues a reset of the SuperMicro BMC via the web interface
#!/usr/bin/env bash
# Issues a reset of the SuperMicro BMC via the web interface
# usage: <ipmi-host>
# e.g.:
set -x
curl -XDELETE 'localhost:9200/test'
curl -XPUT 'localhost:9200/test/doc/1' -d '
"sentence" : "Hi!",
"value" : 1