Skip to content

Instantly share code, notes, and snippets.

View davidmweber's full-sized avatar

David Weber davidmweber

  • Monadic Consulting
  • Cape Town
View GitHub Profile
@davidmweber
davidmweber / pyproject.toml
Last active May 10, 2021 12:36
Infinite loop for azure-core
[tool.poetry]
name = "stream-manager"
version = "0.0.147"
description = ""
authors = ["David Weber <david.weber@stonethree.com>", "Janto Dreijer janto.dreijer@stonethree.com"]
license = "Proprietary"
packages = [
{ include = "server" }
]
/**
* Copyright © 2016 8eo Inc.
*/
package ws
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.client.RequestBuilding._
import akka.http.scaladsl.model.{HttpRequest, StatusCodes}
import akka.http.scaladsl.server.Directives._
@davidmweber
davidmweber / RestClient.scala
Created January 22, 2016 11:49
Using Ahha http client and pooled requests
package co.horn.streaming
import akka.actor.ActorSystem
import akka.http.ConnectionPoolSettings
import akka.http.scaladsl.Http
import akka.http.scaladsl.model.{HttpResponse, HttpRequest}
import akka.stream.ActorMaterializer
import akka.stream.scaladsl.{Sink, Source}
import scala.collection.immutable.SortedMap
@davidmweber
davidmweber / FFT.scala
Created July 16, 2014 12:24
FFT in Scala based on Rosetta Code's implementation but using Spire Complex implementation
package co.horn.services
import spire.math._
import spire.implicits._
/**
* Not the fastest FFT in the world, but we use it just for testing. Based on code from
* http://rosettacode.org/wiki/Fast_Fourier_transform#Scala
*/
object FFT extends App {
@davidmweber
davidmweber / ComposeAPiVersions.scala
Last active August 29, 2015 14:02
Using Spray to compose routes for different API versions
package test
import spray.routing.Directives._
import org.scalatest.{Matchers, FunSpec}
import spray.testkit.ScalatestRouteTest
/**
* Routes that we can compose into our overall ReST API. The current plan
* is to have route completion in a separate compilation unit to keep the
* API layout easy to reason about.
@davidmweber
davidmweber / PickleMe.scala
Created June 2, 2014 12:35
Simple Scala pickler example
package pickleme
trait Zero
case class One(a:Int) extends Zero
case class Two(s:String) extends Zero
object Test extends App {
import scala.pickling._
import json._
@davidmweber
davidmweber / RequestUnmarshal.scala
Created April 5, 2014 12:32
Unmarshal http request data depending on media type
import org.scalatest.{Matchers, FunSpec}
import spray.http.HttpEntity
import spray.http.MediaTypes._
import spray.httpx.unmarshalling._
import spray.routing.HttpService._
import spray.testkit.ScalatestRouteTest
import spray.json._
import spray.httpx.SprayJsonSupport._
import spray.routing.directives._
@davidmweber
davidmweber / RouteTest.scala
Created March 30, 2014 08:48
Route based marshalling example
package za.co.monadic.kumquat
import spray.testkit.ScalatestRouteTest
import org.scalatest.{FunSpec, Matchers}
import spray.json.DefaultJsonProtocol
import spray.routing.Directives._
import spray.httpx.marshalling.Marshaller
import spray.http.MediaTypes._
@davidmweber
davidmweber / MarshalByAccept.scala
Last active August 29, 2015 13:57
Using Spray to return different marshalling formats based on an Accept type in the request header
import org.scalatest.{FunSpec, Matchers}
import spray.http.HttpHeaders.Accept
import spray.http.HttpEntity
import spray.http.MediaTypes._
import spray.httpx.marshalling._
import spray.routing.Directives._
import spray.routing.HttpService.sealRoute
import spray.testkit.ScalatestRouteTest
import spray.json._
import spray.httpx.SprayJsonSupport._
@davidmweber
davidmweber / rest_web_test_example.rb
Created November 2, 2012 15:48
Ruby REST and browser based web test example
#!/usr/bin/ruby
#
# Requires that you have installed the following gem packages:
# json, minitest, watir, watir-webdrive, rest-client
# To use Chrome, you need to install chromedriver on your path
#
# You can use cucumber instead of minitest. There are also other REST clients for Ruby
#
require 'rubygems'