Skip to content

Instantly share code, notes, and snippets.

View scottyab's full-sized avatar

Scott Alexander-Bown scottyab

View GitHub Profile
package com.enquos.nutrition.dashboard;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.view.View;
@scottyab
scottyab / QLog.java
Created March 4, 2016 10:39 — forked from chrisjenx/QLog.java
QLog
package com.bizzby.utils;
import android.util.Log;
import java.io.PrintWriter;
import java.io.StringWriter;
public class QLog
{
@scottyab
scottyab / gist:ff0bf65bd73f1572fa49
Created January 4, 2016 14:06
Example of crittercism api upload for proguard-mapping.txt
curl “https://app.crittercism.com/api_beta/proguard/<app_id>" -F proguard=@”<path/to/proguard-mapping.txt>” -F app_version=”app-version-name” -F key=<key>
Verifying that +scottyab is my openname (Bitcoin username). https://onename.io/scottyab
@scottyab
scottyab / Installer
Created September 17, 2014 14:55
Tamper checks
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
public class InstallerCheck{
private static final String PLAY_STORE_APP_ID = "com.google.android";
public static boolean verifyInstaller(final Context context) {
@scottyab
scottyab / remove2x.sh
Created June 26, 2014 15:43
Rename iOS graphics with foo@2x.ong to foo.png roughly 2x graphics are xhdpi (code from https://stackoverflow.com/questions/17484514/bash-script-command-to-bulk-remove-2x-from-filename-retina-image-normal)
#!/bin/bash
#rename file names to remove the "@2x"
for i in *@2x.*; do
mv "$i" "${i/@2x/}"
done
@scottyab
scottyab / .gitignore
Last active August 29, 2015 14:01
My .gitignore file for Android development
# gimpy mac thingy
.DS_Store
# IDEA Ignores
*.iml
*.ipr
*.iws
.idea/
# Local configuration file (sdk path, etc)
@scottyab
scottyab / IntentExtraEample.java
Created May 14, 2014 16:23
When using Intent extras, pass an Id rather than the object as Intent extras 'could' be intercepted and read be a malicious app.
//bad passing the whole paracable object
public static Intent getStartingIntent(Context context,
User user) {
Intent i = new Intent(context, UserDetailsActivity.class);
i.putExtra(EXTRA_USER, user);
return i;
}
//better to pass just the ID to lookup the user details
public static Intent getStartingIntent(Context context,
@scottyab
scottyab / SafePendingIntent.java
Created May 14, 2014 16:10
Creating an explicit pending intent is safer than implicit
//explicit (to MyService)
Intent intent = new Intent(context, MyService.class);
PendingIntent pi = PendingIntent.getService(getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
//implicit
Intent intent = new Intent("com.my.app.action")
PendingIntent pi = PendingIntent.getService(getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);