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 vec(...args) { | |
| if (args.length > 4) { | |
| throw new Error('Only vectors with up to 4 elements are supported.') | |
| } | |
| const proxied = new Proxy(args, { | |
| get(t, p) { | |
| if (['x', 'r'].includes(p)) return t[0] | |
| if (['y', 'g'].includes(p)) return t[1] | |
| if (['z', 'b'].includes(p)) return t[2] | |
| if (['w', 'a'].includes(p)) return t[3] |
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 $iterate (levels, depth = 0, current = {}, acc = []) { | |
| if (depth > levels.length - 1) { | |
| acc.push({ ...current }) | |
| return acc | |
| } | |
| for (let x = 0; x < levels[depth].length; ++x) { | |
| const prop = levels[depth][x] | |
| current[prop] = `_${prop}` | |
| $iterate(levels, depth + 1, current, acc) |
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 mime from 'mime' | |
| import { getSongAudioStream } from '../../../../../_db/song' | |
| import { headers } from 'next/headers' | |
| import { clamp } from '../../../../../../utils/clamp' | |
| export async function GET ( | |
| _req: Request, | |
| { params }: { params: Promise<{ songId: string }> }, | |
| ) { | |
| const id = (await params).songId |
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 { Query } from 'mingo' | |
| import { assoc, chain, uniq } from 'ramda' | |
| const entries = { | |
| $collection: [ | |
| {}, | |
| { | |
| brandId: [ 'A' ], | |
| agencyId: [ 'C', 'D' ], | |
| }, |
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 { MongoClient } from 'mongodb' | |
| import Bluebird from 'bluebird' | |
| import { add, identity, times } from 'ramda' | |
| const client = new MongoClient('<redacted>') | |
| const db = client.db('searchtest') | |
| const limit = 1e6 | |
| const runs = 1 |
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 R = require('ramda') | |
| function nativeCycle (k) { | |
| return k.map((k) => k * Math.random()) | |
| } | |
| function ramdaCycle (k) { | |
| return R.map((k) => k * Math.random(), k) | |
| } |
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
| // env::common.js | |
| const toString = require('./src/toString') // R.string | |
| const maxScore = 100 | |
| function memorizeForMe (fn) { | |
| const cache = new Map() | |
| const cacheScore = new Map() | |
| return (...args) => { |
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 fs from 'fs' | |
| import { parse } from 'acorn' | |
| import { map, pluck, uniq } from 'ramda' | |
| // Acorn has shitty types. Have to use "any". Questioning my life choices at this point. | |
| function createAST (contents: string): acorn.Node { | |
| return parse(contents) | |
| } |
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, useRef } from 'react' | |
| function useStateWithCb <T>(initialValue?: T): StateContainer<T> { | |
| const { stateValue, setState } = useState<T>(initialValue) | |
| const nextCallback = useRef<SetStateCallback | null>(null) | |
| const updateState: SetStateCallback = (value, cb) => { | |
| nextCallback.current = cb | |
| setState(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
| type Person (initialName: string) = | |
| member this.Name = | |
| initialName | |
| member this.ChangeName (newName: string) = | |
| let nameWithPrefix = "changed" + newName | |
| this | |
| member this.DisplayName () = | |
| let printStr = printfn "%s" |
NewerOlder