This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// String | |
enum Family { | |
Mom = 'M', | |
Daddy = 'D', | |
Brother = 'B', | |
} | |
const indexOf = Object.values(Sizes).indexOf('M' as unknown as Family); | |
const key = Object.keys(Family)[indexOf]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.time.Instant | |
import java.time.LocalDateTime | |
import java.time.ZoneOffset | |
import java.time.format.DateTimeFormatter | |
val epochTime = 1689734454000L | |
val now = System.currentTimeMillis() | |
val ldt = LocalDateTime.ofInstant( | |
Instant.ofEpochMilli(now), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#============================================================================== | |
# GW-Kit | |
# @author : (origin) yunsang.choi([email protected]) | |
# @author : (forked) jinkwon([email protected]) | |
# @src : (origin) https://gist.github.com/gists/3115022 | |
# @src : (forked) https://github.com/Jinkwon/naver-gw-kit/ | |
#------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function WindowAddEventListener(props: WindowAddEventListenerProps) { | |
const {handleFullScreen} = props; | |
const orientationType = useOrientationFullScreen(handleFullScreen); | |
useEffect(() => { | |
console.debug('orientation type', orientationType); | |
}, [orientationType]); | |
} | |
----- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Source: https://github.com/jserz/js_piece/blob/master/DOM/ParentNode/append()/append().md | |
(function (arr) { | |
arr.forEach(function (item) { | |
if (item.hasOwnProperty('append')) { | |
return; | |
} | |
Object.defineProperty(item, 'append', { | |
configurable: true, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useRef } from 'react'; | |
import { useRecoilState } from 'recoil'; | |
import { someAtom } from './recoilstates/someState'; | |
const yourCustomHook = () => { | |
const [someState, setSomeState] = useRecoilState(someAtom); | |
const latestSomeState = useRef(someState); | |
useEffect(()=> { | |
latestSomeState.current = someState; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const changeTimeFormat = (seconds: number) => { | |
var hour = parseInt('' + seconds/3600); | |
var min = parseInt('' + (seconds%3600)/60); | |
var sec = Math.floor(seconds%60); | |
return `${hour}:${min}:${sec}`; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useEffect, useRef } from 'react'; | |
/** | |
* Use setInterval with Hooks in a declarative way. | |
* | |
* @see https://stackoverflow.com/a/59274004/3723993 | |
* @see https://overreacted.io/making-setinterval-declarative-with-react-hooks/ | |
*/ | |
export function useInterval( | |
callback: React.EffectCallback, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Stream<Integer> stream = Stream.of(1,2,3,4); | |
Map<Boolean, List<Integer>> patition = stream.collect(Collectors.partitioningBy(s -> (s % 2) == 0)); | |
List<Integer> oddList = patition.get(false); | |
System.out.println(oddList); | |
List<Integer> evenList = patition.get(true); | |
System.out.println(evenList); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LocalDateTimeSorting { | |
public static void main (String... args) { | |
List<Model> list = new ArrayList<>(); | |
Model m = new Model(); | |
Map<String, Object> map = new HashMap<>(); | |
map.put("datetime", "2019-07-08 18:10:10.0"); |