This file contains 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
/** | |
* Custom Error classes factory | |
* Usage: | |
* var MyError = ErrorFactory('MyError'); | |
* try{ | |
* throw new MyError('my error text'); //or throw MyError('my error text'); | |
* }catch(e){ | |
* if(e instanceof MyError){ | |
* console.log('This is my error!'); | |
* } |
This file contains 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
/** | |
* Synchronous timeout | |
* @param {Integer} delay Delay in milliseconds | |
*/ | |
var syncTimeout = function(delay){ | |
var endTime = new Date((new Date()).getTime() + delay); | |
var curTime; | |
do { | |
curTime = new Date(); | |
}while(curTime.getTime() <= endTime.getTime()); |
This file contains 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
/** | |
* Convert extra properties with multilevel nesting into simple map. | |
* Each nesting level is separated by '.'. | |
* | |
* For example, this: | |
* <pre> | |
* ext { | |
* elem1 = 'val1' | |
* elem2 = 'val2' | |
* lev1 = [ |
This file contains 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
----- Esc ----- | |
Quick change directory: Esc + c | |
Quick change directory history: Esc + c and then Esc + h | |
Quick change directory previous entry: Esc + c and then Esc + p | |
Command line history: Esc + h | |
Command line previous command: Esc + p | |
View change: Esc + t (each time you do this shortcut a new directory view will appear) | |
Print current working directory in command line: Esc + a | |
Switch between background command line and MC: Ctrl + o | |
Search/Go to directory in active panel: Esc + s / Ctrl + s then start typing directory name |
This file contains 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 pushka.json._ | |
import pushka.annotation.pushka | |
@pushka | |
sealed trait TraitA | |
object TraitA { | |
sealed trait TraitB extends TraitA |
This file contains 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 debounce(wait: FiniteDuration)(f: ⇒ Unit): () ⇒ Unit = { | |
var lastStartTime = Long.MinValue | |
var finishTime = lastStartTime + wait.toMillis | |
() ⇒ { | |
val now = System.currentTimeMillis() | |
val ready = finishTime <= now | |
lastStartTime = now | |
finishTime = lastStartTime + wait.toMillis |
This file contains 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 scala.concurrent.{ExecutionContext, Future} | |
/** | |
* Takes care of computations | |
* | |
* Success(either) - the computation will be continued. | |
* Failure(error) - the computation was failed with unhandled error. | |
* | |
* Either[Result, T]: | |
* Left(result) is a final and handled result, another computations (map, flatMap) will be ignored. |
This file contains 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 KafkaSender { | |
sealed trait Config | |
object Config { | |
case class WithPublishing(url: String, queueSize: Int) extends Config | |
case object WithoutPublishing extends Config | |
} | |
} | |
implicit val kafkaSenderConfigConvert: ConfigConvert[KafkaSender.Config] = { | |
val key = "publishing" |
This file contains 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
package ru.dgis.casino.sharpy | |
import java.util.Date | |
import java.util.concurrent.TimeUnit | |
import java.util.concurrent.atomic.{AtomicBoolean, AtomicReference} | |
import akka.actor.Cancellable | |
import akka.stream.scaladsl.Source | |
import akka.stream.stage.{AsyncCallback, GraphStageLogic, GraphStageWithMaterializedValue, OutHandler, StageLogging, TimerGraphStageLogic} | |
import akka.stream.{Attributes, Outlet, SourceShape} |
This file contains 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
https://scastie.scala-lang.org/ | |
libraryDependencies += "org.scalameta" %% "scalameta" % "2.0.1" | |
https://github.com/scalameta/scalameta/blob/master/scalameta/tokens/shared/src/main/scala/scala/meta/tokens/Token.scala | |
https://github.com/scalameta/scalameta/blob/master/scalameta/trees/shared/src/main/scala/scala/meta/Trees.scala |
OlderNewer