Skip to content

Instantly share code, notes, and snippets.

View earthquakesan's full-sized avatar

Ivan Ermilov earthquakesan

View GitHub Profile
@earthquakesan
earthquakesan / msgraph_user_search.py
Created September 19, 2023 20:33
Search for user in Azure AD using username - the same behaviour as in the web console
import asyncio
from azure.identity import AzureCliCredential
from msgraph import GraphServiceClient
from msgraph.generated.users.users_request_builder import UsersRequestBuilder
async def get_user(user_name: str, client: GraphServiceClient) -> None:
# The query used here is the same when searching for users in Azure AD via web console
query_params = UsersRequestBuilder.UsersRequestBuilderGetQueryParameters(
@earthquakesan
earthquakesan / gist:d5329213f92dbc3010ba2ac732da0235
Created June 26, 2023 13:55
Check that AWS Config Cloud Formation Stacks are removed from Account Factory Provisioned Account
#!/bin/bash
set -uo pipefail
IFS=$'\n\t'
export AWS_ACCESS_KEY_ID=""
export AWS_SECRET_ACCESS_KEY=""
export AWS_SESSION_TOKEN=""
ACCOUNT_ID=
ROLE_ARN=arn:aws:iam::${ACCOUNT_ID}:role/AWSControlTowerExecution
@earthquakesan
earthquakesan / gist:9938ec68de4778c1238f76a44122257c
Created June 26, 2023 13:54
Remove AWS Config Cloud Formation Stack from Account Factory Provisioned Account
#!/bin/bash
set -uo pipefail
IFS=$'\n\t'
export AWS_ACCESS_KEY_ID=""
export AWS_SECRET_ACCESS_KEY=""
export AWS_SESSION_TOKEN=""
ACCOUNT_ID=
ROLE_ARN=arn:aws:iam::${ACCOUNT_ID}:role/AWSControlTowerExecution
@earthquakesan
earthquakesan / Compare_ssl_certs.md
Created January 19, 2023 21:07
Comparing End dates of two certificates using Bash

Create test certs

See link

openssl genpkey -out device1.key -algorithm RSA -pkeyopt rsa_keygen_bits:2048
openssl req -new -key device1.key -out device1.csr
openssl req -text -in device1.csr -noout
openssl x509 -req -days 7 -in device1.csr -signkey device1.key -out device1.crt
openssl genpkey -out device2.key -algorithm RSA -pkeyopt rsa_keygen_bits:2048
openssl req -new -key device2.key -out device2.csr
openssl x509 -req -days 14 -in device2.csr -signkey device2.key -out device2.crt
export SERVER=example.org
export EMAIL=mail@example.org
mkdir tls
touch tls/index.txt
cat <<EOF > tls/openssl-ca.cnf
[ ca ]
default_ca = CA_LOC
@earthquakesan
earthquakesan / log.log
Created October 14, 2021 11:03
Huge log file
This file has been truncated, but you can view the full file.
[INFO] Log message 1
[INFO] Log message 2
[INFO] Log message 3
[INFO] Log message 4
[INFO] Log message 5
[INFO] Log message 6
[INFO] Log message 7
[INFO] Log message 8
[INFO] Log message 9
[INFO] Log message 10
@earthquakesan
earthquakesan / gist:960fa1f9bb3ed3de7741e420fc2d2f5d
Created July 12, 2021 10:03
Create CA & Server Certificate with SAN
# Create CA & Server Cert
## Create CA
```
cat <<EOF > openssl.cnf
[ req ]
#default_bits = 2048
#default_md = sha256
#default_keyfile = privkey.pem
@earthquakesan
earthquakesan / jvm.options
Created August 29, 2017 14:13
/usr/share/elasticsearch/config/jvm.options
## JVM configuration
################################################################
## IMPORTANT: JVM heap size
################################################################
##
## You should always set the min and max JVM heap
## size to the same value. For example, to set
## the heap to 4 GB, set:
##
{"type": "FeatureCollection", "features": [{"type": "Feature", "properties": {}, "geometry": {"type": "Point", "coordinates": [12.352752685546873, 51.34433866059924]}}, {"type": "Feature", "properties": {}, "geometry": {"type": "Point", "coordinates": [12.410430908203125, 51.355488840149505]}}, {"type": "Feature", "properties": {}, "geometry": {"type": "Point", "coordinates": [12.390518188476562, 51.365778905402145]}}]}
@earthquakesan
earthquakesan / ICTCSApacheLogParsing.scala
Created October 13, 2017 07:37
Apache Log Parsing in Spark
import org.apache.spark.{SparkConf, SparkContext}
object ICTCSApacheLogParsing {
def main(args: Array[String]): Unit = {
val config = new SparkConf().setMaster("local[4]").setAppName("My Application")
val sc = new SparkContext(config)
val apacheLog = sc.textFile("/path/to/access_log")
case class ApacheLog(ipAddress: String, date: String, statusCode: String)