Skip to content

Instantly share code, notes, and snippets.

Avatar

Ajay Chandran ajaychandran

  • Cochin, India
View GitHub Profile
@ajaychandran
ajaychandran / streaming.scala
Last active Jun 5, 2020
Alternative encoding for ZIO stream abstractions
View streaming.scala
package zio
import java.io.{ InputStream, OutputStream }
import java.nio.charset.StandardCharsets
object streaming {
type Pull[-R, +E, +I] = ZIO[R, Option[E], I]
type Push[-R, +E, -I] = I => ZIO[R, E, Unit]
type Step[-R, +E, -I, +O] = I => ZIO[R, E, O]
View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@ajaychandran
ajaychandran / WindowTest.java
Created Feb 1, 2016
Test for com.badlogic.gdx.backends.lwjgl3.Lwjgl3Window lifecycle
View WindowTest.java
package gdx;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.backends.lwjgl3.*;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
View FinalizerCancelable.scala
final class FinalizerCancelable(finalizer: () => Unit) extends BooleanCancelable {
private val state = new AtomicReference(FinalizerCancelable.State())
def isCanceled: Boolean = state.get().canceled
def acquire(): BooleanCancelable = {
state.get() match {
case FinalizerCancelable.State(true, _) => BooleanCancelable.alreadyCanceled
case s => state.compareAndSet(s, s.copy(active = s.active + 1)) match {
case false => acquire()
@ajaychandran
ajaychandran / DelimitedCodec.scala
Last active Dec 23, 2016
scodec: DelimitedCodec
View DelimitedCodec.scala
package scodec.codecs
import scala.language.higherKinds
import scodec._
import scodec.bits.BitVector
object DelimitedCodec {
/**
@ajaychandran
ajaychandran / ChecksumCodec.scala
Last active Aug 29, 2015
scodec: FilterCodec
View ChecksumCodec.scala
package scodec.codecs
import scodec._
import scodec.bits.{ByteVector, BitVector}
/**
* ChecksumCodec
*/
object ChecksumCodec {
You can’t perform that action at this time.