This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
import json | |
import sys | |
HOST = 'logging.developmentci.rebb.baseless.nl' | |
#HOST = '127.0.0.1' | |
PORT = 1514 | |
try: | |
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
import json | |
import sys | |
HOST = 'logging.developmentci.rebb.baseless.nl' | |
PORT = 1514 | |
try: | |
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
except socket.error, msg: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Redis Client | |
var redis = require("redis"); | |
const DEFAULT_PORT = 6379; | |
const DEFAULT_HOST = '127.0.0.1'; | |
var redis_host, redis_port; | |
global.reportKeys = []; | |
global.reports = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
%w{rubygems time redis csv json}.each{|r| require r} | |
# Key name for primary index. | |
# Using this key, the list of available reports are stored as set in REDIS | |
NBE_REPORTS_KEY = "reports" | |
# REDIS Host | |
REDIS_HOST = "127.0.0.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed trait Interact[A] | |
case class Ask(prompt: String) | |
extends Interact[String] | |
case class Tell(msg: String) | |
extends Interact[Unit] | |
trait Monad[M[_]] { | |
def pure[A](a: A): M[A] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> invertTree(t1) | |
res12: Tree[Int] = | |
Node(4, | |
Node(7, | |
Node(9,EmptyTree,EmptyTree), | |
Node(6,EmptyTree,EmptyTree)), | |
Node(2, | |
Node(3,EmptyTree,EmptyTree), | |
Node(1,EmptyTree,EmptyTree))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def invertTree[A](tree: Tree[A]): Tree[A] = | |
fold (tree, Tree.empty[A]){(leftT, value, rightT) => Node(value, rightT, leftT)} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Tree._ | |
def map[A,B](tree: Tree[A])(f: A => B): Tree[B] = | |
fold(tree, Tree.empty[B]){(l, x, r) => Node(f(x), l,r)} | |
scala> map (t1) ( x => x * 10) | |
res11: Tree[Int] = | |
Node(40, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def size[T] (tree: Tree[T]) = | |
fold(tree, 0: Int){(l,x,r) => l + r + 1} | |
scala> size(t1) | |
res11: Int = 7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fold[A, B](t:Tree[A] , z:B)(f:(B,A,B) => B): B = t match { | |
case EmptyTree => z | |
case Node(x,l,r) => f ( fold( l , z )(f) , x , fold( r , z )(f) ) | |
} |