This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Code from blog post on the State Monad | |
// http://blog.tmorris.net/posts/memoisation-with-state-using-scala/index.html | |
type Memo = Map[Long, BigInt] | |
object FibNaïve { | |
def fibnaïve(n: Long): BigInt = | |
if (n <= 1) | |
BigInt(n) | |
else { | |
val r = fibnaïve(n - 1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class State[S, A](run: S => (A, S)) | |
//Fix FibMemo2 in | |
// http://blog.tmorris.net/posts/memoisation-with-state-using-scala/index.html | |
// 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 = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Fixes memorization bug from code in | |
// http://blog.tmorris.net/posts/memoisation-with-state-using-scala/index.html | |
// 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import coursier.core.Authentication, coursier.MavenRepository | |
interp.repositories() ++= Seq(MavenRepository( | |
"http://bblfish.net/work/repo/snapshots/" | |
)) | |
@ | |
import scala.concurrent.ExecutionContext |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ openssl pkcs12 -clcerts -nokeys -in ~/Certificates.p12 | openssl x509 | |
Enter Import Password: | |
MAC verified OK | |
-----BEGIN CERTIFICATE----- | |
MIIDITCCAgmgAwIBAgIGAUwZZ+oFMA0GCSqGSIb3DQEBBQUAMB0xDjAMBgNVBAMM | |
BVdlYklEMQswCQYDVQQKDAJ7fTAeFw0xNTAzMTQxNzM5NDJaFw0xOTAzMTMxNzQ5 | |
NDJaMBwxGjAYBgNVBC4TEWhlbnJ5QGJibGZpc2gubmV0MIIBIDALBgkqhkiG9w0B | |
AQEDggEPADCCAQoCggEBANq50elB9vhaCGMWnQ22Mo0dShWnHf/j1PTQh1KlL7FF | |
TXNY5KXs81AeOSS8AlLzAEsLshoNa2TKBT8PvLWlTsk+vi3JuR5MQyuCeITEzCrY | |
oQK0bSogF79F2dTIilZNQgI0SEobLkRtu0zUOOecJGbOMQ8yd3OnedJO17YKBaYY |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package shapeless.examples | |
import shapeless.PolyDefns._ | |
import shapeless._ | |
import shapeless.ops.hlist.At | |
import scala.math.Ordering | |
/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright 2012 Henry Story, http://bblfish.net/ | |
* | |
* 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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) |