Skip to content

Instantly share code, notes, and snippets.

View sturmenta's full-sized avatar
🌌

Nicolas Sturm sturmenta

🌌
  • Argentina
  • 19:53 (UTC -03:00)
View GitHub Profile
@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 / DottedLine.js
Last active August 29, 2019 22:26
react native - android - dotted line
import React from 'react';
import { View, Text, StyleSheet } from 'react-native';
const styles = StyleSheet.create({
container: {
width: '100%',
alignItems: 'center',
height: 1,
marginBottom: 10,
marginTop: 10,
@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 / 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 / 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 / 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 / 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 / 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 / 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('",]')
@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);