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
| // Test Component: | |
| interface MarkedMessageProps { | |
| message: string; | |
| matches: { offset: number; length: number }[]; | |
| } | |
| const MarkedMessage: React.FC<MarkedMessageProps> = ({ message, matches }) => { | |
| const parts: React.ReactNode[] = []; | |
| let runningOffset = 0; |
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
| precision highp float; | |
| precision highp int; | |
| #define SHADER_NAME MeshPhongMaterial | |
| #define GAMMA_FACTOR 2 | |
| uniform mat4 viewMatrix; | |
| uniform vec3 cameraPosition; | |
| #define TONE_MAPPING | |
| #ifndef saturate | |
| #define saturate(a) clamp( a, 0.0, 1.0 ) | |
| #endif |
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
| html { | |
| background-color: grey; | |
| } |
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
| .ReactTable { | |
| position: relative; | |
| display: -webkit-box; | |
| display: -ms-flexbox; | |
| display: flex; | |
| -webkit-box-orient: vertical; | |
| -webkit-box-direction: normal; | |
| -ms-flex-direction: column; | |
| flex-direction: column; | |
| border: 1px solid rgba(0, 0, 0, 0.1); |
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 minPerimeter(num) { | |
| let min = 0; | |
| for (let i = 0; i * i <= num; i++) { | |
| if (num % i === 0) { | |
| min = 2 * (i + (num / i)); | |
| if (!(i === num / i)) { | |
| if (min > 2 * (i + (num / i))) { | |
| min = 2 * (i + (num / i)); |
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 getFactorCount(num) { | |
| if (num === 0) { | |
| return; | |
| } | |
| if (num === 1) { | |
| return 1; | |
| } |
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
| https://en.wikipedia.org/wiki/Maximum_subarray_problem | |
| function maxSubArray(arr) { | |
| const len = arr.length; | |
| let cur = arr[0]; | |
| let max = arr[0]; | |
| for (let i = 1; i < len; i++) { | |
| cur = Math.max(arr[i], cur + arr[i]); |
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
| https://en.wikipedia.org/wiki/Negative_base#Calculation | |
| function toNegaBinary( number ) { | |
| var Schroeppel2 = 0xAAAAAAAA; | |
| return ( ( number + Schroeppel2 ) ^ Schroeppel2 ).toString(2); | |
| } | |
| function toNegaQuaternary( number ) { | |
| var Schroeppel4 = 0xCCCCCCCC; | |
| return ( ( number + Schroeppel4 ) ^ Schroeppel4 ).toString(4); |
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 reactanlgeCount(arr) { | |
| const stack = []; | |
| let count = 0; | |
| for (let i = 0; i < arr.length; i++) { | |
| const next = arr[i]; | |
| while (stack.length && next < stack[stack.length - 1]) { | |
| stack.pop(); |
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 map = { '(': ')', '[': ']', '{': '}' }; | |
| function nestedBrackets(s) { | |
| const stack = []; | |
| for (let i = 0; i < s.length; i++) { | |
| if (s[i] === '{' || s[i] === '[' || s[i] === '(') { | |
| stack.push(s[i]); | |
| } else if (s[i] === '}' || s[i] === ']' || s[i] === ')') { | |
| if (map[stack[stack.length - 1]] !== s[i]) { |
NewerOlder