Skip to content

Instantly share code, notes, and snippets.

View dungvn3000's full-sized avatar

Nguyen Duc Dung dungvn3000

View GitHub Profile
@emaxerrno
emaxerrno / Installing zookeper and monitoring it
Created August 20, 2012 19:52
Zookeeper on ubuntu and monitoring
#!/bin/sh
echo "assumes java 7 is instlaled openjdk versio"
#pre dependencies
sudo apt-get install git-core pkg-config libtool automake make g++ connect-proxy unzip python
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
#install zeromq
git clone git clone git://github.com/zeromq/libzmq.git
@searler
searler / HTTP.scala
Created November 10, 2012 17:21
Source code for Akka IO http server example
/**
* © 2012 Typesafe Inc.
*
* Extracted from http://doc.akka.io/docs/akka/2.1.0-RC2/scala/io.html
*/
import akka.actor._
import akka.util.{ ByteString, ByteStringBuilder }
import java.net.InetSocketAddress
@bantonsson
bantonsson / FormUpload.scala
Created March 3, 2015 12:49
Akka HTTP 1.0-M4 File upload using a form
/*
* Copyright (C) 2009-2015 Typesafe Inc. <http://www.typesafe.com>
*/
import akka.actor.ActorSystem
import akka.http.Http
import akka.http.Http.IncomingConnection
import akka.http.model.HttpEntity
import akka.http.model.Multipart.FormData
import akka.http.server.{ Directives, Route, RoutingSetup }
@lubiluk
lubiluk / DataTable.scala
Created July 12, 2012 15:58
lift DataTable view
package code.view
import _root_.scala.xml.{ NodeSeq, Node, Elem, PCData, Text }
import _root_.net.liftweb.common._
import _root_.net.liftweb.util._
import _root_.net.liftweb.http._
import _root_.net.liftweb.http.js._
import JsCmds._
import JE._
import S._
@sofoklis
sofoklis / gist:1730594
Created February 3, 2012 15:05
lift ajax basics
import net.liftweb.http._
import S._
import js._
import JsCmds._
import JE._
import net.liftweb.util._
import Helpers._
import scala.xml.Text
class AjaxCall {
import scala.concurrent.duration._
def scheduleTaskAtFixedRate[A](initialDelay: FiniteDuration, period: FiniteDuration, task: Task[A]): Task[Unit] =
Task.create { (s, callback) =>
def loop(delay: Long): Task[Unit] =
Task.defer {
val startedAt = s.currentTimeMillis()
val t = task.flatMap { _ =>
val duration = s.currentTimeMillis() - startedAt
val nextDelay = {
package shade.local
import shade.local.ImmutableCache.{Timestamp, Value}
import scala.annotation.tailrec
import scala.collection.immutable.SortedMap
import scala.concurrent.duration._
/** Describes an immutable cache data-structure.
*
* It behaves much like a standard `scala.collection.immutable.Map`, but
@naoto-ogawa
naoto-ogawa / MyLog02.hs
Created May 24, 2017 13:27
a small sample (the smallest ?) of MonadLogger
{-
a small sample (the smallest ?) of MonadLogger
-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE OverloadedStrings #-}
module MonadLoggerSample where
import Control.Monad.Logger
@gzoller
gzoller / FlexiFlowExample.scala
Last active November 5, 2018 13:40
Akka Stream FlexiFlow switch example
object PrimaryFlow extends App {
implicit val system = ActorSystem()
implicit val materializer = ActorMaterializer()
val sj = ScalaJack()
val graph = FlowGraph.closed() { implicit builder: FlowGraph.Builder[Unit] =>
import FlowGraph.Implicits._
val in = Source(List.empty[String]) // hook this up to RabbitMQ
val out = Sink.foreach( (mc:Command) => println("Command:" +mc) )
@kellymclaughlin
kellymclaughlin / haskell-smartos.md
Last active January 26, 2019 17:33
GHC build steps for Haskell on SmartOS

I borrowed these steps from the buildbot setup for SmartOS I found at http://haskell.inf.elte.hu/builders/. Generally the standard build steps for ghc seems to work pretty well at this point aside from a few more test failures than I observed when building on Linux.

  1. Clone ghc repo and check out desired branch or tag.
  2. Edit mk/build.mk to be the following: