Skip to content

Instantly share code, notes, and snippets.

View tkqubo's full-sized avatar

Qubo tkqubo

  • 42
View GitHub Profile
@jrudolph
jrudolph / TestMultipartFileUpload.scala
Last active February 13, 2023 18:09
akka-http Multipart file-upload client + server example
package akka.http.scaladsl
import java.io.File
import akka.http.scaladsl.unmarshalling.Unmarshal
import akka.util.ByteString
import scala.concurrent.duration._
import akka.actor.ActorSystem
@JaviSoto
JaviSoto / gist:292435381bb2e0d31402
Last active August 29, 2015 14:12
Functor and Monad in Swift blog post
@codetinkerhack
codetinkerhack / ReTry.scala
Last active June 18, 2020 09:39
Retry Akka actor /Ask pattern with individual timeout, retry intervals
package com.codetinkerhack
import akka.actor.{ ActorRef, Props, Actor, ActorLogging }
import akka.pattern.ask
import akka.util.Timeout
import scala.concurrent.duration._
import akka.actor.Actor.Receive
import akka.pattern.pipe
import scala.util.Success
import scala.util.Failure
@xuwei-k
xuwei-k / build.sbt
Last active June 24, 2021 01:09
show message when sbt build files changed
val buildFiles = SettingKey[Map[File, Seq[Byte]]]("build-files")
buildFiles := getBuildFiles((baseDirectory in ThisBuild).value)
def getBuildFiles(base: File) =
((base * "*.sbt") +++ ((base / "project") ** ("*.scala" | "*.sbt"))).get.map{
f => f -> collection.mutable.WrappedArray.make[Byte](Hash(f))
}.toMap
def changed(base: File, files: Map[File, Seq[Byte]]): Boolean =
@loicdescotte
loicdescotte / Forcomptran.md
Last active May 27, 2023 06:27
Scala for comprehension translation helper

Scala for comprehension translation helper

"For comprehension" is a another syntaxe to use map, flatMap and withFilter (or filter) methods.

yield keyword is used to aggregate values in the resulting structure.

This composition can be used on any type implementing this methods, like List, Option, Future...

@fauxparse
fauxparse / date.coffee
Created December 21, 2011 23:20
CoffeeScript date utilities
Number::pad = (digits, signed) ->
s = Math.abs(@).toString()
s = "0" + s while s.length < digits
(if @ < 0 then "-" else (if signed then "+" else "")) + s
Date.months = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ]
Date.weekdays = [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ]
Date.formats =
"a": -> Date.weekdays[@getDay()].substring(0, 3)