Skip to content

Instantly share code, notes, and snippets.

View scottnixonjr's full-sized avatar

Scott Nixon scottnixonjr

View GitHub Profile

CLI Cheatsheet

Shell

echo quotes are only needed for special characters

quotes are only needed for special characters

' strong quote

Git Checkout in Jenkins

By default, the Jenkins checkout plugin wipes the directory before checkout. This configuration allows you to checkout to a seperate directory. SSH authentication to github.

checkout([
        $class: 'GitSCM', 
        branches: [[name: '*/master']],
        extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'any-directory-name']],
 userRemoteConfigs: [[credentialsId: env.SSH_CRED_ID, url: 'git@github.com:snixon/myrepo-is-awesome.git']]

debugging-python

New in version 3.7: The built-in breakpoint(), when called with defaults, can be used instead of import pdb; pdb.set_trace()

python -m pdb src/index.py

Python's pdb keyboard shortcuts.

Help h

Git Guide

I forgot to rebase and instead merged from the Trunk branch.

Create a patch of your Branch with all Trunk changes included, you can move those changes to a new branch. And you can rebase as needed to keep a clean commit history.

git diff Trunk Branch1 > ../patchfile
git checkout Branch2    
git apply ../patchfile
# Build container
docker build -t <image-name> .
# GET the WEB instance and access CLI.
docker ps | grep <container-name-id> | cut -c1-12 | read CON_ID; docker exec -it $CON_ID /bin/sh
docker ps | grep <container-name-id> | cut -c1-12 | read CON_ID; docker exec -it $CON_ID /bin/sh
# Run container
@scottnixonjr
scottnixonjr / project_specific_tags.json
Created April 16, 2020 18:13
Project Based Access for creating EC2 Instances. Policy for Solution 1 in Developer Sandboxes - https://github.com/stelligent/developer-sandboxes
{
"Version": "2012-10-17",
"Statement": [{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": "ec2:RunInstances",
"Resource": [
"arn:aws:ec2:*:*:instance/*"
],
"Condition": {
@scottnixonjr
scottnixonjr / username_based_policy.json
Created April 16, 2020 18:10
Individual Access Control based on Username for creating EC2 Instances. Policy for Solution 2 in Developer Sandboxes - https://github.com/stelligent/developer-sandboxes
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": "ec2:RunInstances",
"Resource": "arn:aws:ec2:*:*:instance/*",
"Condition": {
"StringEqualsIgnoreCase": {
@scottnixonjr
scottnixonjr / full_attribute_based_policy.json
Created April 16, 2020 17:38
Flexible Attribute based Access Control for creating EC2 Instances for Solution 3 in Developer Sandboxes - https://github.com/stelligent/developer-sandboxes
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": "ec2:RunInstances",
"Resource": "arn:aws:ec2:*:*:instance/*",
"Condition": {
"StringEqualsIgnoreCase": {
@scottnixonjr
scottnixonjr / flexible_policy_permission_boundary.json
Created April 16, 2020 17:27
Permission boundary for creating EC2 Instances for Solution 3 in Developer Sandboxes - https://github.com/stelligent/developer-sandboxes
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"cloudformation:ListExports",
"sts:DecodeAuthorizationMessage"
],
# Get all IAM actions for Tagging using policy_sentry database.
# Not perfect query because it will include actions that contain 'tAg' --> 'artifact:AcceptAgreement'
policy_sentry query action-table --service all | for i in $(cat); do policy_sentry query action-table --service $i; done | grep -i tag > all-aws-tag-actions.txt