Skip to content

Instantly share code, notes, and snippets.

View fomkin's full-sized avatar
🎯
Focusing

Aleksey Fomkin fomkin

🎯
Focusing
View GitHub Profile
@fomkin
fomkin / ppr.py
Last active November 24, 2019 14:59
def PPR(ref, hyp):
def find_words_before_commas(tokens):
words_before_commas = set()
for i, token in enumerate(tokens):
if token == "," and i > 0:
word = tokens[i-1]
words_before_commas.add(word)
return words_before_commas
import javax.crypto.Cipher;
import javax.crypto.Mac;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.security.MessageDigest;
import java.security.SecureRandom;
val message = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris commodo tempus pharetra. Sed non fermentum est, id volutpat risus. Sed lobortis et est at faucibus. Sed id leo porttitor, mollis felis id, rutrum est.";
val messageBytes = message.getBytes
val random = new SecureRandom()

CSS in Korolev

val myClass = CssClassDecl("myClass")

val myCss1: CssDecl = css"""
  /* Any valid CSS */
  .$myClass {
    ...
 }
import levsha.Document.Node
import org.fomkin.berzin.data.EncryptedText
import org.fomkin.berzin.web.view.SvgSymbols
import scala.language.higherKinds
object dropDownMenu {
import SvgSymbols._
import levsha.dsl._
trait MyService[F[_], S[_]] {
def getItem(id: Long): F[Item]
def getItemsByGroup(groupId): F[S[Item]]
}
class MyServiceImpl[F[_], S[_]](xa: Transactor[F]) extends MyService {
def getItemsByGroup(groupId): S[Item] = {
val stream = sql"select * from items where group = $groupId"
.query[Item]
#!/usr/local/bin/amm
import ammonite.ops._
import ammonite.ops.ImplicitWd._
val issue = "#(\\d+)".r
@main def main(
tag: String = %%("git", "describe", "--abbrev=0", "--tags").out.trim) = {
sealed trait MyList[+T]
case object MyNil extends MyList[Nothing]
case class MyCons[+T](value: T, tail: MyList[T]) extends MyList[T]
object MyList {
def empty[T]: MyList[T] = MyNil
implicit class MyListOps[A](val self: MyList[A]) extends AnyVal {
@fomkin
fomkin / docker-compose.yml
Created June 14, 2021 11:24
Docker-compose file to run Minecraft Java Server and Geyser MC
version: "3.0"
services:
minecraft:
image: itzg/minecraft-server
ports:
- "25565:25565"
volumes:
- "./data:/data"
environment: