Skip to content

Instantly share code, notes, and snippets.

View matpag's full-sized avatar
🐧
Noot-Nooting around

MatPag matpag

🐧
Noot-Nooting around
View GitHub Profile
@matpag
matpag / run_test_emulator.sh
Last active November 8, 2023 08:09
Script to run test on a random-generated android emulator with a specific API level
#!/bin/bash
#Usage:
#You need to have installed the API images you are going to start or you can change the createGoogleEmulator function to start the image you want
#For example to start an Android API 28 emulator and perform the app test with Google Apis you just need to call
#./run_test_emulator.sh 28 :app:connectedCheck
#unlock for debugging purposes
# set -ex
#global vars
@matpag
matpag / italian_tax_code_regex.txt
Last active July 11, 2023 12:51
REGEX VALIDAZIONE CODICI FISCALI ITALIANI
Questa sotto é una Regex che permette di validare la corretta formattazione dei codici fiscali italiani.
Tiene conto delle omocodie e di tutto il resto conosciuto finora.
La base di partenza é stata presa qui: http://blog.marketto.it/2016/01/regex-validazione-codice-fiscale-con-omocodia/
quindi tutti i credits vanno all'autore di questo post ma é stata modificata un minimo perché non copriva tutti i casi
^(?:[A-Z][AEIOUX][AEIOUX]|[B-DF-HJ-NP-TV-Z]{2}[A-Z]){2}(?:[\dLMNP-V]{2}(?:[A-EHLMPR-T](?:[04LQ][1-9MNP-V]|[15MR][\dLMNP-V]|[26NS][0-8LMNP-U])|[DHPS][37PT][0L]|[ACELMRT][37PT][01LM]|[AC-EHLMPR-T][26NS][9V])|(?:[02468LNQSU][048LQU]|[13579MPRTV][26NS])B[26NS][9V])(?:[A-MZ][1-9MNP-V][\dLMNP-V]{2}|[A-M][0L](?:[1-9MNP-V][\dLMNP-V]|[0L][1-9MNP-V]))[A-Z]$
@matpag
matpag / OnThrottleClickListener.kt
Created December 2, 2019 09:23
ThrottleClickListener prevent double click using OnClickListener
import android.os.SystemClock
import android.view.View
/**
* This is a custom clicklistener to prevent multiple click events to happens at the same time.
*
* Each click on a button is added in the internal event handler queue, there is no way to remove
* them from there so the only thing we can do is adding a filter to prevent them to run too
* frequently
*
@matpag
matpag / Database.cs
Created April 15, 2016 10:10
Xamarin Forms SQLite database upgrade strategy
using ProjectTest.MyModels;
using SQLite.Net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace ProjectTest.Database
@matpag
matpag / LifecycleControlledCountDownTimer.kt
Created September 7, 2021 10:13
LifecycleControlledCountDownTimer a wrapper class around CountDownTimer
import android.os.CountDownTimer
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.OnLifecycleEvent
import timber.log.Timber
interface LifecycleControlledCountDownTimer {
@matpag
matpag / DialogNavigator.kt
Last active February 16, 2021 12:29 — forked from fbarthelery/DialogNavigator.kt
Minor changes
package com.geekorum.geekdroid.navigation
import android.content.Context
import android.os.Bundle
import android.util.AttributeSet
import androidx.core.content.res.use
import androidx.core.os.bundleOf
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
@matpag
matpag / BaseActivity.java
Last active September 9, 2019 08:35
Implement Zebra EMDK 7.0 on BaseActivity for multiple Activities
//the others Android import....
import com.symbol.emdk.EMDKManager;
import com.symbol.emdk.barcode.BarcodeManager;
import com.symbol.emdk.barcode.ScanDataCollection;
import com.symbol.emdk.barcode.Scanner;
import com.symbol.emdk.barcode.ScannerConfig;
import com.symbol.emdk.barcode.ScannerException;
import com.symbol.emdk.barcode.ScannerInfo;
@matpag
matpag / README.md
Created May 20, 2017 10:06 — forked from lopspower/README.md
Publish AAR to jCenter and Maven Central

Publish AAR to jCenter and Maven Central

Twitter

Now I'm going to list how to publish an Android libray to jCenter and then syncronize it with Maven Central:

  1. I use "Android Studio" and I have this simple android lib that I would like to be available on maven: CircularImageView

  2. In the library folder(module) I have the lib code abovementioned. And applying in the build.gradle of this folder apply plugin: 'com.android.library' I got as output an .aar in the build/outputs/aar/ directory of the module's directory

@matpag
matpag / TextViewDrawableSize.java
Last active December 14, 2016 10:19 — forked from hrules6872/TextViewDrawableSize.java
TextViewDrawableSize - CompoundDrawable size
/**
* Original source from here : http://stackoverflow.com/a/31916731
*/
public class TextViewDrawableSize extends TextView {
private static final int DEFAULT_COMPOUND_DRAWABLE_SIZE = -1;
private int compoundDrawableWidth;
private int compoundDrawableHeight;
public TextViewDrawableSize(Context context) {
this(context, null);
apply plugin: 'com.android.application'
def dbflow_version = "3.1.1"
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.testpackage.test"