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
generated Aug 11, 2025 14:49:29 | |
system "Aurora (Version: latest-42.20250810.1 / FROM Fedora Kinoite 42)" Linux | |
6.15.9-201.fc42.x86_64 x86_64 pgtk | |
emacs 30.1 EMACSDIR=~/.config/emacs/ EMACS=/usr/bin/emacs | |
doom 3.0.0-pre PROFILE=_default@0 HEAD -> master 751ac613 2025-08-11 02:27:38 | |
+0200 ~/.config/doom/ | |
shell /bin/bash | |
features ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG LIBOTF | |
LIBSELINUX LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER | |
PGTK PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS |
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 setupViewEdit from "@lib/view_edit.tsx"; | |
import H2 from "@components/H2.tsx"; | |
import type model from "@/model.ts"; | |
export default function Prompt(props: any) { | |
const [editMode, prompt, EditButton] = setupViewEdit<model.Prompt>(`/api/prompt/${props.id}`, data); | |
function data(): string { | |
const text: HTMLInputElement = document.getElementById("text"); |
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
object Scrabble extends App { | |
import scala.io.Source | |
val words = Source.fromFile("/usr/share/dict/words").getLines.toStream | |
val primes: Stream[Int] = | |
2 #:: Stream.from(3, 2).filter(i => primes.takeWhile(p => p * p <= i).forall(p => i % p > 0)) | |
val letterCounts = words.foldLeft(Map.empty[Char, Long].withDefault(_ => 0L)) { case (counts, word) => | |
word.toLowerCase.filter(_.isLetter).foldLeft(counts) { case (counts2, c) => |
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
object EveRouting extends App { | |
import EveMap.{SolarSystem, SolarSystemJump, loadSystems, loadJumps} | |
import scalax.collection.immutable.Graph | |
import scalax.collection.GraphPredef._, scalax.collection.GraphEdge._ | |
import scalax.collection.edge.Implicits._ | |
// Load the EVE map | |
val systems: List[SolarSystem] = loadSystems | |
val jumps: List[SolarSystemJump] = loadJumps |
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
object Dijkstra { | |
case class Edge[T](node: T, cost: Double) | |
case class Path[T](nodes: List[T], cost: Double) | |
type Graph[T] = Map[T, List[Edge[T]]] | |
def dijkstra[T](graph: Graph[T], paths: List[Path[T]], dest: T, visited: Set[T]): Option[Path[T]] = { | |
def unvisitedPaths(node: T, path: Path[T]): List[Path[T]] = | |
graph(node).filterNot(edge => visited.contains(edge.node)) | |
.map(edge => Path(edge.node +: path.nodes, path.cost + edge.cost)) |
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
trait EntityBase { | |
def id: String | |
} | |
trait Repository { | |
type Entity <: EntityBase | |
def get(id: String): Option[Entity] | |
} |
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
object Primes extends App { | |
val primes: Stream[Int] = | |
2 #:: Stream.from(3, 2).filter(i => primes.takeWhile(p => p * p <= i).forall(p => i % p > 0)) | |
println(primes.take(10).toList) // List(2, 3, 5, 7, 11, 13, 17, 19, 23, 29) | |
} |
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
def titleScore(titleWords: Array[String], sentence: Array[String]) = | |
sentence.count(w => !stopWords.contains(w) && titleWords.contains(w)) / titleWords.size.toDouble |
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
val mimeTypeIsPdf = candidate.mimeType match { | |
case None => false | |
case Some(candidateMimeType) => candidateMimeType.equalsIgnoreCase(MimeTypes.PDF) | |
} | |
val urlHasPdfExtension = candidate.uri match { | |
case None => true | |
LowerCase().endsWith(FileExtensions.PDF) | |
} |
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
case class Parameters(userId: UserId, | |
device: Option[Device] = None, | |
additionalParameters: Map[String, Iterable[String]] = Map.empty) { | |
def getParameter[T](name: String, default: T)(implicit converter: (Iterable[String]) => Option[T]): T = { | |
additionalParameters.get(name).flatMap(converter).getOrElse(default) | |
} | |
} | |
object Parameters { | |
implicit val strings2Int = (values: Iterable[String]) => { |
NewerOlder