Skip to content

Instantly share code, notes, and snippets.

@squeeish
squeeish / FileUtils.java
Created June 18, 2019 17:16 — forked from HBiSoft/FileUtils.java
This fixes the issue when selecting a file from Downloads directory as well as the SD Card. This class can be called like this: String sourcePath = FileUtils.getRealPathFromURI_API19(this, data.getData());
import android.annotation.SuppressLint;
import android.content.ContentUris;
import android.content.Context;
import android.content.CursorLoader;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.provider.DocumentsContract;
import android.provider.MediaStore;
@squeeish
squeeish / nric-validation.java
Last active October 17, 2022 05:40 — forked from eddiemoore/nric-validation.js
Validation for Singapore NRIC and FIN number
/**
* Validates Singapore NRIC / FIN in 2 stages:
* 1) Ensure first letter starts with S, T, F or G and the last letter is A-Z
* 2) Calculate weight of digits in between first and last character of the input string,
* determine what the last letter should be, then match it against the last character of the
* input string.
*
* @param inputString NRIC / FIN string to be validated
* @return true if NRIC/FIN passes, false otherwise
*/