Instantly share code, notes, and snippets.

View devchatter.glsl
// For DevChatter
// License: CC0 - https://creativecommons.org/share-your-work/public-domain/cc0/
#define TOLERANCE 0.0001
#define MAX_RAY_LENGTH 16.0
#define MAX_BOUNCES 4
#define MAX_RAY_MARCHES 48
#define PI 3.141592654
#define TAU (2.0*PI)
View nnug.glsl
// Based of https://www.shadertoy.com/view/4sX3Rn
// Raymarching explained: http://9bitscience.blogspot.com/2013/07/raymarching-distance-fields_14.html
// Distance Estimators: www.iquilezles.org/www/articles/distfunctions/distfunctions.htm
#define TOLERANCE 0.001
#define MAX_RAY_LENGTH 32.0
#define FADE_RAY_LENGTH 16.0
#define MAX_RAY_MARCHES 128
View Parser.cs
namespace CsParsec
{
using System;
using System.Collections.Generic;
using System.Text;
public class Unit
{
private Unit()
{
View on-tail-recursion.md

On the topic of tail calls in .NET

Let's say you have implemented a small data pipeline library to replace LINQ.

module TrivialStream =
  type Receiver<'T> = 'T            -> unit
  type Stream<'T>   = Receiver<'T>  -> unit

  module Details =
View MTransform2.scala
import java.util.concurrent.atomic.AtomicInteger
import scala.reflect._
import scala.util.control._
trait Default[+T] {
val zero: T
}
object Default {
View MTransform.scala
import scala.reflect._
sealed trait TransformResult[+T]
case class TransformContext(path: List[String]) {
def append(p: String) = TransformContext(p::path)
override def toString = path.reverse.mkString(".")
}
View Result.java
import java.util.function.Function;
public abstract class Result<T> {
public static <U> Result<U> good(U v) {
return new Good<U>(v);
}
public static <U> Result<U> bad(String message) {
return new Bad<U>(message);
View Prism.fs
module StackOverFlow =
type [<Struct>] Prism<'T, 'U> = Prism of ('T -> 'U option)*('T -> 'U -> 'T)
module Prism =
module Details =
let inline empty< ^T when ^T : (static member empty: ^T) > () =
(^T : (static member empty: ^T) ())
let inline apply1< ^T, ^U when ^T : (static member apply: ^U -> ^T) > t =
(^T : (static member apply: ^U -> ^T) t)
let inline unapply1< ^T, ^U when ^T : (static member unapply: ^T -> ^U) > u =
View Parser.fs
type [<Struct>] Maybe<'T> =
| Just of 'T
| Nothing
and 'T maybe = Maybe<'T>
module FsTokenParser =
type [<Struct>] Position =
{
Column : int
Row : int