Skip to content

Instantly share code, notes, and snippets.

package nodescala
import scala.language.postfixOps
import com.sun.net.httpserver._
import scala.concurrent._
import scala.concurrent.duration._
import ExecutionContext.Implicits.global
import scala.async.Async.{async, await}
import scala.collection._
package simulations
import math.random
class EpidemySimulator extends Simulator {
def randomBelow(i: Int) = (random * i).toInt
protected[simulations] object SimConfig {
val population = 300
val roomRows = 8
/**
* Copyright (C) 2009-2013 Typesafe Inc. <http://www.typesafe.com>
*/
package actorbintree
import akka.actor._
import scala.collection.immutable.Queue
object BinaryTreeSet {
trait Operation {
@ngocdaothanh
ngocdaothanh / many_users.js
Created January 15, 2015 04:31
MongoDB's DB creation benchmark
// MongoDB's DB creation benchmark:
// * データベースを作る前にデータベース用のユーザを作成。
// * そのユーザ権限でデータベースを作成。
// * コレクションを10個、ドキュメントを10個、フィールドを10個ずつ作成。
// * 作成データベース数は10000
//
// 1.
//
// Start MongoDB server without "--auth" option, and create a bootstrap admin user:
// use admin
@ngocdaothanh
ngocdaothanh / autoretry-one-liner.sh
Last active June 28, 2022 03:56
Retry failed command with random delay
# Autoretry failed command 10 times, with 1-60s random delay:
# https://unix.stackexchange.com/questions/82598
for i in $(seq 1 10); do [ $i -gt 1 ] && delay=$[$RANDOM % 60 + 1] && echo "Retry after ${delay}s" && sleep $delay; command "$1" && failed=0 && break || failed=$?; done; (exit $failed)
@ngocdaothanh
ngocdaothanh / gist:3764694
Created September 22, 2012 00:43
Scala Assignment: Recursion
package recfun
import scala.collection.mutable.ListBuffer
import common._
/** https://class.coursera.org/progfun-2012-001/assignment/view?assignment_id=4 */
object Main {
def main(args: Array[String]) {
println("Pascal's Triangle")
for (row <- 0 to 10) {