Skip to content

Instantly share code, notes, and snippets.

@jsuereth
jsuereth / freer.scala
Last active October 26, 2022 14:19
Freer monad in scala, just toying around.
trait Functor[F[_]] {
def map[A, B](fa: F[A])(f: A => B): F[B]
}
trait Monad[F[_]] {
def apply[A](a: A): F[A]
def flatMap[A,B](fa: F[A])(f: A => F[B]): F[B]
}
sealed trait FFree[G[x], A] {}
case class FPure[G[x], A](data: A) extends FFree[G, A]
@jsuereth
jsuereth / semconv-nextsteps.md
Created October 5, 2022 16:47
Semantic Conventions - Forward Progress proposal

Problem

When investigating #2775, the TC decided to look into expanding the notion of Resource to include Entity.

During this discussion, we identified a lot of hard, challenging problems OpenTelemetry must tackle going forward, including:

  • Telemetry Identity evolving as "scope" increases. E.g. a Jaeger instance running in a single k8s cluster may not need to know the identity of the k8s cluster, as there's only one. However, a datastore spanning mulitple k8s clusters WILL need this information.
  • A simple "Service" model for OpenTelemetry SDKs (e.g. requiring service.name attribute) works in the short run, but beings to struggle in large distributed systems.
  • Defining a consistent guideline on what resource / entity means in practice, how to choose one and what our Entity <-> Signal modelling needs to look like in the long run.
@jsuereth
jsuereth / sbt-build-structure.md
Created June 15, 2015 14:56
Sbt build structure

Here's a short little guide to sbt's build structure.

First off, the key you need to investigate how sbt is building things. Here's a snippet from a build.sbt:

import sbt.Keys._
val bs: sbt.BuildStructure = buildStructure.value

This will give you all the gory details of our build (or builds, as is the case).

@jsuereth
jsuereth / ExampleSocketServer.scala
Created May 14, 2011 02:14
IterateeNonBlockingEchoServer
package scalaz.example.nio
import scalaz._
import concurrent.Promise
import effects.IO
import nio.sockets._
import nio.Channels._
import Scalaz._
import iteratees._
import java.nio.channels.SocketChannel
@jsuereth
jsuereth / download.bash
Created June 20, 2013 16:37
scalawags youtube -> wav download script
#!/bin/bash
if test "$#" != "2"; then
echo "Usage: $0 <url> <directory>"
exit 1
fi
url=$1
directory=$2
@jsuereth
jsuereth / CanSink.scala
Last active August 29, 2016 01:04
Staged Sinks (just a lame cofree).
trait CanSink[First, Now, Final, To] {
def result[E](in: StagedSink[First, E, Final], f: E => Now): To
def result2[E](in: StagedSink[First, E, Final], f: E => TraversableOnce[Now]): To
}
trait LowPrioritySinkImplicits {
implicit def sinkChain[First, E, Final]: CanSink[First, E, Final, StagedSink[First, E, Final]] = ???
}
object CanSink extends LowPrioritySinkImplicits {
implicit def finalSink[First, E]: CanSink[First, E,E, Sink[First]] = ???
}
@jsuereth
jsuereth / Bintray-For-Plugins.rst
Last active December 21, 2015 22:49
Bintray plugin documentation

Bintray For Plugins

This is currently in Beta mode.

sbt hosts their community plugin repository on Bintray. Bintray is a repository hosting site, similar to github, which allows users to contribute their own plugins, while sbt can aggregate them together in a common repository.

This document walks you through the means to create your own repository for hosting your sbt plugins and then linking them into the sbt shared repository. This will make your plugins available for all sbt users without additonal configuration (besides declaring a dependency on your plugin).

@jsuereth
jsuereth / predicitons.md
Created December 21, 2015 12:47
Scalawags #37 - Xmas special predictions
  • @predef1 - Scala will enter page 2 of Stackoverflow tags and surpass Perl. It'll crack 10K Reddit subscribers and pass Clojure
  • @extempore2 - alpaca exports will be up at least 3%
  • @mariussoutier - My other prediction is that Scala.JS + React Native will take off.
@jsuereth
jsuereth / .create-travis-cache.sh
Last active December 7, 2015 14:55
Travis CI caching hackeries
#!/bin/bash
# very simple script to generate a tar of dependencies in ivy cache for extraction in TravisCI.
# usage: ./.create-travis-cache.sh <sbt-command>*
#
# By Default this will run `sbt update` with a clean cache directory and
# generate a .tar.bz2 with all the artifacts. This file can be pushed into
# dropbox and expanded in your TravisCI server later for a slight improvement
# in resolution times.
@jsuereth
jsuereth / parse.scala
Created September 11, 2012 18:36
Parse a string to a tree
scala> import reflect.runtime.currentMirror
import reflect.runtime.currentMirror
scala> import scala.tools.reflect.ToolBox
import scala.tools.reflect.ToolBox
scala> currentMirror.mkToolBox()
res5: scala.tools.reflect.ToolBox[reflect.runtime.universe.type] = scala.tools.reflect.ToolBoxFactory$ToolBoxImpl@2288e718
scala> res5.parseExpr("def x = 'c'")