Skip to content

Instantly share code, notes, and snippets.

View kovacshuni's full-sized avatar

Hunor Kovács kovacshuni

View GitHub Profile
@kovacshuni
kovacshuni / FutureTestApp.scala
Created April 1, 2022 08:56
concurrent-futures-in-for-comprehensions
package com.hiya.h4b.cpas.futuretest
import akka.actor.ActorSystem
import scala.concurrent.{Await, Future}
import scala.concurrent.duration._
object FutureTestApp extends App {
private val sys = ActorSystem.apply("future-test-app")
implicit private val ec = sys.dispatcher
@kovacshuni
kovacshuni / Logger.scala
Created December 22, 2020 00:36
tagless-final-logging-testing
package com.hunorkovacs.catsi
import cats.effect.Sync
import cats.Applicative
import org.log4s.{getLogger, Logger => Log4sLogger}
trait Logger[F[_]] {
def trace(str: String): F[Unit]
{
"name": "MyClass",
"type": "record",
"namespace": "",
"fields": [
{
"name": "name",
"namespace": "name",
"type": "string"
}
@kovacshuni
kovacshuni / PureconfigConfigReader.scala
Created January 31, 2020 12:48
pureconfig-configreader-example
implicit val awsConfigReader: ConfigReader[AWSConfig] = ConfigReader.fromCursor[AWSConfig] { cur =>
for {
objCur <- cur.asObjectCursor
maxConnections <- objCur.atKey("max-connections")
maxConnectionsInt <- maxConnections.asInt
maxErrorRetry <- objCur.atKey("max-error-retry")
maxErrorRetryInt <- maxErrorRetry.asInt
endpoint <- objCur.atKey("endpoint")
endpointStr <- endpoint.asString
region <- objCur.atKey("region")
@kovacshuni
kovacshuni / subtitles-shift-up.rb
Last active August 2, 2020 22:54
subtitles-shift-up
# Appends a new line with a - to every frame of movie subtitles to shift
# the overall position up when the tv cuts down the bottom.
#
# ruby subtitles-shift-up.rb Titanic.srt
# or
# ruby subtitles-shift-up.rb Titanic.srt UTF-8
#
# result: Titanic-shifted.srt
def addEmptyLine(inFile, outFile)
@kovacshuni
kovacshuni / Typeclasses.scala
Created January 27, 2020 10:54
typeclasses-example
package com.hiya.h4b.cpas.service
import java.time.Instant
import java.time.Instant.now
import akka.http.scaladsl.model.StatusCode
import akka.http.scaladsl.model.StatusCodes.{Created, NotFound, OK}
object Typeclasses extends App {
@kovacshuni
kovacshuni / main.go
Created October 20, 2019 19:02
generate-password-hash-scrypt
package main
import (
"fmt"
"math/rand"
"os"
"time"
"golang.org/x/crypto/scrypt"
)
@kovacshuni
kovacshuni / githelp.txt
Last active May 14, 2020 15:19
githelp
Don't let me Google that for you
Just ctrl-f this file
# The Git reference:
git checkout --help
# Pushing
# Recommended pushing method
git push <remote> sourceBranch
git push origin master
@kovacshuni
kovacshuni / feedingPrintingChannels.go
Created December 22, 2017 13:17
feeding-printing-channels
package main
import (
"fmt"
"time"
)
func main() {
q := make(chan string, 1)
@kovacshuni
kovacshuni / CPU-MIPS.txt
Created September 27, 2017 20:56
CPU-MIPS
Intel i7 5820K 33126 MIPS ~ 2^15 MIPS (million instructions per second) = 2^35 IPS
Intel i7 6700K 25475 MIPS ~ roughly rounding up kind-of gives you the same