Skip to content

Instantly share code, notes, and snippets.

View rayalex's full-sized avatar
🦄

Aleksandar Dragojević rayalex

🦄
View GitHub Profile
@rayalex
rayalex / init-alloy.sh
Created August 13, 2025 07:42
Publish host-level metrics from Databricks clusters to Prometheus/Grafana using Alloy
#!/bin/bash
set -euo pipefail
# Init script to send host-level metrics from Databricks clusters to Prometheus/Grafana using Alloy agent.
#
# 1. Add the init script to your cluster(s).
# 2. Add required environment variables in your cluster configuration, e.g.:
# PROMETHEUS_HOST=10.0.0.1:9090
# DB_CLUSTER_ID=cluster-or-job-name
# 3. Add more labels if needed (job name, etc)
@rayalex
rayalex / matrix.kt
Created December 4, 2021 10:25
Kotlin Matrix
class Matrix<T>(val width: Int, val height: Int, init: () -> T) : Iterable<T> {
private val data = List(width) { MutableList(height) { init() } }
fun dimension() = width * height
fun get(x: Int, y: Int): T = data[x][y]
fun set(value: T, x: Int, y: Int) {
data[x][y] = value
}
override fun iterator(): Iterator<T> {
@rayalex
rayalex / make_hibernate_array_again.java
Last active May 23, 2024 12:44
Array Ops support for Postgres ad Hibernate 5
public class PostgreSQLIndexedSearchFunction implements SQLFunction {
@Override
public boolean hasArguments() {
return true;
}
@Override
public boolean hasParenthesesIfNoArguments() {
return true;
}