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
# instead of | |
userColl = (yield client.getUserCollection())._coll | |
self.assertEqual(userColl[0]['userID'],"TestUser") | |
self.assertEqual(len(userColl[0]['userDeviceAddresses']),2) | |
self.assertTrue(userColl[0]['userDeviceAddresses'][0]=="DD:DD:DD:DD" or userColl[0]['userDeviceAddresses'][1]=="DD:DD:DD:DD")· | |
# i would go with something like | |
(userColl,) = (yield client.getUserCollection())._coll # will assign _coll[0] to userColl and explode unless there is exactly one item | |
self.assertEqual(userColl['userID'], 'TestUser') # consistent use of either single or double quotes | |
self.assertEqual(sorted(userColl['userDeviceAddress']), ['AA:AA...', 'DD:DD...']) # more managable than checking each element as above, and checks that both are in there. |
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
@requiresMongo | |
@defer.inlineCallbacks | |
def getEncountersForUser(self, userID, startTime, endTime, areEncountering=lambda a, b: defer.succeed(True)): | |
user = yield findOne(self.users, col.userID == userID).execute() | |
user = ref.user(user) | |
def maybeInclude(encountering, u, row): | |
if encountering: | |
return (u, row) | |
return () |
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
from twisted.internet import reactor, defer | |
from tornado.platform.twisted import TwistedIOLoop | |
import nsq | |
from nsq import Writer, Error | |
from nsq.async import AsyncConn | |
# This doesn't work - the client errors with a failed send, and nsqd (when | |
# invoked with nsqd --verbose, outputs: | |
# 2014/06/01 21:26:09 TCP: new client(127.0.0.1:53443) |
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
from twisted.internet import reactor, defer | |
from tornado.platform.twisted import TwistedIOLoop | |
import nsq | |
from nsq import Writer, Error | |
from nsq.async import AsyncConn | |
# This doesn't work - the client errors with a failed send, and nsqd (when | |
# invoked with nsqd --verbose, outputs: | |
# 2014/06/01 21:26:09 TCP: new client(127.0.0.1:53443) |
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
from zope.interface import implements, Interface | |
class ILimitedProfile(Interface): | |
""" | |
Marker interface for basic profile functionality. | |
""" | |
def doLimited(): | |
pass | |
class IFullProfile(ILimitedProfile): |
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 datrie, random, geohash, guppy, time, itertools | |
ghashBase32Chars = '0123456789bcdefghjkmnpqrstuvwxyz' | |
def timeme(func): | |
def wrapper(*arg,**kw): | |
t1 = time.time() | |
res = func(*arg,**kw) | |
t2 = time.time() | |
return (t2-t1), res |
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 random, geohash, guppy, itertools, time | |
def randomHash(): | |
lat = (random.random() * 180) - 90 | |
lng = (random.random() * 360) - 180 | |
return geohash.encode(lat, lng) | |
def insert(d, hash, userId): | |
for c in hash[:11]: | |
d = d.setdefault(c, {}) |
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
(defmacro broken | |
[x] | |
(println (into {} (map (fn [[k v]] [(name k) (mapv str v)]) x)))) | |
(broken x x {:a [a] :b [b]} x) |
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
diff --git a/vendor/clojure.el b/vendor/clojure.el | |
index d9cfbd3..884cd66 100644 | |
--- a/vendor/clojure.el | |
+++ b/vendor/clojure.el | |
@@ -13,3 +13,9 @@ | |
(add-hook 'cider-repl-mode-hook 'subword-mode) | |
(add-hook 'cider-repl-mode-hook 'paredit-mode) | |
(add-hook 'cider-repl-mode-hook 'rainbow-delimiters-mode) | |
+ | |
+(defun extend-indent () |
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
(ns encounters.geo | |
(:require [geohash.core :as geohash])) | |
(def ^:dynamic *geohash-precision* 1) | |
(def ^:dynamic *radius-km* 6371.009) | |
(defn great-circle-distance | |
([lat lon lat' lon'] | |
(great-circle-distance lat lon lat' lon' *radius-km*)) |
OlderNewer