Skip to content

Instantly share code, notes, and snippets.

Avatar
🐈
Meow

Mike Diarmid Salakar

🐈
Meow
View GitHub Profile
@Salakar
Salakar / settings.gradle
Created Jan 12, 2019
Example applying a plugin to settings.gradle.
View settings.gradle
// REMOTE MAVEN
buildscript {
repositories { mavenCentral() }
dependencies { classpath 'io.invertase.gradle:react-native:+' }
}
apply plugin: "io.invertase.gradle.settings"
// OR ---------------
@Salakar
Salakar / firebase-perf-axios.js
Last active May 4, 2021
Add Firebase Performance Monitoring HTTP Metrics to all Axios requests (RNFB v5). This is taken from a guide on the new React Native Firebase website (not yet ready for public use).
View firebase-perf-axios.js
import axios from 'axios';
import firebase from 'react-native-firebase';
axios.interceptors.request.use(async function (config) {
const httpMetric = firebase.perf().newHttpMetric(config.url, config.method);
config.metadata = { httpMetric };
// add any extra metric attributes if needed
// await httpMetric.putAttribute('userId', '12345678');
@Salakar
Salakar / deepMerge.md
Last active Nov 13, 2020
ES6/ES2015 Object deep merge
View deepMerge.md

Deep Merge

Quick function to deep merge using Object.assign(). Thoughts?

    /**
     * Simple is object check.
     * @param item
     * @returns {boolean}
     */
@Salakar
Salakar / firebase_firestore.md
Last active Jul 17, 2020
Changes preview of the current FlutterFirebase Firestore plugin rework.
View firebase_firestore.md

Description

⚠️ NOTE: These changes may not reflect the final plugin changes/API as it's still going through review.

Along with the below changes, the plugin has undergone a quality of life update to better support exceptions thrown. Any Firestore specific errors now return a FirebaseException, allowing you to directly access the code (e.g. permission-denied) and message.

Firestore:

  • BREAKING: settings() is now a synchronous setter that accepts a Settings instance.
    • NEW: This change allows us to support changing Firestore settings (such as using the Firestore emulator) without having to quit the application, e.g. Hot Restarts.
  • DEPRECATED: Calling document() is deprecated in favor of doc().
@Salakar
Salakar / foreground-service.ts
Created Jun 23, 2020
Testing foreground service notifications in Notifee with progress indicators.
View foreground-service.ts
Notifee.registerForegroundService(notification => {
console.warn('Foreground service started.');
return new Promise(resolve => {
/**
* Cancel the notification and resolve the service promise so the Headless task quits.
*/
async function stopService(): Promise<void> {
console.warn('Stopping service.');
if (notification?.id) {
await Notifee.cancelNotification(notification?.id);
@Salakar
Salakar / cloudSettings
Last active Oct 3, 2019
Visual Studio Code Settings Sync Gist
View cloudSettings
{"lastUpload":"2019-09-11T00:17:27.387Z","extensionVersion":"v3.4.2"}
@Salakar
Salakar / slotCalc.js
Last active Jul 9, 2019
Shard Firebase RTDB by `userId` or any arbitrary string/identifier. Uses a 16 bit cyclic redundancy check to calculate the users shard number based on their user id string. This negates the need for a master instance that maps where users data is stored. See comment below code block for more details.
View slotCalc.js
const lookup = [
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de,
0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485,
0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d,
0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4,
0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc,
0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823,
@Salakar
Salakar / PushNotificationiOS.md
Last active May 10, 2019 — forked from indexzero/PushNotificationiOS.md
Draft proposal for Push Notifications and PushNotificationiOS
View PushNotificationiOS.md

Proposal for Push Notifications and PushNotificationiOS

@salakar, @ashoat, @indexzero, @swaagie, @3rdeden, and @msluther met today to discuss this. This is the draft proposal written up during that meeting. We plan to iterate on this over the next week and then post it into a new proposal in react-native-community.

Prior art

  • Push Notification packages
    • react-native-push-notification
    • react-native-notifications
      • Fork of iOS work used in react-native-fire
@Salakar
Salakar / PushNotificationiOS.md
Created May 10, 2019 — forked from indexzero/PushNotificationiOS.md
Draft proposal for Push Notifications and PushNotificationiOS
View PushNotificationiOS.md

Proposal for Push Notifications and PushNotificationiOS

@salakar, @ashoat, @indexzero, @swaagie, @3rdeden, and @msluther met today to discuss this. This is the draft proposal written up during that meeting. We plan to iterate on this over the next week and then post it into a new proposal in react-native-community.

A recording of that meeting can be found below in MP4 format.

Prior art

  • Push Notification packages
    • react-native-push-notification
@Salakar
Salakar / MainApplication.java
Last active Jan 20, 2019
Example injecting React Native module ReactPackages.
View MainApplication.java
package com.testing;
import android.app.Application;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;