Skip to content

Instantly share code, notes, and snippets.

Alessandro Crugnola sephiroth74

Block or report user

Report or block sephiroth74

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@sephiroth74
sephiroth74 / find-unused-layouts.sh
Created Jul 3, 2019
Android find unused layouts
View find-unused-layouts.sh
for f in `find . -iname "*.xml" | grep src/main/res/layout`; do echo $f ; git grep --count -e "R\.layout\.$(basename $f .xml)\W" --or -e "@layout/$(basename $f .xml)\W" | wc -l ; done | grep -B1 "0$"
View v8.gyp
# Copyright 2012 the V8 project authors. All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
@sephiroth74
sephiroth74 / MyTest.java
Created May 31, 2017
android instrumentationTest grant permissions
View MyTest.java
@RunWith(AndroidJUnit4.class)
@LargeTest
public class MyTest {
@Before
public void grantPhonePermission() {
// In M+, trying to call a number will trigger a runtime dialog. Make sure
// the permission is granted before running this test.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
getInstrumentation().getUiAutomation().executeShellCommand(
"pm grant " + getTargetContext().getPackageName()
View checkstyle.xml
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN" "http://www.puppycrawl.com/dtds/configuration_1_3.dtd"><!--
Checkstyle-Configuration: Android Checkstyle
Description: none
-->
<module name="Checker">
<!--<property name="severity" value="warning" />-->
<module name="FileLength">
<property name="max" value="3000" />
@sephiroth74
sephiroth74 / BitmapRetention.java
Created Jan 16, 2016
Utility class to save and load bitmap to and from a bundle. Use it for onSaveInstanceState/onCreate lifecycle
View BitmapRetention.java
public static class BitmapRetention {
public static Bundle safeSave (@NonNull final Bitmap bitmap) {
try {
return save(bitmap);
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
@sephiroth74
sephiroth74 / FitBitmapDrawable.java
Last active Dec 2, 2015
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
View FitBitmapDrawable.java
/**
* 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 / local-mvn-push.gradle
Last active Aug 27, 2015
publish artifact to local maven repository
View local-mvn-push.gradle
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 / gist:cfed0b50d46582473850
Created Aug 25, 2015
Debug native C/C++ android code in Mac OSX
View gist:cfed0b50d46582473850
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
View DividerItemDecoration.java
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 / git_find_files
Created Mar 25, 2015
Git search string in all files across all commits
View git_find_files
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
}
You can’t perform that action at this time.