Skip to content

Instantly share code, notes, and snippets.

View dimrsilva's full-sized avatar

Anderson Ribeiro e Silva dimrsilva

View GitHub Profile
@dimrsilva
dimrsilva / FloatActionMenu.java
Created November 4, 2015 12:12
A simple FloatActionMenu implementation using design support FloatActionButton
package net.andersonribeiro.customviews;
import android.animation.Animator;
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.support.design.widget.FloatingActionButton;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewAnimationUtils;
@dimrsilva
dimrsilva / ios2android.sh
Last active February 12, 2016 11:25
Change iOS resource files to Android resource files
#!/bin/bash
for f in *.png
do
nf=$(echo $f | perl -pe 's/-/_/g' | perl -pe 's/@[0-9,]+x//')
if [[ $f =~ @1x\.png$ ]]
then
echo "Move file $f to drawable-mdpi/$nf"
mkdir drawable-mdpi
ImageView imageView = new ImageView(this);
Drawable drawable = DrawableCompat.wrap(ContextCompat.getDrawable(this, R.drawable.ic_account_circle));
drawable.mutate();
DrawableCompat.setTint(drawable, ContextCompat.getColor(this, R.color.red));
imageView.setImageDrawable(drawable);
ImageView imageView = new ImageView(this);
Drawable drawable = DrawableCompat.wrap(ContextCompat.getDrawable(this, R.drawable.ic_account_circle));
DrawableCompat.setTint(drawable, ContextCompat.getColor(this, R.color.red));
imageView.setImageDrawable(drawable);
package com.example;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.v4.content.ContextCompat;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@dimrsilva
dimrsilva / git-rm-branches.sh
Created February 27, 2018 13:38
git-rm-branches.sh
#!/bin/bash
# Remove branches da máquina que já estão mergeadas com a branch atual
# Pode trocar `vim` por um editor de preferência
git branch --merged >/tmp/merged-branches && vim /tmp/merged-branches && xargs git branch -d </tmp/merged-branches
open class CoroutineViewModel : ViewModel(), CoroutineScope {
private val job = Job()
override val coroutineContext = Main + job
override fun onCleared() {
super.onCleared()
job.cancel()
}
@dimrsilva
dimrsilva / .gitconfig
Created August 13, 2019 16:11
git rm-merged-branches
[alias]
rm-merged-branches = "!git branch --merged >/tmp/merged-branches && vim /tmp/merged-branches && xargs git branch -d </tmp/merged-branches"