Skip to content

Instantly share code, notes, and snippets.

@scalway
scalway / main.scala
Created June 23, 2025 08:09 — forked from kubukoz/main.scala
http4s + scalatags + htmx + fs2/SSE
//> using scala 3.7
//> using dep org.http4s::http4s-ember-server:0.23.30
//> using dep org.http4s::http4s-dsl:0.23.30
//> using dep org.http4s::http4s-scalatags::0.25.2
//> using option -Wunused:all
import scalatags.Text.all.*
import cats.effect.*
import fs2.Stream
import org.http4s.*
import org.http4s.dsl.io.*
@scalway
scalway / tapir-zio-dynamic-api.sc
Created April 15, 2024 10:36 — forked from dacr/tapir-zio-dynamic-api.sc
An API to rule them all - to define or customize new API at runtime / published by https://github.com/dacr/code-examples-manager #dbccfc26-c532-4aa9-b3cd-eb13cbaa5370/764dc89bc8faf304aa6e1a5394904ae8cca6d0e4
// summary : An API to rule them all - to define or customize new API at runtime
// keywords : scala, zio, tapir, http, zhttp, stateful, state, @testable, @exclusive
// publish : gist
// authors : David Crosson
// license : Apache NON-AI License Version 2.0 (https://raw.githubusercontent.com/non-ai-licenses/non-ai-licenses/main/NON-AI-APACHE2)
// id : dbccfc26-c532-4aa9-b3cd-eb13cbaa5370
// created-on : 2023-12-08T18:45:32+01:00
// managed-by : https://github.com/dacr/code-examples-manager
// run-with : scala-cli $file
// test-with : curl -L http://127.0.0.1:8080/hello/david
@scalway
scalway / web-audio-fetch-stream.js
Last active January 31, 2019 11:13 — forked from revolunet/web-audio-fetch-stream.js
Web Audio streaming with fetch API
//
// loads remote file using fetch() streams and "pipe" it to webaudio API
// remote file must have CORS enabled if on another domain
//
// mostly from http://stackoverflow.com/questions/20475982/choppy-inaudible-playback-with-chunked-audio-through-web-audio-api
//
function play(url) {
var context = new (window.AudioContext || window.webkitAudioContext)();
@scalway
scalway / play.scala
Last active April 18, 2017 08:18 — forked from lihaoyi/play.scala
play.scala
/**
* Single-file play framework application! Make sure everything
* works, as this is the test case that un-earthed #371
*/
import $ivy.`com.typesafe.play::play:2.5.14`
import $ivy.`com.typesafe.play::play-netty-server:2.5.14`
import $ivy.`org.scalaj::scalaj-http:2.2.1`
import play.core.server._, play.api.routing.sird._, play.api.mvc._
import scalaj.http._