Skip to content

Instantly share code, notes, and snippets.

@umit
umit / Effect.java
Created August 1, 2024 07:05
Scala effects like java
import java.time.Duration;
import java.util.Optional;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Supplier;
class Scratch {
static String userName = "Morty";
static Effect<String> effect0 = saveUser(userName);
@umit
umit / 0-interceptors-are-functions-too.md
Created December 6, 2023 07:01 — forked from quad/0-interceptors-are-functions-too.md
Interceptors Are Functions Too

Interceptors Are Functions Too

I could not agree more with my colleague and friend Travis Johnson's opinion that "[INTERCEPTORS ARE SO COOL][iasc]!" In that post, he succinctly describes the [Interceptor pattern][pattern] as used adroitly by [OkHttp][okhttp]. But, as is often the case, I believe a complicated object-oriented pattern obscures the simple functional gem within it.

What is an Interceptor?

I'll quote liberally from [OkHttp's documentation on the topic][okhttp-interceptor]:

Interceptors are a powerful mechanism that can monitor, rewrite, and retry calls. […] >

@umit
umit / Makefile
Created June 26, 2022 18:19
Add help command to show all commands in Makefile
help: ## Display this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\nTargets:\n"} \
/^[a-z0-9A-Z_-]+:.*?##/ { printf " \033[36m%-10s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
# Everything below is an example
target00: ## This message will show up when typing 'make help'
@echo does nothing
@umit
umit / lrucache.java
Created February 22, 2022 20:47
LRUCache
public class LRUCache {
private final Map<Integer, Node> map = new HashMap<>();
private final int capacity;
private Node head, tail;
public LRUCache(int capacity) {
this.capacity = capacity;
}
@umit
umit / hello_endpoint_test.go
Created August 6, 2021 19:38
Testcontainers with Tyk.
import (
"encoding/json"
"net/http"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/testcontainers/testcontainers-go"
"github.com/testcontainers/testcontainers-go/wait"
)
@umit
umit / count_down_latch_example.go
Created April 9, 2021 10:42
Countdownlatch example
package main
import (
"fmt"
"time"
)
func main() {
const numGreeters = 10
@umit
umit / count_down_latch.go
Last active April 9, 2021 10:27
count_down_latch
type CountDownLatch struct {
sync.WaitGroup
counter uint64
}
func (cdl *CountDownLatch) Add(delta int) {
cdl.WaitGroup.Add(delta)
d := uint32(delta)
atomic.AddUint64(&cdl.counter, combineUInt64For(d, d))
}
@umit
umit / README-Template.md
Created September 17, 2020 07:28 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@umit
umit / things-i-believe.md
Created February 11, 2020 08:30 — forked from stettix/things-i-believe.md
Things I believe

Things I believe

This is a collection of the things I believe about software development. I have worked for years building backend and data processing systems, so read the below within that context.

Agree? Disagree? Feel free to let me know at @JanStette. See also my blog at www.janvsmachine.net.

Fundamentals

Keep it simple, stupid. You ain't gonna need it.

@umit
umit / pub_sub_test.go
Created December 3, 2019 12:41
Pub sub testcontainers for gcp
import (
"cloud.google.com/go/pubsub"
"context"
"fmt"
"github.com/testcontainers/testcontainers-go/wait"
"log"
"net/http"
"os"
"time"