Skip to content

Instantly share code, notes, and snippets.

View simerplaha's full-sized avatar

Simer simerplaha

View GitHub Profile
import swaydb._
import swaydb.serializers.Default._

val sortedKeyIndex =
  SortedKeyIndex.Enable(
    prefixCompression = PrefixCompression.Disable(normaliseIndexForBinarySearch = true),
    enablePositionIndex = true,
    ioStrategy = IOStrategy.concurrentStored,
 compressions = _ => Seq.empty
@simerplaha
simerplaha / persistent_map_scala.md
Created February 8, 2020 13:43
Persistent Map in Scala
val map = persistent.Map[Int, String, Nothing, Bag.Less](dir = "target/myMap").get
@simerplaha
simerplaha / CREATE_A_MEMORY_MAP_SCALA.md
Last active February 8, 2020 13:41
Creating a Map in SwayDB
import swaydb._ //swaydb's APIs
import swaydb.serializers.Default._ //default serialisers

val map = memory.Map[Int, String, Nothing, Bag.Less]().get //create a memory map
@simerplaha
simerplaha / Highcharts.scala
Last active February 1, 2020 15:09
Dynamic facade/access to Highcharts's API from Scala.js
@JSGlobal
@js.native
object Highcharts extends js.Object {
def chart(id: String, data: js.Object): js.Any = scalajs.js.native
}
//See - https://www.highcharts.com/docs/getting-started/your-first-chart
Highcharts.chart(
id = "chart",
data =
//See - https://gist.github.com/milessabin/89c9b47a91017973a35f && https://github.com/softwaremill/scala-common
object Tagged {
sealed trait Tagged[+T] extends Any {
type Tagged <: T
}
type @@[+V, +T] = V with Tagged[T]
}
sealed trait MaybeTag
@simerplaha
simerplaha / linode-security.md
Created June 2, 2017 07:06 — forked from eliangcs/linode-security.md
Basic security setup for a brand new Linode

Basic Security Setup for a Brand New Linode

Why

When you start a clean Linode, it isn't secured in the following aspects:

  • Allows root SSH login
  • Uses password authentication on SSH
  • Doesn't have a firewall
@simerplaha
simerplaha / Snake.scala
Created March 11, 2017 08:44 — forked from densh/Snake.scala
Snake game in 200 lines of Scala Native and SDL2 as demoed during Scala Matsuri 2017
import scalanative.native._
import SDL._
import SDLExtra._
@extern
@link("SDL2")
object SDL {
type Window = CStruct0
type Renderer = CStruct0
@simerplaha
simerplaha / JsonToClassNameMapper.scala
Last active March 10, 2016 04:01
Scala macro to generate a sealed trait's sub classes. This macro will generate a function (className: String, jsonString: String) => Option[A]. Depends on shapeless-argonaut.
import scala.language.experimental.macros
import scala.reflect.macros.blackbox.Context
object JsonToClassNameMapper {
def generatePatternMatcher[A](): (String, String) => Option[A] = macro generatePatternMatcherImpl[A]
def generatePatternMatcherImpl[A: c.WeakTypeTag](c: Context)(): c.Tree = {
import c.universe._
@simerplaha
simerplaha / AkkaEventBusExample.scala
Last active April 1, 2016 04:32
Akka event bus simple publisher/subscriber code
package main
import akka.actor._
import akka.event.{EventBus, SubchannelClassification}
import akka.util.Subclassification
object SCEventBus extends EventBus with SubchannelClassification {
type Event = (String, Any, ActorRef)
type Classifier = String
type Subscriber = ActorRef
@simerplaha
simerplaha / GCMSender.scala
Created November 1, 2015 12:42 — forked from anonymous/GCMSender.scala
Part of server with the old akka (akka-typed version: https://gist.github.com/anonymous/28accfa8e5f3fe187c4d)
package app.actors
import akka.actor.{Actor, ActorLogging}
import argonaut._, Argonaut._
import infrastructure.GCM
import launch.RTConfig
import spray.client.pipelining._
import spray.http._
import spray.httpx.marshalling.Marshaller