Instantly share code, notes, and snippets.

View gist:f34a0893388438d823e40a068a2a6370
/***
* Wrapper for instabug implementation
* API docs are (mostly) here: https://instabug.com/public/android-api-reference/com/instabug/library/Instabug.html
*/
public class InstabugUtil {
public static void init(Application context) {
// Builder should run first
Instabug.Builder builder = new Instabug.Builder(context, context.getString(R.string.instabug_key));
if (BuildConfig.DEBUG) {
View gradle-print-tasks-time.gradle
// 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()
}
View Mac Github SSH Quick.md

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

View InstallFullStackAngularJsMean.sh
# Make sure homebrew is installed and latest
brew update
# Run the brew doctor and read the instructions, it will make sure all paths are ready for write and all
brew doctor
# Start installing packages
brew install mongodb
brew install homebrew/versions/node010 #For Yeomen compatability later on
npm install express -g
View detectWebGL.js
/**
* Detects if WebGL is enabled.
* Inspired from http://www.browserleaks.com/webgl#howto-detect-webgl
*
* @return { number } -1 for not Supported,
* 0 for disabled
* 1 for enabled
*/
function detectWebGL()
{
View build.gradle
// 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
View 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'
View gist:068f19545e51e4627749
/***
* 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
View build.gradle
// 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)
}
View build.gradle
android {
defaultConfig {
...
// Fetch the version according to git latest tag and "how far are we from last tag"
def longVersionName = "git -C ${rootDir} describe --tags --long".execute().text.trim()
def (fullVersionTag, versionBuild, gitSha) = longVersionName.tokenize('-')
def(versionMajor, versionMinor, versionPatch) = fullVersionTag.tokenize('.')
// Set the version name
versionName "$versionMajor.$versionMinor.$versionPatch($versionBuild)"