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 { GetServerSideProps } from 'next'; | |
import { getSession } from './auth/[...nextauth]'; | |
export type AddParameters< | |
TFunction extends (...args: any) => any, | |
TParameters extends [...args: any] | |
> = ( | |
...args: [...Parameters<TFunction>, ...TParameters] | |
) => ReturnType<TFunction>; |
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 copyUIntToImageData = (data: Uint8Array, imageData: ImageData) => { | |
for (let i = 0; i < data.length; i += 4) { | |
let index = data.length - i; // flip how data is read | |
imageData.data[index] = data[i]; //red | |
imageData.data[index + 1] = data[i + 1]; //green | |
imageData.data[index + 2] = data[i + 2]; //blue | |
imageData.data[index + 3] = data[i + 3]; //alpha | |
} | |
}; |
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
type Queen = { row: number; column: number }; | |
type Board = Queen[]; | |
// A solution tree is a queen and all possible board combinations that | |
// satisfy the n queens problem for that queen placement | |
type Tree = [Queen, Tree] | [Queen]; | |
// Convert a tree into a flat board | |
const getBoard = (t: Tree): Board => [ | |
t[0], |
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
/* global */ | |
#___gatsby { | |
background:#111; | |
color:#fff; | |
} | |
blockquote { | |
color:#ccc !important; | |
} |
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
body { | |
background: #000; | |
} | |
.game-container { | |
background: #444; | |
} | |
.grid-cell { | |
background: #333; |
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
body { | |
background:#000; | |
} | |
.grid-cell { | |
background: #333; | |
box-shadow: 0 0 10px inset #000; | |
} | |
.tile .tile-inner { |
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
andrewray@~/ray $ npm install -g npm@latest | |
npm WARN npm npm does not support Node.js v16.2.0 | |
npm WARN npm You should probably upgrade to a newer version of node as we | |
npm WARN npm can't make any promises that npm will work with this version. | |
npm WARN npm Supported releases of Node.js are the latest release of 6, 8, 9, 10, 11, 12, 13. | |
npm WARN npm You can find the latest version at https://nodejs.org/ | |
npm WARN registry Unexpected warning for http://registry.npmjs.org/: Miscellaneous Warning UNABLE_TO_GET_ISSUER_CERT_LOCALLY: request to https://registry.npmjs.org/npm failed, reason: unable to get local issuer certificate | |
npm WARN registry Using stale data from http://registry.npmjs.org/ due to a request error during revalidation. | |
/Users/andrewray/.nvm/versions/node/v16.2.0/bin/npm -> /Users/andrewray/.nvm/versions/node/v16.2.0/lib/node_modules/npm/bin/npm-cli.js | |
/Users/andrewray/.nvm/versions/node/v16.2.0/bin/npx -> /Users/andrewray/.nvm/versions/node/v16.2.0/lib/node_modules/npm/bin/npx-cli.js |
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 foldrLazy = (fn, initialValue, [element, ...rest]) => { | |
if (element === undefined) { | |
return initialValue; | |
} | |
const exists = () => foldrShortCircuit(fn, initialValue, rest); | |
return fn(element, exists); | |
}; | |
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 foldr = (fn, initialValue, [element, ...rest]) => { | |
if (element === undefined) { | |
return initialValue; | |
} | |
return fn(element, foldr(fn, initialValue, rest)); | |
}; |
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 queueIfRunning = originalFn => { | |
let queuedCall; | |
let isRunning; | |
const runner = async (...originalArgs) => { | |
// If currently running, queue the next run | |
if (isRunning) { | |
queuedCall = originalArgs; | |
} else { | |
isRunning = true; |
NewerOlder