This file contains hidden or 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 scala.util.{ Failure, Success } | |
import scala.concurrent.{ Future } | |
import scala.concurrent.duration._ | |
import scala.concurrent.ExecutionContext.Implicits.global | |
import math.random | |
object Zoo extends App { | |
val animals = List("monkey", "donkey", "giraffe").map { animal => | |
for { |
This file contains hidden or 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
package graph | |
trait Generator[+T] { | |
self => | |
def generate: T | |
def map[U](f: T => U): Generator[U] = new Generator[U] { | |
def generate: U = f(self.generate) | |
} | |
def flatMap[U](f: T => Generator[U]): Generator[U] = new Generator[U] { | |
def generate: U = f(self.generate).generate |
This file contains hidden or 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
package demo | |
import akka.actor.Actor | |
import akka.actor.FSM | |
import akka.actor.ActorSystem | |
import akka.actor.Props | |
import akka.actor.ActorRef | |
sealed trait State | |
case object Awake extends State |
This file contains hidden or 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
object Hashing { | |
val BUCKETSIZE = 1000 | |
val words = io.Source.fromFile("/usr/share/dict/words").getLines | |
.map(x => x.toLowerCase).toList | |
def initBuckets(size: Int): Array[List[String]] = { | |
var arr = new Array[List[String]](size) | |
arr.map(_ => List[String]()) | |
} |
This file contains hidden or 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 scala.language.postfixOps | |
import sys.process._ | |
import trie._ | |
object Main { | |
val ENTER = 10 | |
val BACKSPACE = 127 | |
val BUFFER_SUGGESTION_THRESHOLD = 2 |
This file contains hidden or 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 graph._ | |
object Main { | |
def main(args: Array[String]): Unit = { | |
println(" Exploring the graph ") | |
val sample = | |
Context(Adj(List(("left", Node(2)), ("up", Node(3)))), | |
Node(1), "a", Adj(List(("right", Node(2))))) &: | |
Context(Adj(List()), Node(2), "b", Adj(List(("down", Node(3))))) &: |
This file contains hidden or 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 test_project(self, projectname): | |
logging.info('Running tests on: %s' % projectname) | |
loader = unittest.TestLoader() | |
tests = loader.discover(projectname) | |
runner = unittest.TextTestRunner() | |
runner.run(tests) |
This file contains hidden or 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 | |
file="~/.gitshots/#{Time.now.to_i}.jpg" | |
unless File.directory?(File.expand_path("../../rebase-merge", __FILE__)) | |
puts "Taking capture into #{file}!" | |
system "imagesnap -q -w 3 #{file} &" | |
end | |
exit 0 |
This file contains hidden or 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
@hosts("local") | |
def prepare_config(data, maxcap='5'): | |
local("cp deploy/template.conf deploy/application.conf") | |
local("sed -i -f \"s/FOLDERPLACEHOLDER/" + data + "/g;s/MAXCAPACITYPLACEHOLDER/" + | |
maxcap + "/g;\" deploy/application.conf") | |
def config(): | |
put("deploy/application.conf", "~/recsys/") | |
run("sed -i \"s/IPPLACEHOLDER/$(hostname -f)/g;\" ~/recsys/application.conf") |
This file contains hidden or 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
... | |
# Read the vectors | |
data = read_from_file(sys.argv[1]) | |
items = numpy.array(data) | |
# Normalise vectors | |
normalised_items = whiten(items) | |
# Cluster time! |