This file contains hidden or 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 android.app.Activity; | |
import android.support.annotation.CheckResult; | |
import android.support.annotation.NonNull; | |
import android.support.annotation.Size; | |
import android.support.v4.app.ActivityCompat; | |
import static android.content.pm.PackageManager.PERMISSION_GRANTED; | |
public class ActivityPermissionDelegate { | |
public interface PermissionRationaleRetryBehavior { |
This file contains hidden or 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
// annotation processor will generate DevicePhoneNumberSumType (see: 4_DevicePhoneNumberSumType.java) | |
@SumType | |
public interface DevicePhoneNumber { | |
String phoneNumber(); | |
void phoneNumberNotAvailable(); | |
String[] permissionsRequired(); | |
} |
This file contains hidden or 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 android.app.Application; | |
import com.fasterxml.jackson.databind.DeserializationFeature; | |
import com.fasterxml.jackson.databind.ObjectMapper; | |
import com.squareup.okhttp.OkHttpClient; | |
import javax.inject.Singleton; | |
import dagger.Module; |
This file contains hidden or 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 android.content.Context; | |
import android.graphics.drawable.Drawable; | |
import android.support.annotation.ColorRes; | |
import android.support.annotation.DrawableRes; | |
import android.support.v4.content.ContextCompat; | |
import android.support.v4.graphics.drawable.DrawableCompat; | |
public class DrawableHelper { | |
public static Drawable setupTintedIcon(Context context, @DrawableRes int iconDrawableResId, @ColorRes int iconColorResId) { | |
Drawable icon = ContextCompat.getDrawable(context, iconDrawableResId); |
This file contains hidden or 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
public static Date parseRawDateWithUnhandledException(String dateString) throws ParseException { | |
// This was previously being handled with Joda (yay!), but Joda eats up nearly 5000 | |
// methods (boo!) in an already big app just to parse a timestamp...so there *is* a reason | |
// we are doing things like this... | |
if (dateString.endsWith("Z")) { | |
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US); | |
dateFormat.setTimeZone(TimeZone.getTimeZone("Zulu")); | |
return dateFormat.parse(dateString); | |
} else { |
This file contains hidden or 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 org.junit.Test; | |
import static org.junit.Assert.assertEquals; | |
public class StringTest { | |
@Test | |
public void testAllTheSame() { | |
assertEquals(true, allDuplicateChars("cccccc")); | |
} |
This file contains hidden or 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
#!/usr/bin/python | |
import sys | |
import xml.etree.ElementTree | |
import collections | |
xmlFile = sys.argv[1] | |
strings = collections.Counter() | |
root = xml.etree.ElementTree.parse(xmlFile).getroot() |
This file contains hidden or 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
ffmpeg -f concat -i concat.txt -c copy output.mp4 |
This file contains hidden or 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
export PS1="\[$(tput bold)\]\[$(tput setaf 6)\]\t \[$(tput setaf 2)\][\[$(tput setaf 3)\]\u\[$(tput setaf 1)\]@\[$(tput setaf 3)\]\h \[$(tput setaf 6)\]\W\[$(tput setaf 2)\]]\[$(tput setaf 4)\]\\$ \[$(tput sgr0)\]" | |
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home # Update to latest | |
export ANDROID_HOME=~/Library/Android/sdk | |
export PATH=$ANDROID_HOME/tools:$PATH | |
export PATH=$ANDROID_HOME/platform-tools:$PATH | |
export PATH=$ANDROID_HOME/build-tools/22.0.1:$PATH # Update to latest |
This file contains hidden or 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
StrictMode policy violation; ~duration=1436 ms: android.os.StrictMode$StrictModeDiskReadViolation: policy=1114143 violation=2 | |
at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1263) | |
at libcore.io.BlockGuardOs.access(BlockGuardOs.java:67) | |
at java.io.File.doAccess(File.java:281) | |
at java.io.File.exists(File.java:361) | |
at android.app.ContextImpl.createFilesDirLocked(ContextImpl.java:418) | |
at android.app.ContextImpl.getCacheDir(ContextImpl.java:503) | |
at android.content.ContextWrapper.getCacheDir(ContextWrapper.java:233) |