Skip to content

Instantly share code, notes, and snippets.

ppurang /
Last active February 18, 2024 04:11 — forked from keynmol/
Scala example of using htmx
package webm
import scala.collection.{GenMap, GenTraversableOnce}
import scala.language.experimental.macros
import scala.reflect.macros.blackbox
import scala.scalajs.js
import scala.scalajs.js.|
object FunctionMacro {
milessabin / trait-instances.scala
Last active June 23, 2020 08:40
Constraining a trait type parameter via a super class type parameter constraint
import cats.{Applicative, Monad}
import cats.implicits._
abstract class Foo[+M[_[_]], F[_]](implicit val M: M[F])
trait Bar[F[_]] extends Foo[Applicative, F] { def bar = Applicative[F] }
trait Baz[F[_]] extends Foo[Monad, F] { def baz = Monad[F] }
class User[F[_]: Monad] extends Bar[F] with Baz[F]
object Test {
gijsbotje / display-utilities.csv
Last active January 22, 2021 04:15
bootstrap v4 migration table for hidden-* and visible-*
Old New
.hidden .d-none
.hidden-xs-up .d-none
.hidden-xs .d-none .d-sm-[value]
.visible-xs .d-sm-none
.visible-xs-block .d-block .d-sm-none
.visible-xs-inline .d-inline .d-sm-none
.visible-xs-inline-block .d-inline-block .d-sm-none
.hidden-xs-down .d-none .d-sm-[value]
.hidden-sm .d-sm-none .d-md-[value]
nafg / toVDOM.scala
Last active November 20, 2022 02:53
HTML to scalajs-react VDOM
#!/usr/bin/env amm
import scala.xml.{Elem, Node, Text, XML}
def quoteString(s: String) =
'"' +
s.replace("\n", "\\n").replace("\"", "\\\"") +
terlar /
Last active January 31, 2021 04:11
Kubernetes fish completions
# kubernetes - is an open source system for managing containerized
# applications across multiple hosts, providing basic mechanisms for
# deployment, maintenance, and scaling of applications.
# See:
function __kubectl_no_command
set -l cmd (commandline -poc)
if not set -q cmd[2]
return 0
adriaanm / nightly.sbt
Created December 11, 2016 19:13
How to use the latest Scala nightly build from your sbt build by @SethTisue
// originally by @SethTisue, see
resolvers += "nightlies" at ""
scalaVersion := {
val propsUrl = new URL("*view*/")
val props = new java.util.Properties
scalaBinaryVersion := "2.12"
djspiewak /
Last active November 28, 2023 15:03
Scala Collections Proposal

Collections Redesign Proposal

I'm going to start off by motivating what I'm doing here. And I want to be clear that I'm not "dissing" the existing collections implementation or anything as unproductively negative as that. It was a really good experiment, it was a huge step forward given what we knew back in 2.8, but now it's time to learn from that experiment and do better. This proposal uses what I believe are the lessons we can learn about what worked, what didn't work, and what is and isn't important about collections in Scala.

This is going to start out sounding really negative and pervasively dismissive, but bear with me! There's a point to all my ranting. I want to be really clear about my motivations for the proposal being the way that it is.


Generic Interfaces

daniel-trinh / prettyPrint.scala
Last active November 11, 2016 09:39
Pretty Print method for formatting case class (as a string input)
def pp(tree: String, indentSize: Int = 2): String = {
var indentLevel = 0
var outputTree = ""
tree foreach { char => char match {
case '(' =>
indentLevel += 1
outputTree += char.toString+'\n'+indents
case ')' =>
indentLevel -= 1
outputTree += "\n" + indents + char.toString
atenni /
Last active April 24, 2024 01:36
How to permalink to a gist's raw file

Problem: When linking to the raw version of a gist, the link changes with each revision.


To return the first file from a gist:[gist_user]/[gist_id]/raw/

To get a file from multi–file gist:[gist_user]/[gist_id]/raw/[file_name]