Skip to content

Instantly share code, notes, and snippets.

Avatar

Martin Krasser krasserm

View GitHub Profile
@krasserm
krasserm / cool_gpu2.sh
Created Jun 23, 2022 — forked from squadbox/cool_gpu2.sh
A script to control Nvidia GPU fan speed on headless (non-X) linux nodes
View cool_gpu2.sh
#!/bin/bash
# cool_gpu2.sh This script will enable or disable fixed gpu fan speed
#
# Description: A script to control GPU fan speed on headless (non-X) linux nodes
# Original Script by Axel Kohlmeyer <akohlmey@gmail.com>
# https://sites.google.com/site/akohlmey/random-hacks/nvidia-gpu-coolness
#
# Modified for newer drivers and removed old work-arounds
@krasserm
krasserm / MonadTransformerExamples.scala
Created Jul 14, 2011
Scalaz 7 monad transformer examples
View MonadTransformerExamples.scala
import scalaz._
import Scalaz._
object MonadTransformerExamples {
def main(args: Array[String]) = run
def run {
// ------------------------------------------------------
// Combined Option/Option
// ------------------------------------------------------
@krasserm
krasserm / akka-persistence-plugins.md
Last active Mar 27, 2017
Akka Persistence Plugins
View akka-persistence-plugins.md
@krasserm
krasserm / BoundedMailboxDirectConsumer.scala
Created Feb 19, 2011
Akka consumer actors best practices
View BoundedMailboxDirectConsumer.scala
class BoundedMailboxDirectConsumer extends Actor with Consumer {
import akka.dispatch._
import akka.util.duration._
// Create a bounded mailbox for this consumer actor with a capacity of 10
self.dispatcher = Dispatchers.newThreadBasedDispatcher(self, 5, 100.milliseconds)
// instruct how the route should be customized during route creation (definition)
onRouteDefinition { rd: RouteDefinition =>
// on exception attempt max 3 redeliveries with a delay of 1000 ms
View gist:9c9651a9423f9d8e2381d1922f9d88ed
import java.nio.ByteBuffer
import java.util.concurrent.TimeUnit
import org.apache.kafka.clients._
import org.apache.kafka.common.metrics.{MetricConfig, Metrics, MetricsReporter}
import org.apache.kafka.common.network.Selector
import org.apache.kafka.common.protocol.ApiKeys
import org.apache.kafka.common.record.{CompressionType, MemoryRecords}
import org.apache.kafka.common.requests.{ProduceRequest, RequestSend}
import org.apache.kafka.common.utils.SystemTime
View akka-persistence-es.scala
import akka.actor._
import akka.persistence._
object EventsourcingExample extends App {
class EventsourcedProcessor extends Processor {
var events: List[Any] = Nil
var awaitStack: List[Actor.Receive] = Nil
def receive = {
case Persistent(event, _) if recoveryRunning update(event)
@krasserm
krasserm / example1.scala
Last active Dec 17, 2015
Eventsourced processors in a parent-child relationship
View example1.scala
import java.io.File
import scala.concurrent.duration._
import akka.actor._
import akka.util.Timeout
import org.eligosource.eventsourced.core._
import org.eligosource.eventsourced.journal.leveldb.LeveldbJournalProps
@krasserm
krasserm / parwrite.scala
Created Feb 3, 2013
Journal parallel writes prototype
View parwrite.scala
package example
import scala.concurrent._
import scala.concurrent.duration._
import akka.actor._
import akka.pattern.ask
import akka.util.Timeout
object Parwrite extends App {
@krasserm
krasserm / es-ext-01.scala
Last active Dec 12, 2015
Event sourcing and external servce integration (blog post snippets)
View es-ext-01.scala
case class Order(id: Int = -1, details: String,
creditCardNumber: String,
creditCardValidation: Validation = Validation.Pending)
sealed trait Validation
object Validation {
case object Pending extends Validation
case object Success extends Validation
case object Failure extends Validation
}