This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package zio.http | |
import zio.ZIO | |
sealed trait QueryParam[+A] { self => | |
def flatMap[B](f: A => QueryParam[B]):QueryParam[B] = QueryParam.FlatMap(self, f) | |
def map[B](f: A => B):QueryParam[B] = self.flatMap(a => QueryParam.succeed(f(a))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package zio.http | |
import zio.schema.Schema | |
import zio.schema.codec.JsonCodec | |
import java.net.URLDecoder | |
sealed trait Flash[+A] { self => | |
def flatMap[B](f: A => Flash[B]):Flash[B] = Flash.FlatMap(self, f) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cats.effect._ | |
import cats.implicits._ | |
import cats.data.State | |
import cats.data.OptionT | |
import cats.Functor | |
import cats.data.EitherT | |
import cats.kernel.Order | |
object Test extends IOApp { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##################################################################### | |
# 1. the input for the script at (2) -- e.g. from a database query | |
##################################################################### | |
# | |
# client_addr | count | |
#----------------+------- | |
# 172.217.16.35 | 45 | |
# | 1 | |
# 62.153.159.92 | 15 | |
# 217.72.219.144 | 24 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mobidat.wp2.missionserviceImpl; | |
import android.graphics.Bitmap; | |
import android.graphics.BitmapFactory; | |
import android.location.Location; | |
import android.support.annotation.Nullable; | |
import android.util.Log; | |
import com.mobidat.dao.IDaoMission; | |
import com.mobidat.dao.IDaoMissionData; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// the highlevel validation combinators reside at the bottom of this gist e.g. "def crown" or "def trunk" | |
protected object Validation { | |
sealed abstract class VRes[+A] | |
case class Vok[+A](get:A) extends VRes[A] | |
case class Verr(err:String) extends VRes[Nothing] | |
type V[+A] = TextView => VRes[A] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. combinator library for transforming and combining sql results to query result models | |
// 2. usage of library resides at the bottom of this gist | |
package object mapping { | |
type Mapper[+A] = String => A | |
type ToValueClass[+A] = Long => A |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sendPdf(htmlContent: String, filename: String) = { | |
val os = new java.io.ByteArrayOutputStream | |
val renderer = new ITextRenderer | |
renderer.setDocumentFromString(htmlContent) | |
renderer.layout | |
renderer.createPDF(os) | |
val bytes = os.toByteArray() | |
os.flush() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ConsoleImage | |
def initialize(m, n) | |
@m = m | |
@n = n | |
@colors = Array.new(m * n) | |
clear | |
end | |
def clear |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include Java | |
include_class "java.util.ArrayList" | |
list = ArrayList.new | |
block = Proc.new do | |
add "entry 1" | |
add "entry 2" | |
end | |
list.instance_eval &block | |
pp list.get(1) |
NewerOlder