Skip to content

Instantly share code, notes, and snippets.

113
@lemonxah
lemonxah / vips.json
Last active November 19, 2026 00:03
koitoys
[Ripple]
MasterNamix
Roy-Boy6911
worsie Foil
Zell 8708
[Koi Keeper]
Kilikina
LdsJonBoy
lemͥonͣxͫah
VivianFoxglove

Keybase proof

I hereby claim:

  • I am lemonxah on github.
  • I am lemonxah (https://keybase.io/lemonxah) on keybase.
  • I have a public key ASBPKUv1ZJq8dx5ecT66xbt_Yy_QZYRv5OQpp3sH6LCHCgo

To claim this, I am signing this object:

object ops {
implicit class SemigroupOps[F](val self: F)(implicit val F: Semigroup[F]) {
def |+|(other: => F): F = F.combine(self, other)
}
}
import ops._
trait Semigroup[A] {
@lemonxah
lemonxah / Option.cs
Created August 15, 2016 12:55
Option Monad example for C#
using System;
namespace Functional {
public class GetOnEmptyOptionException : Exception { }
public interface Some { }
public interface None { }
public abstract class Option {
public static bool operator ==(Option a, Option b) =>
!ReferenceEquals(a, null) && !ReferenceEquals(b, null) && a.Equals(b);
public static bool operator !=(Option a, Option b) => !(a == b);
public static Option<A> None<A>() => new None<A>();
package com.fullfacing.queue
import java.io.{ByteArrayOutputStream, ByteArrayInputStream}
import java.util.Properties
import java.util.concurrent.ConcurrentHashMap
import java.util.zip._
import akka.actor.ActorRef
import com.fullfacing.framework.Security
import com.fullfacing.message.{Response, Request, Retry}
trait ModelWithId[A] { def copy(id: Option[String]):A }
trait Model { def deleted: Boolean; def id: Option[String] }
trait DAO[A <: Model, B, C, Q] {
def interpreter(q: Query, empty: Q): Throwable \/ Q
def insert(a: A)(implicit m: Mappable[A, B, C], ev: A ⇒ ModelWithId[A]): A
def insertRaw(b: B)
def list(skip: Int = 0, limit: Int = 0)(implicit m: Mappable[A, B, C]): Vector[A]
def filter(query: Query, skip: Int = 0, limit: Int = 0)(implicit m: Mappable[A, B, C]): Vector[A]
def headOption(query: Query)(implicit m: Mappable[A, B, C]): Option[A]
class MongoDAO[A <: Model](coll: MongoCollection) extends DAO[A, DBObject, DBObject, DBObject] {
import MongoInterpreter._
def interpreter(q: Query, empty: DBObject = new MongoDBObject()): Option[DBObject] = {
try { Some(implicitly[Writer[Query, DBObject]].write(q)) } catch { case e: Exception => None }
}
override def list(limit: Int = 0)(implicit m: Mappable[A, DBObject, DBObject]): Vector[A] = {
coll.find().limit(limit).toVector.map(m.fromDBType)
}
package com.fullfacing.test
import java.text.DecimalFormat
import com.fullfacing.network.{TcpClient, Execution}
import org.slf4j.LoggerFactory
import scala.concurrent.{Await, Promise, ExecutionContext, Future}
import scala.language.implicitConversions