Skip to content

Instantly share code, notes, and snippets.

View menny's full-sized avatar

Menny Even Danan menny

View GitHub Profile
@menny
menny / build.gradle
Last active August 29, 2015 14:00
Shippable for _Android_ Projects
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.9.+'
}
}
@menny
menny / VersionBuilder.groovy
Last active August 29, 2015 14:19
VersionBuilder for Gradle
package versionbuilder
class VersionBuilder {
static final int GIT_COMMIT_COUNT_NORMALIZE = 230;
static final int GIT_COMMIT_COUNT_MINOR_NORMALIZE = 0;
static def buildGitVersionNumber() {
return Integer.parseInt('git rev-list --count HEAD'.execute().text.trim()) - GIT_COMMIT_COUNT_NORMALIZE;
}
@menny
menny / .git-hooks-pre-push
Last active August 29, 2015 14:19
Get Reviewers using Git Blame
#!/bin/sh
java -jar git-blame-reviewers-suggestions-1.0-SNAPSHOT-jar-with-dependencies.jar
@menny
menny / ScalingImageView.java
Created July 24, 2012 10:20
Android's ImageView scaling hack
package net.evendanan.android.hacks;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
/****
*Note, this ImageView hack will ALWAYS scale the image (up or down) to fit the available
*space, while keeping the image aspect ratio.
*/
public class CustomGradleTestRunner extends RobolectricGradleTestRunner {
private static final int MAX_SDK_LEVEL = 21;
public CustomGradleTestRunner(Class<?> klass) throws InitializationError {
super(klass);
}
@Override
public Config getConfig(Method method) {
Config config = super.getConfig(method);
@menny
menny / .buckconfig.yaml
Last active November 6, 2015 19:01
Buck examples
[buildfile]
includes = //DEFS
@menny
menny / AndroidDumpHprof.java
Last active December 12, 2015 01:08
Android Memory Leaks OR The Different Ways to Leak
File extFolder = Environment.getExternalStorageDirectory();
File target = new File(extFolder, "ask_mem_dump.hprof");
Debug.dumpHprofData(target.getAbsolutePath());
@menny
menny / InnerClassSnippet.java
Last active December 12, 2015 08:59
Android Memory Leaks OR Different Ways to Leak
public class AnySoftKeyboard extends InputMethodService {
private static final class KeyboardUIStateHanlder extends Handler {
//This will NOT be counted as a reference!
private final WeakReference<AnySoftKeyboard> mKeyboard;
public KeyboardUIStateHanlder(AnySoftKeyboard keyboard) {
mKeyboard = new WeakReference<AnySoftKeyboard>(keyboard);
}
private static void unbindDrawable(Drawable d) {
if (d != null)
d.setCallback(null);
}
@menny
menny / AndroidManifest_API3.xml
Created December 10, 2013 16:01
Gists for 2013-12-10-multi_API_level_release post
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.menny.android.anysoftkeyboard"
android:versionCode="112"
android:versionName="20131030">
<uses-sdk
android:minSdkVersion="3"
android:targetSdkVersion="3"
android:maxSdkVersion="3">
</uses-sdk>