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 createSignatureMatrix(characterMatrix: Array[Array[Int]], hashFunctions: List[HashFunction]): Array[Array[Int]] = { | |
| val signatureMatrix: Array[Array[Int]] = createEmptySignatureMatrix(hashFunctions.length, characterMatrix(0).length) | |
| characterMatrix.zipWithIndex.foreach { case (row, i) => | |
| row.zipWithIndex.foreach { case (character, j) => | |
| /* only apply hash functions if character is not 0 */ | |
| if (character == 1) { | |
| hashFunctions.zipWithIndex.foreach { case (hasher, k) => | |
| val hashedRowValue: Int = hasher.apply(i) | |
| if (isReplaceable(signatureMatrix(k)(j), hashedRowValue)) { | |
| signatureMatrix(k)(j) = hashedRowValue |
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 sys | |
| import random | |
| import math | |
| if len(sys.argv) != 3: | |
| print "Usage: ./playcount.py <file_to_parse> <output_counts_to_file>" | |
| exit(1) | |
| countmap = {} |
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! |
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
| #!/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
| 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
| 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
| 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
| 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
| 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 |