Skip to content

Instantly share code, notes, and snippets.

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)
@egonelbre
egonelbre / gist:4528589
Last active December 11, 2015 02:09
raamatud
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
func binaryLeft(i int) int {
return 2*i
}
func karyLeft(k int, i int) {
return k*i - (k - 2)
}
// use closures
function newEnum(start){
start -= 1;
return function(){
start += 1;
return start;
}
}
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.
# 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()
@egonelbre
egonelbre / lock.go
Created April 2, 2013 09:43
locking test
// run this test with
// go test -test.cpu=1,2,3,8 -benctime=0.1s -bench .
package locktest
import (
"sync"
"testing"
)
const (
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
(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))
type Cmd struct {
Message string
Result chan string
}
func CurrentRequest() *http.Request {
// MAGIC
}