Skip to content

Instantly share code, notes, and snippets.

@jimmyFlash
jimmyFlash / c_chape_vector.xml
Created Jul 18, 2020
A set of vector-drawables files for use in android projects
View c_chape_vector.xml
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="40dp"
android:height="40dp"
android:viewportHeight="40.0"
android:viewportWidth="40.0">
<path
android:name="curves"
android:pathData="M 30 5
@jimmyFlash
jimmyFlash / proguard-rules.pro
Created Jul 10, 2020
Removing log calls using proguard / R8 rule
View proguard-rules.pro
# no logging in production
-assumenosideeffects class android.util.Log {
v(...);
d(...);
i(...);
w(...);
e(...);
println(...);
}
@jimmyFlash
jimmyFlash / CurrencyAmoutBdecimalConverter.java
Last active May 24, 2020
Convert a currency formatted string to BigDecimal (double shouldn't be used to represent precision amounts)
View CurrencyAmoutBdecimalConverter.java
import java.math.BigDecimal;
import java.util.Locale;
import java.text.*;
public class CurrencyAmoutBdecimalConverter{
public static void main(String []args)throws ParseException{
final String dollarsA = "$199.00";
final String real = "R$ 399,00";
final String dollarsB = "£25.00";
final String tailingEuro = "90,83 €";
@jimmyFlash
jimmyFlash / CurrencyFormatter.java
Created Jan 7, 2020
Formatting currency in java, standard and non-standard using country ISO code
View CurrencyFormatter.java
import java.text.NumberFormat;
import java.util.Currency;
import java.util.Locale;
import java.util.Scanner;
public class CurrencyFormatter {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
double payment = scanner.nextDouble();
@jimmyFlash
jimmyFlash / Anagrams.java
Created Jan 7, 2020
solving anagrams, print anagrams and non-anagrams in sorted matter
View Anagrams.java
import java.util.*;
import java.util.stream.Collectors;
public class Anagrams {
private static String[] anagrams = {
"pear",
"amleth",
"dormitory",
"tinsel",
"dirty room",
@jimmyFlash
jimmyFlash / ActivityDialogsExtensions.kt
Last active Dec 27, 2019
Set of extension function to use in your activity to display Alertdilog, Snackbar, toast or navigate to new activity
View ActivityDialogsExtensions.kt
fun View.snack(message: String, length: Int = Snackbar.LENGTH_LONG, f: Snackbar.() -> Unit) {
val snack = Snackbar.make(this, message, length)
snack.f()
snack.show()
}
fun Snackbar.action(action: String, color: Int? = null, listener: (View) -> Unit) {
setAction(action, listener)
color?.let { setActionTextColor(color) }
}
@jimmyFlash
jimmyFlash / BundleExtension.kt
Last active Dec 27, 2019
Extension function that tries to put a value of arbitrary type to the bundle, and throws an exception if the type is not supported. thanks to (Dmitry Akishin)
View BundleExtension.kt
fun <T> Bundle.put(key: String, value: T) {
when (value) {
is Boolean -> putBoolean(key, value)
is String -> putString(key, value)
is Int -> putInt(key, value)
is Short -> putShort(key, value)
is Long -> putLong(key, value)
is Byte -> putByte(key, value)
is ByteArray -> putByteArray(key, value)
is Char -> putChar(key, value)
You can’t perform that action at this time.