Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View jimmyFlash's full-sized avatar
:atom:

Jamal jimmyFlash

:atom:
View GitHub Profile
@jimmyFlash
jimmyFlash / c_chape_vector.xml
Created July 18, 2020 08:43
A set of vector-drawables files for use in android projects
<?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 July 10, 2020 10:20
Removing log calls using proguard / R8 rule
# no logging in production
-assumenosideeffects class android.util.Log {
v(...);
d(...);
i(...);
w(...);
e(...);
println(...);
}
@jimmyFlash
jimmyFlash / CurrencyAmoutBdecimalConverter.java
Last active May 24, 2020 11:43
Convert a currency formatted string to BigDecimal (double shouldn't be used to represent precision amounts)
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 January 7, 2020 10:51
Formatting currency in java, standard and non-standard using country ISO code
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 January 7, 2020 10:45
solving anagrams, print anagrams and non-anagrams in sorted matter
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 December 27, 2019 15:42
Set of extension function to use in your activity to display Alertdilog, Snackbar, toast or navigate to new activity
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 December 27, 2019 11:49
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)
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)