This file contains 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
javascript: (() => { | |
const synth = window.speechSynthesis; | |
if (synth.speaking) { | |
synth.cancel(); | |
return; | |
} | |
const selectedText = window.getSelection().toString(); | |
if (!selectedText) { | |
return; |
This file contains 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 withLoading = <P extends object>( | |
Component: React.ComponentType<P> | |
): React.FC<P & WithLoadingProps> => ({ | |
loading, | |
...props | |
}: WithLoadingProps) => | |
loading ? <LoadingSpinner /> : <Component {...props as P} />; |
This file contains 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
// ref: https://css-tricks.com/css-fix-for-100vh-in-mobile-webkit/ | |
body { | |
min-height: 100vh; | |
min-height: -webkit-fill-available; | |
} | |
html { | |
height: -webkit-fill-available; | |
} |
This file contains 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
var getDecimalValue = function(head) { | |
const items = []; | |
let currentHead = head; | |
while(currentHead !== null) { | |
items.push(currentHead.val); | |
currentHead = currentHead.next; | |
} | |
let sum = 0; |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body ng-app="todoApp"> | |
<script src="https://fb.me/react-15.1.0.js"></script> | |
<script src="https://fb.me/react-dom-15.1.0.js"></script> |
This file contains 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
// 數字 X 左邊補零至 N 位數 | |
// ex. X = 23, N = 4 | |
("0000" + 23).slice(-4) // "0023" |