Skip to content

Instantly share code, notes, and snippets.

View axemclion's full-sized avatar

Parashuram N axemclion

View GitHub Profile
@axemclion
axemclion / adding_flipper.diff
Last active September 29, 2019 04:10
Adding Flipper to an existing React Native project
diff --git a/android/app/build.gradle b/android/app/build.gradle
index 6560b78..eade6f6 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -176,12 +176,21 @@ android {
}
}
+ packagingOptions {
+ pickFirst '**/libc++_shared.so'
@axemclion
axemclion / fix-yoga-react-native.sh
Created September 5, 2019 06:03
Fix Yoga conflict when using Flipper with React Native (for rn <0.62)
sed -i '.bak' s/\'yoga\'/\'Yoga\'/ node_modules/react-native/ReactCommon/yoga/yoga.podspec
sed -i '.bak' s/\#\{version\}\.React/1\.14\.3/ node_modules/react-native/ReactCommon/yoga/yoga.podspec
sed -i '.bak' s/\#.Pinning/spec.pod_target_xcconfig=\{\'DEFINES_MODULE\'=\>\'YES\'\\}\#/ node_modules/react-native/ReactCommon/yoga/yoga.podspec
sed -i '.bak' s/\"yoga\",.\"\#\{version\}\.React\"/\"Yoga\"/ node_modules/react-native/React/React-Core.podspec
sed -i '.bak' s/\'yoga\'/\'Yoga\'/ ios/Podfile
@axemclion
axemclion / MainApplication.java
Created August 12, 2019 18:30
Adding Flipper to ReactNative
// Call this in MainApplication.onCreate(), just after Soloader line.
private static void initialize(Context context) {
if (BuildConfig.DEBUG) {
try {
/*
We use reflection here to pick up the class that initializes Flipper,
since Flipper library is not available in release mode
*/
Class<?> aClass = Class.forName("com.facebook.flipper.ReactNativeFlipper");
aClass.getMethod("initializeFlipper", Context.class).invoke(null, context);
@axemclion
axemclion / JSIObject.cpp
Last active October 4, 2023 19:36
React Native JSI Example
// This sample is a Work in Progress for JSI , and specific functions may change.
#pragma once
#include <string>
#include <unordered_map>
#include <jsi/jsi.h>
// This SameplJSIObject needs to inheric from HostObject, and this is the object that will be exposed to JS.
@axemclion
axemclion / FlutterToastPlugin.java
Created December 2, 2018 21:17
An adapter to use React Native's Native Modules in Flutter
package com.example.helloflutterplugin;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.modules.toast.ToastModule;
import com.nparashuram.reactnative.ReactNativeModuleAdapter;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.MethodChannel.Result;
import io.flutter.plugin.common.PluginRegistry.Registrar;
@axemclion
axemclion / PerfLogger.java
Last active August 12, 2023 02:56
React Native Android - Systrace from ReactMarkers
package com.nparashuram;
import android.os.Process;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.ViewTreeObserver;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.bridge.ReactContext;
@axemclion
axemclion / MainApplication.java
Created November 11, 2018 21:02
React Native Android Startup - logging
@Override
public void onCreate() {
super.onCreate();
///////// Add lines below this to capture times of the large sections
final String TAG = "RN_STARTUP"; // If you already have a TAG for the app, use that instead.
final TimingLogger timingLogger = new TimingLogger("AXE", "REACT_NATIVE_STARTUP");
timingLogger.reset();
ReactMarker.addListener(new ReactMarker.MarkerListener() {
@Override
@axemclion
axemclion / showpassword.user.js
Created January 6, 2018 15:58
Greasemonkey script to show password on doubleclick
// ==UserScript==
// @name Show Password
// @version 1
// @grant none
// ==/UserScript==
function handleDblClick(e){
var pwd = e.target;
var type = pwd.getAttribute('type');
pwd.setAttribute('type', type === 'password' ? 'text': 'password');
@axemclion
axemclion / feedly.user.js
Last active May 9, 2019 12:24
Feedly Open in New Background Tab
// ==UserScript==
// @name Feedly - Open entry in background (Modified)
// @description Adds 'h' as a hotkey to open selected entry in background tab
// @namespace gist.github.com/axemclion/11b6968d2418caad7528e1e629af3886/edit
// @author axemclion
// @include http://feedly.com/*
// @include https://feedly.com/*
// @include http://*.feedly.com/*
// @include https://*.feedly.com/*
// @grant GM.openInTab
@axemclion
axemclion / app.jsx
Last active September 5, 2020 14:31
CodePush + Push Notifications for A/B Testing
import Push from 'mobile-center-push';
import CodePush from 'react-native-code-push';
import { AppState } from 'react-native';
export default class MyApp extends Component {
// Component Logic ...
}
Push.setEventListener({
pushNotificationReceived: function (pushNotification) {