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 formatTime = (value) => { | |
| const units = ["hour", "min", "sec"]; | |
| const abs = Math.abs(value * 60 * 60); | |
| if (abs < 1) return "0 hours"; | |
| return [ | |
| Math.floor(abs / (60 * 60)), | |
| Math.floor((abs / 60) % 60), | |
| Math.floor(abs % 60), |
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 getBackReviewFiles = async () => { | |
| const activites = await Firebase.firestore() | |
| .collection("activity") | |
| .where("timestamp", ">=", Firebase.firestore.Timestamp.fromDate(from)) | |
| .get() | |
| .then((querySnapshot) => { | |
| const docs = []; | |
| querySnapshot.forEach((doc) => { | |
| if ( | |
| doc.data().collectionId === "reviewfiles" && |
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 get15MinIntervals = (startDate, span) => { | |
| const start = new Date(startDate); | |
| const endTime = new Date(start); | |
| endTime.setHours(endTime.getHours() + span); | |
| const arr = []; | |
| let minutes = 0; | |
| while (start < endTime) { | |
| const date = new Date(start); | |
| const hours = minutes < 60 ? minutes + " mins" : minutes / 60 + " hrs"; | |
| arr.push({ |
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
| // Let's say we're moving 5 to the top, | |
| // 5 should become index 0 | |
| // 1 should become index 1 | |
| // 2 should become index 4 | |
| // 6 should stay index 5 | |
| // 3 should stay index 3 | |
| // 4 should stay index 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
| const fileSizeBytes = 2848208; // bytes | |
| let fileSizeMB = fileSizeBytes / (1024 ** 2) |
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 quickSort = (array) => { | |
| if(array.length < 2) return array; | |
| else { | |
| const pivot = array[0]; | |
| const shiftedArray = array; | |
| shiftedArray.shift(); | |
| const less = shiftedArray.filter(item => item <= pivot); | |
| const greater = shiftedArray.filter(item => item > pivot); | |
| return [...quickSort(less), pivot, ...quickSort(greater)]; | |
| } |
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
| /** | |
| * Loop through the data from the parsed CSV and | |
| * build up a flat XML string | |
| */ | |
| public function arrayToFlatXml($elements, $headers) | |
| { | |
| $xmlString = ''; | |
| foreach($elements as $elementKey => $element) { | |
| $count = 1; | |
| $xmlString .= "<" . array_keys($element)[0] ." value='". array_values($element)[0] ."'>".PHP_EOL; |
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 delimiter = "/"; | |
| export const TestId = (props = {}) => { | |
| const component = props["data-testid"]; | |
| return (element, key) => { | |
| const testId = [component, element, key] | |
| .filter((v) => v !== undefined) | |
| .join(delimiter); | |
| return { | |
| "data-testid": testId, | |
| }; |
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 { useState } from "react"; | |
| function useSuperContextState(initialState) { | |
| const [errors, setErrors] = useState([]); | |
| const [pending, setPending] = useState([]); | |
| const [state, setState] = useState(initialState); | |
| const setter = (payload) => setState(payload); |
NewerOlder