aws --profile dev ec2 describe-instances | jq '.Reservations[].Instances[] | select(.InstanceId == "i-0abcdefe412345678")'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Dog: | |
def __init__(self, name, age): | |
self.name = name | |
self.age = age | |
pass | |
def bark(self): | |
print("bark bark!") | |
def doginfo(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
filename = "/path/to/some_image.png" | |
image = cv2.imread(filename) | |
# Docs are here: https://docs.opencv.org/3.4/de/dc3/classcv_1_1QRCodeDetector.html | |
detector = cv2.QRCodeDetector() | |
data, vertices_array, binary_qrcode = detector.detectAndDecode(image) | |
if vertices_array is not None: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Run: | |
# aws backup list-recovery-points-by-backup-vault --backup-vault-name aft-controltower-backup-vault | jq --raw-output ".RecoveryPoints[].RecoveryPointArn" > /tmp/aft_recovery_point_arns.txt | |
# first to get the list of recovery points to delete. Then run this script with the filename as the argument | |
# e.g. | |
# aft_delete_recovery_points.sh /tmp/aft_recovery_point_arns.txt | |
while read -r line; do | |
echo "deleting recovery point: $line" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
curl \ | |
--header "Authorization: Bearer $TOKEN" \ | |
--header "Content-Type: application/vnd.api+json" \ | |
"https://app.terraform.io/api/v2/workspaces/$WORKSPACE_ID/vars" > temp_vars_file.json | |
cat temp_vars_file.json | jq -r '.data[].attributes | "\(.key)=\(.value)"' > myvars.tfvars | |
# Ensure we have quotes around values |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Add git branch name to end of the shell prompt | |
source /etc/bash_completion.d/git-prompt | |
# Git bit is just '\[\033[02;03;31m\]$(__git_ps1 " (%s)")\[\033[00m\]' and explained below | |
# [033 - Set the terminal colours and formatting | |
# [02;03; - light font (not bold) | |
# 03; - italic | |
# 31m - red colour |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
# Setup our files | |
mkdir hashtest | |
echo hello > hashtest/file1.txt | |
echo foo > hashtest/file2.txt | |
echo bar > hashtest/file3.txt | |
mkdir hashtest/subdir | |
echo baz > hashtest/subdir/file4.txt | |
echo hello > hashtest/subdir/file5.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# NOTE: Requires the python3-apt package | |
import apt | |
import apt_pkg | |
import json | |
need_upgrade = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
aws --profile dev \ | |
ec2 describe-instances \ | |
--query 'Reservations[].Instances[].[InstanceId,Tags[?Key==`Name`].Value[],NetworkInterfaces[].Association.{IP:PublicIp}]' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express') | |
const app = express() | |
const port = 3000 | |
const NAME = process.env.NAME || "World" | |
app.get('/', (req, res) => { | |
res.send('Hello ' + NAME + '!') | |
}) | |
app.listen(port, () => { |
NewerOlder