Skip to content

Instantly share code, notes, and snippets.

View nightscape's full-sized avatar

Martin Mauch nightscape

  • Regensburg, Germany
  • 04:07 (UTC +02:00)
View GitHub Profile
class ParentType(val id: Long)
class ChildType
class ChildTypeBatchApi {
fun load(keys: List<Long>): List<ChildType> = mutableListOf()
}
val childTypeBatchApi = ChildTypeBatchApi()
// Example BatchLoader
var batchLoader: BatchLoader<Long, ChildType> = BatchLoader { keys ->
@gvolpe
gvolpe / di-in-fp.md
Last active September 16, 2024 07:18
Dependency Injection in Functional Programming

Dependency Injection in Functional Programming

There exist several DI frameworks / libraries in the Scala ecosystem. But the more functional code you write the more you'll realize there's no need to use any of them.

A few of the most claimed benefits are the following:

  • Dependency Injection.
  • Life cycle management.
  • Dependency graph rewriting.

Kakmacs

Introduction

Setup

Dependencies

These aren’t all dependencies, but only the ones which isn’t loaded by my usual init-file.

@StephenSorriaux
StephenSorriaux / install-kubernetes-archlinux.md
Created October 25, 2018 18:47
Install Kubernetes on bare-metal ArchLinux host

Installing Kubernetes on ArchLinux

Packages

pacman -S curl docker ebtables ethtool wget unzip

Also cfssl is needed but available on AUR, using pacaur

pacaur -S cfssl
@hilios
hilios / FutureConcurrentEffect.scala
Last active April 2, 2019 14:44
Effect[Future]
import scala.concurrent.{Await, ExecutionContext, Future, Promise}
import cats.implicits._
import scala.concurrent.duration.Duration
import scala.util.{Failure, Success}
final case class FutureConcurrentEffect()(implicit ec: ExecutionContext) extends FutureEffect with ConcurrentEffect[Future] {
def start[A](fa: Future[A]): Future[Fiber[Future, A]] = Future.successful {
FutureFiber(fa)
}
package jp.rdlabo.capacitor.plugin.screenshotevent;
import com.getcapacitor.JSObject;
import com.getcapacitor.NativePlugin;
import com.getcapacitor.Plugin;
import com.getcapacitor.PluginCall;
import com.getcapacitor.PluginMethod;
import com.getcapacitor.util.HostMask;
import android.os.FileObserver;
@Giovix92
Giovix92 / Nord2Guides.md
Last active May 3, 2025 22:14
Nord 2 Community notes

Nord 2 Guides

Those guides are applicable to every Nord 2 model:

  • DN2101/IND
  • DN2103/EEA
  • DN2103/EEA PAC-MAN Edition

Summary

@anthonyjclark
anthonyjclark / helixish.js
Last active July 18, 2024 23:28
Custom bindings for DCsunset/vscode-modal-editor
// ----------------------------------------------------------------
// ▗▄▄▄▖ █
// ▐▛▀▀▘ ▐▌ ▀
// ▐▌ ▝█ █▘▐███ ▟█▙ ▐▙██▖▗▟██▖ ██ ▟█▙ ▐▙██▖▗▟██▖
// ▐███ ▐█▌ ▐▌ ▐▙▄▟▌▐▛ ▐▌▐▙▄▖▘ █ ▐▛ ▜▌▐▛ ▐▌▐▙▄▖▘
// ▐▌ ▗█▖ ▐▌ ▐▛▀▀▘▐▌ ▐▌ ▀▀█▖ █ ▐▌ ▐▌▐▌ ▐▌ ▀▀█▖
// ▐▙▄▄▖ ▟▀▙ ▐▙▄ ▝█▄▄▌▐▌ ▐▌▐▄▄▟▌▗▄█▄▖▝█▄█▘▐▌ ▐▌▐▄▄▟▌
// ▝▀▀▀▘▝▀ ▀▘ ▀▀ ▝▀▀ ▝▘ ▝▘ ▀▀▀ ▝▀▀▀▘ ▝▀▘ ▝▘ ▝▘ ▀▀▀
// ----------------------------------------------------------------
@jimsrc
jimsrc / gpt4_text_compression.md
Last active June 18, 2024 15:03
Minimizing the number of tokens usage to interact with GPT-4.

Overview

I just read this trick for text compression, in order to save tokens in subbsequent interactions during a long conversation, or in a subsequent long text to summarize.

SHORT VERSION:

It's useful to give a mapping between common words (or phrases) in a given long text that one intends to pass later. Then pass that long text to gpt-4 but encoded with such mapping. The idea is that the encoded version contains less tokens than the original text. There are several algorithms to identify frequent words or phrases inside a given text, such as NER, TF-IDF, part-of-speech (POS) tagging, etc.