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
| export function instrumentPreObjectFunctionCallHook(obj, methodName, hookFn) { | |
| const originalMethod = obj[methodName]; | |
| obj[methodName] = (...args) => { | |
| const result = hookFn({ args, obj, methodName }); | |
| return result instanceof Promise | |
| ? result.then(() => originalMethod.call(obj, args)) | |
| : originalMethod.call(obj, args); | |
| }; | |
| return obj[methodName].__deinstrument = () => { |
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 { DependencyList, useRef } from 'react'; | |
| export function useTrackChangedDependencies( | |
| dependencies: Record<string, any>, | |
| location = 'unknown location' | |
| ): DependencyList { | |
| const prevDependencies = useRef<Record<string, any> | undefined>(); | |
| if (prevDependencies.current !== undefined) { | |
| const changedDependencies = Array.from(Object.entries(dependencies)) | |
| .map<[string, any, any] | undefined>(([key, dependency]) => |
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 DAY = 3600 * 1000 * 24; | |
| const today = new Date(); | |
| const monday = today.getTime() + (1 /* Monday */ - today.getDay()) * DAY; | |
| const weekdays = [ | |
| "sun", | |
| "mon", | |
| "tue", | |
| "wed", |
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
| module.exports = { | |
| root: true, | |
| parser: '@typescript-eslint/parser' | |
| plugins: [ | |
| 'nk' | |
| ], | |
| extends: [ ], | |
| settings: { }, | |
| rules: { | |
| 'nk/print-ast': 'error' |
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 { keys } from 'ts-transformer-keys'; | |
| export type ConvertibleToNumber<T> = { | |
| [K in keyof T]: number | string; | |
| }; | |
| function isNumeric(value: string): boolean { | |
| return isFinite(parseFloat(value)); | |
| } |
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
| export function record(type: string, object: any) { | |
| const recordsByType: Record<string, any[]> = global.___recorded || {} | |
| if (!global.___recorded) { | |
| global.___recorded = recordsByType | |
| } | |
| if (!recordsByType[type]) { | |
| recordsByType[type] = [] | |
| } | |
| recordsByType[type].push(object) |
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 { v4 } from 'uuid'; | |
| interface IProgressMessage<T = any> { | |
| id: string; | |
| type: 'progress'; | |
| progress: T; | |
| } | |
| interface IDoneMessage<T = any> { | |
| id: string; |
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
| #!/bin/bash | |
| # brew install s3cmd@2.3.0 | |
| USERNAME=nikolas | |
| set -e | |
| CreateArchive () { | |
| # generate encryption key | |
| KEY=$(openssl rand -base64 32) | |
| sudo -u ${USERNAME} /bin/bash <<EOT | |
| set -e |
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
| logAllEvents( | |
| el, | |
| options = { | |
| excludeEvents: ['mousemove', 'mouseover', 'mouseout'], | |
| onlyEvents: [], | |
| capture: false, | |
| id: '' | |
| } | |
| ) { | |
| const watchedEventTypes = [ |
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() { | |
| const serializedLS = JSON.stringify(localStorage); | |
| const template = `Object.entries(${serializedLS}).forEach((key, value) => localStorage.setItem(key, value))`; | |
| copy(template); | |
| console.log(`${template.length} bytes copies to the clipboard!`); | |
| })(); |
NewerOlder