Skip to content

Instantly share code, notes, and snippets.

View swankjesse's full-sized avatar
🍩
busy busy

Jesse Wilson swankjesse

🍩
busy busy
View GitHub Profile
@swankjesse
swankjesse / TwitterSample.java
Created March 11, 2014 00:08
Twitter hello world with OkHttp
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;
/*
* 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
/*
* 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
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 June 8, 2014 23:31
An example of the code generated by SslContextBuilder.
/*
* 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 August 7, 2014 00:20
make "git git" the same as "git"
echo '#!/bin/bash' > ~/bin/git-git
echo 'git $*' >> ~/bin/git-git
chmod u+x ~/bin/git-git
@swankjesse
swankjesse / gist:b8c289c8cf527d7e556b
Created September 19, 2014 21:30
Trust Store Example
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;
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 December 27, 2014 19:25
Demonstrates a bug in Jetty ALPN where resumed sessions don't get protocol callbacks.
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;
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;