Skip to content

Instantly share code, notes, and snippets.

Henry Story bblfish

Block or report user

Report or block bblfish

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
bblfish /
Last active May 1, 2019
Code from blog post on the State Monad
// Code from blog post on the State Monad
type Memo = Map[Long, BigInt]
object FibNaïve {
def fibnaïve(n: Long): BigInt =
if (n <= 1)
else {
val r = fibnaïve(n - 1)
bblfish / FibMemo2.scala
Created Apr 30, 2019
Example 2 code from blog post "Memoisation with State"
View FibMemo2.scala
case class State[S, A](run: S => (A, S))
//Fix FibMemo2 in
// Again the results were not being memoised. (Added debug option to see what
// gets calculated
object FibMemo2 {
type Memo = Map[BigInt, BigInt]
def fibmemo2(n: BigInt, debug: Boolean=false): BigInt = {
bblfish / FibMemo1.scala
Created Apr 30, 2019
Memoisation with state using Scala
View FibMemo1.scala
// Fixes memorization bug from code in
// Also adds little debugging tool to allow one to see how state evolves.
// returns the memorisation map, to help see that it has been altered.
object FibMemo1 {
type Memo = Map[BigInt, BigInt]
def fibmemo1(n: BigInt, debug: Boolean = false): (BigInt,Memo) = {
def fibmemoR(z: BigInt, memo: Memo): (BigInt, Memo) =
if(z <= 1)
bblfish /
Created Jul 10, 2017
attempt to get some linked data code working with akka http and streams
import coursier.core.Authentication, coursier.MavenRepository
interp.repositories() ++= Seq(MavenRepository(
import scala.concurrent.ExecutionContext
View keygen generated certificate
$ openssl pkcs12 -clcerts -nokeys -in ~/Certificates.p12 | openssl x509
Enter Import Password:
MAC verified OK
View ScalaReactSpeedTest.scala
package net.bblfish.test
import japgolly.scalajs.react._
import japgolly.scalajs.react.vdom.ReactVDom._
import japgolly.scalajs.react.vdom.ReactVDom.all._
import net.bblfish.test.hlistaux.SelectNOrder
import org.scalajs.dom.{Node, document}
import shapeless.PolyDefns._
import shapeless._
import shapeless.ops.hlist.Mapper
bblfish / extractor.scala
Created Aug 13, 2014
This extractor works. It starts from a very simple base
View extractor.scala
package shapeless.examples
import shapeless.PolyDefns._
import shapeless._
import shapeless.ops.hlist.At
import scala.math.Ordering
bblfish / ScalaJSExample.scala
Created Dec 25, 2013
A simple ajax call using scala-js
View ScalaJSExample.scala
package example
import scala.language.dynamics
import scala.scalajs.js
import js.Dynamic.{ global => g }
import org.scalajs.jquery.{jQuery => jQ, JQueryXHR, JQueryAjaxSettings}
//import scala.scalajs.js.{Dictionary, String, Any}
bblfish / CORSProxy.scala
Last active Dec 20, 2015
simple CORSProxy with Play2.2 - does not quite work. It blocks the HTTP connection, even though the URL is correctly fetched...
View CORSProxy.scala
* Copyright 2012 Henry Story,
* 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
* Unless required by applicable law or agreed to in writing, software
bblfish / crashCompiler.scala
Last active Dec 11, 2015
This code crahes the scala 2.10.0 compiler on OSX with java "1.7.0_11"
View crashCompiler.scala
//Using library from "net.sf.uadetector" % "uadetector-resources" % "2012.12"
import net.sf.uadetector.service._
import net.sf.uadetector.UserAgentFamily._
import net.sf.uadetector.UserAgent
val agentParser = UADetectorServiceFactory.getResourceModuleParser
val UA = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.45 Safari/53.22"
val agent = agentParser.parse(UA)
You can’t perform that action at this time.