Skip to content

Instantly share code, notes, and snippets.

Simon Massey simbo1905

View GitHub Profile
View gist:11349189
package dumbconsumer;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
@simbo1905
simbo1905 / SessionDemo.scala
Last active Aug 29, 2015
minor fix to code from Session state in Scala,1. Immutable Session State at http://higher-state.blogspot.co.uk/2013/02/session-state-in-scala1-immutable.html
View SessionDemo.scala
object SessionDemo {
def main(args: Array[String]) {
import scala.concurrent.duration._
val timeoutSeconds = 10
def usage() {
System.out.println(s"|timoutSeconds: ${timeoutSeconds}")
System.out.println(s"|commands:")
System.out.println(s"|+ <key> <value> // add a value under a key")
View Runner01.java
public class Runner01 {
static class Array1 {
private Object delegate;
private Object allocate(Object delegate, int[] is, int pos) {
if (pos < is.length) {
delegate = new Object[is[pos]];
@simbo1905
simbo1905 / Pickling.scala
Created Apr 23, 2015
org.scala-lang.modules:scala-pickling_2.11:0.10.0.jar crashes Oracle Java OSX 1.8.0_45
View Pickling.scala
package com.github.simbo1905.trex.internals
import java.nio.ByteBuffer
import akka.util.ByteString
object Pickle {
import scala.pickling.Defaults._
@simbo1905
simbo1905 / picklingissues.scala
Created Apr 23, 2015
scala.pickling.PicklingException: Tag scala.Some not recognized, looking for one of: scala.None.type, scala.Some[com.github.simbo1905.trex.internals.Accept]
View picklingissues.scala
// test case
import scala.pickling.Defaults._
import scala.pickling.shareNothing._
import scala.pickling.binary._
val p = PrepareAck(Identifier(1, ProposalNumber(2, 3), 4L), 5, Progress(ProposalNumber(6,7),Identifier(8,ProposalNumber(9,10),11L)), 12, 13, None)
val b = p.pickle.value
val pp = b.unpickle[PrepareAck]
View SecurityConfig.java
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/", "/favicon.ico", "/resources/**", "/signup",
"/register", "/public")
.permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
View ProcessMaster.java
package com.github.simbo1905.chronicle;
import java.util.ArrayList;
import java.util.List;
import com.higherfrequencytrading.chronicle.Chronicle;
import com.higherfrequencytrading.chronicle.datamodel.DataStore;
import com.higherfrequencytrading.chronicle.datamodel.ListWrapper;
import com.higherfrequencytrading.chronicle.datamodel.ModelMode;
import com.higherfrequencytrading.chronicle.impl.IndexedChronicle;
@simbo1905
simbo1905 / docker-cassandra.md
Last active Mar 15, 2017
docked cassandra cluster
View docker-cassandra.md
View perms-of-letters.scala
def perms(positions: List[Int]) = {
val x: Set[List[Int]] = positions.permutations.map(_.take(2)).toSet
val y = x filter {
case a :: b :: Nil =>
(a, b) match {
case (a: Int, b: Int) if a < b => true
case _ => false
}
case _ => false
@simbo1905
simbo1905 / InterruptProbability.scala
Created Sep 4, 2017
The probability that two random numbers in the range [0,1] are 0.35 apart.
View InterruptProbability.scala
/**
* The probability that two numbers in the range [0,1] are 0.35 apart.
*
* See discussion at https://math.stackexchange.com/a/2182330
* Which explains this chart
* http://www.mathsisfun.com/data/grapher-equation.html?func1=x-y%3D0.35&func2=y-x%3D0.35&xmin=-0.2147&xmax=1.512&ymin=-0.01944&ymax=1.276
*/
object InterruptProbability {
import scala.util.Random.nextFloat
def main(args: Array[String]): Unit = {
You can’t perform that action at this time.