Skip to content

Instantly share code, notes, and snippets.

View Amerousful's full-sized avatar

Pavel Bairov Amerousful

View GitHub Profile
@tyb
tyb / print_map.java
Created July 22, 2019 09:47
Pretty-print a Map in Java
//as json
new Gson().toJson(map)
//as json
ObjectMapper mapper = new ObjectMapper();
mapper.writerWithDefaultPrettyPrinter().writeValueAsString(object);
//as json
Map<String, Object> stats = ...;
System.out.println(new JSONObject(stats).toString(2));
@BigOokie
BigOokie / pgrep-regex-example.txt
Last active October 15, 2025 15:41
Use pgrep with regex patterns to identify specific processes and command line flags
Use the following pattern for `pgrep` to identify a running process that contains specific commandline parameters
Note the following pgrep options are needed:
-a, --list-full list PID and full command line
-f, --full use full process name to match
-c, --count count of matching processes
To find a specific process with a specific commandline parameter use the following:
pgrep -a -f "{processname}.*{commandline param}"
@Amerousful
Amerousful / randomIPv6.scala
Created June 9, 2022 14:41
Scala, generate random IPv6
import java.util.concurrent.ThreadLocalRandom
val scope = (0 to 9) ++ ('a' to 'f')
def randomElement[T](seq: T*): T = {
seq(ThreadLocalRandom.current.nextInt(seq.size))
}
def generateIp: String = (1 to 32).foldLeft("") { (acc, _) =>
acc + randomElement(scope: _*)
@Amerousful
Amerousful / gatling-pass-scenario-variables.md
Last active October 20, 2025 14:47
Gatling: How to pass the session variables between two scenarios?

Gatling: How to pass the session variables between two scenarios?

I have a general solution which can easy to use. There are several steps how to do it.

Create methods which get all session variable from one scenario and another method which sets this variables:

import scala.collection.concurrent.{Map => ConcurrentMap}

def passAnotherSession(implicit transferVariable: ConcurrentMap[String, Any]): Expression[Session] =
@Amerousful
Amerousful / MultipleLevelFilter.scala
Created October 12, 2022 14:09
Scala, Logback Multiply Level Filter
class MultipleLevelFilter extends AbstractMatcherFilter[ILoggingEvent] {
private var levels: Set[Level] = _
def setLevels(levels: String): Unit = {
this.levels = levels.split('|').map(Level.toLevel(_, Level.OFF)).toSet
}
def getLevels = levels