Skip to content

Instantly share code, notes, and snippets.

@nickbutcher
nickbutcher / 1 search_bar.xml
Last active March 26, 2022 10:03
Demonstrating morphing a search icon into a search field. To do this we use an AnimatedVectorDrawable (https://developer.android.com/reference/android/graphics/drawable/AnimatedVectorDrawable.html) made up of two paths. The first is the search icon (as a single line) the second is the horizontal bar. We then animate the 'trimPathStart' property …
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
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
@JakeWharton
JakeWharton / README.md
Last active January 8, 2020 02:13
A special activity which facilitates restarting your application process.
@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>
@JakeWharton
JakeWharton / README.md
Last active May 10, 2018 08:39
A workaround for Android "L" Okio packaging problem. Place all of the following in a `libs/` folder.

JarJar'd OkHttp Dependencies

Due to a bug in the packaging of Android OS "L", dependencies which reference Okio need to be repackaged.

For more information see square/okhttp#967

Usage

@dmarcato
dmarcato / strip_play_services.gradle
Last active December 21, 2022 10:10
Gradle task to strip unused packages on Google Play Services library
def toCamelCase(String string) {
String result = ""
string.findAll("[^\\W]+") { String word ->
result += word.capitalize()
}
return result
}
afterEvaluate { project ->
Configuration runtimeConfiguration = project.configurations.getByName('compile')
@chrisbanes
chrisbanes / FloatLabelLayout.java
Last active March 15, 2024 06:39
FloatLabelLayout
/*
* Copyright 2014 Chris Banes
*
* 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 / 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;
@swanson
swanson / gist:7dee3f3474e30fe8f15c
Last active January 11, 2024 16:42
Retrofit LocalJsonClient
import android.annotation.SuppressLint;
import android.content.Context;
import android.util.Log;
import retrofit.client.Client;
import retrofit.client.Header;
import retrofit.client.Request;
import retrofit.client.Response;
import retrofit.mime.TypedInput;
@lhackman
lhackman / microserfs.txt
Created January 14, 2014 22:01
Taken from the wikipedia article on the book Microserfs. Being used as a sample text file for a python problem for a class.
Microserfs, published by HarperCollins in 1995, is an epistolary novel by Douglas Coupland. It first appeared in short story form as the cover article for the January 1994 issue of Wired magazine and was subsequently expanded to full novel length. Set in the early 1990s, it captures the state of the technology industry before Windows 95, and anticipates the dot-com bubble of the late 1990s.
The novel is presented in the form of diary entries maintained on a PowerBook by the narrator, Daniel. Because of this, as well as its formatting and usage of emoticons, this novel is similar to what emerged a decade later as the blog format.
Coupland revisited many of the ideas in Microserfs in his 2006 novel JPod, which has been labeled "Microserfs for the Google generation".
@lhackman
lhackman / gist:8422019
Created January 14, 2014 17:15
descriptors for superhero exercise
adjectives = dict(a="red", b="orange", c="green", d="blue", e="yellow", f="orange", g="black", h="super", i="mysterious", j="flying", k="purple", l="sparkling", m="flashing", n="courageous", o="singing", p="tender", q="magnificent", r="radioactive", s="hypnotic", t="screaming", u="ultraviolet", v="royal", w="tap dancing", x= "silent", y="angry", z="amazing")
nouns = dict(a="waffle", b="turtle", c="lantern", d="herb garden", e="trampoline", f="marshmallow", g="ghost", h="tent", i="water bottle", j="rattle", k="cell phone", l="romantic", m="restaurant", n="coin purse", o="quail", p="pineapple", q="mosquito", r="wrestler", s="sun", t="walrus", u="vigilante", v="jester", w="teddy bear", x= "python", y="racoon", z="wombat")