How to incrementally sample without replacement?

If you know in advance that you’re going to want to multiple samples without overlaps, easiest is to do random.shuffle() on list(range(100)) (Python 3 – can skip the list() in Python 2), then peel off slices as needed. s = list(range(100)) random.shuffle(s) first_sample = s[-10:] del s[-10:] second_sample = s[-10:] del s[-10:] # etc Else … Read more

Do any browsers support trailers sent in chunked encoding responses?

No common browsers support HTTP/1.1 trailers. Look at the column “Headers in trailer” in the “Network” tab of browserscope. Chrome: No, and won’t fix (bug). Supports H/2 trailers (bug). Firefox: No, and I don’t see a ticket in bugzilla for it. Appears to support H/2. IE: No Edge: No Safari: No Opera: Old versions only … Read more

Google Maps Android API v2 – Sample Code crashes

Follow the crib sheet very, very carefully: https://docs.google.com/document/pub?id=19nQzvKP-CVLd7_VrpwnHfl-AE9fjbJySowONZZtNHzw In particular, I think you need to: Import the actual source for the “google-play-services_lib” project and link it as an Android library. Do this through Project -> Properties -> Android -> Library, Add -> google-play-services_lib (you can right click on your project and choose Properties, then select … Read more

Android sample bluetooth code to send a simple string via bluetooth

private OutputStream outputStream; private InputStream inStream; private void init() throws IOException { BluetoothAdapter blueAdapter = BluetoothAdapter.getDefaultAdapter(); if (blueAdapter != null) { if (blueAdapter.isEnabled()) { Set<BluetoothDevice> bondedDevices = blueAdapter.getBondedDevices(); if(bondedDevices.size() > 0) { Object[] devices = (Object []) bondedDevices.toArray(); BluetoothDevice device = (BluetoothDevice) devices[position]; ParcelUuid[] uuids = device.getUuids(); BluetoothSocket socket = device.createRfcommSocketToServiceRecord(uuids[0].getUuid()); socket.connect(); outputStream = socket.getOutputStream(); … Read more