Skip to content

Instantly share code, notes, and snippets.

@mrbald
mrbald / FsmDsl.scala
Created December 9, 2021 15:42
Ridiculously Simple FSM DSL in Scala
/**
* A Ridiculously Simple FSM DSL in Scala, similar to AKKA Actor-based FSM syntax
*
* def MY_STATE(...args...) = state("MY_STATE") {
* ... do something on entry ...
* events {
* case MyEvent =>
* ... do something on event ...
* MY_OTHER_STATE(...)
* }
@mrbald
mrbald / main.cpp
Created July 28, 2021 12:21
ASIO-based main.cpp skeleton
#include <boost/asio/io_context.hpp>
#include <boost/asio/post.hpp>
#include <boost/asio/signal_set.hpp>
#include <boost/exception/diagnostic_information.hpp>
#include "logger.hpp"
namespace {
@mrbald
mrbald / MyXmlMessage.java
Created December 14, 2020 15:02
XStream XML Codec
package xstreamist;
@XStreamAlias("my-msg")
public class MyXmlMessage {
// ...
};
@mrbald
mrbald / jolokia.py
Created July 17, 2020 16:09
Jolokia API request with python
from __future__ import with_statement
import argparse
import requests
from requests.auth import HTTPBasicAuth
from contextlib import closing
class PyJmx:
@mrbald
mrbald / example.sh
Last active January 20, 2021 15:26 — forked from tristanbes/example.sh
Install Graphite on a Debian Server
# Install graphite dependencies
apt-get install -y python3 python3-pip python3-cairo python3-django
apt-get install -y apache2 libapache2-mod-wsgi-py3
# Install graphite
pip3 install https://github.com/graphite-project/whisper/tarball/master
pip3 install https://github.com/graphite-project/carbon/tarball/master
pip3 install https://github.com/graphite-project/graphite-web/tarball/master
# Setup a vhost by grabbing the example the graphite team released on their repo.
@mrbald
mrbald / activemq.conf
Created May 13, 2019 15:07
/etc/supervisor/conf.d/activemq.conf
[program:activemq]
directory=/path/to/activemq/base
command=/path/to/activemq/base/bin/activemq console
user=activemq
redirect_stderr=true
autostart=true
autorestart=false
stopasgroup=true
killasgroup=true
stdout_logfile=/path/to/activemq.log
@mrbald
mrbald / StampedLockSyntax.scala
Created January 8, 2019 18:34
Scala syntax for Java 8 StampedLock
object StampedLockSyntax {
def syncRead[T](lock: StampedLock)(block: => T): T = {
val stamp = lock.readLock()
try {
block
} finally {
lock.unlockRead(stamp)
}
}
@mrbald
mrbald / build.gradle
Last active February 27, 2024 16:39
JMH gradle without plugin for multi-module projects
...
subprojects {
...
apply plugin: 'java'
apply plugin: 'scala'
sourceCompatibility = 1.8
targetCompatibility = 1.8
@mrbald
mrbald / logback.xml
Last active October 20, 2018 07:00
Logback configuration filtering JEE noise stack trace elelemts
<configuration scan="false" debug="true">
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} > %-5p > %t > %c > %m%n%rEx{full,
java.lang.reflect.Method,
org.springframework.aop,
org.springframework.transaction,
org.springframework.security,
org.springframework.web,
org.springframework.cglib,
@mrbald
mrbald / remarked.md
Last active September 19, 2018 08:38
Remarkjs-based presentation example

layout: true

.header[.grey[© 2018 Vladimir Lysyy | All rights reserved]] .footer[]


class: center, middle

name: title