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 / 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 / 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
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 / 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)
@fokot
fokot / docker-compose.yml
Last active November 1, 2020 21:06
Wordpress with mysql
version: '3.3'
services:
db:
image: mysql:latest
volumes:
- db_data:/var/lib/mysql
ports:
- 3306:3306
restart: always
@fokot
fokot / MiniTest.scala
Last active December 13, 2019 15:25
ZIO workshop
package com.upstartcommerce.rating
import zio.ZIO
import zio.console.Console
object MiniTest extends zio.App {
trait GetUser {
def user: User
@fokot
fokot / gist:edbeec7de61552a291ef566bb55fba7e
Created October 4, 2017 11:13
Bi-directional ssh tunnel
#!/bin/bash
export EXTERNAL_PORT=$(cat conf/application.conf | awk -F'=' '/web.port/ {printf $2}' | tr -d ' ')
# this is the port for externalAddress
export TEMP_PORT=3331
echo ""
echo "Connecting localhost:$EXTERNAL_PORT to <SERVER>:8076"
echo "As externalAddress in application.conf use \"http://localhost:$TEMP_PORT\""
echo ""
@fokot
fokot / ShapelessTest.scala
Created August 23, 2017 15:23
Shapeless - two classes to list
import shapeless._
import shapeless.labelled.{FieldType, field}
import shapeless.ops.hlist.{Align, ToTraversable, ZipWith}
object ShapelessTest {
def zipClasses[A, B, P <: Poly2, ARepr <: HList, BRepr <: HList, R <: HList, X]
(a: A, b: B, f: P)(
implicit
@fokot
fokot / SchemaCompare.scala
Last active June 29, 2017 11:51
GraphQL schema compare
package raptorclientapi
import io.circe.Encoder
import io.circe.parser.parse
import sangria.schema.{Schema, SchemaChange}
import scalaj.http.{Http => SJHttp}
import sangria.marshalling.circe.CirceInputUnmarshaller
import io.circe._
import io.circe.generic.semiauto._
@fokot
fokot / Example.scala
Created November 4, 2016 12:09
Akka-http + specs2 routes testing
package com.raptorintelligence
import akka.http.specs2.RouteTestSpecs2
import org.specs2.concurrent.ExecutionEnv
import org.specs2.mutable.Specification
class ConnectotMicroserviceTest extends Specification with RouteTestSpecs2 {
"routes are tested" >> { implicit ee: ExecutionEnv =>
Get("/test") ~> ConnectorMicroservice.route ~> checkEntity must equalTo("this is test").await