Skip to content

Instantly share code, notes, and snippets.

View chrisswanda's full-sized avatar

Chris Swanda chrisswanda

View GitHub Profile
-----BEGIN PGP PUBLIC KEY BLOCK-----
mDMEZIc0chYJKwYBBAHaRw8BAQdAqFTi3sOPOWgleWpVrP1nZqkTkpOARaAAnTzI
kfAB0960JUNocmlzIFN3YW5kYSA8Y2hyaXMuc3dhbmRhQGdtYWlsLmNvbT6IlQQT
FgoAPRYhBDpRICammgJ8BaGr4dbHHO+nqtYwBQJkhzRyAhsBBQkDwmcABAsJCgQF
FQoJCAMFFgIDAQACHgECF4AACgkQ1scc76eq1jBKDQD/SB0jjX6m03dcX7MN6H92
knv7biiLaCrX5L+hvwDxNZcBAJIct9GOioiNmN6DP4aTW/kE9jRT0y3Xrliz2ekY
xcsCuDMEZIc1FxYJKwYBBAHaRw8BAQdA2UAhdHk4t3RKP/Frba6wTVO1R5u0ME9/
wUR3XP1JrI+IfgQYFgoAJhYhBDpRICammgJ8BaGr4dbHHO+nqtYwBQJkhzUXAhsg
BQkDwmcAAAoJENbHHO+nqtYwhkcBAMb1psMqXDyJ7bBe1zg0LvtV6d5yEY9Um2I6
@chrisswanda
chrisswanda / AWS Datasync.md
Last active March 6, 2023 13:51
AWS Datasync between two S3 buckets across two different AWS accounts

What is it?

DataSync fully automates the data transfer. It comes with retry and network resiliency mechanisms, network optimizations, built-in task scheduling, monitoring via the DataSync API and Console, and CloudWatch metrics, events and logs that provide granular visibility into the transfer process. DataSync performs data integrity verification both during the transfer and at the end of the transfer.

DataSync provides end-to-end security, and integrates directly with AWS storage services. All data transferred between the source and destination is encrypted via TLS, and access to your AWS storage is enabled via built-in AWS security mechanisms such as IAM roles. DataSync with VPC endpoints are enabled to ensure that data transferred between an organization and AWS does not traverse the public internet, further increasing the security of data as it is copied over the network.

How to copy between two different AWS Accounts and S3 buckets

You will need to define a source account and bucket, and a dest

@chrisswanda
chrisswanda / age_functions.txt
Created October 4, 2022 14:16
Adding age functions in my bash_profile
I banged rocks together and came up with this. I was needing a quick way to do age encryption/decryption for various files.
Dropped this in my ~/.bash_profile.
age_encrypt()
{
pub_key=$(cat ~/.config/age/pubkey.pub.age)
if [ -f $1 ] ; then
case $1 in
*.age) echo "'$1' is not a valid file" && return 1 ;;
@chrisswanda
chrisswanda / Azure-webhook.yml
Created July 19, 2022 14:24
Cloud Custodian (c7n) to Azure Teams Incoming Webhook
# Unfortunately we use Teams and I needed a way to deliver a payload to an incoming webhook via Lambda for
# various c7n things.
#
# Below is just an example.
policies:
- name: call-Azure-webhook
resource: ec2
description: |
@chrisswanda
chrisswanda / age_encryption_scripts.md
Last active June 4, 2024 09:32
Age encryption scripts

I've slowly been converting various processes and encryption schemes over to age, versus using PGP to store encrypted data at rest and sending of encrypted payloads to other users/machines.

If you are not familiar with age, see the specs here -> https://github.com/C2SP/C2SP/blob/main/age.md

And the current project in GitHub -> https://github.com/FiloSottile/age

Man page - https://htmlpreview.github.io/?https://github.com/FiloSottile/age/blob/master/doc/age.1.html

Since version 1.0.0 is out and is considered release, hopefully we will start seeing some cool projects using age for encryption, and hopefully some mobile apps, slick UIs, etc... will soon follow.

@chrisswanda
chrisswanda / contact_info.py
Last active June 14, 2023 19:44
How you can contact me
import os
import sys
import numpy
import string
if sys.version > '3':
strl = str
else:
strl = string
@chrisswanda
chrisswanda / cook_perfect_rice.py
Last active July 4, 2021 10:00
Cook perfect rice in your instant pot
'''This stupid little script I use all the time to make perfect rice in my instant pot.
I also have a Siri Shortcut in the event that I'm near my HomePod, or other Apple devices.
https://www.icloud.com/shortcuts/c67d4960a15b42d6afb0cc58c649ff03 Just tell Siri, Cook Rice.
It makes the perfect white rice in your pressure cooker or instant pot.
How I use it, is to use a kitchen scale to weigh my inner pot (which is always 1102 grams,
but added in the formula in the event I find myself at someone else's house and need to make some perfect rice).
I then weigh my rice individually to get the weight. I then wash my rice in multiple changes of water until it runs clear.
{
"meta": {
"theme": "elegant"
},
"basics": {
"name": "Chris Swanda",
"label": "DevOps Dude",
"picture": "https://seccdn.libravatar.org/avatar/3af4117781e0d69367900432f45dbe41?size=128&default=mm",
"website": "https://olathewx.duckdns.org/about.html",
"email": "naphtha-decibel0t@icloud.com",
@chrisswanda
chrisswanda / crypto_price_mail.py
Last active March 20, 2021 13:48
Send daily emails of crypto prices from coinmarketpro.com.
from requests import Request, Session
from requests.exceptions import ConnectionError, Timeout, TooManyRedirects
import json
import smtplib
''' you will need an API from https://coinmarketcap.com/api/ '''
''' let's get Bitcoin prices '''
BTCurl = 'https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest'
@chrisswanda
chrisswanda / smtp_icloud.py
Last active January 24, 2024 08:53
Python script to send mail via Apple's iCloud. Be sure to setup an app specific password for and do not use or expose your iCloud password. https://support.apple.com/en-us/HT204397
import smtplib
#email.mime.multipart is specific to python3
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
msg = MIMEMultipart()
msg['From'] = 'sendfrom@mail.com'
msg['To'] = 'sendto@mail.com'
msg['Subject'] = 'Subject'