Skip to content

Instantly share code, notes, and snippets.

View prenagha's full-sized avatar

Padraic Renaghan prenagha

View GitHub Profile
@kalpeshsingh
kalpeshsingh / pre-push
Last active April 26, 2024 04:31
A pre-push git hook that notify Amazon Chime group
#!/bin/sh
branch="$(git rev-parse --abbrev-ref HEAD)"
# get computer name to append in Chime message
username=$USER
# a branch name where you want to prevent git push. In this case, it's "master"
if [ "$branch" = "master" ]; then
echo "You can't commit directly to '"${branch}"' branch" # webstorm or intellij will show this as popup
@paulgalow
paulgalow / awscreds-lpass.sh
Last active August 17, 2020 19:02
Get AWS CLI IAM credentials from LastPass CLI. Blog post: https://paulgalow.com/securing-aws-credentials-macos-lastpass
#!/bin/bash
# Get AWS CLI IAM credentials from LastPass CLI
# Blog post: https://paulgalow.com/securing-aws-credentials-macos-lastpass
# ##############################################################################
# Please adjust those properties
readonly lastPassEntry="REPLACE-ME" # Name of LastPass entry that stores your IAM credentials
readonly lpass="/usr/local/bin/lpass" # Path to LastPass CLI
# ##############################################################################
@simonbs
simonbs / Import Contacts from Slack.js
Created October 26, 2018 22:56
Scriptable script that imports contacts from Slack. Existing contacts will also have their avatar and social profiles updated. The contacts must have their phone number set in Slack.
// In order to use the script,
// you must create a Slack bot
// with the user:read scope and
// generate an accesss token.
// The script will prompt you
// to copy the access token in.
// The token is stored securely
// in the keychain.
let containers = await ContactsContainer.all()
let contacts = await Contact.all(containers)
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: pink; icon-glyph: user;
// lookup gravatar for contacts without images.
var MD5 = function (string) {
function RotateLeft(lValue, iShiftBits) {
return (lValue<<iShiftBits) | (lValue>>>(32-iShiftBits));
}
@QuinnyPig
QuinnyPig / buildspec.yml
Last active October 16, 2018 04:43
The buildspec.yml that deploys Last Week in AWS.
version: 0.2
phases:
install:
commands:
- echo Entered the install phase...
- pip install -r requirements.txt
build:
commands:
- echo Entered the build phase...
@bootrino
bootrino / gist:7ae38d38dabf0a4be109374247178e90
Last active August 22, 2018 08:10
Python 3.6 AWS Lambda function to create a hosts file from running EC2 instances and put it in a bucket
import boto3
import json
import jmespath
s3 = boto3.resource('s3')
ec2 = boto3.resource('ec2')
# creates a hosts file for all running ec2 instances
# you can add alias hostnames by adding a tag "hostname" to the EC2 instance
@skwashd
skwashd / README.md
Last active April 2, 2024 15:59
Copy AWS SSM Parameter Store Path

This Python (3.6+) script is for migrating Amazon AWS System Manager (SSM) Parameter Store keys from one path to another.

Quick Start

To install the script do the following:

  • Configure your AWS credentials
  • Grab the code from this gist
  • Make it executable (chmod +x /path/to/copy-ssm-ps-path.py)
  • pip install boto3 (if you don't have it installed already)
@incyclum
incyclum / AWS IAM Policy - ForceMFA.json
Last active April 2, 2020 20:02
AWS IAM Policy - Force MFA - This policy allows users to manage their own passwords and MFA devices but nothing else unless they authenticate with MFA -- *EDIT*: I forgot where I found it in the 1st place. In fact this policy is explained statement by statement in AWS docs: https://docs.aws.amazon.com/IAM/latest/UserGuide/tutorial_users-self-man…
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowAllUsersToListAccounts",
"Effect": "Allow",
"Action": [
"iam:ListAccountAliases",
"iam:ListUsers",
"iam:GetAccountPasswordPolicy",
@a7ul
a7ul / jamf.md
Last active March 29, 2024 09:47
removing all restrictions on jamf managed macos device - Provided you have root access.

REMOVE JAMF RESTRICTIONS ON MAC

REMOVE ONLY RESTRICTIONS

sudo jamf removeMDMProfile removes all restrictions

sudo jamf manage brings back all restrictions and profiles

REMOVE ALL RESTRICTIONS AND DISABLE JAMF BINARIES WHILE KEEPING YOUR ACCESS TO VPN AND OTHER SERVICES

sudo jamf removeMDMProfile removes all restrictions

@pierreozoux
pierreozoux / stale_security_groups.py
Last active September 30, 2021 01:31 — forked from astrikos/stale_security_groups.py
Script to detect stale AWS security groups
#!/usr/bin/env python3
import boto3
import argparse
class StaleSGDetector(object):
"""
Class to hold the logic for detecting AWS security groups that are stale.
"""
def __init__(self):
super(StaleSGDetector, self).__init__()