Skip to content

Instantly share code, notes, and snippets.

View usrbowe's full-sized avatar
🤓
Digging into React Native

Lukas Kurucz usrbowe

🤓
Digging into React Native
View GitHub Profile
@usrbowe
usrbowe / react-native-kill-packager.sh
Created May 23, 2019 04:06
Kill background running packager for React Native
# Find process running with port 8081 and later kill it.
# Tested on Mac OSx (should work on all unix based os as well)
kill $(lsof -t -i :8081)
@chengkiang
chengkiang / paynow.js
Last active April 3, 2024 04:24
SG PayNow QR Code Generator Sample
String.prototype.padLeft = function (n, str) {
if (n < String(this).length) {
return this.toString();
}
else {
return Array(n - String(this).length + 1).join(str || '0') + this;
}
}
function crc16(s) {
@bvaughn
bvaughn / index.md
Last active April 19, 2024 04:34
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.

@usrbowe
usrbowe / camelize.js
Last active June 15, 2018 15:16
Camelize string in Javascript / ES6 💪
/* Transform dasherized, underscored string to camelCase */
const cameliseMe = (str, separator = "-") => {
const splitted = str.split(separator);
if (splitted.length === 1) return str;
return splitted.reduce(
(acc, [up, ...rest]) => `${acc}${up.toUpperCase() + rest.join("")}`
);
};
@usrbowe
usrbowe / branch-delete.js
Created June 27, 2017 04:17
Delete all origin branches on GitHub
// Open console and run this script
[...document.querySelectorAll('.branch-delete')].forEach(button => button.click());
// URL to try
// https://github.com/--url-to-repository/branches/stale
@luisliuchao
luisliuchao / sk-release
Last active December 6, 2019 01:54
Automatically make a release by incrementing the version number in package.json or with a version number supplied
# SK Release
# https://gist.github.com/bclinkinbeard/1331790
#!/bin/bash
# file in which to update version number
versionFile="package.json"
# extract version number from versionFile
# https://gist.github.com/DarrenN/8c6a5b969481725a4413
@lelandrichardson
lelandrichardson / react-native.js
Last active July 21, 2022 17:56
React Native flow types
declare var __DEV__: boolean;
declare module 'react-native' {
declare type Color = string | number;
declare type Transform =
{ perspective: number } |
{ scale: number } |
{ scaleX: number } |