Skip to content

Instantly share code, notes, and snippets.

@SeanZoR
SeanZoR / Mac Github SSH Quick.md
Last active September 19, 2017 09:18
Mac + Github = SSH

Generate the key with no password (just click enter) ssh-keygen -t rsa -b 4096 -C "email@example.com"
Copy to clipboard pbcopy < ~/.ssh/id_rsa.pub
Paste the key to your github account
Allow access ssh -T git@github.com, say yes

@SeanZoR
SeanZoR / gist:068f19545e51e4627749
Created October 19, 2014 19:00
Android L - fixing "IllegalArgumentException: Service Intent must be explicit"
/***
* Android L (lollipop, API 21) introduced a new problem when trying to invoke implicit intent,
* "java.lang.IllegalArgumentException: Service Intent must be explicit"
*
* If you are using an implicit intent, and know only 1 target would answer this intent,
* This method will help you turn the implicit intent into the explicit form.
*
* Inspired from SO answer: http://stackoverflow.com/a/26318757/1446466
* @param context
* @param implicitIntent - The original implicit intent
@SeanZoR
SeanZoR / gradle-print-tasks-time.gradle
Last active July 6, 2016 06:54
Android Gradle Tasks Timing
// Log timings per task.
class TimingsListener implements TaskExecutionListener, BuildListener {
private Clock clock
private timings = []
@Override
void beforeExecute(Task task) {
clock = new org.gradle.util.Clock()
}
@SeanZoR
SeanZoR / build.gradle
Last active April 11, 2016 05:49 — forked from khernyo/build.gradle
// This hack works with com.android.tools.build:gradle:0.2, won't work in later version without modification
apply plugin: 'android'
targetCompatibility = 1.6
sourceCompatibility = 1.6
android {
target = 'android-14'
@SeanZoR
SeanZoR / build.gradle
Created June 17, 2015 14:28
Adding a top level build.gradle file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.1'
// NOTE: Do not place your application dependencies here; they belong
@SeanZoR
SeanZoR / build.gradle
Created September 7, 2014 05:49
Android - add version name to APK file name
// Add the version name to the build
applicationVariants.all { v ->
def f = v.outputFile
def fname = f.name.replace(".apk",
"-${defaultConfig.versionName}.apk")
v.outputFile = new File(f.parent, fname)
}
@SeanZoR
SeanZoR / Adding a dependency to library
Last active August 29, 2015 13:57
Gradle - download a library
dependencies {
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.0'
}
@SeanZoR
SeanZoR / BasicStringSecurity
Last active August 29, 2015 13:56
Android - Manage your shared preference with a strings resource file (and secure strings)
import android.content.Context;
import android.provider.Settings;
import android.util.Base64;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.PBEParameterSpec;
@SeanZoR
SeanZoR / activateStrictModeFull
Created February 22, 2014 11:26
Android - Monitor using strict mode
public static void activateStrictModeFull(){
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectAll()
.penaltyLog()
.build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectAll()
.penaltyLog()
.build());
}
@SeanZoR
SeanZoR / UnbindingHelper
Created February 22, 2014 11:18
Android - Remove Binding helper - When you want to finish Activity w/o leaks
public static class UnbindingHelper {
/**
* Removes the reference to the activity from every view in a view hierarchy (listeners,
* images etc.).
* This method should be called in the onDestroy() method of each activity
*
* @param viewID normally the id of the root layout
* <p/>
* see http://code.google.com/p/android/issues/detail?id=8488