Skip to content

Instantly share code, notes, and snippets.

type ParserState = {
InHeader: bool
Command: string
Checksum: int
PayloadLength: int
Data: byte[]
}
type BitcoinMessageParser(networkData: IObservable<byte[]>) =
let headerLen = 24

Digital Signatures

Intro

Let's imagine an island whose inhabitants all have an identification number and a phone number. The identification number (ID) starts from 1 and the phone number is a 10 digit number. They have a phone directory that lists everyone's ID and phone number.

The phone number is given to the user in a way that is difficult to understand.

Given a phone number, we cannot figure out the person ID. There is no reverse directory.

@hhanh00
hhanh00 / MDb.md
Last active August 29, 2015 14:15
MarketDB

Proposed Architecture

Component Diagram

Market data provider bridge

  • Interface to the Market data vendor (RMDS, Bloomberg, etc.)
  • Convert their data model into our own
    • Data fields
    • Image vs Refresh messages
    • Market by order, by depth
  • Outputs tick by tick in unified data model
libtool unzip pax hg ed texinfo bison flex cvs automake autoconf gcc cmake svn gcc-c++ epel-release yasm wget xz xz-devel bzip2 patch lzma
@hhanh00
hhanh00 / reverse-ws-proxy.js
Created June 24, 2015 15:05
Reverse Proxy for websockets using Express JS
var http = require('http'),
httpProxy = require('http-proxy'),
express = require('express');
// create a server
var app = express();
var proxy = httpProxy.createProxyServer({ target: 'http://localhost:8080', ws: true });
var server = require('http').createServer(app);
// proxy HTTP GET / POST
@hhanh00
hhanh00 / MultiLevelLens.scala
Last active August 29, 2015 14:23
Multi level lens with scalaz
import scalaz._
case class Valuation(realized: BigDecimal, unrealized: BigDecimal) {
def addR(r: BigDecimal) = this copy (realized = this.realized+r)
def addU(u: BigDecimal) = this copy (unrealized = this.unrealized+u)
}
object Valuation {
def apply() = new Valuation(0, 0)
}
@hhanh00
hhanh00 / akka-http-jsonapi.scala
Created November 9, 2015 15:26
How to make a custom marshaller for JSON API
case class MyData(id: String, d: Int)
object MyData {
implicit def dataMarshaller: ToEntityMarshaller[MyData] = {
Marshaller.StringMarshaller.wrap(MediaTypes.`application/vnd.api+json`)(data => {
val jo = JsObject("data" ->
JsObject("type" -> JsString("dashboard"), "id" -> JsString(data.id),
"attributes" -> JsObject("exposure" -> JsNumber(data.d)))
)
jo.compactPrint
@hhanh00
hhanh00 / d.rb
Created June 19, 2016 14:36
Chef cookbook for installing dub/dmd
d_apt = template '/etc/apt/sources.list.d/d-apt.list' do
source 'd-apt.list.erb'
notifies :run, 'execute[update-d-home]', :immediately
end
execute 'update-d-home' do
command 'apt-get update && apt-get -y --allow-unauthenticated install --reinstall d-apt-keyring && apt-get update'
only_if { d_apt.updated_by_last_action? }
end
@hhanh00
hhanh00 / lasso-hydra.md
Created December 29, 2018 15:52
Configuring Lasso with Hydra

If you get a validation loop, check that the jwt cookie could be set:

  • Look for a no jwt message,
  • Check the Set-Cookie LassoCookie,
  • in particular, Domain should be set, if not set it in the config

If you get an error 'no username in jwt', make sure that the open id provider gave an email in the response to /userinfo In Hydra, it is returned in the id_token by the consent endpoint. For reference, check okta