Skip to content

Instantly share code, notes, and snippets.

View dumkydewilde's full-sized avatar
🐢

Dumky de Wilde dumkydewilde

🐢
View GitHub Profile
@dumkydewilde
dumkydewilde / dbt-streamlit-materialization-macro.sql
Created August 23, 2025 08:06
Custom dbt materialization for Snowflake Streamlit Apps
{% materialization streamlit, adapter='snowflake', supported_languages = ['python'] %}
{% set original_query_tag = set_query_tag() %}
{% set identifier = model['alias'] %}
{% set app_name = config.get('app_name', identifier) %}
{% set stage_name = config.get('stage', 'streamlit_apps') %}
{% set create_stage = config.get('create_stage', true) %}
@dumkydewilde
dumkydewilde / gist:d7051ad3175856a3234792390b4927c5
Last active November 2, 2023 12:01
dbt databricks: Auto generate model files (.sql) with source and column names
# You can run this script to generate the SQL files for the models and fetch columns names from Databricks.
# Run it on the command line, like this:
# python utils/generate_models.py \
# -yml models/staging/salesforce/_source_salesforce.yml \
# -o models/staging/salesforce
# Or see all options with python utils/generate_models.py --help
import yaml
import os
import requests
@dumkydewilde
dumkydewilde / fetch_ips.py
Last active May 23, 2023 20:00
Fetch all IP ranges (CIDR) for major cloud providers (AWS, GCP, Azure, Cloudflare) to use for bot or crawler detection
import requests, json, ipaddress
def get_cidr_ranges(provider):
if provider == 'aws':
url = 'https://ip-ranges.amazonaws.com/ip-ranges.json'
base_key = 'prefixes'
key = 'ip_prefix'
elif provider == 'gcp':
url = 'https://www.gstatic.com/ipranges/cloud.json'
base_key = 'prefixes'
@dumkydewilde
dumkydewilde / cloudflare-worker-csp-header.js
Created December 9, 2021 12:57
Use Cloudflare Workers to inject CSP headers in your requests
const NONCE_SECRET = "S3CR3T" // Identify where to inject nonces in your page
class ElementHandler {
constructor(generatedNonce, nonceReplaceValue) {
this.generatedNonce = generatedNonce
this.nonceReplaceValue = nonceReplaceValue
}
element(element) {
// An incoming element, such as `div`