Skip to content

Instantly share code, notes, and snippets.

@dacr
dacr / tapir-zio-dynamic-api.sc
Last active May 25, 2024 08:39
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/c2f6303cd7dc5719bb533664fce41e5f60fbc5db
// 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
@carlosedp
carlosedp / Readme.md
Last active May 3, 2023 19:13
Find plugin updates for Scala cli, mill build tool and ammonite scripts

This is a Scala script to check for Mill build plugin and scala-cli lib updates. The plugin requires scala-cli.

Run directly from the gist with:

scala-cli https://gist.github.com/carlosedp/c3ea2814ac5392051a562e95c1298239/raw/checkdeps.sc

Or download the script, make it executable and run as:

What follows are some of my (very) rough thoughts on what we can and should do with respect to CPS transformation in Scala at the language level. I'll try to start with some motivation behind my thinking, as well as some rambling observations on the nature of the problem space, but don't expect too much coherence here. :-)

The Problem

Async programming is hard.

Okay let's actually be more specific than that. High-performance I/O is hard. Signal multiplexing is a powerful technique for achieving high(er) performance I/O, particularly network I/O, but the tradeoff is that, in order to utilize it, the user-space programming model must allow for suspension and resumption of sequential continuations (often called "fibers" or "coroutines"). Achieving this type of programming model without significant tradeoffs in usability is what is exceptionally hard.

If that wasn't bad enough though, these problems are inextricably conflated with another set of problem spaces which are, themselves, very difficult. In

@julien-truffaut
julien-truffaut / Monocle3.MD
Last active July 7, 2022 09:31
Monocle 3.x

We recently started the development of the next major version of Monocle, Monocle 3.x. In this post, I would like to explain our objectives and discuss some of the changes we intend to make.

Monocle 3.x will be a complete rewrite. It doesn't mean we will change everything, but we will question every aspect of the library: optics encoding, API, names, dependencies, etc. We defined the following objectives to help us make trade-offs in the new design:

  1. User-friendly interface. A user should be able to perform the most common actions without requiring in-depth knowledge of optics.
  2. Correctness. Optics follow certain essential principles. Those rules may not be intuitive, but without them, optics would not be a useful abstraction. The API should make it easy to follow those principles and avoid any undesired behaviours.
  3. Focus on Scala 3. We should design the API and include features such as they are suitable for Scala 3.
  4. Performance. Optics are slower than handwritten equivalent code
@dacr
dacr / index.md
Last active June 28, 2024 23:14
David's programming examples knowledge base / published by https://github.com/dacr/code-examples-manager #fecafeca-feca-feca-feca-fecafecafeca/207c50c8da525812363701a12ee72e8eb9151628

David's programming examples knowledge base

akka-pekko

@abeln
abeln / scala-explicit-nulls.md
Last active December 18, 2020 13:57
Scala with Explicit Nulls
@fbaierl
fbaierl / Format
Created October 25, 2018 07:59
Scala.js string interpolation like java.text.MessageFormat
object Format {
/**
* String interpolation [[java.text.MessageFormat]] style:
* {{{
* format("{1} {0}", "world", "hello") // result: "hello world"
* format("{0} + {1} = {2}", 1, 2, "three") // result: "1 + 2 = three"
* format("{0} + {0} = {0}", 0) // throws MissingFormatArgumentException
* }}}
* @return
@MeNiks
MeNiks / RealPathUtil.kt
Last active July 10, 2024 08:57
Kotlin code to get real path / sd card path from intent data while browsing file.
import android.annotation.SuppressLint
import android.content.ContentUris
import android.content.Context
import android.content.CursorLoader
import android.database.Cursor
import android.net.Uri
import android.os.Build
import android.os.Environment
import android.provider.DocumentsContract
import android.provider.MediaStore
@scalway
scalway / Bootstrap3.scala
Last active May 19, 2018 19:06
bootstrap3 scalatags pug'like heler.
/**
* Copyright 2017 Scalway Krzysztof Pecyna
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
@calippo
calippo / Mappable.scala
Created July 27, 2016 21:51
Convert case class to map in shapeless
object Mappable {
implicit class ToMapOps[A](val a: A) extends AnyVal {
import shapeless._
import ops.record._
def toMap[L <: HList](implicit
gen: LabelledGeneric.Aux[A, L],
tmr: ToMap[L]
): Map[String, Any] = {
val m: Map[tmr.Key, tmr.Value] = tmr(gen.to(a))