Skip to content

Instantly share code, notes, and snippets.

View pkafel's full-sized avatar

Piotr Kafel pkafel

View GitHub Profile
@pkafel
pkafel / stripe.kt
Created October 15, 2023 19:44
Solution to Stripe phone interview questions (you can find them here - https://leetcode.com/discuss/interview-question/2585038/Stripe-or-Phone-Screen-or-Senior-SE-or-Reject
class OpeningTime {
internal var isClosed = false
internal val customerPresence: StringBuilder = StringBuilder()
}
fun computePenalty(log: String, closingTime: Int): Int {
val logArray = log.split(" ")
var penalty = 0
for (i in logArray.indices) {
if (i < closingTime) {
package com.piotrkafel.ratelimiter;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
public class DifferentFixedWindowRateLimiter<T> {
private final int windowMaxSize;
private final Map<T, Window> store = new ConcurrentHashMap<>();
private final long windowSizeInMillies;

Welcome to Kafka from scratch workshops!

The below insructions will work on the assumption that

  • You are using OSX
  • You use Kafka 2.0 version

Exercise 1 (Setup)

  1. Install Kafka on your machine - brew install kafka
  2. Start Kafka together with ZooKeeper - zookeeper-server-start /usr/local/etc/kafka/zookeeper.properties & kafka-server-start /usr/local/etc/kafka/server.properties
  3. Make sure auto.create.topics.enable property is set to true
@pkafel
pkafel / kafka-command.md
Last active March 3, 2024 13:49
Kafka command-line tools (examples in OSX)

Kafka command line tools

List (not complete)

  • zookeeper-server-start.sh - starting Zookeeper
  • kafka-server-start.sh - start Kafka
  • kafka-topics.sh - manage topics in Kafka
  • kafka-console-producer.sh - script for sending messages to Kafka topic
  • kafka-console-consumer.sh - script for consuming messages from Kafka topic
  • kafka-run-class.sh - script for running different tools (list of tools can be found here)
@pkafel
pkafel / intellij.md
Last active October 2, 2017 19:57
Most essential Intellij shortcuts (that I use in my everyday job)

Most essential Intellij IDEA shortcuts (that I use in my everyday job)

All below shortcuts work on keymap Mac OS X (10.5+)

Search

  • command + o - search class
  • command + shift + o - search file
  • command + alt + o - search symbol
  • double shift - search everywhere
  • alt + F7 - search for usage
@pkafel
pkafel / java9features.md
Last active July 21, 2017 21:47
List of major features in Java 9

Java 9 features

Convenience Factory Methods for Collections (JEP 269)

Provide static factory methods on the List, Set and Map interfaces for creating unmodifiable instances of those collections.

List.of();
List.of(E e1);
List.of(E e1, E e2);