Skip to content

Instantly share code, notes, and snippets.

View ghostbuster91's full-sized avatar

Kasper Kondzielski ghostbuster91

View GitHub Profile

Keybase proof

I hereby claim:

  • I am ghostbuster91 on github.
  • I am kghost0 (https://keybase.io/kghost0) on keybase.
  • I have a public key whose fingerprint is 46CA 4691 7EA2 E22D AC0C 295B 887E DDF3 419F C083

To claim this, I am signing this object:

implicit val showConfig = ShowConfig.noColors
val result = diffForString(
"""alice bob mark""".stripMargin,
"""bob mark john""".stripMargin
)
println(result.show())
implicit val showConfig = ShowConfig.noColors
val result = diffForString(
"""alice
|bob
|mark""".stripMargin,
"""bob
|mark
|john""".stripMargin
)
println(result.show())
@ghostbuster91
ghostbuster91 / gist:78c41f1b2e77fb0c7a0f22045fb51917
Created August 24, 2020 07:27
postgers_synchronous_replication_summary
+--------------+----------------+-----------------------------------------------------+
| | local | standbys |
+--------------+----------------+-------------------+----------------+----------------+
| | durable commit | query consistency | durable commit | durable commit |
| | | | after OS crash | after PG crash |
+--------------+----------------+-------------------+----------------+----------------+
| remote_apply | X | X | X | X |
+--------------+----------------+-------------------+----------------+----------------+
| on | X | | X | X |
+--------------+----------------+-------------------+----------------+----------------+
class WithdrawBatchingExecutor(repository: WithdrawalRepository,
externalSystem: ExternalWithdrawSystem) {
def startExecutor: Observable[Unit] =
Observable
.intervalWithFixedDelay(config.interval)
.mapEval( _ => repository.findAllWaitingOrderedBySerialIdAsc())
.distinctUntilChanged
.scan(List.empty[Withdrawal]) { (oldSet, newSet) =>
newSet.takeWhile(w => !oldSet.contains(w))
def mergeMap[B](f: A => Observable[B])(
implicit os: OverflowStrategy[B] = OverflowStrategy.Default): Observable[B]
def groupBy[K](keySelector: A => K)(
implicit os: Synchronous[Nothing] = OverflowStrategy.Unbounded
): Observable[GroupedObservable[K, A]]
Observable
.intervalWithFixedDelay(config.interval)
.mapEval( _ => repository.findAllWaitingOrderedBySerialIdAsc(config.maxBatchSize))
.distinctUntilChanged
.scan(List.empty[Withdrawal]) { (oldSet, newSet) =>
newSet.takeWhile(w => !oldSet.contains(w))
}
.flatMap(Observable.fromIterable)
.bufferTimedAndCounted(config.timeWindow, config.batchSizeThreshold)
Observable
.intervalWithFixedDelay(config.interval)
.mapEval( _ => repository.findAllWaitingOrderedBySerialIdAsc(config.maxBatchSize))
.distinctUntilChanged
.scan(List.empty[Withdrawal]) { (oldSet, newSet) =>
newSet.takeWhile(w => !oldSet.contains(w))
}
def scan[S](seed: => S)(op: (S, A) => S): Observable[S]