Skip to content

Instantly share code, notes, and snippets.

Avatar
🍩
busy busy

Jesse Wilson swankjesse

🍩
busy busy
View GitHub Profile
@swankjesse
swankjesse / TwitterSample.java
Created Mar 11, 2014
Twitter hello world with OkHttp
View TwitterSample.java
package com.squareup.okhttp.sample;
import com.squareup.okhttp.ConnectionPool;
import com.squareup.okhttp.OkHttpClient;
import java.lang.reflect.Field;
import twitter4j.Paging;
import twitter4j.ResponseList;
import twitter4j.Twitter;
import twitter4j.TwitterFactory;
import twitter4j.auth.AccessToken;
View TwitterHpackTest.java
/*
* Copyright (C) 2014 Square, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
View Utf8Benchmark.java
/*
* Copyright (C) 2014 Square, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
View JsonRewriter.java
package com.squareup.okhttp.sample;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
@swankjesse
swankjesse / PinnedCertificatesGoogleDotCom.java
Created Jun 8, 2014
An example of the code generated by SslContextBuilder.
View PinnedCertificatesGoogleDotCom.java
/*
* Copyright (C) 2014 Square, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@swankjesse
swankjesse / git-git
Created Aug 7, 2014
make "git git" the same as "git"
View git-git
echo '#!/bin/bash' > ~/bin/git-git
echo 'git $*' >> ~/bin/git-git
chmod u+x ~/bin/git-git
View gist:b8c289c8cf527d7e556b
import android.content.Context;
import com.squareup.okhttp.OkHttpClient;
import java.io.InputStream;
import java.security.KeyStore;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManagerFactory;
import static java.util.concurrent.TimeUnit.SECONDS;
View Ciphers.java
package com.squareup.okhttp.recipes;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class Ciphers {
@swankjesse
swankjesse / SessionResumeFail.java
Created Dec 27, 2014
Demonstrates a bug in Jetty ALPN where resumed sessions don't get protocol callbacks.
View SessionResumeFail.java
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketException;
import java.security.KeyFactory;
import java.security.KeyStore;
import java.security.PrivateKey;
View RetrofitInterceptTest.java
import com.squareup.okhttp.Dispatcher;
import com.squareup.okhttp.Interceptor;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.mockwebserver.MockResponse;
import com.squareup.okhttp.mockwebserver.MockWebServer;
import java.io.IOException;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import org.junit.Test;