Skip to content

Instantly share code, notes, and snippets.

Tristan Waddington twaddington

Block or report user

Report or block twaddington

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@twaddington
twaddington / LICENSE
Last active Nov 23, 2017
This code demonstrates a method of signing OkHttp requests with an OAuth access token. An Authenticator is provided to renew an expired token using a refresh token.
View LICENSE
Copyright (C) 2017 Tristan Waddington <tristan.waddington@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
@twaddington
twaddington / gist:c59a8957facf47b81249799a5664b963
Created Oct 12, 2017
Loading keystore signing info into Gradle
View gist:c59a8957facf47b81249799a5664b963
// Load release signing info from keystore.properties
def keystoreProps = new Properties()
keystoreProps.load(new FileInputStream(rootProject.file('keystore.properties')))
keystoreProps.each { prop ->
if (!project.hasProperty(prop.key)) {
project.ext.set(prop.key, prop.value)
}
}
android {
@twaddington
twaddington / UserAgentInterceptor.java
Created Oct 12, 2017
Injects a User-Agent header into outgoing OkHttp requests.
View UserAgentInterceptor.java
package com.enlighthq.mobile.http;
import android.os.Build;
import java.io.IOException;
import java.util.Locale;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;
@twaddington
twaddington / build.gradle
Created Jul 25, 2017
Android - Load signing info from keystore.properties
View build.gradle
// Load release signing info from keystore.properties
def keystoreProps = new Properties()
keystoreProps.load(new FileInputStream(
rootProject.file('keystore.properties')))
keystoreProps.each { prop ->
if (!project.hasProperty(prop.key)) {
project.ext.set(prop.key, prop.value)
}
}
View sci-fi-films.txt
1977 - A New Hope
1978 - Dawn of the Dead
1979 - Alien
1980 - The Empire Strikes Back
1981 - Escape from New York
1982 - Blade Runner
The Thing
1983 - Return of the Jedi
1984 - Ghostbusters
The Terminator
@twaddington
twaddington / modtime.py
Created Jan 2, 2017
Script to update file modification and access times. Unfortunately, does not update file creation time.
View modtime.py
#!/usr/bin/python
import sys
import os
import time
from datetime import datetime
def modtime(path):
print path
View CompoundButtonContract.java
/*
* Copyright (C) 2017 Simple Finance Technology Ltd.
*
* 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
View crashlytics-offline.txt
:Mobile-Android:crashlyticsCleanupResourcesDebug
ERROR - Crashlytics Developer Tools error.
java.net.UnknownHostException: api.crashlytics.com: nodename nor servname provided, or not known
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:901)
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1293)
at java.net.InetAddress.getAllByName0(InetAddress.java:1246)
at java.net.InetAddress.getAllByName(InetAddress.java:1162)
at java.net.InetAddress.getAllByName(InetAddress.java:1098)
at com.crashlytics.reloc.org.apache.http.impl.conn.SystemDefaultDnsResolver.resolve(SystemDefaultDnsResolver.java:44)
@twaddington
twaddington / gist:8035951
Created Dec 19, 2013
Fetch the Activity title from the Android manifest
View gist:8035951
try {
ActivityInfo activityInfo = getPackageManager().getActivityInfo(getComponentName(), 0);
setTitle(activityInfo.labelRes);
} catch (NameNotFoundException e) {
SFLog.w(String.format("%s is not a valid Activity", getComponentName()));
}
You can’t perform that action at this time.