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
| config defaultToCurrentScreen true | |
| config nudgePercentOf screenSize | |
| config resizePercentOf screenSize | |
| # Resize Bindings | |
| bind right:ctrl;cmd;shift resize +25% +0 | |
| bind left:ctrl;cmd;shift resize -25% +0 | |
| bind up:ctrl;cmd;shift resize +0 -25% | |
| bind down:ctrl;cmd;shift resize +0 +25% | |
| bind right:ctrl;cmd resize -25% +0 bottom-right |
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 handleRequestWith(makeResponse) { | |
| return (rawRequest) => { | |
| const { xhr } = rawRequest; | |
| Object.defineProperty(xhr.__proto__, 'response', { writable: true }); | |
| xhr.response = JSON.stringify(makeResponse(rawRequest)); | |
| return rawRequest; | |
| } | |
| } | |
| // sample usage: |
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
| # Read more about SSH config files: https://linux.die.net/man/5/ssh_config | |
| Host ec2_vm_01 | |
| HostName 18.189.29.105 | |
| User ec2-user | |
| IdentityFile ~/.ssh/james-1.pem |
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
| // | |
| // useTime hook | |
| // | |
| import { useEffect, useState } from 'react'; | |
| export const useTime = (refreshCycle = 100) => { | |
| // Returns the current time | |
| // and queues re-renders every `refreshCycle` milliseconds (default: 100ms) | |
| const [now, setNow] = useState(getTime()); |
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, useCallback, useRef } from 'react'; | |
| // React hook for delaying calls with time | |
| // returns callback to use for cancelling | |
| const useTimeout = ( | |
| callback: () => void, // function to call. No args passed. | |
| // if you create a new callback each render, then previous callback will be cancelled on render. | |
| timeout: number = 0, // delay, ms (default: immediately put into JS Event Queue) | |
| ): () => void => { |
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 { getTime } from './getTime'; | |
| import { DateTime } from 'luxon'; | |
| export interface IUseTimeOptions { | |
| _getTime: () => DateTime | |
| } | |
| export const useTime = ( | |
| refreshCycleMilliseconds: number = 100, |
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 { renderHook } from '@testing-library/react-hooks' | |
| import { useTime } from '.'; | |
| describe('useTime (pure)', () => { | |
| it('should return the current time (mocked through parameters)', () => { | |
| const now = 'mockNow'; | |
| const _getTime = jest.fn().mockReturnValue(now); | |
| // Override the default value and inject our mock _getTime function | |
| const { result } = renderHook(() => useTime(100, { _getTime })); |
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 from 'react'; | |
| import { DateTime } from 'luxon'; | |
| import { useTime } from '.'; | |
| interface ICountdownProps { | |
| end: DateTime, | |
| } | |
| export const Countdown: React.FC<ICountdownProps> = ({ end }: ICountdownProps) => { | |
| const now: DateTime = useTime(200); // this countdown will queue a re-render every 200ms. |
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 { renderHook, act } from '@testing-library/react-hooks' | |
| // Before importing useTime hook | |
| jest.mock('./getTime', () => ({ | |
| getTime: jest.fn().mockReturnValue('mockNow') | |
| })); | |
| import { getTime } from './getTime'; // mocked function | |
| import { useTime } from '.'; |
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 { useContext, createContext } from 'react'; | |
| const defaultConfig = { | |
| baseurl: 'https://localhost:1948', | |
| env: 'dev', | |
| }; | |
| export const ConfigurationContext = createContext(defaultConfig); | |
| export const useResumeURL = () => { |
OlderNewer