Skip to content

Instantly share code, notes, and snippets.

@pathikrit
pathikrit / Not.scala
Last active August 3, 2016 16:17
Simple Negation Types in Scala
trait NotSubTypeOf[A, B] // encoding to capture A is not a subtype of B
// Note: We can use infix notation to write `A NotSubTypeOf B` instead of `NotSubTypeOf[A, B]`
// evidence for any two arbitrary types A and B, A is not a subtype of B
implicit def isSub[A, B]: A NotSubTypeOf B = null
// define ambigous implicits to trigger compile error in case A is a subtype of B (or A =:= B)
implicit def iSubAmbig1[A, B >: A]: A NotSubTypeOf B = null
implicit def iSubAmbig2[A, B >: A]: A NotSubTypeOf B = null

Provisional benchmarks of AST-free serialization puts my WIP branch of uPickle about ~40% faster than circe on my current set of ad-hoc benchmarks, if the encoders/decoders are cached (bigger numbers is better)

playJson Read 2761067
playJson Write 3412630
circe Read 6005895
circe Write 5205007
upickleDefault Read 4543628
upickleDefault Write 3814459
upickleLegacy Read 8393416
@Odomontois
Odomontois / callByName.scala
Last active October 18, 2018 14:57
Поправь так, чтобы работало
def fix[A](f: A => A): A = f(fix(f))
val fib = fix[Int => Int]( recur => n =>
if (n <= 1) 1
else recur(n - 1) + recur(n - 2))
@fanf
fanf / TestSocket.scala
Last active June 19, 2019 10:34
Example of an async socket handling multiple connection in ZIO + nio
import scalaz.nio._
import scalaz.nio.channels.{AsynchronousServerSocketChannel, AsynchronousSocketChannel}
import scalaz.zio.console._
import scalaz.zio._
object TestSocket extends App {
override def run(args: List[String]): ZIO[Environment, Nothing, Int] = {
theSocket.foldM(
@ikhoon
ikhoon / must-watch-talks.md
Last active April 14, 2020 10:46
Must watch talks - reddit /r/scala
@o9uzdev
o9uzdev / change-apple-osx-dock-size-from-apple-terminal.md
Created May 3, 2016 20:05
Change Apple OS X Dock size from Apple Terminal

Change Apple OS X Dock size from Apple Terminal

defaults write com.apple.dock tilesize -int 32; killall Dock

32 is icon size

@pathikrit
pathikrit / README.md
Last active April 24, 2021 17:36
My highly opinionated list of things needed to build an app in Scala
@rodneyrehm
rodneyrehm / gist:40e7946c0cff68a31cea
Last active November 7, 2022 09:11
Diagrams for Documentation

some tools for diagrams in software documentation

Diagrams For Documentation

Obvious Choices

ASCII

@Raynos
Raynos / x.md
Last active January 28, 2023 05:12
A list of minimal DOM libraries

DOM Libraries, the easy way

  • [by. Select elements][1]
  • [fragment. Turn HTML into DOMFragments][2]
  • [class-list. Cross browser HTML5 classList implementation][3]
  • [dom-walk. Traverse the DOM in tree order][4]
  • [xhr. Minimal cross browser, cross domain XHR][5]
  • [insert. Cross browser DOM4 insertion methods][6]
  • [to-array. Convert nodelists into arrays][7]
  • [hidden. Cross browser HTML5 hidden property][8]