Skip to content

Instantly share code, notes, and snippets.

View jboner's full-sized avatar

Jonas Bonér jboner

View GitHub Profile
@bdarfler
bdarfler / microbenchmark-runner.scala
Created September 8, 2011 15:27
Scala Microbenchmark Runner
def benchmark(runs: Long, reps: Long, funct: => Any) = {
// warmup
println("Warming Up")
var i = 0
while ( i < 25000 ) { funct; i = i + 1 }
// test runs
println("Running Test")
var j = 0
while ( j < runs ) {
var k = 0
anonymous
anonymous / overtone-1.clj
Created December 6, 2011 05:04
(ns test.core
(:use [overtone.live]
[overtone.inst.synth]))
(def kick (sample "kick.wav"))
(def snare (sample "snare.wav"))
(def hit (sample "hit.wav"))
(def insts {:kick kick
:snare snare
:hit hit})
@jimbojsb
jimbojsb / gist:1630790
Created January 18, 2012 03:52
Code highlighting for Keynote presentations

Step 0:

Get Homebrew installed on your mac if you don't already have it

Step 1:

Install highlight. "brew install highlight". (This brings down Lua and Boost as well)

Step 2:

@daggerrz
daggerrz / CircuitBreakingDispatcherSemantics
Created January 24, 2012 15:04
Akka 1.3 circuit breaking dispatcher
package com.tapad.util
import akka.dispatch._
import java.util.concurrent.atomic.{AtomicInteger, AtomicBoolean}
class LogAndDiscardCircuitBreakerPolicy(val maxMailboxSize: Int, loggable: Logging) extends CircuitBreakerPolicy {
def onOverflowStart(mailboxSize: Int) { loggable.log.warn("Mailbox size is above {}. Ignoring messages until size is back below.", maxMailboxSize) }
def onBackToNormal(overflowCount: Int) { loggable.log.info("Mailbox size is back below {}. A total of {} messags were discarded.", maxMailboxSize, overflowCount) }
def replyToOverflow(overflowCount: Int, msg: Any) : Either[Exception, Any] = Left(new IllegalArgumentException("This overflow policy is not configured for request-reply actors."))
@henrikengstrom
henrikengstrom / gist:1843428
Created February 16, 2012 08:50
Akka2.0-RC1 example of using futures to re-start long running task
import akka.actor.{ Props, ActorSystem, Actor }
import akka.pattern.ask
import akka.util.Timeout
import akka.util.duration._
import akka.dispatch.Await
import util.Random
object DangerousOpTest extends App {
println("starting system")
val system = ActorSystem("daOp")
@chrsan
chrsan / AkkaUnfilteredSample.scala
Created February 17, 2012 09:47
Akka 2.0 unfiltered RESTful sample
package akka.unfiltered
import akka.actor._
import akka.dispatch.Future
import akka.pattern.ask
import akka.util.duration._
import akka.util.Timeout
import unfiltered.Async
import unfiltered.request._
@marnix
marnix / scala-di-from-comment-7789930.scala
Created March 2, 2012 06:27
This code is a copy (roughly reconstructed from reformatted and reordered parts in an abandoned Eclipse project) of the code that was originally in http://jonasboner.com/2008/10/06/real-world-scala-dependency-injection-di.html#comment-7789930.
trait BeeperDevice {
def beep(beepSound: String)
}
trait DependsOnBeeper {
protected val beeper: BeeperDevice
}
class Beeper extends BeeperDevice {

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@jpoehls
jpoehls / node-cluster-messaging.js
Created March 29, 2012 01:48
Simple message passing between cluster master and workers in Node.js
var cluster = require('cluster');
if (cluster.isWorker) {
console.log('Worker ' + process.pid + ' has started.');
// Send message to master process.
process.send({msgFromWorker: 'This is from worker ' + process.pid + '.'})
// Receive messages from the master process.
@viktorklang
viktorklang / minscalaactors.scala
Last active March 25, 2024 19:01
Minimalist Scala Actors
/*
Copyright 2012-2021 Viktor Klang
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software