Skip to content

Instantly share code, notes, and snippets.

View jsamuel1's full-sized avatar

Josh Samuel jsamuel1

  • Melbourne, Australia
View GitHub Profile
@jsamuel1
jsamuel1 / gist:26a5d1d1dac1343cc794288c9f04162a
Created February 22, 2024 09:50
CDK Create role for EKS Pod Identities
const podIdentityRole = new Role(this, 'PodIdentityRole',
{
assumedBy: new SessionTagsPrincipal(new ServicePrincipal('pods.eks.amazonaws.com')),
managedPolicies: [
ManagedPolicy.fromAwsManagedPolicyName('AmazonEC2ContainerRegistryReadOnly'),
]
});
curl -s https://gist.githubusercontent.com/wongcyrus/a4e726b961260395efa7811cab0b4516/raw/6a045f51acb2338bb2149024a28621db2abfcaab/resize.sh | bash /dev/stdin 60
@jsamuel1
jsamuel1 / private_fork.md
Created November 5, 2022 05:40 — forked from 0xjac/private_fork.md
Create a private fork of a public repository

The repository for the assignment is public and Github does not allow the creation of private forks for public repositories.

The correct way of creating a private frok by duplicating the repo is documented here.

For this assignment the commands are:

  1. Create a bare clone of the repository. (This is temporary and will be removed so just do it wherever.)

git clone --bare git@github.com:usi-systems/easytrace.git

@jsamuel1
jsamuel1 / nuke_ec2_fsx.py
Last active March 5, 2021 04:58
For that time that someone leaves unused EC2 and FSx running in a bunch of sub-accounts in an AWS Organization. Supply the list of subaccounts to assume-role into.
#!/usr/bin/env python
from __future__ import print_function
import boto3
import botocore
import time
import sys
import argparse
import pandas
@jsamuel1
jsamuel1 / move_account_ou
Created March 1, 2021 05:14
Move accounts in an AWS Organization from one OU to a new OU - change variable in script then run from cloudshell
#!/usr/bin/env python
from __future__ import print_function
import boto3
import botocore
import time
import sys
import argparse
def move_account_ou(
@jsamuel1
jsamuel1 / sudokeepalive.sh
Created January 27, 2021 23:25
sudo Keep-alive for scripts: update existing `sudo` time stamp until script has finished
# Keep-alive: update existing `sudo` time stamp until script has finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
@jsamuel1
jsamuel1 / install_neovim_to_amazonlinux.sh
Created September 1, 2020 05:19 — forked from kawaz/install_neovim_to_amazonlinux.sh
install neovim to amazonlinux
#!/usr/bin/env bash
sudo yum groups install -y Development\ tools
sudo yum install -y cmake
sudo yum install -y python34-{devel,pip}
sudo pip-3.4 install neovim --upgrade
(
cd "$(mktemp -d)"
git clone https://github.com/neovim/neovim.git
cd neovim
make CMAKE_BUILD_TYPE=Release
@jsamuel1
jsamuel1 / aws-athena-auto-partition-lambda.py
Last active June 9, 2020 04:24 — forked from SQLadmin/aws-athena-auto-partition-lambda.py
AWS Athena create auto partition for CloudTrail logs on Daily Basis
# Lambda function to create partition for Cloudtrail log on daily basis.
# You need to schedule it in AWS Lambda.
'''
-------------------------------------------
AWS Athena Create Partitions Automatically
-------------------------------------------
Version 1.0
Author: SqlAdmin
@jsamuel1
jsamuel1 / generate-tesla-token.md
Last active March 11, 2020 03:31
Generate Tesla API Token

Generate a tesla token

Runs locally, no installation. enter email/password on commandline. then copy/paste the generated token.

npx generate-tesla-token

Output

Hi! I'm going to generate a Tesla-login ‘token’ for you, which will allow
@jsamuel1
jsamuel1 / slash.sh
Created August 1, 2019 01:54 — forked from luciomartinez/slash.sh
Add or Remove trailing slash in bash
### Add trailing slash if needed
STR="/i/am/a/path"
length=${#STR}
last_char=${STR:length-1:1}
[[ $last_char != "/" ]] && STR="$STR/"; :
echo "$STR" # => /i/am/a/path/