Skip to content

Instantly share code, notes, and snippets.

View scarlac's full-sized avatar

Seph Soliman scarlac

View GitHub Profile
@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'
@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 / 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
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 / 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
@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 / server.js
Created May 1, 2019 17:41
File Upload Server
const app = require('express')();
const upload = require('multer')();
app.post('/upload', upload.single('file'), function (req, res) {
console.log('file', req.file);
res.status(200).send(JSON.stringify({ ...req.file, buffer: null }));
});
app.listen(4242, () => { console.log('ready.'); });

Keybase proof

I hereby claim:

  • I am scarlac on github.
  • I am scarlac (https://keybase.io/scarlac) on keybase.
  • I have a public key ASDceRd1ij02J9C8XwWN-ACB7-7X7s6ipdnhzVa0J-csAgo

To claim this, I am signing this object:

@scarlac
scarlac / purge_advertisers.md
Last active June 7, 2021 09:36
Facebook Hack: Purge list of "Advertisers you've interacted with"

For those of you who want to remove all in “Advertisers and Businesses” / "Who uploaded a list with your info and advertised to it":

  1. Go to https://www.facebook.com/ads/preferences/?entry_product=ad_settings_screen and open the section "Advertisers you've interacted with"
  2. Collapse all sections but keep "Advertisers and Businesses" open
  3. Open Web Inspector
  4. Copy-paste this script to load all advertisers: smt=setInterval(() => {let x=document.querySelector('div[shade=medium]'); x ? x.click() : clearInterval(smt), console.log('done')}, 1000)
  5. It will output a number. Wait for it to say “done” in the console. This may take a long time. you'll notice the scrollbar changing while it's loading all advertisers.
  6. Copy-paste this and press enter:
@scarlac
scarlac / gist:777c070912e9fe90f1330d493591360f
Created March 25, 2018 21:31
Test of Slack link og:title escaping feature, tag here: <Slack>
Test of Slack link og:title escaping feature, tag here: <Slack>