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
| "Some String Here".trim() | |
| .toLowerCase() | |
| .replace(/([^A-Z0-9]+)(.)/ig, | |
| function(match) { | |
| return arguments[2].toUpperCase(); | |
| } | |
| ); |
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
| $('#content-body table').each(function(i) { | |
| $('<button class="json-table">JSON</button>').insertBefore($(this)); | |
| $(this).attr('id', 'json-table-' + i) | |
| }); | |
| $(document).on('click', 'button', function() { | |
| if ($(this).is('.json-table')) { | |
| buildJSONFromTable('#' + $(this).next().attr('id')) | |
| } | |
| }) |
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, | |
| useCallback, | |
| useLayoutEffect | |
| } from "react"; | |
| interface DimensionObject { | |
| width: number; | |
| height: number; | |
| top: number; |
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
| /** | |
| * Handles try/catch for promises | |
| * @param {Promise<any>} prom | |
| * @returns {Promise<[T | null, any]>} Fulfilled or unfulfilled promise | |
| */ | |
| async function asyncHandler<T>( | |
| prom: Promise<T> | |
| ): Promise<[T | null, any]> { | |
| try { | |
| return [await prom, null]; |
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 util = require('util'); | |
| const exec = util.promisify(require('child_process').exec); | |
| const fs = require('fs'); | |
| // The func | |
| const functionName = 'LAMBDA FUNCTION NAME'; | |
| /** | |
| * | |
| */ | |
| (async () => { |
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
| /** | |
| * Converts a number into an IPv4 address. | |
| * @param int Number to be converted | |
| * @returns {string} - formatted value | |
| * @example let ipAddress = formatIntToIP(167772160) | |
| */ | |
| const formatIntToIP = (int: number): string => ( | |
| `${(int>>>24)}.${(int>>16 & 255)}.${(int>>8 & 255)}.${(int & 255)}` | |
| ); |
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 dynamic from 'next/dynamic'; | |
| const NoComponent = () => ( | |
| <p>No Component Exist</p> | |
| ); | |
| /** | |
| * Helper function to dynamically import components | |
| * @param path Path to the component | |
| * @returns React Component |
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, useState, useCallback, useRef } from 'react'; | |
| const defaultOptions = { | |
| cancelOnUnmount: true, | |
| }; | |
| /** | |
| * An async hook that accepts a callback function and a delay time (in milliseconds), then delays the | |
| * execution of the given function by the defined time. | |
| */ |
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, { FC, useMemo } from "react"; | |
| interface MyComponentInterface { | |
| text: string | |
| } | |
| export const MyComponent: FC<MyComponentInterface> = ({ text }) => { | |
| const MemoizedComponent = useMemo(() => ( | |
| <Component |
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 { memo as m, NamedExoticComponent } from "react"; | |
| import { isEqual } from "./lodash"; | |
| /** | |
| * React memo utility function. Uses the Lodash 'isEqual' function to compare | |
| * by default. You may also create and pass in your own compare function. | |
| * @param component Your React Component | |
| * @param areEqual Optional: Pass your own compare function. | |
| * @example memo(<Component />, areEqual) | |
| */ |