Skip to content

Instantly share code, notes, and snippets.

@fforbeck
fforbeck / JProfiler-with-Docker.md
Created August 14, 2020 16:08 — forked from kevin-lee/JProfiler-with-Docker.md
JVM Profiler with Docker

JProfiler with Docker

Docker

DockerFile

DockerFile should have JProfiler installation.

RUN wget <JProfiler file location> -P /tmp/ && \
  tar -xzf /tmp/<JProfiler file> -C /usr/local && \
  rm /tmp/<JProfiler file>
@illright
illright / слова.txt
Created August 27, 2017 17:55
Слова для крокодила
Будильник
Зарядка
Акварель
Травма
Оригами
Пульс
Спорт
Канатоходец
Магнитофон
Халат

Thread Pools

Thread pools on the JVM should usually be divided into the following three categories:

  1. CPU-bound
  2. Blocking IO
  3. Non-blocking IO polling

Each of these categories has a different optimal configuration and usage pattern.

@adamw
adamw / log.scala
Last active May 10, 2021 09:33
Logging request duration, path, status code using Akka HTTP
val rejectionHandler = RejectionHandler.default
def logDuration(inner: Route): Route = { ctx =>
val start = System.currentTimeMillis()
// handling rejections here so that we get proper status codes
val innerRejectionsHandled = handleRejections(rejectionHandler)(inner)
mapResponse { resp =>
val d = System.currentTimeMillis() - start
logger.info(s"[${resp.status.intValue()}] ${ctx.request.method.name} ${ctx.request.uri} took: ${d}ms")
resp
}(innerRejectionsHandled)(ctx)
@mikehearn
mikehearn / threadbox.kt
Created August 15, 2015 12:15
More advanced ThreadBox with affinity guards
// This is a class that attempts to stop you accessing variables outside a lock.
//
// It does not do a perfect job, but can catch some common kinds of mistake, in
// particular when you accidentally try to work with objects inside closures that
// end up running later, outside the locked region (or in a different thread).
// EXAMPLE
val bank = ThreadBox(object {
val accounts by arrayListOf(10, 0, 0, 0).guard()
@wickman
wickman / case_class.py
Created March 7, 2011 01:02
case-class like thing in python
# E.g. TaskClass = CaseClass('name', 'owner', 'pid')
# task1 = TaskClass(name = "hello", owner = "brian", pid = 15)
# task2 = TaskClass(name = "world", owner = "brian", pid = 13)
# tasks = [task1, task2]
#
# filter(lambda task: task.where(owner = "brian"), tasks) => [task1, task2]
# filter(lambda task: task.where(owner = "brian", pid = 13), tasks) => [task2]
#
# matcher = TaskClass(pid = 13)
# filter(lambda task: task.match(matcher), tasks) => [task2]
@Arkanosis
Arkanosis / properties.cpp
Last active May 14, 2023 16:53
C# style properties in C++
/*
** C# style properties in C++
** (C) 2010 Arkanosis
** jroquet@arkanosis.net
**
** Example code released under the MIT license
** http://www.opensource.org/licenses/mit-license.php
**
** This is an original portable version of
** http://www.codeproject.com/KB/cpp/properties.aspx