Skip to content

Instantly share code, notes, and snippets.

@marcelog
marcelog / lambda-website-checker.js
Created October 22, 2016 12:10
This AWS Lambda can be used to check your website for availability
'use strict';
var url = require('url');
var target = 'http://www.yourwebsite.com'; // Change this one
exports.handler = function(event, context, callback) {
var urlObject = url.parse(target);
var mod = require(
urlObject.protocol.substring(0, urlObject.protocol.length - 1)
);
@Dev-Dipesh
Dev-Dipesh / ELK with Nginx.md
Last active January 24, 2024 14:34
Setting up Elasticsearch, Logstash and Kibana with Nginx.

ELK (Elasticsearch Logstash Kibana)

Though we're focused more on server setup procedure in this document, I will still give a very brief explanation in laymen terms for ELK. To those who are starting new in this stack, must have already heard of MVC (Model View Controller), so take it like this:

  • Model => Elasticsearch (for Storage, Indexing & Search)
  • View => Kibana (for DataViz & G-Man, yeah the one in half life 😏)
  • Controller => Logstash (For Logs & Filtering)

@torgeir
torgeir / aws-stream-logs-from-cloudwatch-lambda-es--lambda-code.js
Created August 4, 2016 12:18
AWS stream logs from "cloudwatch -> lambda -> es" node.js lambda-code
// v1.1.2
var https = require('https');
var zlib = require('zlib');
var crypto = require('crypto');
var endpoint = '<aws es endpoint>';
exports.handler = function(input, context) {
// decode input from base64
var zippedInput = new Buffer(input.awslogs.data, 'base64');
@johngidt
johngidt / encdec.py
Created June 13, 2016 21:25 — forked from jforr/encdec.py
2 way encryption decryption based on pycrypto
# Inspired and adopted from https://gist.github.com/sekondus/4322469
# COMES WITH ABOSLUTELY NO WARRANTY OF ANY KIND.
# TOTAL FREEWARE, NO CLAIMS MADE OF ANY SORT.
# SELL IT, BURN IT, PRETEND ITS YOUR OWN.
# RELEASED UNDER NOBODY CARES LICENSE.
import os
import base64
from Crypto.Cipher import AES
@jforr
jforr / encdec.py
Created April 11, 2016 18:20 — forked from mohsinhijazee/encdec.py
2 way encryption decryption based on pycrypto
# Inspired and adopted from https://gist.github.com/sekondus/4322469
# COMES WITH ABOSLUTELY NO WARRANTY OF ANY KIND.
# TOTAL FREEWARE, NO CLAIMS MADE OF ANY SORT.
# SELL IT, BURN IT, PRETEND ITS YOUR OWN.
# RELEASED UNDER NOBODY CARES LICENSE.
import os
import base64
from Crypto.Cipher import AES
@naiquevin
naiquevin / ansible-vault-diff
Last active April 26, 2016 14:01
Decrypted git diff for encrypted ansible vault files
#!/usr/bin/env bash
set -e
usage()
{
cat << EOF
usage: $(basename $0) [ -c COMMIT -v VAULT_PASSWORD_FILE ] -f FILE
To view the actual changes in ansible vault/secret files for a git commit.
@varunmehta
varunmehta / reindex.sh
Last active March 28, 2019 14:06
Reindex elasticsearch to reduce shards from 5 to 1. Some manual work is needed before running the script.
#!/bin/bash
# Help menu for the script.
usage () {
echo "Usage: `basename $0` [-h] [-b] [-d] [-r] [-i] [-s] [http://es-ESname:9200]"
echo ""
echo "where: "
echo " -h Show this help text "
echo " -b Backup the elasticsearch indices to .json files "
echo " -d Delete the indices backed up"
@burdandrei
burdandrei / nameservers.rb
Created January 25, 2016 17:16
Ohai dns(nameserves) Plugin
require 'json'
Ohai.plugin(:Nameservers) do
provides "network/nameservers"
depends "network"
collect_data do
Ohai::Log.debug('Parsing resolv.conf for nameservers.')
nameservers = []
@mlapida
mlapida / CloudWatchLogsKinesisFirehose-Lambda.py
Last active October 3, 2019 01:01
A short Lambda Function the can be sent CloudWatch Logs (in the case Flow Logs) and send them to Kinesis Firehose for storage in S3. A full writeup can be found on my site http://mlapida.com/thoughts/exporting-cloudwatch-logs-to-s3-lambda
import boto3
import logging
import json
import gzip
from StringIO import StringIO
logger = logging.getLogger()
logger.setLevel(logging.INFO)
client = boto3.client('firehose')
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#