Skip to content

Instantly share code, notes, and snippets.

View khadorkin's full-sized avatar

Dima Khadorkin khadorkin

  • Mobile Roadie
  • Vilnius, Lithuania
  • 10:34 (UTC +02:00)
View GitHub Profile
const express = require('express');
const app = express();
// Application
app.get('/', function(req, res) {
if (process.env.NODE_ENV === 'development') {
for (var key in require.cache) {
delete require.cache[key];
}
}
@khadorkin
khadorkin / example.cs
Created November 9, 2019 13:50 — forked from brandonmwest/example.cs
Generating base64-encoded Authorization headers in a variety of languages
httpClient.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue(
"Basic",
Convert.ToBase64String(
System.Text.ASCIIEncoding.ASCII.GetBytes(
string.Format("{0}:{1}", username, password))));
@khadorkin
khadorkin / PlatformTouchable.tsx
Created September 28, 2019 20:22 — forked from brunolemos/PlatformTouchable.tsx
TypeScript version of react-native-platform-touchable
// Source: https://github.com/react-community/react-native-platform-touchable
import React, { PureComponent, ReactNode } from 'react'
import {
BackgroundPropType,
Platform,
StyleProp,
TouchableNativeFeedback,
TouchableNativeFeedbackProperties,
TouchableNativeFeedbackStatic,
TouchableOpacity,
@khadorkin
khadorkin / React.unstable_Profiler.md
Created September 28, 2019 20:17 — forked from bvaughn/React.unstable_Profiler.md
Notes about the in-development React <Profiler> component

Profiler

React 16.4 will introduce a new Profiler component (initially exported as React.unstable_Profiler) for collecting render timing information in order to measure the "cost" of rendering for both sync and async modes.

Profiler timing metrics are significantly faster than those built around the User Timing API, and as such we plan to provide a production+profiling bundle in the future. (The initial release will only log timing information in DEV mode, although the component will still render its children- without timings- in production mode.)

How is it used?

Profiler can be declared anywhere within a React tree to measure the cost of rendering that portion of the tree. For example, a Navigation component and its descendants:

@khadorkin
khadorkin / conditionalwrap.js
Created September 28, 2019 20:13 — forked from kitze/conditionalwrap.js
one-line React component for conditionally wrapping children
import React from 'react';
const ConditionalWrap = ({condition, wrap, children}) => condition ? wrap(children) : children;
const Header = ({shouldLinkToHome}) => (
<div>
<ConditionalWrap
condition={shouldLinkToHome}
wrap={children => <a href="/">{children}</a>}
>
@khadorkin
khadorkin / index.md
Created September 28, 2019 13:19 — forked from bvaughn/index.md
How to use profiling in production mode for react-dom
import {
Dimensions,
LayoutChangeEvent,
Platform,
ScrollEvent,
ScrollView,
StyleSheet,
View,
} from "react-native";
import {Font, Space} from "../atoms";
@khadorkin
khadorkin / TouchableScale.tsx
Created September 28, 2019 13:08 — forked from brunolemos/TouchableScale.tsx
Touchable component with Scale effect, common on iOS 12 (works on mobile and web)
// Demo: https://snack.expo.io/@brunolemos/touch-button-scale-effect
import React from 'react'
import { Animated, StyleProp, TouchableWithoutFeedback, TouchableWithoutFeedbackProps, ViewStyle } from 'react-native'
import { styleMerge } from 'shared/src/utils'
export interface TouchableScaleProps extends TouchableWithoutFeedbackProps {
containerStyle?: StyleProp<ViewStyle>
}
@khadorkin
khadorkin / metro.config.js
Created September 3, 2019 06:22 — forked from mbret/metro.config.js
Symlink for React Native 0.59 (symlink + scoped package + hast name collision)
/* eslint no-useless-escape: 0 */
/* eslint max-len: 0 */
/**
* For more info regarding metro config:
* @see https://facebook.github.io/metro/docs/en/configuration
*/
const path = require("path");
const fs = require("fs");
// Get blacklist factory
@khadorkin
khadorkin / Fastfile.rb
Created July 20, 2019 20:30 — forked from cball/Fastfile.rb
Fastlane file for updating ids, display names, and icons w/ badges in React Native
# this should be the folder name under `ios` for your project
project_name = 'MyProject'
# NOTE: This is meant to be run on CI where it changes everything before building the app.
# Usage:
# `RN_RELEASE_TYPE=beta fastlane prep_release_type` (on CI these ENV variables should be set via the UI)
# Available release types: alpha, beta, production (default)
#
# If you're trying this script out locally, make sure you have ImageMagick installed, and discard the changes via git when you're done.
desc "Updates the app identifier, display name and icon for alpha, beta, and production releases"