Skip to content

Instantly share code, notes, and snippets.

View naamancampbell's full-sized avatar

Naaman Campbell naamancampbell

  • Brisbane, Australia
View GitHub Profile
@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"]){
@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)
@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 = []
---
- hosts: docker
tasks:
- command: "echo {{ item }}"
register: result
with_items:
- 1dag
- 2
- 3
- debug:
@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)]
@seeebiii
seeebiii / LambdaConstants.java
Last active February 9, 2024 04:17
Available default environment variables in AWS Lambda. Just copy&paste into your Node or Java project.
public class Constants {
/**
* Contains the path to your Lambda function code.
*/
public static final String LAMBDA_TASK_ROOT = System.getenv("LAMBDA_TASK_ROOT");
/**
* The environment variable is set to one of the following options, depending on the runtime of the Lambda function:
* AWS_Lambda_nodejs, AWS_Lambda_nodejs4.3, AWS_Lambda_nodejs6.10
@m-x-k
m-x-k / active_directory_users.py
Created July 18, 2017 12:12
Python ldap3 active directory add and search for users
import ssl
from flask import json
from ldap3 import Server, \
Connection, \
SUBTREE, \
ALL_ATTRIBUTES, \
Tls, MODIFY_REPLACE
OBJECT_CLASS = ['top', 'person', 'organizationalPerson', 'user']
@irvingpop
irvingpop / ssh_key.tf
Last active April 8, 2024 07:18
Terraform external data source example - dynamic SSH key generation
# ssh key generator data source expects the below 3 inputs, and produces 3 outputs for use:
# "${data.external.ssh_key_generator.result.public_key}" (contents)
# "${data.external.ssh_key_generator.result.private_key}" (contents)
# "${data.external.ssh_key_generator.result.private_key_file}" (path)
data "external" "ssh_key_generator" {
program = ["bash", "${path.root}/../ssh_key_generator.sh"]
query = {
customer_name = "${var.customer_name}"
customer_group = "${var.customer_group}"
-- /usr/local/pgsql/bin/psql postgres://citus:o8PyA_-OFBq6cQO88gfipw@c.fx2kdxziaw5epni332ukk4al72q.db.citusdata.com:5432/citus?sslmode=require
-- get the latest commits from the top 5 contributors in a particular repo
PREPARE latest_commits(text) AS
WITH postgres_commits AS (
SELECT
created_at, jsonb_array_elements(payload->'commits') AS comm
FROM
@yidas
yidas / csr.conf.md
Last active May 22, 2024 12:11
Certificate(CSR) configuration file

Openssl commands:

openssl genrsa -out self-ssl.key
openssl req -new -key self-ssl.key -out self-ssl.csr -config csr.conf
openssl x509 -req -days 365 -in self-ssl.csr -signkey self-ssl.key -out self-ssl.crt -extensions req_ext -extfile csr.conf

Sign from Root CA: openssl x509 -req -days 365 -extensions req_ext -extfile csr.conf -CA RootCA.crt -CAkey RootCA.key -in self-ssl.csr -out self-ssl.crt