Skip to content

Instantly share code, notes, and snippets.

@josdirksen
josdirksen / Boot.scala
Last active September 20, 2022 11:24
HTTP server using akka-http and akka-streams
import akka.actor._
import akka.http.model.HttpMethods._
import akka.http.model._
import akka.stream.scaladsl._
import akka.stream.scaladsl.Flow
import play.modules.reactivemongo.json.BSONFormats
import reactivemongo.bson.BSONDocument
import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global
import play.api.libs.json._
<!DOCTYPE html>
<html ng-app="helloworld">
<head>
<meta charset="UTF-8">
<title>Minimal angular.js</title>
<link rel="stylesheet" href="css/foundation.css" />
<style>
.tile {
background: #ffeeee;
}
@josdirksen
josdirksen / server.go
Created February 20, 2015 12:28
Simple HTTP Server in Go using mongoDB and channels
package main
import (
"encoding/json"
"fmt"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
"io"
"math/rand"
"net/http"
object ReadSample extends App {
/**
* The readable trait defines how objects can be converted from a string
* representation to the objects instance. For most of the standard types
* we can simply use the toType function of String.
*/
trait Readable[T] {
def read(x: String): T
}
import java.net.{SocketOptions, Inet4Address, InetAddress, Socket}
import java.util.concurrent.TimeoutException
import akka.actor.{ActorRef, Props, ActorSystem}
import akka.http.scaladsl.Http
import akka.http.scaladsl.model.HttpMethods._
import akka.http.scaladsl.model._
import akka.http.scaladsl.model.ws._
import akka.io.Inet
import akka.routing.BroadcastGroup
@josdirksen
josdirksen / default.css
Last active February 25, 2018 20:35
Voronoi fractals using d3.js
* {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
span {
font-size: smaller;
}
package org.smartjava.dw
import java.io.{File, FileInputStream}
import com.github.mtailor.srtdissector.SrtDissector
import scala.annotation.tailrec
import scala.collection.immutable.ListMap
import scala.io.Source
import scala.util.{Failure, Success}
package Boot
import akka.actor.{Cancellable, Actor, ActorSystem, Props}
import akka.stream.{OverflowStrategy, ActorFlowMaterializer}
import akka.stream.actor.ActorSubscriberMessage.{OnComplete, OnNext}
import akka.stream.actor.{ActorSubscriber, OneByOneRequestStrategy, RequestStrategy}
import akka.stream.scaladsl._
import org.akkamon.core.exporters.StatsdExporter
import org.akkamon.core.instruments.{CounterTrait, LoggingTrait, TimingTrait}
import java.io.File
import akka.actor._
import akka.routing.{Routee, RemoveRoutee, ActorRefRoutee, AddRoutee}
import akka.stream.actor.ActorPublisher
import org.akkamon.core.ActorStack
import org.akkamon.core.instruments.CounterTrait
import play.api.libs.json.Json
import scala.annotation.tailrec
import scala.concurrent.duration._
package handlers
import (
"net/http"
"github.com/josdirksen/slackproxy/config"
"strings"
"net/url"
)
// Define a simple interface. Which provides access to the command that needs to be
// executed and the response writer, so that the handler can send information back.