Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am tomasherman on github.
  • I am tomasherman (https://keybase.io/tomasherman) on keybase.
  • I have a public key whose fingerprint is F834 1B85 DD5D DFAC 1758 9DB7 A3A9 2C3D BA75 C23F

To claim this, I am signing this object:

ORDER {'status': 'New', 'clientOrderId': 'f3a8a55f-9bb2-4743-bcc8-3332ee6ecc3e', 'origClientOrderId': '<null>', 'lastPrice': 'Optional.empty', 'totalQuantity': '1', 'instrument': 'cme_M6EM5', 'side': 'Buy'}
ER {'clientOrderId': 'f3a8a55f-9bb2-4743-bcc8-3332ee6ecc3e', 'origClientOrderId': '<null>', 'lastPrice': 'Optional.empty', 'totalQuantity': '1', 'orderStatus': 'New', 'side': 'Buy'}
ER {'clientOrderId': 'f3a8a55f-9bb2-4743-bcc8-3332ee6ecc3e', 'origClientOrderId': '<null>', 'lastPrice': 'Optional[1.1104]', 'text': 'Fill', 'totalQuantity': '1', 'orderStatus': 'Filled', 'side': 'Buy'}
ORDER {'status': 'New', 'clientOrderId': '58f023ac-3dc0-448d-836b-562a78b8fd3c', 'origClientOrderId': '<null>', 'lastPrice': 'Optional.empty', 'totalQuantity': '1', 'instrument': 'cnx_EURUSD', 'side': 'Sell'}
ER {'clientOrderId': '58f023ac-3dc0-448d-836b-562a78b8fd3c', 'origClientOrderId': '58f023ac-3dc0-448d-836b-562a78b8fd3c', 'lastPrice': 'Optional.empty', 'totalQuantity': '1.00000', 'orderStatus': 'New', 'side': 'Sell'}
O
@tomasherman
tomasherman / Server.scala
Created June 13, 2011 17:49
Scala structural type dependency injection between modules
//This file is assumed to be in the server module
class ConfigImpl extends Config {
lazy val potSensor = new PotSensor
lazy val heater = new Heater
lazy val warmer = new Warmer(this) // this is where injection happens
}
CodecConfig.config = new ConfigImpl
@tomasherman
tomasherman / gist:1031429
Created June 17, 2011 13:40
SBT 0.10 test output
Tomas-Hermans-MacBook:specus tomasherman$ sbt
[info] Set current project to specus (in build file:/Users/tomasherman/workspace/specus/)
> test
[info] No tests to run.
[info] No tests to run.
[info] DecodingUtils should
[info] + decode byte
[info] + decode short
[info] + decode int
[info] + decode long
@tomasherman
tomasherman / gist:1048670
Created June 27, 2011 10:55
Scala off the record logging
trait Logging {
def offTheRecords[A](f: => A):A = {
val lvl = loggingLevel // loggingLevel returns current logging leve;
disableLogging()
val result = f //invokes off-the-records function
setLoggingLevel(lvl) //undo of the disableLogging call
result
}
@tomasherman
tomasherman / gist:1069988
Created July 7, 2011 17:04
Specs2 driving me nuts ^_^
package net.tomasherman.specus.server.grid
import org.specs2.mutable.Specification
import org.specs2.specification.Scope
import akka.actor.Channel
import org.specs2.mock._
import net.tomasherman.specus.common.api.net.Packet
/**
* This file is part of Specus.
@tomasherman
tomasherman / gist:1164840
Created August 23, 2011 10:51
InfiniteList
object InfiList{
def cons[A](x:A,f:(A)=>A) = {
new InfiList(x,f)
}
}
class InfiList[A](val init:A,gen: A=>A) {
var c:A = init
def next() = {
c = gen(c)
@tomasherman
tomasherman / Herewegogo.scala
Created October 24, 2011 14:40
Dispatch, Https and self signed certificate
/**
* Sorry about the mess in imports but i figured this in REPL and i didn't want to refactor it because i'm sure i would eff it up.
* First of all you need to import certificate into a keystore like so:
/opt/java/bin/keytool -import -alias ca -file ~/Desktop/www.ondrej.vostal.net -keystore cacerts
* This should create file castore. I'm not sure about the details of this but i'm sure it's fine ^_^
* This code is basically a ripoff of the http://stackoverflow.com/questions/5206010/using-apache-httpclient-for-https
*/
import dispatch._
import java.security._
@tomasherman
tomasherman / gist:1340196
Created November 4, 2011 19:05
Scala swing
package net.tomasherman.replayvault.client.gui
import swing._
import event.{EditDone, ButtonClicked}
import net.miginfocom.swing.MigLayout
import javax.swing.BorderFactory
import java.awt.Color
import java.util.Arrays
import akka.actor.Actor
@tomasherman
tomasherman / gist:1596598
Created January 11, 2012 20:28
sumofdigits
def sumOfDigits(x: BigInt, sum: BigInt):BigInt = { //funkce se menuje sumOfDigits, bere dva argumenty, x kterej ma typ BigInt a sum, taky BigInt a vraci BigInt
x match { //tohle rika ze se ma porovnavat x s nasledujicim:
case xx if xx == 0 => sum //pokud x, ktery prejmenuju na xx == 0, tak to znamena ze sme vsechno secetli a v promenny sum je suma vsech cisel
case xx => sumOfDigits(xx / 10, sum + (xx % 10)) //pokud to neni 0, tak tam jeste nejaky cislice zbyvaj...zavolame znova sumOfDigits, ale s upravenejma parametrama tak, ze z x zahodime posledni cislo a k sume to posledni cislo pricteme
}
}