Skip to content

Instantly share code, notes, and snippets.

View scottyab's full-sized avatar

Scott Alexander-Bown scottyab

View GitHub Profile
@scottyab
scottyab / QuickInstallScript.sh
Last active August 29, 2015 13:58
From article http://www.vkalchev.co.uk/content/quickinstallapk/ Spoke to Val and he clarified the Licensed under the Apache License, Version 2.0
#!/bin/bash
#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
#Copyright 2013 Valentin Kalchev
#Date: 26/02/2013
#Target: Mac OS X Terminal + Android ADB + AAPT
sharePackageName=""

Keybase proof

I hereby claim:

  • I am scottyab on github.
  • I am scottyab (https://keybase.io/scottyab) on keybase.
  • I have a public key whose fingerprint is 88AE 289F 03AE 3684 94BA B89F A056 9F94 AD10 76CD

To claim this, I am signing this object:

@scottyab
scottyab / Installation.java
Last active August 29, 2015 14:01
Code from http://android-developers.blogspot.co.uk/2011/03/identifying-app-installations.html -- For the vast majority of applications, the requirement is to identify a particular installation, not a physical device. Fortunately, doing so is straightforward. There are many good reasons for avoiding the attempt to identify a particular device. Fo…
package com.vf.tools
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.UUID;
import android.content.Context;
@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 / .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 / 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
Verifying that +scottyab is my openname (Bitcoin username). https://onename.io/scottyab
@scottyab
scottyab / ConvertLatLongToStaticMapUri
Created May 3, 2012 14:46
Quick and dirty util to convert a lat/long into a uri for google static maps.
/**
* simple util to build the static google map url for the lat/long
* @param latitude
* @param longitude
* @return static google map url
*/
public static Uri buildStaticGoogleMapUrlForAddress(String latitude, String longitude){
Builder builder = Uri.parse("http://maps.google.com/maps/api/staticmap").buildUpon();
builder.appendQueryParameter("center", latitude+","+longitude);
@scottyab
scottyab / MyXofYPagerAdapter.java
Created April 16, 2013 19:59
PagerAdapter X of Y. When using a view pager you can simply override the getPageTitle to create a page x of y text as seen in apps like gmail. This was used in a app to swipe through the RSS stories with android.support.v4.app.FragmentPagerAdapter. Alternatively you could use something like https://github.com/ManuelPeinado/NumericPageIndicator
public class MyXofYPagerAdapter extends FragmentPagerAdapter {
private final ArrayList<RssItem> items;
public MyXofYPagerAdapter(FragmentManager fm,
ArrayList<RssItem> items) {
super(fm);
this.items = items;
}
@Override
@scottyab
scottyab / proguard-project.txt
Created August 23, 2013 13:02
Android Proguard config to remove all logging. Remember to enabled the -optimize progaurd config
#Remove Android logging code
-assumenosideeffects class android.util.Log {
public static boolean isLoggable(java.lang.String, int);
public static int v(...);
public static int i(...);
public static int w(...);
public static int d(...);
public static int e(...);
public static java.lang.String getStackTraceString(java.lang.Throwable);
}