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 com.novoda.example.MemoryLeaker; | |
import android.os.Debug; | |
import android.view.View; | |
import java.io.File; | |
import java.io.IOException; | |
public class HeapDumpOnClickListener implements View.OnClickListener { | |
private static final String HPROF_DUMP_BASENAME = "MemoryLeaker.dalvik-hprof"; |
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 com.novoda.example.MemoryLeaker; | |
import android.app.Activity; | |
import android.os.Bundle; | |
public class LeakingActivity extends Activity { | |
... | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); |
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 com.novoda.example.MemoryLeaker; | |
import android.os.Debug; | |
import java.io.File; | |
import java.io.IOException; | |
public class HeapDumpingUncaughtExceptionHandler implements Thread.UncaughtExceptionHandler { | |
private static final String HPROF_DUMP_BASENAME = "LeakingApp.dalvik-hprof"; | |
private final String dataDir; |
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 com.novoda.example.MemoryLeaker; | |
import android.app.Application; | |
public class MemoryLeakingApplication extends Application { | |
@Override | |
public void onCreate() { | |
super.onCreate(); | |
Thread.currentThread().setUncaughtExceptionHandler( |
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 com.novoda.example; | |
import java.text.DateFormat; | |
import java.text.SimpleDateFormat; | |
import java.util.Date; | |
public class LoggingWorker implements Runnable { | |
private static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); | |
private final int workerId; |
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
# 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 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
@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 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
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 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
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 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
from zope.interface import implements, Interface | |
class ILimitedProfile(Interface): | |
""" | |
Marker interface for basic profile functionality. | |
""" | |
def doLimited(): | |
pass | |
class IFullProfile(ILimitedProfile): |