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 extractCommitsFromPR() { | |
| return [ | |
| ...document | |
| .querySelector('#commits_bucket') | |
| .querySelectorAll('li.Box-row a.js-navigation-open'), | |
| ].map(commit => commit.textContent); | |
| } |
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
| <script lang="ts" context="module"> | |
| import * as Card from '$lib/components/ui/card'; | |
| import { List } from '$lib/components/ui/list'; | |
| import type { TUser } from '$lib/ts'; | |
| </script> | |
| <script lang="ts"> | |
| const data: Array<TUser> = [ | |
| { | |
| id: 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
| <script lang="ts" context="module"> | |
| import * as Card from '$lib/components/ui/card'; | |
| import { VirtualList } from '$lib/components/ui/virtual-list'; | |
| import type { TUser } from '$lib/ts'; | |
| </script> | |
| <script lang="ts"> | |
| const data: Array<TUser> = [ | |
| { | |
| id: 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
| /** | |
| * Represents the search keywords for a search engine. | |
| */ | |
| type TSearchKeywords = { | |
| exact: Array<string>; | |
| partial: Array<string>; | |
| exclude: Array<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
| /** | |
| * Represents a request object. | |
| */ | |
| export type TRequest = { | |
| id: number; | |
| title: string; | |
| url: string; | |
| timeout: number; | |
| }; |
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 type { Updater, Writable } from 'svelte/store'; | |
| export type ChangeFn<T> = (args: { curr: T; next: T }) => T; | |
| export const overridable = <T>(store: Writable<T>, onChange?: ChangeFn<T>) => { | |
| const update = (updater: Updater<T>, sideEffect?: (newValue: T) => void) => | |
| store.update((curr) => { | |
| const next = updater(curr); | |
| let res: T = next; | |
| if (onChange) res = onChange({ curr, next }); |
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 { AnyZodObject, ZodError, z } from 'zod'; | |
| import { fromZodError } from 'zod-validation-error'; | |
| export async function zParse<T extends AnyZodObject>( | |
| schema: T, | |
| data: any | |
| ): Promise<z.infer<T>> { | |
| try { | |
| return await schema.parseAsync(data); | |
| } catch (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
| const users = [ | |
| { id: 1, name: 'Bruno', group: 'admin' }, | |
| { id: 2, name: 'João', group: 'coder' }, | |
| { id: 3, name: 'Maria', group: 'coder' }, | |
| ]; | |
| // --- Solution 01 --- | |
| function groupBy(array, callback) { | |
| return array.reduce((accumulator, item) => { | |
| const key = callback(item); |
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 { animate } from "framer-motion"; | |
| import React, { useEffect, useRef, useState } from "react"; | |
| import "./styles.css"; | |
| function Counter({ from, to }) { | |
| const nodeRef = useRef(); | |
| useEffect(() => { | |
| const node = nodeRef.current; |
NewerOlder