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
"use client"; | |
import { type CoinflowEnvs, CoinflowWithdraw, type SolanaWallet } from "@coinflowlabs/react"; | |
import { type Connection, PublicKey, type Transaction, type VersionedTransaction } from "@solana/web3.js"; | |
import { useEffect, useMemo, useState } from "react"; | |
// dynamic | |
import { isSolanaWallet } from "@dynamic-labs/solana"; | |
import { useDynamicContext } from "@dynamic-labs/sdk-react-core"; |
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 { Buffer } from "node:buffer"; | |
import { writeFile } from "node:fs"; | |
import * as changeCase from "change-case"; | |
import { asString, generateCsv, mkConfig } from "export-to-csv"; | |
import { z } from "zod"; | |
// schemas | |
const bigListQuerySchema = z.object({ | |
data: z.object({ | |
investors: z.object({ |
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 { stripHtml } from "string-strip-html"; | |
import { mkConfig, generateCsv, asString } from "export-to-csv"; | |
import { writeFile } from "node:fs"; | |
import { Buffer } from "node:buffer"; | |
// merge all pages (get from...) | |
const allPages = [ | |
]; | |
// parse data from all pages |
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
function hasRepeatedDigits(value: number): boolean { | |
const stringValue = String(value); | |
return new Set(stringValue).size !== stringValue.length; | |
} | |
function uniqueSum(values: number[]): number { | |
return values.reduce((accumulator, value) => hasRepeatedDigits(value) ? accumulator : accumulator + value, 0) | |
} | |
console.log(uniqueSum([1, 2, 3])) // 6 |
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
/* | |
Given an integer array arr, return the maximum difference between two successive elements in arr's sorted form. Return 0 if there's 0 or 1 elements. | |
*/ | |
function maxGap(numbers: number[]): number { | |
if ([0, 1].includes(numbers.length)) { | |
return 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
function getIsEmailValid(email: string): boolean { | |
if (!email.includes('@') || !email.includes('.')) { | |
return false; | |
} | |
const parts = email.split('@'); | |
const hasMoreThanOneAtSymbol = parts.length !== 2; | |
if (hasMoreThanOneAtSymbol) { | |
return false; |
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
/* | |
Given a number and a digit to remove from that number, | |
maximize the resulting number after the digit has been removed and print it. | |
You can choose how you want to handle a digit not existing in the number. | |
*/ | |
function removeDigit(initialNumber: number, numberToRemove: number): number { | |
const numbers: number[] = []; | |
const number = initialNumber.toString(); |
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
/* | |
Given a 2D array, write a function that flips it vertically or horizontally. | |
*/ | |
export function flip(matrix: number[][], direction: "horizontal" | "vertical") { | |
if (direction === "horizontal") { | |
return matrix.map((row) => row.toReversed()); | |
} | |
if (direction === "vertical") { |
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
function minSubs(integers: number[], k: number): number[] { | |
const sums = []; | |
for (let i = 0; i < integers.length; i++) { | |
if (i + k > integers.length) { | |
break; | |
} | |
let innerSum = 0; | |
const innerArray = []; |
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
// async helpers | |
async function requestUsbDevices() { | |
return navigator.serial.requestDevice({ filters: [] }); | |
} | |
async function getDevice() { | |
const [device] = await navigator.serial.getDevices(); | |
return Promise.resolve(device); | |
} |
NewerOlder