Skip to content

Instantly share code, notes, and snippets.

View jweyrich's full-sized avatar
:octocat:
Making some lives easier and happier!

Jardel Weyrich jweyrich

:octocat:
Making some lives easier and happier!
View GitHub Profile
@jweyrich
jweyrich / discovery.go
Last active August 28, 2019 22:36
Simple Service Discovery in Go
package discovery
import (
"errors"
"net"
"log"
)
//
// USAGE:
@jweyrich
jweyrich / aws_alb_log_parser.py
Last active June 11, 2024 14:39
AWS ALB Log Parser written in Python
#!/usr/bin/env python3
# coding=utf8
#
# AUTHOR: Jardel Weyrich <jweyrich at gmail dot com>
#
from __future__ import print_function
import re, sys
def parse_alb_log_file(file_path):
fields = [
@jweyrich
jweyrich / sample_dfs_height.cpp
Last active August 12, 2019 21:11
Sample I wrote to show someone how to find the height of an element in a binary tree using DFS
//
// AUTHOR: Jardel Weyrich <jweyrich dot gmail dot com>
//
#include <iostream>
#include <cstdlib>
template <class ValueT>
class NodeType {
public:
@jweyrich
jweyrich / backup_mongodb_to_s3.sh
Created August 7, 2018 17:40
Backup a MongoDB cluster and upload it to S3
#!/bin/bash
#
# DESCRIPTION:
# Make a gzipped backup from a MongoDB cluster >=3.2.0,
# preferrable from a slave, and upload it to the
# specified S3 bucket.
#
# REQUIREMENTS:
# sudo apt-get install -y awscli
# sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
@jweyrich
jweyrich / s3_delete_bucket.py
Created July 6, 2018 18:41
Easily delete an entire S3 bucket, including its markers.
import sys
if len(sys.argv) < 2:
print 'Missing parameter: BUCKET_NAME'
exit(1)
BUCKET_NAME = sys.argv[1]
ACCESS_KEY = 'CHANGE_ME'
SECRET_KEY = 'CHANGE_ME'
@jweyrich
jweyrich / tree_charset.py
Created November 21, 2017 13:01
Attempt to detect the charset of files recursively
#!/usr/bin/python
import chardet
import os
# traverse root directory, and list directories as dirs and files as files
for root, dirs, files in os.walk("."):
path = root.split('/')
for file in files:
print '%s/%s => %s (%s)' % (root, file, chardet.detect(file)['encoding'], chardet.detect(file)['confidence'])
@jweyrich
jweyrich / azure_sql_find_circular_ref_paths.sql
Created November 14, 2017 14:31
Azure SQL - Find circular reference paths
--
-- Script originally from https://azure.microsoft.com/en-gb/blog/finding-circular-foreign-key-references/
--
SET NOCOUNT ON
-- WWB: Create a Temp Table Of All Relationship To Improve Overall Performance
CREATE TABLE #TableRelationships (
FK_Schema nvarchar(max),
FK_Table nvarchar(max),
@jweyrich
jweyrich / exit_handlers.sh
Last active March 22, 2020 22:34
Bash script to send an email via SNS in case of error or success
#!/bin/bash
#
# AUTHOR: Jardel Weyrich <jweyrich dot gmail dot com>
#
# HOW TO USE IT?
#
# 1) Replace the SNS_TOPIC_ARN value with your SNS topic's ARN;
# 2) Customize the messages to be sent in each case;
# 3) Add the following 2 lines after the #! line in your script:
# WORKDIR=$(dirname "$0")
@jweyrich
jweyrich / libpe-demo.c
Last active October 21, 2017 20:45
Example of program using libpe - https://github.com/merces/libpe
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libpe/pe.h>
int main(int argc, char *argv[]) {
if (argc < 2) {
fprintf(stderr, "Usage: poc <filename>\n");
return EXIT_FAILURE;
@jweyrich
jweyrich / config.ovpn
Created July 19, 2017 01:25
Tunnelblick (OpenVPN client) configuration file sample
#
# Move the following 3 files to "~/Library/Application Support/Tunnelblick/Configurations/"
#
# 1. CA certificate (.crt)
# 2. Client certificate (.crt)
# 3. Client private key (.key)
#
##############################################
# Sample client-side OpenVPN 2.0 config file #
# for connecting to multi-client server. #