Skip to content

Instantly share code, notes, and snippets.

@amaksoft
amaksoft / export_plugin.gradle
Created Aug 22, 2016
An extremely simple plugin for exporting data from gradle script into properties file.
View export_plugin.gradle
/**
* Created by amak on 8/19/16.
*
* An extremely simple plugin for exporting data from gradle script into properties file.
* It's very useful for CI systems: turn your gradle script variables into environment variables.
*
* Plugin adds an extension exportExt for variables you want to export:
*
* exportExt {
* prop "version", myProjectVersion
@amaksoft
amaksoft / build.gradle
Created Aug 22, 2016 — forked from rponte/build.gradle
Excluding global dependency from all configurations (Gradle)
View build.gradle
// ...
configurations {
all*.exclude group: 'xml-apis', module: 'xmlParserAPIs'
}
// Equivalent to:
configurations {
all.collect { configuration ->
configuration.exclude group: 'xml-apis', module: 'xmlParserAPIs'
}
View gitcheats.txt
# shortform git commands
alias g='git'
# get most modified files and counts
git log --all -M -C --name-only --format='format:' "$@" | sort | grep -v '^$' | uniq -c | sort | awk 'BEGIN {print "count\tfile"} {print $1 "\t" $2}' | sort -g
# Locally checkout all remote branches of a repository
git branch -r | cut -d '/' -f2 | grep -Ev '( |master)' | xargs -Ibranch git checkout -b branch origin/branch
# Open current Git repository URL
@amaksoft
amaksoft / MainActivity.kt
Last active Sep 28, 2017
Example for Stackoverflow answer 46459795
View MainActivity.kt
package com.example.testrxkotlin
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.widget.TextView
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import okhttp3.OkHttpClient
import okhttp3.Request
@amaksoft
amaksoft / PlaceholderRecyclerViewAdapter.java
Created Oct 9, 2017
Missing emptyVIew for RecyclerVIew
View PlaceholderRecyclerViewAdapter.java
package com.github.amaksoft.recyclerviewtools.adapter;
import android.support.annotation.IdRes;
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
@amaksoft
amaksoft / AndroidDisposable.java
Created Oct 9, 2017
RxJava2 Disposable bound to Activity/Fragment lifecycle
View AndroidDisposable.java
package com.github.amaksoft.tools;
import android.arch.lifecycle.Lifecycle;
import android.arch.lifecycle.LifecycleObserver;
import android.arch.lifecycle.LifecycleOwner;
import android.arch.lifecycle.OnLifecycleEvent;
import io.reactivex.disposables.Disposable;
/**
@amaksoft
amaksoft / 70-sign-virtual.sh
Last active Oct 17, 2017
Virtualbox and VMware modules signing for Fedora
View 70-sign-virtual.sh
#!/bin/bash
#
# Inspired by:
# http://gorka.eguileor.com/vbox-vmware-in-secureboot-linux-2016-update/
# http://elemc.name/?p=1020
#
# Designed and tested on Fedora 24/25
#
# This script is designed to automate Virtualbox and VMware module signing for SecureBoot
# Run it after each "vmware-modconfig --console --install-all", "/sbin/rcvboxdrv setup", "sudo /etc/init.d/vboxdrv setup" or kernel update
@amaksoft
amaksoft / RequestViewModel.java
Created Feb 21, 2018
Generalized request wrapping viewmodel
View RequestViewModel.java
/**
* ViewModel for wrapping HTTP requests and keeping their results during configuration changes
*/
public class RequestViewModel<T> extends AndroidViewModel {
private Disposable disposable;
private final MutableLiveData<Response<T>> response = new MutableLiveData<>();
public RequestViewModel(@NonNull Application application) {
@amaksoft
amaksoft / Jenkinsfile
Last active Apr 15, 2021
My example Jenkins Pipeline setup for Android app project
View Jenkinsfile
#!/usr/bin/groovy
/*
* Copyright (c) 2016, Andrey Makeev <amaksoft@gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
@amaksoft
amaksoft / CompoundDrawableClickListener.java
Last active Jul 5, 2021
Handling TextView compound drawables touch and click events
View CompoundDrawableClickListener.java
/*
* Copyright 2017, Andrey Makeev
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software