Skip to content

Instantly share code, notes, and snippets.

View r0b0t3d's full-sized avatar
🏠
Working from home

Tuan Luong r0b0t3d

🏠
Working from home
View GitHub Profile
@r0b0t3d
r0b0t3d / useCallback.md
Created July 10, 2021 09:06
Use of useCallback and useMemo

1. Use

1.1. in callback

const handlePress = useCallback(() => {
	// handle press
}, [])

Good 👍

<Button onPress={handlePress} />
@r0b0t3d
r0b0t3d / react-native-bootsplash+2.2.5.patch
Last active July 18, 2023 03:06
Add option for react-native-bootsplash to use custom xml
diff --git a/node_modules/react-native-bootsplash/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplash.java b/node_modules/react-native-bootsplash/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplash.java
index 83dbff8..aae4fae 100644
--- a/node_modules/react-native-bootsplash/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplash.java
+++ b/node_modules/react-native-bootsplash/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplash.java
@@ -4,6 +4,7 @@ import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.app.Activity;
import android.content.Context;
+import android.view.LayoutInflater;
import android.view.View;
@r0b0t3d
r0b0t3d / FileHelper.java
Created June 17, 2020 08:13
Get file path from Uri
import android.annotation.TargetApi;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.provider.DocumentsContract;
import android.provider.MediaStore;
@r0b0t3d
r0b0t3d / toIso2.json
Created April 3, 2020 15:49
A JSON file that maps ISO2 country codes to ISO3 country codes and vice versa
{
"AND": "AD",
"ARE": "AE",
"AFG": "AF",
"ATG": "AG",
"AIA": "AI",
"ALB": "AL",
"ARM": "AM",
"AGO": "AO",
"ATA": "AQ",
@r0b0t3d
r0b0t3d / react-native+0.62.0.patch
Last active July 6, 2022 05:58
[ios] Trigger onRequestClose when swiping down a pageSheet
diff --git a/node_modules/react-native/React/Views/RCTModalHostView.h b/node_modules/react-native/React/Views/RCTModalHostView.h
index e16dd22..97f24a6 100644
--- a/node_modules/react-native/React/Views/RCTModalHostView.h
+++ b/node_modules/react-native/React/Views/RCTModalHostView.h
@@ -17,7 +17,7 @@
@protocol RCTModalHostViewInteractor;
-@interface RCTModalHostView : UIView <RCTInvalidating>
+@interface RCTModalHostView : UIView <RCTInvalidating, UIAdaptivePresentationControllerDelegate>
import Foundation
import UIKit
// Usage Examples
let shadowColor = Color.shadow.value
let shadowColorWithAlpha = Color.shadow.withAlpha(0.5)
let customColorWithAlpha = Color.custom(hexString: "#123edd", alpha: 0.25).value
enum Color {
import Foundation
import UIKit
// Usage Examples
let system12 = Font(.system, size: .standard(.h5)).instance
let robotoThin20 = Font(.installed(.RobotoThin), size: .standard(.h1)).instance
let robotoBlack14 = Font(.installed(.RobotoBlack), size: .standard(.h4)).instance
let helveticaLight13 = Font(.custom("Helvetica-Light"), size: .custom(13.0)).instance
struct Font {
@r0b0t3d
r0b0t3d / Utility.swift
Created October 6, 2017 03:31
Swift Utilities methods
class Utility {
/// Logs all available fonts from iOS SDK and installed custom font
class func logAllAvailableFonts() {
for family in UIFont.familyNames {
print("\(family)")
for name in UIFont.fontNames(forFamilyName: family) {
print(" \(name)")
}
}
@r0b0t3d
r0b0t3d / DividerItemDecoration.java
Created September 7, 2016 06:10 — forked from alexfu/DividerItemDecoration.java
An ItemDecoration that draws dividers between items. Pulled from Android support demos.
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
// Created by Ullrich Schäfer on 16/08/14.
// Updated to Swift 1.1 and CocoaLumberjack beta4 by Stan Serebryakov on 24/10/14
import Foundation
extension DDLog {
private struct State {
static var logLevel: DDLogLevel = .Error
static var logAsync: Bool = true