Skip to content

Instantly share code, notes, and snippets.

View sturmenta's full-sized avatar
🌌

Nicolas Sturm sturmenta

🌌
  • Argentina
  • 14:19 (UTC -03:00)
View GitHub Profile
@sturmenta
sturmenta / GetContainerDimensions.js
Last active February 22, 2024 19:49
react get div dimensions - using react hooks
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 / 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 / keybase.md
Created November 14, 2019 13:47
keybase.md

Keybase proof

I hereby claim:

  • I am sturmenta on github.
  • I am sturmenta (https://keybase.io/sturmenta) on keybase.
  • I have a public key ASCDQDUVsCMsapvOT9Dv2-9VnH4Hnoxx1SQvIPJ2zPtu9go

To claim this, I am signing this object:

@sturmenta
sturmenta / exampleOfUse.js
Created October 16, 2019 21:54
react-native ask permissions
requestLocationPermission({
grantPermission: () => console.warn('location granted'),
refusePermission: () => console.warn('location not granted'),
});
@sturmenta
sturmenta / dist2GPS.ts
Last active June 16, 2023 23:29
Distance between two gps locations
const numToRad = (num) => (num * Math.PI) / 180;
export const getDistFrom2GpsLocations = ({ lat1, long1, lat2, long2 }) => {
lat1 = parseFloat(lat1);
long1 = parseFloat(long1);
lat2 = parseFloat(lat2);
long2 = parseFloat(long2);
const R = 6371e3;
const φ1 = numToRad(lat1);
@sturmenta
sturmenta / App.js
Last active September 11, 2019 03:08
react native KeyboardContext
import React, { PureComponent } from 'react';
import { AppNavigator, setTopLevelNavigator } from './navigation';
import { KeyboardProvider } from './utils/keyboardContext';
export default class App extends PureComponent {
render() {
return (
<KeyboardProvider>
<AppNavigator ref={navigationRef => setTopLevelNavigator(navigationRef)} />
@sturmenta
sturmenta / dimensions.js
Last active September 9, 2019 14:04
JS Media Queries for Desktop, Tablet, Mobile.
const w = window.innerWidth;
export const isPhone = w >= 320 && w < 480;
export const isTablet = w >= 480 && w < 768;
export const isLargeTablet = w >= 768 && w < 1024;
export const isDesktop = w >= 1024 && w < 1280;
export const isLargeDesktop = w >= 1280;
@sturmenta
sturmenta / formatBigNumber.js
Created July 22, 2019 22:36
Parse big numbers
const values = [
{ K: 1000 },
{ M: 1000000 },
{ B: 1000000000 },
{ Qd: 1000000000000 },
{ Qt: 1000000000000000 },
{ St: 1000000000000000000 },
{ Sp: 1000000000000000000000 },
{ O: 1000000000000000000000000 },
{ N: 1000000000000000000000000000 },
@sturmenta
sturmenta / readme.md
Last active January 11, 2024 10:27
use "react-native-vector-icons" in "create-react-app" with "react-app-rewired"

guide of how to use react-native-vector-icons on web with webpack and react-app-rewired

  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",
@sturmenta
sturmenta / ObjectsArrayutils.ts
Last active November 9, 2020 11:24
remove object from array in javascript, add, and replace
export const arrayRemoveObject = (array: Object[] = [], toRemove: Object): Array<Object> => {
const tempArray = array.slice();
if (JSON.stringify(tempArray).includes(JSON.stringify(toRemove))) {
return JSON.parse(
JSON.stringify(tempArray)
.replace(JSON.stringify(toRemove), '')
.split('},]')
.join('}]')
.split('",]')