Skip to content

Instantly share code, notes, and snippets.

View sturmenta's full-sized avatar
🌌

Nicolas Sturm sturmenta

🌌
  • Argentina
  • 23:25 (UTC -03:00)
View GitHub Profile
@sturmenta
sturmenta / container-with-dimensions.tsx
Last active December 17, 2023 06:42
react native - get the father component dimensions
import React, { useState } from "react"
import { View, ViewProps } from "react-native"
interface ContainerWithDimensionsProps {
children: ({
width,
height
}: {
width: number
height: number
@sturmenta
sturmenta / cloudSettings
Last active November 1, 2023 19:55
vscode config
{"lastUpload":"2020-06-17T23:02:23.799Z","extensionVersion":"v3.4.3"}
@sturmenta
sturmenta / getPercentageInHex.ts
Created July 24, 2023 05:05
convert decimal percentage on hexadecimal percentage to be used with hex colors
export const getPercentageInHex = (percentage: number): string => {
if (percentage >= 0 && percentage <= 100) {
const preHexNumber = (percentage * 255) / 100;
const hexNumber = preHexNumber.toString(16).split('.')[0].padStart(2, '0').replace('f0', 'ff');
return hexNumber;
}
return 'ff';
};
@sturmenta
sturmenta / mac-config.md
Last active August 31, 2023 21:53
mac m1- start configuration
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
@sturmenta
sturmenta / feedback.tsx
Last active August 29, 2023 18:20
react native collapse animation dynamic height
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 / 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 / WeekdaysSelector.tsx
Created June 12, 2023 03:53
react native WeekdaysSelector
import { TouchableOpacity, View } from 'react-native';
import { withLightHapticFeedback } from '_utils';
import { C_Text } from './C_Text';
const weekdays = ['L', 'M', 'X', 'J', 'V', 'S', 'D'];
export const WeekdaysSelector = ({
selectedDays,
@sturmenta
sturmenta / plausible.ts
Last active May 28, 2023 16:29
plausible react-native expo config
import Plausible, { EventOptions, PlausibleOptions } from 'plausible-tracker';
import { setLocationHref } from '@expo/metro-runtime/build/location/Location.native.js';
// NOTE: see tracking events here: https://plausible.io/asd.xyz
const runPlausibleInitialConfig = () => {
let alreadyRun = false;
if (!alreadyRun) {
alreadyRun = true;
@sturmenta
sturmenta / stringifyWithCustomDepth.ts
Last active November 19, 2022 14:48
Version of JSON.stringify limitied to a specific depth.
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 / removeHoursMinutesAndSecondsFromDate.ts
Created November 7, 2022 23:16
remove Hours Minutes And Seconds From Date
import dayjs from 'dayjs';
/**
* return DD/MM/YYYY
*/
export const removeHoursMinutesAndSecondsFromDate = (
date: Date,
): {newDate: dayjs.Dayjs; DDMMYYYY: string} => {
const _date = dayjs(date);