Skip to content

Instantly share code, notes, and snippets.

View sturmenta's full-sized avatar
🌌

Nicolas Sturm sturmenta

🌌
  • Argentina
  • 15:59 (UTC -03:00)
View GitHub Profile
@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 / comments.md
Last active October 1, 2021 17:52
Firebase Functions Send Mail
@sturmenta
sturmenta / Table.tsx
Last active June 24, 2022 23:51
simple react table
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 / addObjectsToArrayIfIdNotExists.ts
Created August 7, 2022 21:50
get from graphql with pagination
export const addObjectsToArrayIfIdNotExists = (
baseArray: any[],
objects: any[],
): any[] => {
objects.forEach(obj1 => {
if (!baseArray.find(obj2 => obj2.id === obj1.id)) {
baseArray.push(obj1);
}
});
@sturmenta
sturmenta / baseScraper.js
Last active September 30, 2022 12:18
basic scraper
const axios = require('axios');
const cheerio = require('cheerio');
const baseUrl = 'https://www.infomerlo.com';
const urlToScrap = baseUrl + '/noticias';
const numberOfFirstElementsToScrap = 10;
axios(urlToScrap)
.then(response => {
@sturmenta
sturmenta / get-new-image-size-by-aspect-ratio.ts
Created October 11, 2022 07:31
resize image and keep aspect ratio
type OneRequiredOneOptional =
| {desiredWidth: number; desiredHeight?: number}
| {desiredWidth?: number; desiredHeight: number};
interface CommonProps {
widthReadFromImage: number;
heightReadFromImage: number;
}
type FullProps = CommonProps & OneRequiredOneOptional;
@sturmenta
sturmenta / show-progress.tsx
Created October 11, 2022 08:28
react-native progress indicator
import React from 'react';
import {useTheme} from '@react-navigation/native';
import {ProgressChart} from 'react-native-chart-kit';
import {MyThemeInterfaceColors, getPercentageInHex} from '_utils';
import {useComponentTrackTrace} from '_hooks';
interface ShowProgressProps {
progress: number;
height?: number;
@sturmenta
sturmenta / scalable-image-uri.tsx
Created October 11, 2022 08:33
react-native uri-image with progress indicator
import React, {useState} from 'react';
import {ImageProps, View} from 'react-native';
import FastImage, {FastImageProps} from 'react-native-fast-image';
import {useComponentTrackTrace} from '_hooks';
import {ShowProgress} from '_atoms';
import {ToastShow} from '_utils';
import {getNewImageSizeByAspectRatio} from './get-new-image-size-by-aspect-ratio';
@sturmenta
sturmenta / get-google-maps-place-by-autocomplete.ts
Last active October 19, 2022 11:31
get google maps place by autocomplete
import Qs from 'qs';
import {GOOGLE_MAPS_API_KEY} from 'react-native-dotenv';
export const getGoogleMapsPlaceByAutocomplete = (
place: string,
): Promise<{
data?: {
predictions: Array<{
description: string;
place_id: string;
@sturmenta
sturmenta / example.ts
Last active October 28, 2022 18:29
get gist text - get gist raw text - fetch gist text
const gistUrl = 'https://gist.github.com/sturmenta/df1c9da1f219c88e996e48f19d57acd3';
const {data, error} = await getGistFirstFileText(`${gistUrl}.json`);
console.log(data);
// ## some title
//
// some text