Skip to content

Instantly share code, notes, and snippets.

View khadorkin's full-sized avatar

Dima Khadorkin khadorkin

  • Mobile Roadie
  • Vilnius, Lithuania
  • 01:09 (UTC +03:00)
View GitHub Profile
@YBogomolov
YBogomolov / uuid.ts
Last active June 21, 2023 14:15
Type-level UUID
type VersionChar =
| '1' | '2' | '3' | '4' | '5';
type Char =
| '0' | '1' | '2' | '3'
| '4' | '5' | '6' | '7'
| '8' | '9' | 'a' | 'b'
| 'c' | 'd' | 'e' | 'f';
type Prev<X extends number> =
@steida
steida / FitText.tsx
Created November 7, 2021 20:45
Fit text to container for React Native for Web. Fast. Reliable. Done.
import { pipe } from 'fp-ts/function';
import { lens } from 'monocle-ts';
import { memo, useLayoutEffect, useRef, useState } from 'react';
import { LayoutChangeEvent, Text, View } from 'react-native';
import { useTheme } from '../contexts/ThemeContext';
const isOverflown = ({
clientWidth,
clientHeight,
scrollWidth,
@joe-bell
joe-bell / stack.ts
Last active October 5, 2021 12:15
Stitches: Themed Variants
import type * as Stitches from '@stitches/react';
import { css, config } from "./stitches.config";
type TCSS = Stitches.CSS<typeof config>;
const { space } = config.theme;
type TSpaceKey = keyof typeof space;
const gap = (Object.keys(space) as Array<TSpaceKey>).reduce<
Record<TSpaceKey, TCSS>
import { ColorSchemeName, Platform, StyleSheet, ViewStyle } from 'react-native';
// AFAIK, Android has a problem with negative margins.
type RhythmSize = 'XXS' | 'XS' | 'Sm' | '' | 'Lg' | 'XL' | 'XXL';
type RhythmProp =
| `${
| 'm'
| 'p'
| `${'m' | 'p'}${'l' | 'r' | 't' | 'b' | 'v' | 'h'}`}${RhythmSize}`
| `${'w' | 'h' | `${'max' | 'min'}${'W' | 'H'}`}${RhythmSize}`
import * as React from 'react';
import { render } from 'react-native-testing-library';
import { Provider } from 'react-redux';
import { createStore } from 'redux';
import { MyContainerComponent, MyPresentationalComponent } from '...';
// Create a real redux store, with your reducers and middleware, and a useful initial
// state tree...
const store = createStore(...);
- name: Restore yarn workspaces
id: yarn-cache
uses: actions/cache@master
with:
path: |
node_modules
*/*/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- name: Install dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
+ import com.facebook.react.modules.network.OkHttpClientProvider;
+ import okhttp3.OkHttpClient;
+ import okhttp3.brotli.BrotliInterceptor;
...
public void onCreate() {
super.onCreate();
+ OkHttpClientProvider.setOkHttpClientFactory(() -> {
import * as React from 'react';
import {
EmitterSubscription,
Keyboard,
KeyboardEvent,
LayoutAnimation,
Platform,
Dimensions,
ScreenRect,
} from 'react-native';
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];
}
}
import AsyncStorage from '@react-native-community/async-storage';
import {
InitialState,
NavigationContainer,
NavigationContainerProps,
NavigationContainerRef,
} from '@react-navigation/core';
import * as React from 'react';
import { InteractionManager } from 'react-native';