Skip to content

Instantly share code, notes, and snippets.

View fokot's full-sized avatar

František Kocun fokot

  • Bratislava, Slovakia
View GitHub Profile
@fokot
fokot / DateParsing.scala
Last active January 19, 2021 09:21
Scala date parsing with optional time and optional time zone
import java.time.format.{ DateTimeFormatterBuilder}
import java.time.format.DateTimeFormatter.{ISO_LOCAL_DATE, ISO_LOCAL_TIME}
import java.time.{LocalDate, LocalDateTime, OffsetDateTime, ZoneOffset}
import scala.util.{Success, Try}
object DateParsing extends App {
private val formatter = new DateTimeFormatterBuilder()
.parseCaseInsensitive
.append(ISO_LOCAL_DATE)
import scala.io.Source
import java.nio.file.{Files, Paths}
/**
* Fixes file where only end of subtitles are set.
* Set start of next line to the end of previous
*/
object ContinuousSubtitles extends scala.App {
val path = "/home/fokot/Downloads"
val filename = "ss.srt"
@fokot
fokot / README.md
Last active January 5, 2022 10:23
iPhone vs Android

I was using Android for many years and switched to iPhone few weeks ago.

What I miss on iPhone

  • When I set alarm, I do not get notification how long it will take until the alarm will fire.
  • When timer on Adroid ends it shows notification and it starts a stopwatch inside notification so I know how long after I turned it off. It has two buuttons close and restart timer. On iPhone it just shows that time is off.
  • Calendar widget - if I want bigger widget I need to have it full with. On Android I have tall widget just on one half of the screen and I can scroll over events even go to other day without opening calendar app
@fokot
fokot / DependencyJsTree.scala
Last active December 15, 2023 23:11
dependency tree to jstree
import java.io.{BufferedWriter, OutputStreamWriter}
import java.nio.file.{Files, Paths, StandardOpenOption}
import StandardOpenOption._
import scala.io.Source
import scala.util.Using
/**
* Generates a dependency tree in html format.
* `dependencyBrowseTree` fails on SO in our big project but `dependencyTree` works.
*
@fokot
fokot / Main.scala
Last active December 1, 2025 09:24
Json with endpoints in zio-http
package com.simpleset
import zio.*
import zio.http.*
import zio.http.codec.*
import zio.http.codec.PathCodec.*
import zio.http.endpoint.*
import zio.http.endpoint.openapi.*
import zio.json.{DeriveJsonDecoder, DeriveJsonEncoder, JsonDecoder, JsonEncoder}
import zio.json.ast.Json
@fokot
fokot / ControllerNew.scala
Created January 29, 2026 10:47
Stream usage
class Controller {
def getReuslt = {
...
val responseStream = Source.future(resultFuture).merge(Source.tick(1.minute, 1.minute, " "), eagerComplete = true)
Future.successful(Ok.chunked(responseStream, Some("text/json")))
}
}