Skip to content

Instantly share code, notes, and snippets.

View adil-hussain-84's full-sized avatar

Adil Hussain adil-hussain-84

View GitHub Profile
@adil-hussain-84
adil-hussain-84 / MJRKeychainStorage.h
Last active May 25, 2017 10:55
Helper class which adds/gets/deletes entries in the iOS Keychain
//
// Class modified from this GitHub repository:
// https://github.com/jeremangnr/JNKeychain
//
#import <Foundation/Foundation.h>
@interface MJRKeychainStorage : NSObject
/**
@adil-hussain-84
adil-hussain-84 / MJRSecKeyRefProvider.h
Last active June 6, 2017 16:13
Helper class which adds/gets/deletes RSA public keys in the iOS Keychain for signature verification.
#import <Foundation/Foundation.h>
@interface MJRSecKeyRefProvider : NSObject
/**
* @param tag the identifier with which to save keys in the Keychain.
*/
- (instancetype)initWithTag:(NSString *)tag;
/**
@adil-hussain-84
adil-hussain-84 / ShowToastLeftOfView.java
Last active November 25, 2017 12:20
Show a Toast which is positioned to the left of a given View. The message in the Toast is the content description of the View.
/**
* Shows a {@link Toast} which is positioned to the left of a given {@link View}.
* The message in the {@link Toast} is the content description of the {@link View}.
* <p>
* Much of the code in this method is inspired by <a href="https://stackoverflow.com/a/21026866/1071320">this</a> StackOverflow answer.
*/
private void showContentDescriptionOfViewAsToast(View view) {
// toasts are positioned relative to the decor view and views relative to their parents;
// we have to gather additional data to have a common coordinate system
Rect rect = new Rect();
@adil-hussain-84
adil-hussain-84 / ElapsedTimeLogger.kt
Created December 8, 2023 14:15
Android class that helps log the number of milliseconds that have elapsed since a reference point.
class ElapsedTimeLogger(private val tag: String = ElapsedTimeLogger::class.simpleName!!) {
private var startTime = SystemClock.elapsedRealtime()
/**
* Logs the number of milliseconds that have elapsed since this [ElapsedTimeLogger] was initialised.
*
* The logs are sent to log output (i.e. Logcat) as a debug message.
*/
fun logElapsedTime() {