Skip to content

Instantly share code, notes, and snippets.

@bkruger99
bkruger99 / disable.sh
Created August 6, 2020 20:51
Disable bunch of #$!@ in Catalina
#!/bin/bash
# IMPORTANT: Don't forget to logout from your Apple ID in the settings before running it!
# IMPORTANT: You will need to run this script from Recovery. In fact, macOS Catalina brings read-only filesystem which prevent this script from working from the main OS.
# This script needs to be run from the volume you wish to use.
# E.g. run it like this: cd /Volumes/Macintosh\ HD && sh /Volumes/Macintosh\ HD/Users/sabri/Desktop/disable.sh
# WARNING: It might disable things that you may not like. Please double check the services in the TODISABLE vars.
# Get active services: launchctl list | grep -v "\-\t0"
# Find a service: grep -lR [service] /System/Library/Launch* /Library/Launch* ~/Library/LaunchAgents
@bkruger99
bkruger99 / gist:b5f80cc20e79aae19dcecc89942fab10
Last active March 4, 2021 23:31
ES7 Initial Bootstrap Script - use at your own risk - use tags and ec2 discovery. install boto3 somewhere, ensure you have the cluster name set in the config and ec2 discovery configured.
#!/usr/bin/env python
# It's up to the enduser to make a backup of their config incase things break. If you're bootstrapping, this should only run once.
# You'll also need to install boto3 somehow. This should be reasonable python version agnostic.
import boto3
import requests
import yaml
import json
# src and dst file
@bkruger99
bkruger99 / MultiRunXML
Created October 5, 2018 22:23 — forked from astraw38/MultiRunXML
Combine multiple pytest runs into one XML.
from _pytest.junitxml import LogXML, Junit
from io import open
import pytest
import sys
import time
class MultiRunXml(LogXML):
"""
This is a wrapper around Pytest's LogXML, which
@bkruger99
bkruger99 / gist:f810101853f2dfca64c5c753dde07824
Created September 4, 2018 19:49
Generate a user token for the new jenkins subsystem (works in 2.139+)
import jenkins.security.*
import jenkins.security.apitoken.*
def username = '<pre-existing user goes here>'
def token = '<what you want to name your token>'
User u = User.get(username)
ApiTokenProperty p = u.getProperty(ApiTokenProperty.class);
ApiTokenStore.TokenUuidAndPlainValue tokenUuidAndPlainValue = p.tokenStore.generateNewToken(token);
@bkruger99
bkruger99 / gist:aebd57ba9a130de2eb3025a78eb14dad
Created August 16, 2018 21:38
terraform aws assume role - quick and easy.
Version:
Terraform v0.11.8
+ provider.aws v1.28.0
+ provider.template v1.0.0
terraform:
AWS has same format for credentials and config. I simply symlink them, I have one file more or less.
@bkruger99
bkruger99 / gist:6bbaacf1e7fa49891d421d6a1a7ba9c9
Last active April 4, 2019 20:17
aws connection helper for python. Allows you to use a single call to get either a client or resource and also has sts support built in. If you use this, I'd appreciate feedback.
#!/usr/bin/env python
import boto3
import sys
"""
Generic AWS Helper call class to setup a boto3 Session. Now with assume role support.
Pass in 'type=' to do either 'client' or 'resource'
@bkruger99
bkruger99 / README.md
Created March 10, 2017 21:46 — forked from leonardofed/README.md
A curated list of AWS resources to prepare for the AWS Certifications


A curated list of AWS resources to prepare for the AWS Certifications

A curated list of awesome AWS resources you need to prepare for the all 5 AWS Certifications. This gist will include: open source repos, blogs & blogposts, ebooks, PDF, whitepapers, video courses, free lecture, slides, sample test and many other resources.

For more about AWS and AWS Certifications and updates to this Gist you should follow me @leonardofed


@bkruger99
bkruger99 / 0-STATE-RUN-SALT-API-GITHUB-HOOK-USE-CASE.md
Created February 28, 2017 19:52 — forked from Teino1978-Corp/0-STATE-RUN-SALT-API-GITHUB-HOOK-USE-CASE.md
State runner on salt-api POST from GitHub push hook

Validate and run a state when a valid GitHub hook call has been received from salt-api

Idea is that we can setup salt-api to receive hook call from GitHub, and configured run stat.sls only if the request HMAC signature matche is successful.

Unfortunately most documentation says to deactivate salt-api hooks authentication (i.e. webhook_disable_auth: True) which is not a good idea.

This Gist is about finding a way to declare which state to run based on data GitHub sends on push hook. But ONLY if the request is valid.

Skeleton defines desired logic, see reactor_github_push.py below.

@bkruger99
bkruger99 / README.rst
Created January 17, 2017 19:45 — forked from PatOShea/README.rst
SaltStack Bootstrap for AWS EC2
SaltStack Bootstrap Script for AWS EC2

This script will currently only work with Windows8, Windows 2012R2, Amazon Linux, RHEL6 and RHEL7.

@bkruger99
bkruger99 / role_arn_to_session.py
Created December 30, 2016 03:08 — forked from gene1wood/role_arn_to_session.py
Simple python function to assume an AWS IAM Role from a role ARN and return a boto3 session object
import boto3
def role_arn_to_session(**args):
"""
Usage :
session = role_arn_to_session(
RoleArn='arn:aws:iam::012345678901:role/example-role',
RoleSessionName='ExampleSessionName')
client = session.client('sqs')
"""