Skip to content

Instantly share code, notes, and snippets.

View devethan's full-sized avatar
🚀
Go high

Ethan Lee devethan

🚀
Go high
View GitHub Profile
@devethan
devethan / Sample.tsx
Created March 11, 2024 21:49
iOS context menu in React-native
import React, {useState} from 'react';
import {
Animated,
Image,
ImageBackground,
StyleSheet,
Pressable,
Text,
View,
} from 'react-native';
@devethan
devethan / useDelay.ts
Last active September 24, 2023 05:36
How to apply delay on your event
import { useRef, useEffect } from "react";
/**
* debounce: Ensuring that only the last event gets executed after the delay
* throttle: Ensuring that only the first event gets executed and subsequent events within the delay period are ignored.
*/
type DelayType = "debounce" | "throttle";
/**
* The hook is designed to provide a delayed execution of a callback function based on either a debounce or throttle mechanism.
@devethan
devethan / react-native-nested-text.md
Last active May 7, 2021 05:46
react-native에서 중첩 텍스트를 사용할 때의 유의사항

react-native에서 중첩 텍스트를 사용할 때의 유의사항

[Check] Android 플랫폼에서만 발생하는 이슈

Broken

<Text style={{fontFamily: 'customFontFamily-Bold'}}>
  It seems to be
  <Text style={{fontFamily: 'customFontFamily-LightItalic'}}>
    broken
 
@devethan
devethan / renderChildrenWithGap.ts
Last active May 7, 2021 05:48
Render children components with specific gap
const renderChildrenWithGap = (): Array<
React.ReactChild | React.ReactFragment | React.ReactPortal
> | null => {
return children
? Children.toArray(children).map((child, index) => {
return (
<React.Fragment key={index}>
{index !== 0 && gap ? (
<View
style={{
@devethan
devethan / generateOpacityToHexString.ts
Last active April 8, 2021 05:34
generateOpacityToHexString
const hexOpacityList = [
'00',
'03',
'05',
'08',
'0A',
'0D',
'0F',
'12',
'14',
@devethan
devethan / gist:683d5cd7c7a20aa582f65b8f0cd18cb1
Created May 11, 2020 04:42 — forked from tonymtz/gist:d75101d9bdf764c890ef
Uninstall nodejs from OSX Yosemite
# first:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following:
# go to /usr/local/lib and delete any node and node_modules
cd /usr/local/lib
sudo rm -rf node*
@devethan
devethan / react_children_render.js
Created February 25, 2020 07:59
How to use React.Children
React.Children.map(children, (child: ReactElement, index) => {
const { props } = child;
return React.cloneElement(child, {
...props,
});
})
@devethan
devethan / clean.sh
Last active January 24, 2020 11:32
Clean command
# yarn clean
watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache verify && yarn
@devethan
devethan / prettierrc.js
Last active January 23, 2020 02:32
Setting file for Prettier in vscode
// prettier.config.js or .prettierrc.js
module.exports = {
trailingComma: 'all',
arrowParens: 'always',
singleQuote: true,
jsxSingleQuote: false,
bracketSpacing: false,
jsxBracketSameLine: true,
};
@devethan
devethan / settings.json
Last active February 7, 2021 11:43
vscode settings.json with slack theme
{
"terminal.integrated.fontFamily": "D2Coding",
"terminal.integrated.fontSize": 14,
"editor.tabSize": 2,
"editor.renderWhitespace": "all",
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"window.zoomLevel": 0,
"[json]": {