Skip to content

Instantly share code, notes, and snippets.

View joshrotenberg's full-sized avatar
🐢

Josh Rotenberg joshrotenberg

🐢
View GitHub Profile
defmacro is_loaded_module(module) do
quote do
case Code.ensure_loaded(unquote(module)) do
{:module, module_name} -> true
_ -> false
end
end
end
@joshrotenberg
joshrotenberg / merge.kt
Created July 26, 2018 20:34 — forked from josdejong/merge.kt
Merge two data classes in Kotlin
import kotlin.reflect.full.declaredMemberProperties
import kotlin.reflect.full.primaryConstructor
/**
* Merge two data classes
* The resulting data class will contain
* - all fields of `other` which are non null
* - the fields of `this` for the fields which are null in `other`
*/
infix inline fun <reified T : Any> T.merge(other: T): T {
package main
import (
"fmt"
"log"
"net/http"
"github.com/gin-gonic/gin"
)
defmodule MyApp.SSERouter do
use Plug.Router
@event_delay 2000
plug(:match)
plug(:dispatch)
defp send_chunk(conn) do
:timer.sleep(@event_delay)
(def input [[1 2 3] [4 5 6] [9 8 9]])
(defn diag-diff2
[arr]
(->> arr
(map-indexed (fn [i e] [(nth e i) (nth e (- (count arr) i 1))]))
(reduce (fn [acc [x y]] [(+ (first acc) x) (+ (second acc) y)]))
(reduce -)
Math/abs))
import kotlin.math.absoluteValue
fun diagonalDifference(arr: Array<Array<Int>>) = arr
.mapIndexed { index, ints -> Pair(ints[index], ints[arr.size - index - 1]) }
.reduce { pair, acc -> Pair(pair.first + acc.first, pair.second + acc.second) }
.let { pair -> pair.first - pair.second }
.absoluteValue
@joshrotenberg
joshrotenberg / Dockerfile.oso-local
Created April 2, 2024 01:36
A Dockerfile to run the Oso Local Development Binary
# syntax=docker/dockerfile:1
# The Oso Local Development binary will be available at http://localhost:8080
# Test it out with the following curl command:
#
# Simple Dockerfile to run the Oso Local Development binary in a container.
#
# To build the image, run:
# docker build -t oso-local .
#
@joshrotenberg
joshrotenberg / ADR-SYSTEM-GUIDE.md
Created July 18, 2025 02:22
Claude ADR System Guide - Comprehensive architectural decision record system for software projects with AI assistant integration

Claude ADR System Guide

A comprehensive Architectural Decision Record system designed for AI-assisted development workflows

Overview

This ADR (Architectural Decision Record) system is specifically designed for projects where AI assistants (like Claude) work alongside human developers. It provides structured decision tracking, context preservation, and branching strategy integration that scales from small chores to major architectural changes.

Key Principles

@joshrotenberg
joshrotenberg / RUST-PROJECT-SETUP.md
Created July 18, 2025 02:22
Rust Project ADR Setup Guide - Rust-specific companion guide for setting up ADR system in Rust projects

Rust Project ADR Setup Guide

A companion guide to the main ADR-SYSTEM-GUIDE.md, specifically tailored for Rust projects.

Quick Start for Rust Projects

1. Initial Setup

# In your Rust project root (where Cargo.toml lives)

POSSIBLY OUTDATED!!

Claude Context System: Complete Setup & Guide

A self-contained, AI-managed system for maintaining project context and architectural decisions. You focus on coding, your AI assistant handles the rest.

🎯 The Promise: AI Does the Work, You Stay Focused