Skip to content

Instantly share code, notes, and snippets.

View rleibman's full-sized avatar

Roberto Leibman rleibman

  • Las Vegas, NV, US, Earth, Milky Way, Local Cluster, Universe
  • 13:59 (UTC -12:00)
View GitHub Profile
/*
* Copyright 2020 Roberto Leibman
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
abstract class DBTFSuiteSetRunner() extends DefaultRunnableSpec {
val routes: Http[ApplicationLayer & ZEnv, Throwable, Request, Response[ApplicationLayer, Nothing]] = ???
val zapp: ZIO[ApplicationLayer,
Throwable,
Http[ApplicationLayer & ZEnv, Throwable, Request, Response[ApplicationLayer, Nothing]]] =
for {
_ <- log.info("Initializing routes")
yield routes
}
object ParentComponent {
val ctx: Context[ParentState] = React.createContext(ParentState())
case class ChildProps(childName: String, addMenuProvider: (() => Seq[(String, Callback)]) => Callback)
case class ChildState(childName: String, childString: String = "Child String", strings: Seq[String] = Seq.empty)
class ChildBackend($ : BackendScope[ChildProps, ChildState]) {
def childMenuProvider(s: ChildState)(): Seq[(String, Callback)] = {
val items = Seq(
(
@rleibman
rleibman / cookingSquants.scala
Created February 23, 2020 23:27
Cooking Squants: some squant based utilities to deal with cooking
import scala.util.matching.Regex
import squants.experimental.formatter.Formatter
import squants.experimental.unitgroups.UnitGroup
import squants.mass.{ Grams, Kilograms, Mass, Ounces, Pounds }
import squants.{ Dimensionless, DimensionlessUnit, Dozen, Each, Quantity, UnitOfMeasure }
package object cookingSquants {
private val mathContext: java.math.MathContext = new java.math.MathContext(3)
private val rangeRegex = "^([0-9\\s/./ ]+)(to|-)([0-9\\s/./ ]+)(.*)".r
private val singleNumRegex = "([0-9\\s/./]+)(.*)".r
package slickzio
import org.scalatest.{FlatSpec, Matchers}
import slick.basic.BasicBackend
import slick.dbio.DBIO
import slick.jdbc.{H2Profile, JdbcProfile}
import zio.internal.PlatformLive
import zio.{Runtime, ZIO}
class SlickZioSpec extends FlatSpec with Matchers {
@rleibman
rleibman / gist:f4e71cfcbafef8c45c12443a5a995bb7
Last active February 4, 2019 19:52
First pass at a scala.js react toastr
package net.leibman.react
import chandu0101.scalajs.react.components.semanticui.{ SuiIcon, SuiIconType }
import japgolly.scalajs.react.vdom.html_<^._
import japgolly.scalajs.react.{ BackendScope, Callback, Ref, ScalaComponent }
import scala.concurrent.duration.{ Duration, _ }
import scala.scalajs.js.timers._
object HorizontalPosition extends Enumeration {
/*
* Copyright 2018 Roberto Leibman
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
package components
import japgolly.scalajs.react.vdom.html_<^._
import japgolly.scalajs.react.Callback
import japgolly.scalajs.react.BackendScope
import japgolly.scalajs.react.ScalaComponent
import scala.collection.immutable
import scalacss.ProdDefaults._
import java.nio.ByteBuffer
import scala.util.Failure
import scala.util.Success
import scala.util.Try
import org.apache.commons.codec.binary.Hex
import org.jboss.netty.buffer.ChannelBuffers
import org.joda.time.DateTime
import org.joda.time.DateTimeZone