Skip to content

Instantly share code, notes, and snippets.

View b-b3rn4rd's full-sized avatar

Bernard Baltrusaitis b-b3rn4rd

  • Bendigo Bank
  • Melbourne
View GitHub Profile
@tuansoibk
tuansoibk / cryptography-file-formats.md
Last active September 22, 2024 14:54
Cryptography material conversion and verification commands
  1. Introduction
  2. Standards
  3. Common combinations
  4. Conversion
  5. Verification/Inspection
  6. Tips for recognising

Introduction

It happens that there are many standards for storing cryptography materials (key, certificate, ...) and it isn't always obvious to know which standard is used by just looking at file name extension or file content. There are bunch of questions on stackoverflow asking about how to convert from PEM to PKCS#8 or PKCS#12, while many tried to answer the questions, those answers may not help because the correct answer depends on the content inside the PEM file. That is, a PEM file can contain many different things, such as an X509 certificate, a PKCS#1 or PKCS#8 private key. The worst-case scenario is that someone just store a non-PEM content in "something.pem" file.

@GrigorievNick
GrigorievNick / GracefulStopOnShutdownListener.scala
Last active April 10, 2024 14:01
Spark Structure Streaming GraceFullShutdown on Sigterm. Sigterm will not interrupt currently running batch, but due to asynс nature of SparkQueryListner.onProgres method, can interrupt next batch during first few moments.
import org.apache.hadoop.util.ShutdownHookManager
import org.apache.spark.sql.streaming.StreamingQueryListener
import org.apache.spark.sql.streaming.StreamingQueryManager
import org.slf4j.LoggerFactory
import java.util.UUID
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.SynchronousQueue
import java.util.concurrent.TimeUnit
@gwalkey
gwalkey / gist:b168d532b472333e96663cf607bf84eb
Last active October 2, 2024 09:14
Create a NuGet Package to Install a Powershell Module
Download the CLI Version of NuGet
https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
--Create Work Paths
md c:\nuget
md c:\nuget\source
md c:\nuget\publish
-- One-Time - Create local NuGet Repo/feed using a local drive path
cd c:\nuget
@galiana
galiana / [email protected]
Created January 16, 2020 09:01
Transforming MongoDB WebHooks notifications payload into Microsoft teams message cards
#r "Newtonsoft.Json"
using System.Net;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using Newtonsoft.Json;
using System.Net.Http.Headers;
public static async Task<IActionResult> Run(HttpRequest req, ILogger log)
{
@toff63
toff63 / terraform_retrieve_secret_aws.tf
Created December 10, 2018 17:21
How to retrieve a secret stored in AWS Secret Manager in terraform.
variable "region" {}
variable "access_key" {}
variable "secret_key" {}
provider "aws" {
version = "~> 1.25"
region = "${var.region}"
access_key = "${var.access_key}"
secret_key = "${var.secret_key}"}
@jonathan-kosgei
jonathan-kosgei / schedule_function.sh
Created April 19, 2017 03:52
AWS Lambda backup EBS volumes with BOTO3
# Scheduling the above script hourly. Ensure you're properly authenticated via aws configure.
#!/bin/bash
zip ebs-backup-worker.zip .schedule-ebs-snapshot-backups.py
aws lambda create-function --function-name ebs-backup-worker \
--runtime python2.7 \
--role "arn for your lambda user's role" \
--handler lambda_handler \
--zip-file fileb:///ebs-backup-worker.zip
1. Setup a project
2. Add groovy SDK support:
https://www.bonusbits.com/wiki/HowTo:Add_Groovy_SDK_to_IntelliJ_IDEA
3. Download http://(yourjenkinsurl)/job/(yourpipelinejob)/pipeline-syntax/gdsl
- this will give you the .gdsl file - download this to the src folder of your project.
4. Finally follow this step - right click on the src folder -> Mark directory as -> Sources Root
@ikrauchanka
ikrauchanka / read-aws-flowlogs.go
Created March 24, 2017 22:26
read AWS FlowLogs
/*
Program require access to S3 objects.
It will download gz file, gunzip it, read flat file and convert output into json.
You can use output as a data in HTTP and stream into elastic search(or ELK).
INFO: https://aws.amazon.com/blogs/aws/vpc-flow-logs-log-and-view-network-traffic-flows/
*/
package main
import (
"bufio"
@bjinwright
bjinwright / cognito.py
Last active January 18, 2022 00:25
Example of how to make an authorized call to API Gateway using Boto3, Requests, and AWS4Auth. http://stackoverflow.com/questions/37336286/how-do-i-call-an-api-gateway-with-cognito-credentials-in-python
import boto3
import datetime
import json
from requests_aws4auth import AWS4Auth
import requests
boto3.setup_default_session(region_name='us-east-1')
identity = boto3.client('cognito-identity', region_name='us-east-1')
account_id='XXXXXXXXXXXXXXX'
@arturo-c
arturo-c / python-to-es.py
Created August 26, 2016 19:45
sample python to es
import base64
import datetime
import json
import os
import time
import traceback
import urlparse
import botocore.auth
import botocore.awsrequest