Skip to content

Instantly share code, notes, and snippets.

View almozavr's full-sized avatar

Oleksii Malovanyi almozavr

  • Lviv, UA
View GitHub Profile
@almozavr
almozavr / .gitconfig
Created June 10, 2014 07:33
global git config
# core {{{
[core]
excludesfile = /Users/almozavr/.gitignore_global
pager=less -x4
quotepath = false
pager = less
autocrlf = input
#}}}
# user {{{
@almozavr
almozavr / Script to start-stop Genymotion with connection to ADB
Last active August 29, 2015 14:06
Start(resume)/stop virtual machine by serial number and connect/disconnect with adb. Could be useful to control remote CI Genymotion instance
#!/bin/bash
#=====EXAMPLE OF USAGE===============
# $ ./scripts/gm.sh -r 526d4be6-9964-4a84-83fd-31af8029cf44
# $ ./gradlew clean connectedAndroidTest
# $ ./scripts/gm.sh -s 526d4be6-9964-4a84-83fd-31af8029cf44
#====================================
#===========
# VM helpers
@almozavr
almozavr / .gitconfig
Last active August 29, 2015 14:06
Basic config with great aliases
# core {{{
[core]
excludesfile = ~/.gitignore_global
pager=less -x4
quotepath = false
pager = less
autocrlf = input
#}}}
# user {{{
private static WeakReference<RenderScript> rsRef = new WeakReference<>(null);
private static WeakReference<ScriptIntrinsicBlur> blurScriptRef = new WeakReference<>(null);
/**
* Use {@link RenderScript} to blur bitmap.
*
* @param bitmap to be blurred
* @param radius of blur
* @throws RSRuntimeException when some .so libs are not available (e.g. on Genymotion emulator)
*/
@almozavr
almozavr / open_db.sh
Created October 1, 2014 16:08
Downloads db from non-root devices and opens it via provided sqlite-viewer.
#!/bin/sh
# Script for getting database form device via adb and open in sqlite_client(work with not rooted devices)
#
# While you aren't breaking script execution(CTLR+C),
# each closing of sqlite_client will be download and open database again and again.
#
# Note: if you don't have installed sqliteman override sqlite_client variable with your favorite client
#
# Usage: open_db.sh {app_package} {db_name} {app}
@almozavr
almozavr / gist:f4d990fef964d0a1d4bd
Created October 5, 2014 14:29
PositionResizeAnimator
public class PositionResizeAnimator {
public static Animator createAnimator(Holder srcHolder, Holder targetHolder, final View animateView) {
ValueAnimator heightAnimator = ValueAnimator.ofInt(srcHolder.height, targetHolder.height);
heightAnimator.addUpdateListener(
new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
int val = (Integer) animation.getAnimatedValue();
ViewGroup.LayoutParams layoutParams = animateView.getLayoutParams();
@almozavr
almozavr / AndroidPaletteCallback
Last active August 29, 2015 14:19 — forked from imminent/ExampleActivity.java
Gist for a modified approach to integrating Palette with Picasso proposed by Jake Wharton for the interim while Picasso doesn't have a supported way to pass meta data along the pipeline. http://jakewharton.com/coercing-picasso-to-play-with-palette/ Fork provides diff RoundedImageView support
package your.package;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.support.annotation.NonNull;
import android.widget.ImageView;
public abstract class AndroidPaletteCallback extends PaletteCallback<ImageView> {
public AndroidPaletteCallback(@NonNull ImageView imageView) {
@almozavr
almozavr / ModalUrl
Last active August 29, 2015 14:19
Modal which preserves unique url via query, best with with routeProvider's reloadOnSearch: false
angular.module("services").factory('ModalUrl', [
'$rootScope', '$modal', '$location', '$routeParams', '$window', '$timeout',
($rootScope, $modal, $location, $routeParams, $window, $timeout) ->
modalInstance = null
checkModal = () ->
modalParam = decodeURIComponent($routeParams.modal)
if (modalParam != 'undefined')
optionsParam = decodeURIComponent($routeParams.options)
if (optionsParam != 'undefined')
options = JSON.parse(optionsParam)
@almozavr
almozavr / gist:fc76f605c03822a3ee14
Created July 13, 2015 17:36
Sms intent builder
public static Intent newSmsIntent(Context context, String body, String... phoneNumber) {
Uri smsUri;
if (phoneNumber == null) {
smsUri = Uri.parse("smsto:");
} else {
smsUri = Uri.parse("smsto:" + Uri.encode(TextUtils.join(",", phoneNumber)));
}
Intent intent;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
intent = new Intent(Intent.ACTION_SENDTO, smsUri);
public List<Class<?>> getEventTypesBySubscriber(Object subscriber) {
List<SubscriberMethod> subscriberMethods = subscriberMethodFinder.findSubscriberMethods(subscriber.getClass(), defaultMethodName);
List<Class<?>> eventTypes = new ArrayList<Class<?>>(subscriberMethods.size());
for (SubscriberMethod method : subscriberMethods) {
eventTypes.add(method.eventType);
}
return eventTypes;
}