Skip to content

Instantly share code, notes, and snippets.

View khadorkin's full-sized avatar

Dima Khadorkin khadorkin

  • Mobile Roadie
  • Vilnius, Lithuania
  • 23:03 (UTC +03:00)
View GitHub Profile
@khadorkin
khadorkin / App.tsx
Created January 7, 2022 18:40 — forked from intergalacticspacehighway/App.tsx
Add row/col gaps in flatlist
function App() {
const data = Array(10).fill(0);
const GAP = 5;
const numColumns = 3;
const { width } = Dimensions.get("window");
// Reduce the size to accomodate margin space by items
const ITEM_SIZE = width / numColumns - ((numColumns - 1) * GAP) / numColumns;
const renderItem = ({ index }) => {
@khadorkin
khadorkin / uuid.ts
Created November 9, 2021 17:13 — forked from YBogomolov/uuid.ts
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> =
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}`
@khadorkin
khadorkin / FitText.tsx
Created November 9, 2021 07:20 — forked from steida/FitText.tsx
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,
// Adapted from http://lukajcb.github.io/blog/functional/2018/01/03/optimizing-tagless-final.html
import { Applicative, Applicative1 } from 'fp-ts/lib/Applicative'
import { Apply, Apply1, Apply2C, applySecond, liftA4 } from 'fp-ts/lib/Apply'
import * as array from 'fp-ts/lib/Array'
import * as const_ from 'fp-ts/lib/Const'
import { HKT, Type, Type2, URIS, URIS2 } from 'fp-ts/lib/HKT'
import { IO, io, URI as IOURI } from 'fp-ts/lib/IO'
import { Option, some } from 'fp-ts/lib/Option'
import { getProductSemigroup, Semigroup } from 'fp-ts/lib/Semigroup'
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(...);
@khadorkin
khadorkin / FlightRadar24.hs
Created August 6, 2021 15:56 — forked from msakai/FlightRadar24.hs
Sample for fetching JSON data from flightradar24.com
import Control.Concurrent
import Control.Monad
import Data.Maybe
import Data.Time
import Network.Browser
import Network.HTTP
import Network.HTTP.Proxy
import Network.URI
import System.Locale
http://miot-spec.org/miot-spec-v2/instances?status=all
http://miot-spec.org/miot-spec-v2/instances?status=debug
http://miot-spec.org/miot-spec-v2/instances?status=released
and for example air purifier 3 cn (zhimi.airpurifier.ma4)
https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:air-purifier:0000A007:zhimi-ma4:1
http://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:light:0000A001:philips-bulb:1
http://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:fan:0000A005:zhimi-sa1:1
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';
@khadorkin
khadorkin / RNMultipleTargetsInstructions.md
Created October 8, 2020 18:07 — forked from jacks205/RNMultipleTargetsInstructions.md
Settings up multiple app targets in React-Native