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
{"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 / dbpedia-queries.md
Created November 9, 2017 09:06
Example queries for DBpedia 2016-10

Washington population

PREFIX  dc:   <http://purl.org/dc/elements/1.1/>
PREFIX  dbpedia-owl: <http://dbpedia.org/ontology/>
PREFIX  geo:  <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX  foaf: <http://xmlns.com/foaf/0.1/>
PREFIX  dbpedia-prop: <http://dbpedia.org/property/>
PREFIX  yago: <http://dbpedia.org/class/yago/>
PREFIX  rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX  umbel-sc: <http://umbel.org/umbel/sc/>
@earthquakesan
earthquakesan / Connect-to-server.sh
Created October 19, 2017 16:53
Docker Certificate Generation
#!/bin/bash
export DOCKER_HOST="ubuntubox.ermilov.org"
export DOCKER_CERT_PATH="$(pwd)/.docker"
export DOCKER_CONFIG="$(pwd)/.docker"
export DOCKER_TLS_VERIFY=1