Skip to content

Instantly share code, notes, and snippets.

@twaddington
twaddington / Timer.java
Created May 8, 2012 07:07
Simple Java Timer class.
package com.geoloqi.android.sdk.util;
import java.util.concurrent.TimeUnit;
/**
* A simple class for timing short lived events.
*
* @author Tristan Waddington
*/
public class Timer {
@twaddington
twaddington / TypefaceTextView.java
Last active March 31, 2020 15:48
An Android TextView with support for custom typefaces.
/*
* TypefaceTextView.java
* Simple
*
* Copyright 2012 Simple Finance Corporation (https://www.simple.com)
*
* 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
*
@twaddington
twaddington / getInstanceLength.java
Created November 8, 2011 01:18
Simple method to parse an HttpResponse for a Content-Range header and extract the instance length (total size). Great for making partial-content requests.
/**
* <p>This method checks an HttpResponse for a Content-Range
* header and, if present, attempts to parse the instance-length
* from the header value.</p>
* <p>{@link http://tools.ietf.org/html/rfc2616#section-14.16}</p>
*
* @param response
* @return the total number of bytes for the instance, or a negative number if unknown.
*/
public static long getInstanceLength(HttpResponse response) {
@twaddington
twaddington / gist:c59a8957facf47b81249799a5664b963
Created October 12, 2017 02:19
Loading keystore signing info into 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)
}
}
android {
@twaddington
twaddington / build.gradle
Created July 25, 2017 03:36
Android - Load signing info from keystore.properties
// 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)
}
}
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 January 2, 2017 05:41
Script to update file modification and access times. Unfortunately, does not update file creation time.
#!/usr/bin/python
import sys
import os
import time
from datetime import datetime
def modtime(path):
print path
/*
* 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
@twaddington
twaddington / gist:8035951
Created December 19, 2013 08:11
Fetch the Activity title from the Android manifest
try {
ActivityInfo activityInfo = getPackageManager().getActivityInfo(getComponentName(), 0);
setTitle(activityInfo.labelRes);
} catch (NameNotFoundException e) {
SFLog.w(String.format("%s is not a valid Activity", getComponentName()));
}
@twaddington
twaddington / charities.md
Created December 12, 2013 19:15
Charitable Giving