Skip to content

Instantly share code, notes, and snippets.

public class MyHTTPClient {
private URL mUrl;
public MyHTTPClient(URL url) {
mUrl = url;
}
public String getString() throws IOException {
HTTPUrlConnection urlConnection = null;
URL url = new URL(mUrl, "/string");
public class MyHTTPClientTest extends AndroidTestCase {
private MockWebServer mServer;
private MyHTTPClient mClient;
public void setUp() throws Exception {
mServer = new MockWebServer();
mServer.play();
mClient = new MyHTTPClient(mServer.getUrl("/"));
}
@bsphere
bsphere / errs.go
Last active August 29, 2015 14:01
package main
import (
"errors"
)
var (
// ErrNotFound is returned when something isn't found
ErrNotFound = errors.New("not found")
)
@bsphere
bsphere / py_exceptions.py
Last active November 17, 2022 15:01
How to catch exceptions raised by Python worker threads
import Queue
import threading
class WorkerThread(threading.Thread):
def __init__(self, q):
super(WorkerThread, self).__init__()
self q = q
self.exception = None
@bsphere
bsphere / timestamp.go
Last active January 23, 2024 02:50
UNIX timestamps in Golang
package timestamp
import (
"fmt"
"labix.org/v2/mgo/bson"
"strconv"
"time"
)
type Timestamp time.Time