Skip to content

Instantly share code, notes, and snippets.

curl -XDELETE 'localhost:9200/test'
curl -XPUT 'localhost:9200/test/doc/1' -d '
{
"sentence" : "Hi!",
"value" : 1
}
'
@DavidWittman
DavidWittman / supermicro-bmc-reset.sh
Created September 11, 2014 22:24
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: supermicro-bmc-reset.sh <ipmi-host>
# e.g.: supermicro-bmc-reset.sh 10.0.0.1
#
set -x
@human39
human39 / gist:8b80d51a75c99e64eb42
Last active October 17, 2019 14:26
Logstash split field solution.
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:
Animal::Dog::bark
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".
@untergeek
untergeek / ls-es-template-20150831.json
Created August 31, 2015 18:20
Logstash -> Elasticsearch Template 2015-08-31
{
"template" : "logstash-*",
"settings" : {
"index.refresh_interval" : "5s"
},
"mappings" : {
"_default_" : {
"_all" : {"enabled" : true, "omit_norms" : true},
"dynamic_templates" : [ {
"message_field" : {
@pgporada
pgporada / centos7_kernel_update.md
Last active December 18, 2021 11:11
Upgrade Kernel on Centos7 via ELRepo
Install the ELRepo and GPG key
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
yum install -y http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
Enable kernel updates from elrepo
yum-config-manager --enable elrepo-kernel
@fffaraz
fffaraz / dns.c
Created May 29, 2016 05:58
DNS Query Code in C with linux sockets
//DNS Query Program on Linux
//Author : Silver Moon (m00n.silv3r@gmail.com)
//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
@lukeplausin
lukeplausin / bash_aws_jq_cheatsheet.sh
Last active January 29, 2024 10:00
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
@DaisukeMiyamoto
DaisukeMiyamoto / assume_role.py
Created September 12, 2018 05:00
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"]
print(account_id)