Skip to content

Instantly share code, notes, and snippets.

@ahmadmo
ahmadmo / srt2vocab.kt
Last active August 21, 2020 18:26
Builds vocabulary from a set of english movie subtitles (.srt files)
import java.nio.charset.Charset
import java.nio.charset.StandardCharsets
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
import java.nio.file.StandardOpenOption
import java.util.regex.Pattern
import kotlin.math.ln
import kotlin.streams.asSequence
@ahmadmo
ahmadmo / Channel.scala
Last active October 17, 2018 06:39
Go Channels in Scala
import Channel.{Core, Message}
object Channel {
private case class Message[A](value: A, last: Boolean)
private object Message {
private val LAST = Message(null, last = true)
def last[A]: Message[A] = LAST.asInstanceOf[Message[A]]
}