Skip to content

Instantly share code, notes, and snippets.

View scarlac's full-sized avatar

Seph Soliman scarlac

View GitHub Profile
@scarlac
scarlac / react-native+0.61.2.patch
Last active February 10, 2020 17:23
Patch to trigger onDismiss for iOS 13-style pageSheet/formSheet modals
diff --git a/node_modules/react-native/React/Views/RCTModalHostView.h b/node_modules/react-native/React/Views/RCTModalHostView.h
index e421e59..ba461e0 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>
@scarlac
scarlac / memory-efficient-rq-client.tsx
Last active June 2, 2022 00:16
Persist & Purge unused React Query query data from memory
// Note that some disk-related and disk-auto-delete code has been removed
// PersistedQuery defines the JSON structure for the disk cache
type PersistedQuery = {
queryKey: QueryKey,
queryHash: string,
cacheTime: number,
state: {
data: unknown | undefined;
dataUpdatedAt: number; // Roughly same as 'last modified' date on filesystem
diff --git a/node_modules/@nozbe/watermelondb/native/android-jsi/src/main/java/com/nozbe/watermelondb/jsi/JSIInstaller.java b/node_modules/@nozbe/watermelondb/native/android-jsi/src/main/java/com/nozbe/watermelondb/jsi/JSIInstaller.java
index 055cede..8dc52e6 100755
--- a/node_modules/@nozbe/watermelondb/native/android-jsi/src/main/java/com/nozbe/watermelondb/jsi/JSIInstaller.java
+++ b/node_modules/@nozbe/watermelondb/native/android-jsi/src/main/java/com/nozbe/watermelondb/jsi/JSIInstaller.java
@@ -14,8 +14,7 @@ class JSIInstaller {
// Helper method called from C++
static String _resolveDatabasePath(String dbName) {
- // On some systems there is some kind of lock on `/databases` folder ¯\_(ツ)_/¯
- return context.getDatabasePath(dbName + ".db").getPath().replace("/databases", "");
@scarlac
scarlac / convert-persist-state-to-json.js
Last active January 12, 2023 19:51
Redux Persist script that convert the double-encoded persisted reducer state files into normal JSON files
/* eslint-disable no-console */
const fs = require('fs');
const path = require('path');
/**
* Redux Persist script that convert the double-encoded persisted reducer state files into normal JSON files.
* Usage: node convert-persist-state-to-json.js /tmp/Documents/persistStore
* generates several files:
* persistStore/persist-root -> persistStore/persist-root.json
* persistStore/persist-user -> persistStore/persist-user.json
@scarlac
scarlac / caffeinate-android.sh
Created July 20, 2023 22:18
Keep your Android device unlocked while developing. Works like 'caffeinate' on macOS
# add this to your mac's ~/.zshrc
alias caffeinate-android='while true; do adb -d shell input keyevent mouse; sleep 10; done'
@scarlac
scarlac / .zshrc
Created October 11, 2023 16:52
Keep Android phone screen on while connected to your computer
# similar to the old 'caffeinate' command for macOS, this will keep the connected android phones active
alias caffeinate-android='while true; do adb -d shell input keyevent mouse ; sleep 10 ; done'