Skip to content

Instantly share code, notes, and snippets.

View mtomas's full-sized avatar

Marek TOMAS mtomas

View GitHub Profile
@heathermiller
heathermiller / scala-cheatsheet.md
Last active August 7, 2025 13:02
Scala Cheatsheet

This cheat sheet originated from the forum, credits to Laurent Poulain. We copied it and changed or added a few things.

Evaluation Rules

  • Call by value: evaluates the function arguments before calling the function
  • Call by name: evaluates the function first, and then evaluates the arguments if need be
    def example = 2      // evaluated when called
    val example = 2      // evaluated immediately
@hejld
hejld / reactive-2015.md
Last active December 10, 2021 10:24
Advanced React.js Performance - Reactive 2015 Lightning Talk Proposal

Note: This is a submission for a Reactive2015 lightning talk. If you'd like to see a lightning talk about this (or read a detailed blog post if you are not going for the conference), vote for it by starring this gist! Thanks a lot!

Advanced React.js Performance

Performance is one of the reasons why React.js is so popular for building complex, highly interactive web applications. It became the go-to library for developers who don’t like to make compromises for technical reasons when building awesome user experiences. However even with React.js it still can be easy to hit it’s performance limits.

In this lightning talk Daniel will go beyond the basics of shouldComponentUpdate and immutable data structures and will discuss how to correctly instrument, measure and optimize performance in complex React apps. He will help you understand the overhead of different parts of the React component lifecycle, how some of it’

@searler
searler / ScalaxbFuture.scala
Created July 8, 2015 02:58
Akka Future based HTTP client implementation of Scalaxb HttpClientsAsync
import scala.concurrent.Await
import scala.concurrent.Future
import scala.concurrent.duration.Duration
import scala.util.Try
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.model.ContentType
import akka.http.scaladsl.model.HttpCharsets
import akka.http.scaladsl.model.HttpEntity.Strict
@LeZuse
LeZuse / macos-setup.md
Last active August 14, 2025 13:33
macOS Machine Setup

Mac OS Dev Machine Setup

General

For latest settings refer to this comment

For previous settings check this Gist revisions

Remarks

  • always read and follow Homebrew formulae installation instructions
@mbonaci
mbonaci / installScalaSbt.sh
Last active July 6, 2021 17:07
Install Scala 2.10.4 and Sbt 0.13.8 on Ubuntu 14.04 (Spark)
sudo wget www.scala-lang.org/files/archive/scala-2.10.4.deb
sudo dpkg -i scala-2.10.4.deb
# in case of unmet libjansi-java dependency fire:
# sudo apt-get install -f
sudo apt-get install curl
wget https://dl.bintray.com/sbt/debian/sbt-0.13.8.deb
sudo dpkg -i sbt.deb
@brikis98
brikis98 / CacheFilter.scala
Last active August 4, 2017 22:22
An outline of how to de-dupe remote service calls in Play.
// Put this filter early in your filter chain so it can initialize and clean up
// the cache
object CacheFilter extends Filter {
def apply(next: RequestHeader => Future[Result])(request: RequestHeader): Future[Result] = {
def init = RestClient.initCacheForRequest(request)
def cleanup = RestClient.cleanupCacheForRequest(request)
// You have to be very careful with error handling to garauntee the cache gets cleaned
// up, or you'll have a memory leak.
@agemooij
agemooij / customformat.scala
Last active November 28, 2022 13:50
More advanced example of a custom spray-json format
implicit object ProductItemFormat extends RootJsonFormat[ProductItem] {
// some fields are optional so we produce a list of options and
// then flatten it to only write the fields that were Some(..)
def write(item: ProductItem) = JsObject(
List(
Some("product_number" -> item.productNumber.toJson),
item.ean.map(ean ⇒ "ean" -> ean.toJson),
Some("title" -> item.title.toJson),
item.description.map(description ⇒ "description" -> description.toJson),
Some("price" -> item.price.toJson),
@petrbel
petrbel / .travis.yml
Last active October 26, 2019 10:29 — forked from iedemam/gist:9830045
Travis-CI submodules
# Use https (public access) instead of git for git-submodules. This modifies only Travis-CI behavior!
# disable the default submodule logic
git:
submodules: false
# use sed to replace the SSH URL with the public URL, then init and update submodules
before_install:
- sed -i 's/[email protected]:/https:\/\/github.com\//' .gitmodules
- git submodule update --init --recursive
@mikemckibben
mikemckibben / EitherExampleSpec.scala
Last active June 28, 2017 17:19
Example Unmarshalling an Either[A, B] with spray-json
import org.specs2.mutable.Specification
import spray.http.{HttpResponse, StatusCodes}
import spray.httpx.SprayJsonSupport
import spray.httpx.marshalling._
import spray.httpx.unmarshalling._
import spray.json._
/***
* scalaVersion := "2.11.2"
*
@jaytaylor
jaytaylor / EnvHacker.scala
Created August 21, 2014 02:41
Setting environment variables in Scala JVM
trait EnvHacker {
/**
* Portable method for setting env vars on both *nix and Windows.
* @see http://stackoverflow.com/a/7201825/293064
*/
def setEnv(newEnv: Map[String, String]): Unit = {
try {
val processEnvironmentClass = Class.forName("java.lang.ProcessEnvironment")
val theEnvironmentField = processEnvironmentClass.getDeclaredField("theEnvironment")
theEnvironmentField.setAccessible(true)