Skip to content

Instantly share code, notes, and snippets.

Avatar
🌌

Nicolas Sturm sturmenta

🌌
View GitHub Profile
@sturmenta
sturmenta / feedback.tsx
Last active May 23, 2022
react native collapse animation dynamic height
View feedback.tsx
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 / GetContainerDimensions.js
Last active May 4, 2022
react get div dimensions - using react hooks
View GetContainerDimensions.js
import { useState, useEffect } from 'react';
const useContainerDimensions = containerRef => {
const getDimensions = () => ({
width: containerRef.offsetWidth,
height: containerRef.offsetHeight
});
const [dimensions, setDimensions] = useState({ width: 0, height: 0 });
@sturmenta
sturmenta / container-with-dimensions.tsx
Last active May 4, 2022
react native - get the father component dimensions
View container-with-dimensions.tsx
import React, {useState} from 'react';
import {View, ViewProps} from 'react-native';
interface ContainerWithDimensionsProps extends ViewProps {
children: ({
width,
height,
}: {
width: number;
height: number;
@sturmenta
sturmenta / firestore2json.js
Last active Apr 22, 2022
firestore to json & json to firestore
View firestore2json.js
const admin = require('firebase-admin');
const fs = require('fs');
const serviceAccount = require('../../../../../../Private/myschool-data_transfer-key.json');
admin.initializeApp({ credential: admin.credential.cert(serviceAccount) });
const schema = require('./schema').schema;
const firestore2json = (db, schema, current) => {
@sturmenta
sturmenta / readme.md
Last active Apr 4, 2022
use "react-native-vector-icons" in "create-react-app" with "react-app-rewired"
View readme.md
  1. yarn add react-native-vector-icons react-native-web
  2. yarn add react-app-rewired -D
  3. update package.json scripts (before react-scripts start/build/test)
    "start": "react-app-rewired start",
    "build": "react-app-rewired build",
    "test": "react-app-rewired test --env=jsdom",
  1. create a new file named config-overrides.js add it to the root of the project
@sturmenta
sturmenta / mac-config.md
Last active Nov 17, 2021
mac m1- start configuration
View mac-config.md
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
defaults write com.apple.finder AppleShowAllFiles -bool YES && killall Finder
@sturmenta
sturmenta / comments.md
Last active Oct 1, 2021
Firebase Functions Send Mail
View comments.md
@sturmenta
sturmenta / stringifyWithCustomDepth.ts
Last active Sep 1, 2021
Version of JSON.stringify limitied to a specific depth.
View stringifyWithCustomDepth.ts
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 Jul 26, 2021
hex percentage - cta with fading
View CTAWithFading.tsx
/* 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 / Table.tsx
Last active May 25, 2021
simple react table
View Table.tsx
import React from 'react'
import { ClassNames, CSSObject } from '@emotion/react'
import { Column, useTable } from 'react-table'
import TextByScale from './TextByScale'
interface Props {
columns: Array<Column>
data: Array<any>
}