Skip to content

Instantly share code, notes, and snippets.

View octopitus's full-sized avatar

Luy Tran octopitus

View GitHub Profile
@esinanturan
esinanturan / README.md
Created March 29, 2022 21:27 — forked from cskeppstedt/README.md
Modify proguard rules in a managed expo project

Modify proguard rules in a managed expo project

If you ever need to modify the proguard rules for the Android-part of your Expo managed workflow, you can achieve this by using a config plugin.

  1. Make a folder for config-plugins called ./plugins in the project root folder.
  2. Place the withProguardRules.js and my-proguard-rules.pro in the folder
  3. Add the config plugin to the plugins array of your app.config.js (or app.json if you're using that instead).

NOTE: if you rename your .pro file, don't forget to change the two occurrences of my-proguard-rules in withProguardRules.js as well.

" Specify a directory for plugins
call plug#begin('~/.vim/plugged')
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'scrooloose/nerdtree'
"Plug 'tsony-tsonev/nerdtree-git-plugin'
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
Plug 'ryanoasis/vim-devicons'
Plug 'airblade/vim-gitgutter'
@zone117x
zone117x / crypto-webworker-support-check.js
Created January 15, 2019 14:43
Check for web worker Crypto API support
// Checks if the global.crypto API is supported inside web workers.
// Uses a serialized function inside a Blob URL to run a web worker
// without an external file.
// See https://medium.com/@roman01la/run-web-worker-with-a-function-rather-than-external-file-303add905a0
function checkCryptoWorkerSupport() {
return new Promise((resolve) => {
const checkFn = () => {
const cryptoSupported = self.crypto && self.crypto.getRandomValues
postMessage(!!cryptoSupported)
@bvaughn
bvaughn / index.md
Last active June 16, 2024 21:50
How to use profiling in production mode for react-dom

React recently introduced an experimental profiler API. This page gives instructions on how to use this API in a production release of your app.

Table of Contents

Profiling in production

React DOM automatically supports profiling in development mode for v16.5+, but since profiling adds some small additional overhead it is opt-in for production mode. This gist explains how to opt-in.

@bvaughn
bvaughn / index.md
Last active April 3, 2024 07:41
Interaction tracing with React

This API was removed in React 17


Interaction tracing with React

React recently introduced an experimental profiler API. After discussing this API with several teams at Facebook, one common piece of feedback was that the performance information would be more useful if it could be associated with the events that caused the application to render (e.g. button click, XHR response). Tracing these events (or "interactions") would enable more powerful tooling to be built around the timing information, capable of answering questions like "What caused this really slow commit?" or "How long does it typically take for this interaction to update the DOM?".

With version 16.4.3, React added experimental support for this tracing by way of a new NPM package, scheduler. However the public API for this package is not yet finalized and will likely change with upcoming minor releases, so it should be used with caution.

@RyanMillerC
RyanMillerC / set-primary-monitor-pantheon-greeter
Last active November 7, 2020 13:29
Set correct primary monitor for login screen when lightdm greeter starts up on Elementary OS
#!/bin/bash
#
# Created: 2017-07-02 16:20
# Updated: 2018-02-09 12:23
# Creator: Ryan Miller
# Website: http://devopsmachine.com/
# File: /usr/local/bin/set-primary-monitor-pantheon-greeter
#
# Set correct primary monitor for login screen when lightdm greeter starts up on Elementary OS.
#
@teameh
teameh / PanResponder_Overview.js
Last active October 21, 2023 05:28
React native PanResponder interface overview
this._panResponder = PanResponder.create({
// ----------- NEGOTIATION:
// A view can become the touch responder by implementing the correct negotiation methods.
// Should child views be prevented from becoming responder on first touch?
onStartShouldSetPanResponderCapture: (evt, gestureState) => () => {
console.info('onStartShouldSetPanResponderCapture');
return true;
},
@mmazzarolo
mmazzarolo / hideOnScroll.js
Last active October 31, 2023 07:32
react-native-action-button hide on scroll
// 1. Define a state variable for showing/hiding the action-button
state = {
isActionButtonVisible: true
}
// 2. Define a variable that will keep track of the current scroll position
_listViewOffset = 0
// 3. Add an onScroll listener to your listview/scrollview
<ListView
@developit
developit / example.js
Last active May 6, 2024 05:10
Preact + Web Components = <333 Demo: http://www.webpackbin.com/VJyU9wK5W
import { h, Component } from 'preact';
import Markup from 'preact-markup';
import register from './preact-custom-element';
// just a proxy component: WC -> Preact -> WC
const A = () => <x-b foo="initial foo from <x-a>" />;
// stateful component that can re-render
class B extends Component {
render(props, state) {
@jarretmoses
jarretmoses / React Native Clear Cache
Last active June 3, 2024 05:22
Clearing the Cache of your React Native Project
RN < 0.50 - watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache clean && npm install && npm start -- --reset-cache
RN >= 0.50 - watchman watch-del-all && rm -rf $TMPDIR/react-native-packager-cache-* && rm -rf $TMPDIR/metro-bundler-cache-* && rm -rf node_modules/ && npm cache clean && npm install && npm start -- --reset-cache
RN >= 0.63 - watchman watch-del-all && rm -rf node_modules && npm install && rm -rf /tmp/metro-* && npm run start --reset-cache
npm >= 5 - watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache verify && npm install && npm start -- --reset-cache
Windows - del %appdata%\Temp\react-native-* & cd android & gradlew clean & cd .. & del node_modules/ & npm cache clean --force & npm install & npm start -- --reset-cache