Skip to content

Instantly share code, notes, and snippets.

View chrisswanda's full-sized avatar

Chris Swanda chrisswanda

View GitHub Profile
@chrisswanda
chrisswanda / generate_random_characters.sh
Last active October 10, 2019 23:31
Generate random numbers, strings and characters.
#!/bin/bash
read -p "How many characters? " numlen
#MacOS uses head, linux uses cat /dev/random
head /dev/urandom | LC_CTYPE=C tr -dc 'a-zA-Z0-9,;.:_#*+~!@$%&()=?{[]}|><-' | fold -w $numlen | head -n 1
@chrisswanda
chrisswanda / qrencodeDuoMobile.txt
Last active June 12, 2020 13:06
qrencode syntax for Duo Mobile
https://duo.com/product/multi-factor-authentication-mfa
https://fukuchi.org/works/qrencode/
qrencode -l L -v 1 -o test.png 'text_input'
Example - qrencode -l L -v 1 -o GoogleText.png 'otpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&issuer=Example'
For standard Google Authenticator or Authy QR codes, see this example:
@chrisswanda
chrisswanda / User specific host file wrapper
Last active August 18, 2020 12:52
Create a user specific host file
$HOSTALIASES no longer works with glibc (https://bugs.launchpad.net/debian/+source/glibc/+bug/1483187)
For my project, I needed to create a user specifc hosts file.
First clone this repo - https://github.com/figiel/hosts.git
################ README #####################################
hosts - wrapper for libc which provides defining host aliases in a per-user file
@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 / 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.
@chrisswanda
chrisswanda / Moving_gpg_keys.txt
Last active January 1, 2022 16:06
Moving GPG keys to new machine
Mac and Linux work the same, storing the keys in ~/.gnupg. The safest way to transfer the files is using scp (part of ssh):
To copy from your local machine to another:
scp -rp ~/.gnupg othermachine:
To copy from a remote machine to your local:
scp -r othermachine:~/.gnupg ~
If you're on the machine that already has the key:
@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_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 / 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

{
"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",