Skip to content

Instantly share code, notes, and snippets.

@ejohansson
ejohansson / proguardConfigurationTask
Created December 4, 2016 21:16
Multi config Proguard
/*
* Creates a combined proguard file ${project.name}-combined.pro
* put files in `project/app/proguard/{proguardfile}`
* Usage: proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro', 'app-combined.pro'
*/
task proguardConfiguration { task ->
println "${project.name}:${task.name}"
def output = new File("${project.projectDir}/${project.name}-combined.pro")
delete file(output);
fileTree("proguard").visit { FileVisitDetails details ->
@ejohansson
ejohansson / ImagePicker.java
Last active August 10, 2016 15:47 — forked from Mariovc/ ImagePicker.java
Utility for picking an image from Gallery/Camera with Android Intents
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.content.res.AssetFileDescriptor;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.media.ExifInterface;
@ejohansson
ejohansson / OrientationChangeAction.java
Last active May 3, 2016 15:16 — forked from nbarraille/OrientationChangeAction.java
An Espresso ViewAction that changes the orientation of the screen
/*
* The MIT License (MIT)
*
* Copyright (c) 2015 - Nathan Barraille
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
08:45:03.043 [ERROR] [org.gradle.BuildExceptionReporter] 
08:45:03.047 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
08:45:03.047 [ERROR] [org.gradle.BuildExceptionReporter] 
08:45:03.049 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
08:45:03.050 [ERROR] [org.gradle.BuildExceptionReporter] Execution failed for task ':app:compileDebugJavaWithJavac'.
08:45:03.050 [ERROR] [org.gradle.BuildExceptionReporter] > Compilation failed; see the compiler error output for details.
08:45:03.056 [ERROR] [org.gradle.BuildExceptionReporter] 
08:45:03.057 [ERROR] [org.gradle.BuildExceptionReporter] * Exception is:
08:45:03.059 [ERROR] [org.gradle.BuildExceptionReporter] org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:compileDebugJavaWithJavac'.

File -> Project Structure -> SDK Location

JDK Location: /Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home

echo "export STUDIO_JDK=/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk" >> ~/.bash_profile
source ~/.bash_profile
@ejohansson
ejohansson / build.gradle
Last active April 7, 2016 21:23
Android Studio 2.0 & Java 8
// Source: http://developer.android.com/preview/j8-jack.html
android {
defaultConfig {
jackOptions {
enabled true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8

adb shell ifconfig | grep 'inet addr' | grep -v 127.0.0.1 | cut -d: -f2 | awk '{print $1}'

Bash Alias - Note $ escaping $

alias androidIp="adb shell ifconfig | grep 'inet addr' | grep -v 127.0.0.1 | cut -d: -f2 | awk '{print \$1}'"

import android.content.Context;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
-- REPLACE ${SCHEMA}, ${USER}, ${PASSWORD}
SET GLOBAL FOREIGN_KEY_CHECKS = 0;
DROP SCHEMA `${SCHEMA}`;
CREATE SCHEMA `${SCHEMA}`;
USE `${SCHEMA}`;
-- EJB TimerService
CREATE TABLE IF NOT EXISTS `${SCHEMA}`.EJB__TIMER__TBL (
`CREATIONTIMERAW` BIGINT NOT NULL,
`BLOB` BLOB,
@ejohansson
ejohansson / docximages.sh
Created October 19, 2015 12:47
Extract Images From a .docx
!/bin/bash
fullpath=$1
filename=$(basename "$1")
extension="${filename##*.}"
filename="${filename%.*}"
dzip="${filename}.zip"
cp "$fullpath" "${dzip}"
unzip -o "${dzip}" -d "/tmp/${filename}"