Skip to content

Instantly share code, notes, and snippets.

View mitraman's full-sized avatar

Ronnie Mitra mitraman

View GitHub Profile
@mitraman
mitraman / 0_reuse_code.js
Created January 20, 2014 15:48
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@mitraman
mitraman / http-gzip.java
Created August 27, 2012 18:45
Android/Java gzip request
private void getCompressedResource(String urlString) throws IOException {
// NOTE: Android's HTTPURLConnection automatically adds the "accept-encoding: gzip" header to requests and deflates responses.
// This code sample demonstrates how you would implement this feature if it wasn't handled for you automatically.
URL url = new URL(urlString);
HttpsURLConnection conn = (HttpsURLConnection)url.openConnection();
conn.setRequestProperty("accept-encoding", "gzip");
conn.setRequestMethod("GET");
InputStream is = new BufferedInputStream(conn.getInputStream());
// Note: If the library did not automatically deflate the response, we would need to use a GZipInputStream on the response.