Skip to content

Instantly share code, notes, and snippets.

View jsamuel1's full-sized avatar

Josh Samuel jsamuel1

View GitHub Profile
@jsamuel1
jsamuel1 / clean_code.md
Created July 29, 2019 22:39 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@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/
@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 / 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 / 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 / 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 / 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 / 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 / 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 [email protected]:usi-systems/easytrace.git

curl -s https://gist.githubusercontent.com/wongcyrus/a4e726b961260395efa7811cab0b4516/raw/6a045f51acb2338bb2149024a28621db2abfcaab/resize.sh | bash /dev/stdin 60