Skip to content

Instantly share code, notes, and snippets.

@FireZenk
FireZenk / SnackbarAnimation.java
Last active August 11, 2020 13:06
With this class you can clone the {Snackbar} animation to move the {ViewGroup} above of the Snackbar when it is visible and avoid view overlapping (clone of fab animation)
package com.your.package;
import android.support.design.widget.Snackbar;
import android.view.View;
import android.view.ViewGroup;
import com.daimajia.easing.BaseEasingMethod;
import com.daimajia.easing.Glider;
import com.daimajia.easing.Skill;
import com.nineoldandroids.animation.AnimatorSet;
@shkschneider
shkschneider / Log
Last active November 21, 2021 03:51
Android Log helper (automatic class, method and line) replacing android.util.Log
package me.shkschneider.skeleton.helper;
import android.text.TextUtils;
import android.util.Log;
/**
* Improved android.util.Log.
*
* Logs class and method automatically:
* [MyApplication onCreate():34] Hello, world!
@matheusjardimb
matheusjardimb / android_colors
Last active August 29, 2015 14:12
Great Flat Colors
<?xml version="1.0" encoding="utf-8"?>
<!--
Great set of colors from from http://flatuicolors.com/ and converted into Android colors.xml
-->
<resources>
<color name="turquoise">#1abc9c</color>
<color name="emerald">#2ecc71</color>
<color name="peter_river">#3498db</color>
@AlexBlokh
AlexBlokh / RatioViewPager.java
Last active March 31, 2017 11:36
ViewPager with custom aspect ratio
public class RatioViewPager extends ViewPager {
private float mRatio = 1f;
public RatioViewPager(Context context) {
super(context);
}
public RatioViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
package trikke.gists;
import android.graphics.Typeface;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.BackgroundColorSpan;
import android.text.style.ForegroundColorSpan;
import android.text.style.RelativeSizeSpan;
import android.text.style.StrikethroughSpan;
import android.text.style.StyleSpan;
@curioustechizen
curioustechizen / EnhancedCheckBox.java
Last active September 14, 2020 05:50
Android programmatically checkable widgets, differentiate between user clicks & programmatic setChecked calls. Based on this answer on StackOverflow: http://stackoverflow.com/a/14307643/570930. There are times when setting a switch to ON results in some action (Save to DB/ perform an HTTP POST etc). However, you want this action to happen only o…
/**
* An enhanced {@code CheckBox} that differentiates between user clicks and
* programmatic clicks. In particular, the {@code OnCheckedChangeListener} is
* <strong>not</strong> triggered when the state of the checkbox is changed
* programmatically.
*
*/
public class EnhancedCheckBox extends CheckBox implements ProgrammaticallyCheckable{
private CompoundButton.OnCheckedChangeListener mListener = null;
public EnhancedCheckBox(Context context) {
@deepankarb
deepankarb / svg-to-android.sh
Last active July 14, 2018 13:13
A script to generate android assets from a SVG file. Requires inkscape to resize and convert.
#!/bin/bash
if [[ -z "$1" ]];
then
echo "No SVG file specified. Exiting."
exit -1
fi
ispng=$(file $1)
echo $ispng | grep -q SVG
@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active April 25, 2024 02:01
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

@bripkens
bripkens / event-loop-nashorn.js
Last active August 21, 2021 06:18
Java 8 Nashorn event loop "polyfill". javax.script.ScriptEngine#eval calls should immediately call window.main to enter the event loop and thus to avoid concurrency issues. The XMLHttpRequest simulation is not yet finished.
(function(context) {
'use strict';
var Timer = Java.type('java.util.Timer');
var Phaser = Java.type('java.util.concurrent.Phaser');
var TimeUnit = Java.type('java.util.concurrent.TimeUnit');
var AsyncHttpClient = Java.type('com.ning.http.client.AsyncHttpClient');
var timer = new Timer('jsEventLoop', false);
var phaser = new Phaser();
@aviflax
aviflax / gist:3147740
Created July 19, 2012 23:55
Compile your CoffeeScript along with your Clojure
;;; Compile your CoffeeScript along with your Clojure
;; NOTE: For Clojure projects using Leiningen 1.7.x.
;; Instructions for Leiningen 2.0.x coming soon.
;; Step 1: add [robert/hooke "1.1.2"] to the :dev-dependencies option of your defproject call
;; Step 2: add the following code to the bottom of your project.clj:
(require ['robert.hooke :as 'hooke]