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 / 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:
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 {
#!/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) = {
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]
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._

CSS in Korolev

val myClass = CssClassDecl("myClass")

val myCss1: CssDecl = css"""
  /* Any valid CSS */
  .$myClass {
    ...
 }
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()
@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
@fomkin
fomkin / korolev-dynamic-template.scala
Created January 12, 2018 08:35
Generate Levsha nodes from HTML
import scala.xml.XML
import scala.xml.{Node => XmlNode}
import levsha.Document.Node
def nodeFromHtml[T](html: String): Node[T] = Node[T] { rc =>
val document = XML.loadString(html)
def aux(node: XmlNode): Unit = node match {
case scala.xml.Text(text) =>
rc.addTextNode(text)
case _ =>
val users = Vector(
"@demyanam1",
"@CipHuK",
"@sergey_samoylov",
"@ermakovolegs",
"@wouzar",
"@_sashashakun",
"@myBloodyScala",
"@lmnet89",
"@laughedelic",