Skip to content

Instantly share code, notes, and snippets.

@imminent
imminent / AndroidCookieStore.java
Last active December 14, 2015 06:38
Collection of code to use the Client interface of Retrofit to use HttpUrlConnection with SharedPreferences persistent cookies.
import android.annotation.TargetApi;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.PatternMatcher;
import com.keepandshare.android.utils.CryptographyUtil;
import com.keepandshare.android.utils.Ln;
import javax.inject.Singleton;
import java.net.CookieStore;
import java.net.HttpCookie;
@damianflannery
damianflannery / gist:5717329
Last active December 18, 2015 03:19
android square okhttp, mimecraft & cookies
public static int okSubmitAttachment(Context ctx, String filePath, String mimeType, String uuid) throws IOException, URISyntaxException, MalformedURLException {
int responseCode = 0;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx);
String baseUrl = prefs.getString("server_preference", Constants.DEFAULT_BASE_URL);
if (!(baseUrl.charAt(baseUrl.length() - 1) == '/')) {
baseUrl += "/";
}
@orip
orip / build.gradle
Last active April 19, 2016 11:56
ProGuard rules for using Dagger 1.1.0 with gradle.
dependencies {
def dagger_version = "1.1.0"
compile "com.squareup.dagger:dagger:${dagger_version}"
compile "com.squareup.dagger:dagger-compiler:${dagger_version}"
}
@JakeWharton
JakeWharton / README.md
Last active January 8, 2020 02:13
A special activity which facilitates restarting your application process.
@swankjesse
swankjesse / RetrofitCachingExample.java
Created June 29, 2013 03:03
Demonstrate HTTP caching with OkHttp and Retrofit.
/*
* Copyright (C) 2013 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
@JakeWharton
JakeWharton / AutoGson.java
Last active November 28, 2021 12:32
A Gson TypeAdapterFactory which allows serialization of @autovalue types. Apache 2 licensed.
import com.google.auto.value.AutoValue;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* Marks an {@link AutoValue @AutoValue}-annotated type for proper Gson serialization.
* <p>
@pedpess
pedpess / rnstudy.md
Last active May 2, 2022 04:31
React Native Study Notes

React Native Study Notes

(by @pedpess)


These are my own paper version notes meeting the digital world. They are related to my learnings from 2017-18, or just stuff I thought would be nice to keep a record during the time I was grasping React Native to use in several projects of mine.

I also did a study notes about Javascript. Check it out! ;)

@pedpess
pedpess / jstudy.md
Last active May 31, 2022 09:48
Javascript Study Notes

Javascript Study Notes

(by @pedpess)


These are my own paper version notes meeting the digital world. They are related to my learnings from 2017-18, or just stuff I thought would be nice to keep a record during the time I was grasping some Javascript topics.

PS: Don't expect all the material here to be 100% accurate or up-to-date. If you find some part that's wrong, or missing or old, please send me a comment to fix! :)

@JakeWharton
JakeWharton / OkHttpStack.java
Created May 21, 2013 01:14
A `HttpStack` implementation for Volley that uses OkHttp as its transport.
import com.android.volley.toolbox.HurlStack;
import com.squareup.okhttp.OkHttpClient;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
/**
* An {@link com.android.volley.toolbox.HttpStack HttpStack} implementation which
* uses OkHttp as its transport.
*/
@JakeWharton
JakeWharton / README.md
Last active April 17, 2023 14:07
A JUnit @rule which launches an activity when your test starts. Stop extending gross ActivityInstrumentationBarfCase2!