Skip to content

Instantly share code, notes, and snippets.

Avatar
🌌

Nicolas Sturm sturmenta

🌌
View GitHub Profile
@sturmenta
sturmenta / getCUIT.js
Last active Jun 6, 2022
codigo generador de CUIT javascript - CUIT generator
View getCUIT.js
/**
* 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 / Table.tsx
Last active Jun 24, 2022
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>
}
@sturmenta
sturmenta / feedback.tsx
Last active Jun 29, 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 / firestore2json.js
Last active Aug 4, 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 / addObjectsToArrayIfIdNotExists.ts
Created Aug 7, 2022
get from graphql with pagination
View addObjectsToArrayIfIdNotExists.ts
export const addObjectsToArrayIfIdNotExists = (
baseArray: any[],
objects: any[],
): any[] => {
objects.forEach(obj1 => {
if (!baseArray.find(obj2 => obj2.id === obj1.id)) {
baseArray.push(obj1);
}
});