Skip to content

Instantly share code, notes, and snippets.

@eidosam
eidosam / scala.Makefile
Created November 2, 2020 13:05
Default lifecycle phases of Maven build as Makefile
# https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
# Validate the project is correct and all necessary information is available.
validate:
mvn validate
# Compile the source code of the project.
compile:
mvn compile
# Test the compiled source code using a suitable unit testing framework.
function newlineDelimitedKeyValue(obj, parentKey = '') {
return Object.entries(obj)
.map(([k, v]) => {
if (typeof v === 'object') {
return newlineDelimitedKeyValue(v, `${parentKey}${k}_`);
}
const kUpper = `${parentKey}${k}`.toUpperCase();
return `${kUpper}=${v}`;
from boto3.session import Session
import base64
from botocore.exceptions import ClientError
def get_secret(secret_name, region_name='us-west-2'):
secret_value_response = {}
try:
secret_value_response = (
import copy
def merge_dict_deep(dest, src):
merged_dict = copy.deepcopy(dest)
for key in src:
if key not in dest:
merged_dict[key] = src[key]
elif isinstance(dest[key], dict) and isinstance(src[key], dict):
@eidosam
eidosam / BigQuery_re2_udfs
Created January 23, 2023 12:05
BigQuery RegExp functions in Spark
https://cloud.google.com/bigquery/docs/reference/standard-sql/string_functions#regexp_contains
https://cloud.google.com/bigquery/docs/reference/standard-sql/string_functions#regexp_extract
https://cloud.google.com/bigquery/docs/reference/standard-sql/string_functions#regexp_replace
@eidosam
eidosam / clone_instance_profile.py
Created April 5, 2024 21:16
Clone AWS IAM instance profile
import json
import boto3
original_instance_profile_name = 'original-role'
new_instance_profile_name = 'new-role'
def clone_instance_profile(original_instance_profile_name,
new_instance_profile_name):
import json
import boto3
def clone_iam_role(original_role_name,
new_role_name):
iam = boto3.client("iam")
@eidosam
eidosam / snowflake_cost_per_user
Created May 6, 2024 11:22
Compute Snowflake cost per user
SELECT
user_name,
warehouse_name,
warehouse_size,
database_name,
run_date,
ROUND(t/1000/3600*credits_per_hour, 2) credits
FROM (
SELECT
@eidosam
eidosam / airflow_api_example.py
Created October 16, 2025 10:53
Extracts the Airflow authentication token from a local Chrome profile using Selenium and accesses the Airflow REST API
import shutil
import tempfile
import time
from pathlib import Path
import requests
from selenium import webdriver
from selenium.webdriver.chrome.options import Options