This file contains hidden or 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 React, { FC, useLayoutEffect, CSSProperties, useEffect, useRef, useMemo, useCallback, useState } from 'react'; | |
import { createPopper, VirtualElement, Options, Instance } from '@popperjs/core'; | |
/** | |
* Helper hooks | |
*/ | |
function usePrevious<T>(value: T): T | undefined { | |
const ref = useRef<T>(); | |
useEffect(() => { |
This file contains hidden or 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 { ApolloClient, QueryOptions, MutationOptions } from 'apollo-client'; | |
import { DocumentNode } from 'graphql'; | |
import { getSdk, Requester } from '.generated/schema-typedefs'; | |
import { ApolloRequestError } from './ApolloRequestError'; | |
export type ApolloRequesterOptions<V, R> = | |
| Omit<QueryOptions<V>, 'variables' | 'query'> | |
| Omit<MutationOptions<R, V>, 'variables' | 'mutation'>; |
This file contains hidden or 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 * as fs from 'fs'; | |
import * as _path from 'path'; | |
export const normalizeElectronPath = (s: string): string => { | |
const alp = s.replace(/app\.asar(?!\.unpacked)/g, 'app.asar.unpacked'); | |
let inAsarUnpacked = false; | |
if (fs.existsSync(alp)) { | |
inAsarUnpacked = true; |
This file contains hidden or 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 monix.execution.Ack.{Continue, Stop} | |
import monix.execution.{Ack, Scheduler} | |
import monix.reactive.Observable.Operator | |
import monix.reactive.observers.Subscriber | |
import scala.concurrent.{Future, Promise} | |
class ElasticBufferOperator[A](size: Int) extends Operator[A, A] { | |
override def apply(out: Subscriber[A]): Subscriber[A] = new Subscriber[A] { | |
private[this] var buffer: List[A] = Nil |
This file contains hidden or 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 scala.collection.mutable.ArrayBuffer | |
import scala.util.Try | |
class FrameReader[A]( | |
before: Int, | |
after: Int, | |
onNextFrame: (MovingFrame[A], Boolean) => Unit | |
) { | |
private val b: ArrayBuffer[A] = ArrayBuffer() | |
private var cf: Option[MovingFrame[A]] = None |
This file contains hidden or 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 scala.collection.Map | |
import scala.reflect.ClassTag | |
final case class TypefullMapOps[K, V, M <: Map[_, _]](m: M)(implicit ev: M <:< Map[K, V]) { | |
def getT[A <: V : ClassTag](k: K): Option[A] = m.get(k) match { | |
case Some(x) => x match { | |
case v: A => Some(v) | |
case _ => throw new RuntimeException | |
} | |
case _ => None |
This file contains hidden or 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 shapeless.labelled._ | |
import shapeless.ops.hlist | |
import shapeless.{HList, HNil, LabelledGeneric} | |
trait Updater[A, B] { | |
def apply(a: A, b: B): A | |
} | |
object Updater { | |
def apply[A, B](implicit updater: Updater[A, B]): Updater[A, B] = updater |
This file contains hidden or 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
// I have no experience with Scalaz, but I believe that Scalaz's Kleisli and the one of Cats are quite similar | |
import cats.Id | |
import cats.data.Kleisli | |
import cats.implicits._ | |
case class User(id: Int, name: String, active: Boolean) | |
trait UserService { | |
type DeactivateConfigT |