This file contains 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 convertHrtime from 'convert-hrtime'; | |
export const timeSpan = () => { | |
const start = process.hrtime(); | |
const end = (type) => convertHrtime(process.hrtime(start))[type]; | |
const returnValue = () => end('milliseconds'); | |
returnValue.rounded = () => Math.round(end('milliseconds')); | |
returnValue.seconds = () => end('seconds'); | |
returnValue.nanoseconds = () => end('nanoseconds'); |
This file contains 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 run = async () => { | |
}; | |
(async () => { | |
try { | |
await run(); | |
} catch (err) { | |
// eslint-disable-next-line | |
console.log(err); |
This file contains 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 const monkeyPatchAggregateApm = (M: Model<any>) => { | |
const aggregate = M.aggregate; | |
M.aggregate = async (pipeline: Array<any>) => { | |
const spanName = `${M.collection.collectionName}.aggregate`; | |
const span = apm.startSpan(spanName); | |
if (span) { | |
span.setLabel('pipeline', JSON.stringify(pipeline)); | |
} |
This file contains 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
<?php | |
// Set headers to allow cross-origin resource sharing (CORS) | |
header("Access-Control-Allow-Origin: *"); | |
header("Content-Type: application/json; charset=UTF-8"); | |
header("Access-Control-Allow-Methods: POST"); | |
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With"); | |
// Get the JSON data sent in the request body | |
$request_body = file_get_contents('php://input'); |
This file contains 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 useLoaderPreloadedQuery<Query> = () => { | |
const preloadedQueryRef = useLoaderData() as PreloadedQuery<Query>; | |
// clean up is important as we are using loadQuery directly without useQueryLoader | |
/ which will handle to dispose auto. | |
useEffect(() => () => preloadedQueryRef.dispose(), [preloadedQueryRef]); | |
return preloadedQueryRef | |
} |
This file contains 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 mongoose from 'mongoose'; | |
const { ObjectId } = mongoose.Types; | |
// transform all ObjectId to string | |
export const mongooseObjectIdToString = (data: any) => { | |
if (!data) { | |
return data; | |
} |
This file contains 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 Prototype = { | |
Version: '1.7', | |
Browser: (function () { | |
const ua = navigator.userAgent; | |
const isOpera = | |
Object.prototype.toString.call(window.opera) == '[object Opera]'; | |
return { | |
IE: !!window.attachEvent && !isOpera, | |
Opera: isOpera, |
This file contains 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 { ROOT_TYPE } from 'relay-runtime'; | |
import type { MissingFieldHandler } from 'relay-runtime/lib/store/RelayStoreTypes'; | |
export const missingScalarDebug = { | |
kind: 'scalar', | |
handle(field, record, args, store) { | |
// eslint-disable-next-line | |
console.log('missing scalar', { | |
field, | |
record, |
This file contains 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 const relayTransactionLogger = (event: LogEvent) => { | |
if (!isDev) { | |
return; | |
} | |
// eslint-disable-next-line | |
console.log('RELAY: ', event); | |
return; | |
} |