Skip to content

Instantly share code, notes, and snippets.

View sarath-soman's full-sized avatar

Sarath Soman sarath-soman

View GitHub Profile
@sarath-soman
sarath-soman / dop
Created October 3, 2024 22:36
Data oriented programming - Examples | TS | C++ | Java
----------------------------------------TS----------------------------------------
import { z } from "zod";
// User Schema using Zod
// Principle 4: Separating data schema from data representation
// The schema is defined using Zod, allowing us to validate the structure of User data independently of its representation in the program.
const UserSchema = z.object({
id: z.number(),
name: z.string(),
age: z.number(),
@sarath-soman
sarath-soman / docker-compose.yml
Last active March 31, 2025 11:20
Keycloak docker compose with health checks
# Keycloak containers doesn't come with curl or wget in it, this forces the users to use alternative mechanisms to realise
# health check for the keycloak standard containers. This example leverages the capability of modern Java to dynamically
# compile a *.java source file and execute it on the fly using the `java` command. The HealthCheck class uses
# java.net.URL to open a connection to the `health/live` endpoint of keycloak and exits the process with a non-zero status
# if the http status is not `Ok`
version: '3'
services:
############################
# Keycloak service
############################
sealed trait SKI
case object S extends SKI
case object K extends SKI
case object I extends SKI
case class APP(x: SKI, y: SKI) extends SKI
case class VAR(v: String) extends SKI
object SKI {
package kjug;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.DoubleStream;
import java.util.stream.IntStream;
/**
#!/usr/bin/env python3
"""
Linear regression learning algorithm
"""
class LinearRegression:
def train(self, x, y):
"""
Trains a linear model from the data set
class Node:
"""Node represents a single node of a linked list"""
def __init__(self, val):
self.val = val
self.next = None
def __str__(self):
return str(self.val) + " -> " + str(self.next)
package ast
import (
"fmt"
)
type NumericConstant struct {
Value string
Type int
}