This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package cash.andrew | |
import javax.imageio.ImageIO | |
import java.awt.image.BufferedImage | |
import java.time.LocalDateTime | |
// 0xffffff + 1 | |
// so that random returns a value from 0 to 0xffffff | |
final int MAX_COLOR_VALUE = 16777216 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ws.🍉💩; | |
import android.support.v7.widget.RecyclerView; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; | |
/** | |
* A recycler view adapter that makes life better. | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ext.keystorePassword = project.hasProperty('keystorePassword')?project.getProperty('keystorePassword'):System.getenv('KEYSTORE_PASSWORD')?:'' | |
ext.aliasKeyPassword = project.hasProperty('aliasKeyPassword')?project.getProperty('aliasKeyPassword'):System.getenv('ALIAS_KEY_PASSWORD')?:'' | |
ext.storeKeyAlias = project.hasProperty('storeKeyAlias')?project.getProperty('storeKeyAlias'):System.getenv('STORE_KEY_ALIAS')?:'' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.andrewreitz.utils; | |
import android.text.Spannable; | |
import android.text.SpannableString; | |
import android.text.TextPaint; | |
import android.text.method.LinkMovementMethod; | |
import android.text.style.URLSpan; | |
import android.widget.TextView; | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Does what you expect | |
println ZonedDateTime.ofInstant(Instant.now(), ZoneId.systemDefault()).minusYears(10).toInstant() | |
// throws an exception java.time.DateTimeException: Unable to obtain ChronoZonedDateTime from TemporalAccessor: class java.time.Instant | |
println ZonedDateTime.from(Instant.now()).minusYears(10).toInstant() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.smartthings.android.common.http; | |
import com.inkapplications.preferences.IntPreference; | |
import com.smartthings.android.di.annotation.HttpDisasterRate; | |
import com.squareup.okhttp.Interceptor; | |
import com.squareup.okhttp.Protocol; | |
import com.squareup.okhttp.MediaType; | |
import com.squareup.okhttp.Response; | |
import com.squareup.okhttp.Request; | |
import com.squareup.okhttp.ResponseBody; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.imageio.ImageIO | |
import java.awt.image.BufferedImage | |
def image = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB) | |
for (x in 0..99) { | |
for (y in 0..99) { | |
int color = (x + y) % 2 == 0 ? 0x000000 : 0xffffff | |
image.setRGB(x, y, color) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Adds extra tasks to improve android usage | |
project.android.applicationVariants.all { variant -> | |
def adb = new File(project.android.sdkDirectory as File, '/platform-tools/adb') | |
def variantName = variant.name.capitalize() | |
def flavor = variant.flavorName | |
def buildType = variant.buildType.name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def parseArgs = { String input -> | |
def args = [] | |
def m = Pattern.compile("([^\"]\\S*|\".+?\")\\s*").matcher(input); | |
while (m.find()) { | |
args.add(m.group(1)) | |
} | |
return args | |
} | |
run { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Create a string representation of an object. This will include all fields that are not | |
* transient or static. The returned string will be in the form of `full_class_name{fieldName='value'}` | |
* This will also include all super types values as well in the string. | |
* | |
* @param object The object to get a string representation from. | |
* @return String representation of the object. | |
*/ | |
public static String toString(Object object) { | |
Class<?> aClass = object.getClass(); |