Skip to content

Instantly share code, notes, and snippets.

@OleksiyRudenko
OleksiyRudenko / why-newline.md
Last active June 4, 2024 15:13
Why should text files end with a newline?

Why should text files end with a newline?

Reasons:

  • UNIX standard
  • If the last line in a file doesn't end with a newline then addition of next line affects two lines instead of one. This also pollutes diff on multiple files, so reader may wonder what has changed in a line whereas no significant change has occured.

Multiple newlines at the file end are also redundant as well as spaces at the end of line.

@sahilsk
sahilsk / kafka-rebalancing.md
Last active March 11, 2023 12:41
Kafka-rebalancing

Lets say i want to rebalance my-sample-topic topic on my kafka cluster

Create topcis.json

{
  "version": 1,
  "topics": [
 { "topic": "my-sample-topic" 
@olafurpg
olafurpg / AutomateScalafmtPlugin.scala
Last active September 5, 2018 07:58
Experiment to add reformatOnCompile settings to scalafmt sbt >v0.5
// Works for scalafmt 0.5.5
// From https://gist.github.com/hseeberger/03677ef75bfadb7663c3b41bb58c702b
// Thank you @hseeberger!
import org.scalafmt.bootstrap.ScalafmtBootstrap
import org.scalafmt.sbt.ScalafmtPlugin
import sbt._
import sbt.Keys._
import sbt.inc.Analysis
@ursuad
ursuad / kafka-cheat-sheet.md
Last active June 25, 2024 13:23
Quick command reference for Apache Kafka

Kafka Topics

List existing topics

bin/kafka-topics.sh --zookeeper localhost:2181 --list

Describe a topic

bin/kafka-topics.sh --zookeeper localhost:2181 --describe --topic mytopic

Purge a topic

bin/kafka-topics.sh --zookeeper localhost:2181 --alter --topic mytopic --config retention.ms=1000

... wait a minute ...

@manjuraj
manjuraj / scalaz-disjunction.scala
Last active November 12, 2018 16:15
scalaz disjunction
//
// Disjunction - aka Scalaz Either
// \/[A, B] is an alternative to Either[A, B]
// -\/ is Left (usually represents failure by convention)
// \/- is Right (usually represents success by convention)
// Left or Right - which side of the Disjunction does the "-" appear?
//
// Prefer infix notation to express Disjunction Type v: String \/ Double
//
// References
@Yiabiten
Yiabiten / Links.md
Last active August 26, 2016 16:50
Links - A must [read | watch | use] list.
@jsuereth
jsuereth / sbt-build-structure.md
Created June 15, 2015 14:56
Sbt build structure

Here's a short little guide to sbt's build structure.

First off, the key you need to investigate how sbt is building things. Here's a snippet from a build.sbt:

import sbt.Keys._
val bs: sbt.BuildStructure = buildStructure.value

This will give you all the gory details of our build (or builds, as is the case).

@viktorklang
viktorklang / Future-retry.scala
Last active July 23, 2023 23:48
Asynchronous retry for Future in Scala
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext
import scala.concurrent.Future
import akka.pattern.after
import akka.actor.Scheduler
/**
* Given an operation that produces a T, returns a Future containing the result of T, unless an exception is thrown,
* in which case the operation will be retried after _delay_ time, if there are more possible retries, which is configured through
* the _retries_ parameter. If the operation does not succeed and there is no retries left, the resulting Future will contain the last failure.