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
labels = as.matrix(louter(data, data, pairname)) | |
dist.levenshtein = run(data, compose(), levenshtein) | |
dist.none = run(data, compose(convertToMatrix), euclidean) | |
dist.blur = run(data, compose(convertToMatrix, mkBlur()), euclidean) | |
dist.fourier = run(data, compose(convertToMatrix, fourier), euclideanIm) | |
dist.fourierM = run(data, compose(convertToMatrix, fourier), manhattan) | |
dist.fourierRe = run(data, compose(convertToMatrix, fourier, Re), euclidean) | |
dist.fourierIm = run(data, compose(convertToMatrix, fourier, Im), euclidean) | |
dist.haar = run(data, compose(convertToMatrix, haar), euclidean) |
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
Kogumik nõuandeid: | |
http://www.amazon.com/Things-Every-Programmer-Should-Know/dp/0596809484 | |
http://www.amazon.com/Things-Every-Software-Architect-Should/dp/059652269X | |
http://www.amazon.com/Things-Every-Project-Manager-Should/dp/0596804164 | |
Muu: | |
http://www.amazon.com/Software-Tools-Brian-W-Kernighan/dp/020103669X | |
http://www.amazon.com/Lean-Architecture-Agile-Software-Development/dp/0470684208/ref=cm_cr_pr_product_top | |
http://www.amazon.com/Peopleware-Productive-Projects-Teams-Second/dp/0932633439 |
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
func binaryLeft(i int) int { | |
return 2*i | |
} | |
func karyLeft(k int, i int) { | |
return k*i - (k - 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
// use closures | |
function newEnum(start){ | |
start -= 1; | |
return function(){ | |
start += 1; | |
return start; | |
} | |
} |
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
The goal is to let N worker threads traverse the graph until it has been fully processed. | |
=== Initiator === | |
unvisited.put(startingNode) | |
start N worker threads | |
wait until workers finish | |
=== Initiator === | |
The constraint is that no worker should terminate before the whole graph is processed. | |
Also worker should start working if it can get a node to process. |
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
# non-solution 1 # | |
added = Semaphore(0) | |
workingCount = 0 | |
WORKER: | |
while: | |
added.wait() # when terminating all threads wait here | |
if (queue.count == 0) and (workingCount == 0): | |
added.signal() |
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
// run this test with | |
// go test -test.cpu=1,2,3,8 -benctime=0.1s -bench . | |
package locktest | |
import ( | |
"sync" | |
"testing" | |
) | |
const ( |
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
class Parent(object): | |
def something(self, a): | |
print a | |
class Child(Parent): | |
"""docstring for Child""" | |
def __init__(self, toAdd): | |
self._parent = super(Child, self) | |
self._parent.__init__() | |
self.toAdd = toAdd |
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-edges [[:a :b] [:c :a] [:c :e] [:e :f] [:b :f]]) | |
(defn edges-to-hashes [edges] | |
(map (fn [[from to]] {from {to 1}}) edges)) | |
(defn make-graph [edges] | |
(apply merge-with merge (edges-to-hashes edges))) | |
(defn graph-get [graph from to default] | |
((graph from {}) to default)) |
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
type Cmd struct { | |
Message string | |
Result chan string | |
} | |
func CurrentRequest() *http.Request { | |
// MAGIC | |
} |