Skip to content

Instantly share code, notes, and snippets.

@rhyskeepence
rhyskeepence / tracing.scala
Created August 14, 2018 16:45
Demonstrate tracing at the system boundaries
import cats.data.{Kleisli, ReaderT}
import cats.effect.IO
import org.http4s.client.{Client, DisposableResponse}
import org.http4s.dsl.Http4sDsl
import org.http4s.{HttpService, Request}
class Something(client: Client[IO]) extends Http4sDsl[IO] {
private val service =
new ServiceThatKnowsNothingAboutTracing(new TracingAwareHttpClient(client))
@rhyskeepence
rhyskeepence / clientconnections.scala
Last active May 9, 2018 09:40
Demonstrate client connections are not freed within recursive calls to expect when a non-2xx status code is returned.
import cats.effect.IO
import cats.implicits._
import org.http4s.HttpService
import org.http4s.Method.{GET, POST}
import org.http4s.Uri.uri
import org.http4s.client.blaze.Http1Client
import org.http4s.client.middleware.Logger
import org.http4s.client.dsl.io._
import org.http4s.dsl.io._
import org.http4s.server.blaze.BlazeBuilder
@rhyskeepence
rhyskeepence / launchpad.hs
Created January 10, 2018 07:46
Launchpad/hs
module Main where
import System.MIDI
import System.MIDI.Utility
import Control.Monad
import Data.Word
import Data.Char
main :: IO ()
main = do
@rhyskeepence
rhyskeepence / connectionio.md
Last active January 3, 2018 21:12
doobie connections and stuff
If so, can you give me some advice on how to do standard http transaction boundary stuff. That is

* unpack request
* get stuff from db
* update db based on request
* return request

all this in a single transaction (succeed/fail).
@rhyskeepence
rhyskeepence / pipe_down.py
Created June 25, 2017 13:50
Limit sonos volume
# pip install soco
import soco
import time
start_time = time.time()
sonos_zones = list(soco.discover())
while True:
time.sleep(0.25 - ((time.time() - start_time) % 0.25))

Keybase proof

I hereby claim:

  • I am rhyskeepence on github.
  • I am rhysk (https://keybase.io/rhysk) on keybase.
  • I have a public key whose fingerprint is 4690 25C8 D371 86B2 A7BB 309A 20D2 798D 40AB 4BCE

To claim this, I am signing this object:

@rhyskeepence
rhyskeepence / codemirror.html
Last active January 4, 2016 08:09
bit of code mirror
<html>
<head>
<link rel="stylesheet" href="codemirror/lib/codemirror.css">
<link rel="stylesheet" href="codemirror/addon/lint/lint.css">
<link rel="stylesheet" href="codemirror/addon/dialog/dialog.css">
<script src="codemirror/lib/codemirror.js"></script>
<script src="codemirror/addon/lint/lint.js"></script>
package sky.sns.jibberjabber
import org.squeryl.{Schema, Session}
import org.squeryl.adapters.OracleAdapter
import org.squeryl.PrimitiveTypeMode._
object Connectaroo extends App {
val database = Database(
driver = "oracle.jdbc.driver.OracleDriver",
package example
object Stereotypes {
val stereotypes = Seq(australia, newzealand, preston, liverpool, manchester)
def find(name: String): Either[String, Stereotype] = {
stereotypes
.find(stereotype => stereotype.names.exists(name.equalsIgnoreCase))
.toRight("Invalid Stereotype [%s]. Must be one of [%s]".format(name, allPossibleStereotypes))
}
@rhyskeepence
rhyskeepence / ExtraOptionMatchers.scala
Created October 17, 2012 16:47
specs2 beSomeMatching
package org.specs2.matcher
object ExtraOptionMatchers {
def beSomeMatching[T](someValueMatcher: =>Matcher[T]) = new Matcher[Option[T]] {
def apply[S <: Option[T]](value: Expectable[S]) = value.value match {
case Some(x) => matchSome(value)
case None => MatchFailure(
value.description + " is Some",
value.description + " is not Some",
value)