Skip to content

Instantly share code, notes, and snippets.

@sephiroth74
sephiroth74 / Crypto
Created November 22, 2014 05:17
Decrypt open-ssl encrypted file using android
package it.sephiroth.android.library.simpleaes;
import android.support.annotation.NonNull;
import android.util.Base64;
import java.security.GeneralSecurityException;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
@sephiroth74
sephiroth74 / gist:f84c36f679f1205543a0
Created January 8, 2015 21:51
Android MediaScanner scan folder
adb shell am broadcast -a android.intent.action.MEDIA_MOUNTED -d file:///mnt/sdcard/
@sephiroth74
sephiroth74 / git pretty stat
Last active April 17, 2024 22:23
Show lines added/deleted and total commits per author in a period of time on all branches
git log --all --numstat --pretty="%H" --author="author" --since=1.year | awk 'NF==3 {plus+=$1; minus+=$2} NF==1 {total++} END {printf("lines added: +%d\nlines deleted: -%d\ntotal commits: %d\n", plus, minus, total)}'
@sephiroth74
sephiroth74 / Reveal.java
Created March 4, 2015 05:52
Circular Reveal Transition
package it.sephiroth.android.library.myapplication;
import android.animation.Animator;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.TypedArray;
import android.os.Build;
import android.transition.TransitionValues;
import android.transition.Visibility;
import android.util.AttributeSet;
@sephiroth74
sephiroth74 / git_find_files
Created March 25, 2015 23:12
Git search string in all files across all commits
function git_find_files() {
if [ "$#" -ne 1 ]
then
echo "Usage: git_find_files string"
return
fi
git log -p -S$1 --pickaxe-all --full-diff
}
package com.adobe.android.ui.view;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.support.v4.view.ViewCompat;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
@sephiroth74
sephiroth74 / gist:cfed0b50d46582473850
Created August 25, 2015 13:43
Debug native C/C++ android code in Mac OSX
cp {project}/src/main/libs/armeabi-v7a/gdbserver {project}/build/intermediates/bundles/{flavor}/debug/jni/armeabi-v7a/
adb shell
su
ps | grep '{packagename}'
/data/app/{packagename}/lib/arm/gdbserver :8888 --attach 8150
* new terminal tab *
adb forward tcp:8888 tcp:8888
arm-linux-androideabi-gdb
@sephiroth74
sephiroth74 / local-mvn-push.gradle
Last active August 27, 2015 21:59
publish artifact to local maven repository
apply plugin: 'maven'
apply plugin: 'signing'
def isReleaseBuild() {
return VERSION_NAME.contains("SNAPSHOT") == false
}
def getReleaseRepositoryUrl() {
return "file:///${project.rootDir}/mvn-repo/release/"
@sephiroth74
sephiroth74 / FitBitmapDrawable.java
Last active December 2, 2015 17:05
Always draw the given bitmap into the Drawable's bounds, respecting the bitmap's aspect ratio. Best use with an ImageView with scaleType set to FIT_XY
/**
* Always draw the given bitmap into the Drawable's bounds, respecting
* the bitmap's aspect ratio.
* Best use with an ImageView with scaleType set to FIT_XY
*/
public class FitBitmapDrawable extends BitmapDrawable {
private final Matrix matrix = new Matrix();
private final RectF mTempSrc = new RectF();
private final RectF mTempDst = new RectF();
@sephiroth74
sephiroth74 / BitmapRetention.java
Created January 16, 2016 22:18
Utility class to save and load bitmap to and from a bundle. Use it for onSaveInstanceState/onCreate lifecycle
public static class BitmapRetention {
public static Bundle safeSave (@NonNull final Bitmap bitmap) {
try {
return save(bitmap);
} catch (IOException e) {
e.printStackTrace();
}
return null;
}