Skip to content

Instantly share code, notes, and snippets.

View sturmenta's full-sized avatar
🌌

Nicolas Sturm sturmenta

🌌
  • Argentina
  • 14:38 (UTC -03:00)
View GitHub Profile
@sturmenta
sturmenta / feedback.tsx
Last active August 29, 2023 18:20
react native collapse animation dynamic height
import React, {useEffect, useImperativeHandle, useState} from 'react';
import {Keyboard, View} from 'react-native';
import {useTheme} from '@react-navigation/native';
import {useSpring, animated} from '@react-spring/native';
import {MyThemeInterfaceColors} from '_styles';
import {GetDimensions} from '_atoms';
import {MultilineTextInput, Button, TextInputRef} from '_molecules';
import {getPercentageInHex, themedStyleSheet} from '_utils';
import {usePrevious} from '_hooks';
@sturmenta
sturmenta / container-with-dimensions.tsx
Last active December 17, 2023 06:42
react native - get the father component dimensions
import React, { useState } from "react"
import { View, ViewProps } from "react-native"
interface ContainerWithDimensionsProps {
children: ({
width,
height
}: {
width: number
height: number
@sturmenta
sturmenta / stringifyWithCustomDepth.ts
Last active November 19, 2022 14:48
Version of JSON.stringify limitied to a specific depth.
export const stringifyWithCustomDepth = (obj: any, depth = 1): string => {
return !obj
? JSON.stringify(obj, null, 2)
: typeof obj === 'object'
? JSON.stringify(
JSON.parse(
depth < 1
? '"???"'
: `{${Object.keys(obj)
.map((k) => `"${k}": ${stringifyWithCustomDepth(obj[k], depth - 1)}`)
@sturmenta
sturmenta / CTAWithFading.tsx
Created July 26, 2021 05:21
hex percentage - cta with fading
/* eslint-disable react/no-array-index-key */
import React, {ReactNode} from 'react';
import {SafeAreaView, View} from 'react-native';
import {withTheme} from '../../Elements';
import {baseTheme, darkTheme, PuraMenteTheme} from '../../../styles/base';
import {makeStyles} from '../../Utils/MakeStylesHoc';
interface CTAWithFadingProps {
theme: PuraMenteTheme;
@sturmenta
sturmenta / KeyboardListener.ts
Created April 6, 2021 17:27
react-native KeyboardListener
import React, {useEffect} from 'react';
import {Keyboard} from 'react-native';
const KeyboardListener: React.FC<{
onDidShow: (e: any) => void;
onDidHide: (e: any) => void;
}> = ({onDidShow, onDidHide}) => {
useEffect(() => {
if (onDidShow) Keyboard.addListener('keyboardDidShow', onDidShow);
if (onDidHide) Keyboard.addListener('keyboardDidHide', onDidHide);
@sturmenta
sturmenta / getFontScale.ts
Created October 23, 2020 03:32
react native - get font scale
import {PixelRatio, Platform} from 'react-native';
type fontScales = -3 | -2 | -1 | 0 | 1 | 2 | 3;
type iOS_fontScales = '0.823' | '0.882' | '0.941' | '1' | '1.118' | '1.235' | '1.353';
type iOS_fontScalesMap<T> = {[scale in iOS_fontScales]: T};
const fontScale_iOS: iOS_fontScalesMap<number> = {
'0.823': -3,
'0.882': -2,
'0.941': -1,
@sturmenta
sturmenta / getStatusBarHeight.ts
Created October 22, 2020 19:41
react native - get status bar height
import {Dimensions, Platform, StatusBar} from 'react-native';
const {width, height} = Dimensions.get('window');
const X_WIDTH = 375;
const X_HEIGHT = 812;
const XSMAX_WIDTH = 414;
const XSMAX_HEIGHT = 896;
@sturmenta
sturmenta / cloudSettings
Last active November 1, 2023 19:55
vscode config
{"lastUpload":"2020-06-17T23:02:23.799Z","extensionVersion":"v3.4.3"}
@sturmenta
sturmenta / getCUIT.js
Last active June 6, 2022 12:09
codigo generador de CUIT javascript - CUIT generator
/**
* Given a DNI and a gender it returns the corresponding CUIT.
* @param {String} dni
* @param {String} gender
*/
const getCUIT = (dni, gender = 'M') => {
if (!dni || dni.length !== 8) {
throw new Error('The DNI number must contain 8 numbers');
}
@sturmenta
sturmenta / mac-config.md
Last active August 31, 2023 21:53
mac m1- start configuration
defaults write com.apple.dock autohide-delay -float 0; defaults write com.apple.dock autohide-time-modifier -int 0;killall Dock
  • show hide folders & files