Skip to content

Instantly share code, notes, and snippets.

View naamancampbell's full-sized avatar

Naaman Campbell naamancampbell

  • Brisbane, Australia
View GitHub Profile
@lorengordon
lorengordon / Manage-R53RecordSet.ps1
Last active May 30, 2023 11:18
PowerShell Script to Create/Delete/Update AWS Route53 Record Set
[CmdLetBinding()]
Param(
[Parameter(Mandatory=$true,ValueFromPipeLine=$false,ValueFromPipeLineByPropertyName=$true)]
[String] $HostedZoneId,
[Parameter(Mandatory=$true,ValueFromPipeLine=$false,ValueFromPipeLineByPropertyName=$true)]
[ValidateSet("CNAME","A","AAAA","MX","TXT","PTR","SRV","SPF","NS","SOA")]
[String] $Type,
[Parameter(Mandatory=$true,ValueFromPipeLine=$false,ValueFromPipeLineByPropertyName=$true)]
---
- hosts: docker
tasks:
- command: "echo {{ item }}"
register: result
with_items:
- 1dag
- 2
- 3
- debug:
@mneedham
mneedham / app.py
Last active February 9, 2024 18:26
Mapping Strava runs using Leaflet and Open Street Map
from flask import Flask
from flask import render_template
import csv
import json
app = Flask(__name__)
@app.route('/')
def my_runs():
runs = []
@nmarley
nmarley / dec.py
Last active August 8, 2023 13:55
AWS KMS encryption/decryption using Python/Boto3
import boto3
import base64
if __name__ == '__main__':
session = boto3.session.Session()
kms = session.client('kms')
encrypted_password = 'AQECAHjgTiiE7TYRGp5Irf8jQ3HzlaQaHGYgsUJDaavnHcFm0gAAAGswaQYJKoZIhvcNAQcGoFwwWgIBADBVBgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDDwxVQuG0oVwpkU7nQIBEIAoVGk1/wpserb+GVUOzE7PiL/Nr9fTDFKZfpKpF0ip2ct4B2q0Wn6ZZw=='
binary_data = base64.b64decode(encrypted_password)
@tanyagupta
tanyagupta / and_example_json_data.js
Last active October 28, 2017 11:23
Accessing heterogenous JSON data (using &&) - Part 4
function test_and(){
var cars=[
{make: "Jeep",model: "Cherokee",trim:"Sport 4dr Front-wheel Drive",year:"2016",wheel:{wheel_size:"17 x 7.5",wheel_metal:"Aluminum"}},
{make: "Jeep",model: "Wrangler",trim:"Sahara 2dr 4x4",year: "2015"}
]
for (var i in cars){
if (cars[i]["wheel"] && cars[i]["wheel"]["wheel_size"]){

How to setup AWS lambda function to talk to the internet and VPC

I'm going to walk you through the steps for setting up a AWS Lambda to talk to the internet and a VPC. Let's dive in.

So it might be really unintuitive at first but lambda functions have three states.

  1. No VPC, where it can talk openly to the web, but can't talk to any of your AWS services.
  2. VPC, the default setting where the lambda function can talk to your AWS services but can't talk to the web.
  3. VPC with NAT, The best of both worlds, AWS services and web.
@Faheetah
Faheetah / Jenkinsfile.groovy
Last active March 6, 2024 18:14
Jenkinsfile idiosynchrasies with escaping and quotes
node {
echo 'Results included as an inline comment exactly how they are returned as of Jenkins 2.121, with $BUILD_NUMBER = 1'
echo 'No quotes, pipeline command in single quotes'
sh 'echo $BUILD_NUMBER' // 1
echo 'Double quotes are silently dropped'
sh 'echo "$BUILD_NUMBER"' // 1
echo 'Even escaped with a single backslash they are dropped'
sh 'echo \"$BUILD_NUMBER\"' // 1
echo 'Using two backslashes, the quotes are preserved'
sh 'echo \\"$BUILD_NUMBER\\"' // "1"
@mogproject
mogproject / PythonUnitTestCheatSheet.md
Created July 24, 2015 11:17
Python unittest Cheat Sheet

Python unittest Cheat Sheet

Skeleton

@justinclayton
justinclayton / add-dns-record.sh
Created July 15, 2015 22:04
CLI to add DNS Records in Route53
#!/bin/bash -eo pipefail
## Allows for creation of "Basic" DNS records in a Route53 hosted zone
function main() {
record_name=$1
record_value=$2
[[ -z $record_name ]] && echo "record_name is: $record_name" && exit 1
[[ -z $record_value ]] && echo "record_value is: $record_value" && exit 1
@JungeAlexander
JungeAlexander / import-package-from parent.py
Created November 27, 2014 17:22
Import modules from parent folder in Python
# From http://stackoverflow.com/a/11158224
# Solution A - If the script importing the module is in a package
from .. import mymodule
# Solution B - If the script importing the module is not in a package
import os,sys,inspect
current_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
parent_dir = os.path.dirname(current_dir)
sys.path.insert(0, parent_dir)