text stringlengths 14 100k | source stringclasses 1
value | repo stringclasses 810
values | language stringclasses 13
values |
|---|---|---|---|
<|fim_suffix|> },
});
return createAggregatedQuestionEncounter(questionEncountersData);
},
},
);
<|fim_prefix|>import { z } from 'zod';
import { createAggregatedQuestionEncounter } from '~/utils/questions/server/aggregate-encounters';
import { createRouter } from '../context';
export const qu... | fim | yangshun/tech-interview-handbook | typescript |
import { z } from 'zod';
import { TRPCError } from '@trpc/server';
import { createProtectedRouter } from '../context';
import { SortOrder } from '~/types/questions.d';
export const questionsQuestionEncounterUserRouter = createProtectedRouter()
.mutation('create', {
input: z.object({
cityId: z.string().nu... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|>,
}
: {}),
...(input.countryIds.length > 0
? {
country: {
id: {
in: input.countryIds,
},
},
}
: {}),... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_prefix|>import { z } from 'zod';
import { QuestionsQuestionType, Vote } from '@prisma/client';
import { TRPCError } from '@trpc/server';
import { createProtectedRouter } from '../context';
export const questionsQuestionUserRouter = createProtectedRouter()
.mutation('create', {
input: z.object({
city... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_prefix|>import { z } from 'zod';
import { createRouter } from '../context';
import type { ResumeComment } from '~/types/resume-comments';
export const resumeCommentsRouter = createRouter().query('list', {
<|fim_suffix|>d.user.image,
name: child.user.name,
userId: child.userId,
... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_prefix|>import { z } from 'zod';
import { ResumesSection } from '@prisma/client';
import { createProtectedRouter } from '../context';
type ResumeCommentInput = Readonly<{
description: string;
resumeId: string;
section: ResumesSection;
userId: string;
}>;
export const resumesCommentsUserRouter = createP... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_prefix|>import { z } from 'zod';
import { Vote } from '@prisma/client';
import { createRouter } from '../context';
import type { ResumeCommentVote } from '~/types/resume-comments';
export const resumesCommentsVotesRouter = createRouter().query('list', {
input: z.object({
commentId: z.string(),
}),
as... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|>entId,
userId,
value,
},
update: {
value,
},
where: {
userId_commentId: { commentId, userId },
},
});
},
})
.mutation('delete', {
input: z.object({
commentId: z.string(),
}),
async resolve({ ctx... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_prefix|>import { z } from 'zod';
import { Vote } from '@prisma/client';
import type { FilterCounts } from '~/utils/resumes/resumeFilters';
import {
getWhereClauseFilters,
resumeGetFilterCounts,
} from '~/utils/resumes/resumePrismaUtils';
import { createRouter } from '../context';
import type { Resume } fro... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_prefix|>import { z } from 'zod';
import type { FilterCounts } from '~/utils/resumes/resumeFilters';
import {
getWhereClauseFilters,
resumeGetFilterCounts,
} from '~/utils/resumes/resumePrismaUtils';
import { createProtectedRouter } from '../context';
import type { Resume } from '~/types/resume';
export co... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|>= ctx.session.user.id;
return await ctx.prisma.resumesStar.delete({
where: {
userId_resumeId: {
resumeId,
userId,
},
},
});
},
})
.mutation('star', {
input: z.object({
resumeId: z.string(),
}),
async resolve(... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|> data: {
status: input.status,
text: input.text,
},
where: {
id: input.id,
},
});
},
})
.mutation('delete', {
input: z.object({
id: z.string(),
}),
async resolve({ ctx, input }) {
// TODO: Check if session u... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_prefix|>import { createRouter } from './context';
export const todosRouter = createRouter().query('list', {
async resolve({ ctx }) {
return await ctx.prisma.todo.findMan<|fim_suffix|> },
},
orderBy: {
createdAt: 'desc',
},
});
},
});
<|fim_middle|>y({
include: {... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|> const userId = ctx.session?.user?.id;
return await ctx.prisma.user.update({
data: {
email: input.email,
name: input.name,
},
where: {
id: userId,
},
});
},
},
);
<|fim_prefix|>import { z } fr<|fim_middle|>om 'zod';
impo... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|>t-any
gtag: any;
}
}
<|fim_prefix|>export {};
declare glo<|fim_middle|>bal {
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
interface Window {
// eslint-disable-next-line @typescript-eslint/no-explici<|endoftext|> | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|>e 'next-auth' {
/**
* Returned by `useSession`, `getSession` and received as a prop on the `SessionProvider` React Context
*/
type Session = {
user?: DefaultSession['user'] & {
id: string;
};
};
}
<|fim_prefix|>import type { DefaultSession } from 'next-<|fim_middle|>auth';
decla... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|>;
bonus?: Valuation | null;
id: string;
level: string;
stocks?: Valuation | null;
title: string;
totalCompensation: Valuation;
};
export type Intern = {
id: string;
internshipCycle: string;
monthlySalary: Valuation;
startYear: number;
title: string;
};
export type Reply = {
creat... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|>port type StateLocation = {
cityId?: never;
countryId: string;
stateId: string;
};
export type CountryLocation = {
cityId?: never;
countryId: string;
stateId?: never;
};
export type Location = CityLocation | CountryLocation | StateLocation;
export type AggregatedQuestionEncounter = {
comp... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_prefix|>import type { ResumesCommentVote, ResumesSection } from '@prisma/client';
/**
* Retu<|fim_suffix|>ery
*/
export type ResumeComment = Readonly<{
children: Array<ResumeComment>;
createdAt: Date;
description: string;
id: string;
parentId?: string | null;
resumeId: string;
section: ResumesSec... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|>nalInfo?: string | null;
createdAt: Date;
experience: string;
id: string;
isResolved: boolean;
isStarredByUser: boolean;
location: string;
locationId: string;
numComments: number;
numStars: number;
role: string;
title: string;
url: string;
user: string;
};
<|fim_prefix|>ex<|fim_m... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_prefix|>import clsx from 'clsx';
import type { ReactNode } from 'react';
import {
CheckCircleIcon,
ExclamationTriangleIcon,
InformationCircleIcon,
XCircleIcon,
} from '@heroicons/react/20/solid';
export type AlertVariant = 'danger' | 'info' | 'success' | 'warning';
type Props = Readonly<{
children: Re... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_prefix|>import clsx from 'clsx';
export type BadgeVariant =
| 'danger'
| 'info'
| 'primary'
| 'success'
| 'warning';
type Props = Readonly<{
endAddOn?: React.ComponentType<React.ComponentProps<'svg'>>;
label: string;
startAddOn?: React.ComponentType<React.ComponentProps<'svg'>>;
variant: Badge... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_prefix|>import clsx from 'clsx';
import React from 'react';
import { XMarkIcon } from '@heroicons/react/24/outline';
export type BannerSize = <|fim_suffix|> <XMarkIcon aria-hidden="true" className="h-6 w-6 text-white" />
</button>
</div>
)}
</div>
</div>
);
}
<|... | fim | yangshun/tech-interview-handbook | typescript |
import clsx from 'clsx';
import Link from 'next/link';
import type { HTMLAttributeAnchorTarget } from 'react';
import type { UrlObject } from 'url';
import { Spinner } from '../';
export type ButtonAddOnPosition = 'end' | 'start';
export type ButtonDisplay = 'block' | 'inline';
export type ButtonSize = 'lg' | 'md' | ... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_prefix|>import clsx from 'clsx';
import type { ChangeEvent } from 'react';
import type<|fim_suffix|> string;
label: string;
name?: string;
onChange?: (
value: boolean,
event: ChangeEvent<HTMLInputElement>,
) => undefined | void;
value?: boolean;
}>;
function CheckboxInput(
{
defaultValue,... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_prefix|>import clsx from 'clsx';
import { useId } from 'react';
import type CheckboxInput from '../CheckboxInput/CheckboxInput';
export type CheckboxListOrientation = 'horizontal' | 'vertical';
type Props = Readonly<{<|fim_suffix|>Hidden ? 'sr-only' : 'mb-2')}>
<label className="text-sm font-medium tex... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|>);
}
<|fim_prefix|>import clsx from 'clsx';
import type { ReactNode } from 'react';
import { Disclosure } from '@headlessui/react';
import { ChevronDownIcon } from '@heroicons/react/20/solid';
typ<|fim_middle|>e Props = Readonly<{
children: ReactNode;
defaultOpen?: boolean;
label: ReactNode;
}>;
e... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_prefix|>import clsx from 'clsx';
import { Fragment, useRef } from 'react';
import { Dialog as HeadlessDialog, Transition } from '@headlessui/react';
type Props = Readonly<{
children: React.ReactNode;
isShown: boolean;
onClose: () => void;
primaryButton: React.ReactNode;
secondaryButton?: React.ReactNod... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|>
const baseClasses: Record<DropdownMenuSize, string> = {
lg: 'text-base rounded-xl',
md: 'text-sm rounded-lg',
sm: 'text-xs rounded-md',
};
const sizeIconSpacingEndClasses: Record<DropdownMenuSize, string> = {
lg: 'ml-3 -mr-1',
md: 'ml-2 -mr-1',
sm: 'ml-2 -mr-0.5',
};
const sizeIconClasses: ... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_prefix|>import clsx from 'clsx';
import React from 're<|fim_suffix|> // TODO: Change to <Link> when there's a need for client-side navigation.
return <a href={href} {...props} />;
}}
</Menu.Item>
);
}
<|fim_middle|>act';
import { Menu } from '@headlessui/react';
type Props = Readonly<{
... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_prefix|>import clsx from 'clsx';
type Props = Readonly<{
className?: string;
}>;
export default function HorizontalDivider({ className }: Props) {
return (
<hr
<|fim_suffix|>, className)}
/>
);
}
<|fim_middle|> aria-hidden={true}
className={clsx('my-2 h-0 border-t border-slate-200'<|end... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|>Page(i);
}
if (lastAddedPage < end - pagePadding - 1) {
elements.push(<PaginationEllipsis key="ellipse-2" />);
}
for (let i = end - pagePadding; i <= end; i++) {
addPage(i);
}
const isPrevButtonDisabled = current === start;
const isNextButtonDisabled = current === end;
return (... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_prefix|>import clsx from 'clsx';
import type { ChangeEvent } from 'react';
import { useId } from 'react';
import { RadioListContext } from './RadioListContext';
import RadioListItem from './RadioListItem';
export type RadioListOrientation = 'horizontal' | 'vertical';
type Props<T> = Readonly<{
children: Read... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_prefix|>import type { ChangeEvent } from 'react';
import { createContext, useContext<|fim_suffix|> value: T,
event: ChangeEvent<HTMLInputElement>,
) => undefined | void;
value?: T;
};
export const RadioListContext =
createContext<RadioListContextValue<unknown> | null>(null);
export function useRadio... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_prefix|>import clsx from 'clsx';
import { useId } from 'react';
import { useRadioListContext } from './RadioListContext';
type Props<T> = Readonly<{
description?: string;
disabled?: boolean;
label: string;
value: T;
}>;
export default function RadioListItem<T>({
description,
disabled = false,
lab... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|> (
<p className="mt-2 text-sm text-danger-600" id={errorId}>
{errorMessage}
</p>
)}
</div>
);
}
export default forwardRef(Select);
<|fim_prefix|>import clsx from 'clsx';
import type { ForwardedRef, SelectHTMLAttributes } from 'react';
import { forwardRef } from 'reac... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|> size,
title,
onClose,
}: Props) {
const enterFromClass = enterFromClasses[enterFrom];
return (
<Transition.Root as={Fragment} show={isShown}>
<Dialog
as="div"
className={clsx('relative z-40', className)}
onClose={() => onClose?.()}>
<Transition.Child
... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|>t-center">{spinner}</div>;
}
return spinner;
}
<|fim_prefix|>import clsx from 'clsx';
export type SpinnerColor = 'default' | 'inherit';
export type SpinnerSize = 'lg' | 'md' | 'sm' | 'xs';
export type SpinnerDisplay = 'block' | 'inline';
type Props = Readonly<{
className?: string;
color?: Spinn... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|> undefined,
role: 'tab',
};
if (tab.href != null) {
// TODO: Allow passing in of Link component.
return (
<Link
key={String(tab.value)}
href={tab.href}
{...commonProps}
... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_prefix|>import clsx from 'clsx';
import type {
ChangeEvent,
FocusEvent,
ForwardedRef,
TextareaHTMLAttributes,
} from 'react';
import React, { forwardRef, useId } from 'react';
type Attributes = Pick<
TextareaHTMLAttributes<HTMLTextAreaElement>,
| 'autoComplete'
| 'autoFocus'
| 'disabled'
| 'max... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_prefix|>import clsx from 'clsx';
import type {
ChangeEvent,
FocusEvent,
ForwardedRef,
InputHTMLAttributes,
} from 'react';
import React, { forwardRef, useId } from 'react';
type Attributes = Pick<
InputHTMLAttributes<HTMLInputElement>,
| 'autoComplete'
| 'disabled'
| 'max'
| 'maxLength'
| 'mi... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|>.current = null;
}
function close() {
onClose();
clearTimer();
}
useEffect(() => {
timer.current = window.setTimeout(() => {
close();
}, duration);
return () => {
clearTimer();
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_prefix|>import React, { createContext, useContext, useState } from 'react';
import type { ToastMessage } from './Toast';
import Toast from './Toast';
type Context = Readonly<{
showToast: (message: ToastMessage) => void;
}>;
export const ToastContext = createContext<Context>({
// eslint-disable-next-line @t... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|>sLabelHidden
? 'sr-only'
: clsx(
'mb-1 block font-medium text-slate-700',
textSizes[textSize],
),
)}>
{label}
{required && (
<span aria-hidden="true" className="text-danger-500">
... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|>ation/Pagination';
// RadioList
export * from './RadioList/RadioList';
export { default as RadioList } from './RadioList/RadioList';
// Select
export * from './Select/Select';
export { default as Select } from './Select/Select';
// SlideOut
export * from './SlideOut/SlideOut';
export { default as SlideOut... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|>obExperienceLevel;
}> {
if (years <= 2) {
return {
label: 'Entry Level',
level: JobExperienceLevel.Entry,
};
}
if (years <= 5) {
return {
label: 'Mid Level',
level: JobExperienceLevel.Mid,
};
}
return {
label: 'Senior Level',
level: JobExperience... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_prefix|>import type { Session } from 'next-auth';
import type {
City,
Company,
Country,
OffersAnalysis,
OffersAnalysisUnit,
OffersBackground,
OffersCurrency,
OffersExperience,
OffersFullTime,
OffersIntern,
OffersOffer,
OffersProfile,
Prisma,
PrismaClient,
State,
} from '@prisma/clien... | fim | yangshun/tech-interview-handbook | typescript |
export const analysisInclusion = {
companyAnalysis: {
include: {
analysedOffer: {
include: {
company: true,
offersFullTime: {
include: {
totalCompensation: true,
},
},
offersIntern: {
include: {
m... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|>
case 'SI':
case 'SK':
case 'SM':
case 'TF':
case 'VA':
case 'WS':
case 'YT':
return Currency.EUR;
case 'GS':
case 'GB':
case 'JE':
case 'IM':
return Currency.GBP;
case 'CA':
return Currency.CAD;
case 'SG':
return Currency.SGD;
... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|> display="inline"
isLabelHidden={true}
label="Currency"
name=""
options={currencyOptions}
value={selectedCurrency}
onChange={(currency: string) => handleCurrencyChange(currency)}
/>
);
}
<|fim_prefix|>import { Select } from '~/ui';
import { Currency } from '~/uti... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|>torical API yet, so we use latest for now.
const formattedDate = 'latest';
return await fetch(
`https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@${formattedDate}/v1/${fromCurrency}.json`,
)
.then((res) => res.json())
.then((data) => value * data[toCurrency]);
};
<|fim_prefix|>// A... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_prefix|>import type { Money } from '~/components/offers/types';
import { Currency } from './CurrencyEnum';
export const baseCurrencyString = Currency.USD.toString();
export function convertMoneyToString(money: Money | undefined<|fim_suffix|>cy',
});
return `${formatter.format(value)}`;
}
<|fim_middle|>) {
... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_prefix|>/* eslint-disable @typescript-eslint/no-explicit-any */
import { FieldError } from '~/components/offers/constants';
/**
* Removes empty objects, empty strings, `null`, `undefined`, and `NaN` values from an object.
* Does not remove empty arrays.
* @param object
* @returns object without empty values... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_prefix|>export function getProfileLink(<|fim_suffix|>: string, token?: string) {
if (token) {
return `/offers/profile/${profileId}?token=${token}`;
}
return `/offers/profile/${profileId}`;
}
export function getProfileEditPath(profileId: string, token: string) {
return `/offers/profile/edit/${profileI... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|>
<|fim_prefix|>import type { Config } from 'unique-names-generator';
import { countries, names } from 'unique-names-generator';
import {
adjectives,
animals,
colors,
uniqueNamesGenerator,
} from 'unique-names-generator';
import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClie... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|>offersProfile.findMany({
where: {
profileName: uniqueName,
},
});
while (sameNameProfiles.length !== 0) {
uniqueName = uniqueNamesGenerator(customConfig);
sameNameProfiles = await prisma.offersProfile.findMany({
where: {
profileName: uniqueName,
},
});
... | fim | yangshun/tech-interview-handbook | typescript |
import type { JobType } from '@prisma/client';
import { JobTypeLabel } from '~/components/offers/constants';
import type { Location } from '~/types/offers';
export function joinWithComma(...strings: Array<string | null | undefined>) {
return strings.filter((value) => !!value).join(', ');
}
export function getLoca... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_prefix|>import { getMonth, getYear } from 'date-fns';
import type { MonthYear } from '~/components/shared/MonthYearPicker';
export function formatDate(value: Date | number | string) {
const date = new Date(value);
const month = date.toLocaleString('default', { month: 'short' });
const year = date.toLocale... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_prefix|>import { useRouter } from 'next/router';
import { useCallback, useEffect, useState } from 'react';
type SearchParamOptions<Value> = [Value] extends [string]
? {
defaultValues?: Array<Value>;
paramToString?: (value: Value) => string | null;
stringToParam?: (param: string) => Value | nu... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_prefix|>export const createValidationRegex = (
keywordArray: Array<string>,
prepend: string | null | undefined,
) => {
const sortingKeysRegex = keywordArray.join('|');
prepend = prepend != null ? prepend : '';
return new RegExp('^' + prepend + '(' + sortingKeysRegex + '<|fim_suffix|>
<|fim_middle|>)$');... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_prefix|>export type RequireAllOrNone<T><|fim_suffix|> T | { [K in keyof T]?: never };
<|fim_middle|> =<|endoftext|> | fim | yangshun/tech-interview-handbook | typescript |
<|fim_prefix|>import type {
FilterChoice,
FilterOption,
} from '~/components/questions/filter/FilterSection';
export function companyOptionToSlug(option: FilterChoice): string {
return `${option.id}_${o<|fim_suffix|>ompanyOption(slug: string): FilterOption {
const [id, label] = slug.split('_');
return {
... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|>integer target, return indices of the two numbers such that they add up. Given an array of integers nums and an integer target, return indices of the two numbers such that they add up. Given an array of integers nums andiven an array of integers nums and an integer target, return indices of the two number... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_prefix|>export default function createSlug(content: string) {
<|fim_suffix|>(^-|-$)+/g, '')
.substring(0, 100);
}
<|fim_middle|> return content
.toLowerCase()
.replace(/[^a-z0-9]+/g, '-')
.replace(/<|endoftext|> | fim | yangshun/tech-interview-handbook | typescript |
<|fim_prefix|>import type { Typeahead<|fim_suffix|>m '~/ui';
import type { Location } from '~/types/questions';
export function locationOptionToSlug(
value: Location & TypeaheadOption,
): string {
return [
value.countryId,
value.stateId,
value.cityId,
value.id,
value.label,
value.value,
... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_prefix|>import { useGoogleAnalytics } from '~/components/global/GoogleAnalytics';
import { trpc } from '../trpc';
export function useAddQuestionToListAsync() {
const { event } = useGoogleAnalytics();
const utils = trpc.useContext();
const { mutateAsync: addQuestionToListAsync } = trpc.useMutation(
'qu... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_prefix|>import type { JobTitleType } from '~/compon<|fim_suffix|> ...rest,
};
return relabeledAggregate;
}
<|fim_middle|>ents/shared/JobTitles';
import { getLabelForJobTitleType } from '~/components/shared/JobTitles';
import type { AggregatedQuestionEncounter } from '~/types/questions';
export default fun... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_prefix|>import type {
City,
Company,
Country,
QuestionsQue<|fim_suffix|>nter.company !== null) {
if (!(encounter.company.name in companyCounts)) {
companyCounts[encounter.company!.name] = 0;
}
companyCounts[encounter.company!.name] += 1;
}
if (encounter.country !== null)... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|>ogle');
return companyOptions[0];
}
<|fim_prefix|>import type { FilterChoice } from '~/components/questions/filter/FilterSection';
import useCompanyOptions from '../shared/useCompanyOptions';
export default functi<|fim_middle|>on useDefaultCompany(): FilterChoice | undefined {
const { data: companyO... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|>n';
import useLocationOptions from './useLocationOptions';
import type { Location } from '~/types/questions';
export default function useDefaultLocation():
| (FilterChoice & Location)
| undefined {
const { data: locationOptions } = useLocationOptions('singapore');
return locationOptions[0];
}
<... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|>);
return formRegister;
};
export const useSelectRegister = <TFieldValues extends FieldValues>(
register: UseFormRegister<TFieldValues>,
) => {
const formRegister = useCallback(
(...args: Parameters<typeof register>) => {
const { onChange, ...rest } = register(...args);
return {
... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|>
'locations.cities.list',
{
name: query,
},
]);
const locationOptions = useMemo(() => {
return (
locations?.map(({ id, name, state }) => ({
cityId: id,
countryId: state.country.id,
id,
label: `${name}, ${state.name}, ${state.country.name}`,
... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|>T) => {
if (status === 'authenticated') {
return callback(...args);
}
showDialog();
},
[callback, showDialog, status],
);
return protectedCallback;
};
<|fim_prefix|>import { useSession } from 'next-auth/react';
import { useCallback, useContext } from 'react';
import ... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|> if (query) {
const queryValues = Array.isArray(query) ? query : [query];
setParams(
queryValues
.map(stringToParam)
.filter((value) => value !== null) as Array<Value>,
);
} else {
// Try to load from local storage
const loc... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|> for (const revertFunction of revertFunctions) {
revertFunction();
}
};
},
query: 'questions.answers.comments.user.getVote',
setDownVoteKey: 'questions.answers.comments.user.setDownVote',
setNoVoteKey: 'questions.answers.comments.user.setNoVote',
setUpVot... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|> (const revertFunction of revertFunctions) {
revertFunction();
}
};
},
query: 'questions.answers.user.getVote',
setDownVoteKey: 'questions.answers.user.setDownVote',
setNoVoteKey: 'questions.answers.user.setNoVote',
setUpVoteKey: 'questions.answers.user.setUpVot... | fim | yangshun/tech-interview-handbook | typescript |
import type { InfiniteData } from 'react-query';
import { trpc } from '~/utils/trpc';
import useVote from './useVote';
import type { QuestionComment } from '~/types/questions';
export default function useQuestionCommentVote(id: string) {
const utils = trpc.useContext();
return useVote(id, {
idKey: 'questio... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|> id }],
prevQuestion,
);
});
}
return () => {
for (const revertFunction of revertFunctions) {
revertFunction();
}
};
},
query: 'questions.questions.user.getVote',
setDownVoteKey: 'questions.questions.user.setDownVote',
... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|>y,
{
[idKey]: id,
} as any,
],
currentData as any,
);
const voteValueChange =
getVoteValue(currentData?.vote ?? null) -
getVoteValue(previousData?.vote ?? null);
const revert = await onMutate?.(voteValu... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_prefix|>const withHref = <Props extends Record<string, unknown>>(
C<|fim_suffix|>s-visible:outline-none active:bg-slate-100"
href={href}>
<Component {...(others as unknown as Props)} />
</a>
);
};
};
export default withHref;
<|fim_middle|>omponent: React.ComponentType<Props>,
) => {... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|> filters: {
...INITIAL_FILTER_STATE,
isUnreviewed: true,
},
name: 'Unreviewed',
sortOrder: 'latest',
},
{
filters: {
...INITIAL_FILTER_STATE,
experience: [
{
id: 'entry-level',
label: 'Entry Level (0 - 2 years)',
value: 'en... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|>xperience: { in: experienceFilters },
}),
...(roleFilters.length > 0 && {
role: { in: roleFilters },
}),
...(locationFilters.length > 0 && {
locationId: { in: locationFilters },
}),
};
};
<|fim_prefix|>import type { Resume } from '~/types/resume';
export function resumeG... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|> return () => {
clearTimeout(handler);
};
}, [value, delay]);
return debouncedValue;
}
<|fim_prefix|>import { useEffect, useState } from 'react';
export default function useDebounceValue(value: string, delay: number) {
const [debouncedValue, setDebouncedValue] = useState(value);
useE... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_prefix|>import { useRouter } from 'next/router';
import { useEffect, useState } from 'react';
export const useSearchParams = <T>(name: string, defaultValue: T) => {
const [isInitialized, setIsInitialized] = useState(false);<|fim_suffix|>;
useEffect(() => {
if (router.isReady && !isInitialized) {
/... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|> id,
label: name,
value: id,
})) ?? [],
...restQuery,
};
}
<|fim_prefix|>import { trpc } from '../trpc';
export default function useCompanyOptions(query: string) {
const companies = trpc.useQuery([
'companies.list',
{
name: query,
},
]);
const { data, ... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_prefix|>import type { Country } fro<|fim_suffix|>ing appearing
// in the country name since we can't do that in Prisma.
.sort(compareCountry)
.map(({ id, name }) => ({
id,
label: name,
value: id,
}));
return {
...restQuery,
data: countryOptions,
};
}
<|fim_middle|>m ... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|>,
label,
ranking,
value: slug,
}))
.sort((a, b) => b.ranking - a.ranking);
export default function useJobTitleOptions(query: string) {
const jobTitles = sortedJobTitleOptions.filter(({ label }) =>
label.toLocaleLowerCase().includes(query.trim().toLocaleLowerCase()),
);
return j... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|>supabase = createClient(SUPABASE_URL, SUPABASE_ANON_KEY);
<|fim_prefix|>import { createClient } from '@supabase/supabase-js';
import { env } from '~/env/server.mjs';
const { SUPABASE_URL, SUPABASE_ANON_KEY } = env;
// Create a single supabase client for inte<|fim_middle|>racting with the file storage
e... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_prefix|>// Src/utils/trpc.ts
import { createReactQueryHooks } from '@trpc/react';
import type { inferProcedureInput, inferProcedureOutput } from '@trpc/server';
import type { AppRouter } from '~/server/router';
export const trpc = createReactQueryHooks<AppRouter>();
/**
* These are helper types to infer the i... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|>from '@site/src/components/SidebarAd';
export default function InDocAd() {
return (
<div className="padding-top--lg">
<SidebarAd position="in_doc" />
</div>
);
}
<|fim_prefix|>imp<|fim_middle|>ort React from 'react';
import SidebarAd <|endoftext|> | fim | yangshun/tech-interview-handbook | javascript |
<|fim_prefix|>import React from 'react';
import QuestionGroups from './QuestionGroups.json';
function DifficultyLabel({ difficulty }) {
return (
<span
style={{
<|fim_suffix|> <div className="margin-bottom--lg" key={sectionTitle}>
<h4>Week {index + 5}</h4>
<table>
... | fim | yangshun/tech-interview-handbook | javascript |
<|fim_suffix|> sitemap: {
ignorePatterns: [
'/blog/',
'/blog/a-glimpse-into-front-end-interviews/',
'/blog/are-front-end-development-skills-enough-for-a-career/',
'/blog/facebook-career-questions-and-answers/',
'/blog/importance-of-communicati... | fim | yangshun/tech-interview-handbook | javascript |
<|fim_prefix|>// Does not handle negative binary numbers.
function binToInt(binary) {
let res = 0;
for (let i = 0; i < binary.length; i++) {
res = res * 2 + +binary[i]<|fim_suffix|>inToInt('1') === parseInt('1', 2) && parseInt('1', 2) === 1);
console.log(binToInt('10') === parseInt('10', 2) && parseInt('10', 2)... | fim | yangshun/tech-interview-handbook | javascript |
<|fim_suffix|> 10], 0) === -1);
console.log(binarySearch([1, 2, 3, 10], 11) === -1);
console.log(binarySearch([5, 7, 8, 10], 3) === -1);
<|fim_prefix|>function binarySearch(arr, target) {
let left = 0;
let right = arr.length - 1;
while (left <= right) {
const mid = left + Math.floor((right - left) / 2);
i... | fim | yangshun/tech-interview-handbook | javascript |
function deepEqual(val1, val2) {
if (typeof val1 !== typeof val2) {
return false;
}
// Array comparison.
if (Array.isArray(val1) && Array.isArray(val2)) {
if (val1.length !== val2.length) {
return false;
}
for (let i = 0; i < val1.length; i++) {
if (!deepEqual(val1[i], val2[i])) {
... | fim | yangshun/tech-interview-handbook | javascript |
<|fim_suffix|>
for (let outgoing_id of nodes.get(node_id).out) {
nodes.get(outgoing_id).in -= 1;
if (nodes.get(outgoing_id).in === 0) {
queue.push(outgoing_id);
}
}
order.push(node_id);
}
return order.length == numberNodes ? order : [];
}
console.log(
graphTopoSort(3, [
... | fim | yangshun/tech-interview-handbook | javascript |
// Does not handle negative numbers.
function intToBin(number) {
if (number === 0) {
return '0';
}
let res = '';
while (number > 0) {
res = String(number % 2) + res;
number = parseInt(number / 2, 10);
}
return res;
}
console.log(intToBin(0) === (0).toString(2) && (0).toString(2) === '0');
conso... | fim | yangshun/tech-interview-handbook | javascript |
<|fim_suffix|> [1, 2]) === true);
<|fim_prefix|>// Interval: [start, end].
function intervalsIntersect(a, b) {
return a[0] < b[1] && b[0] < a[1];
}
console.log(intervalsIntersect([1, 2], [3, 4]) === false);
c<|fim_middle|>onsole.log(intervalsIntersect([1, 2], [2, 4]) === false);
console.log(intervalsIntersect([1, 2]... | fim | yangshun/tech-interview-handbook | javascript |
<|fim_prefix|>// Interval: [start, end].
// Merges two overlapping intervals into one.
function intervalsMerge(a, b) {
return [Math.min(a[0], b[0]), Math.max(a[1], b[1])];
}
const deepEqual = require('./deepEqual');
console.log(deepEqual(intervalsMerge([1, 2], [1, 4]), [1, 4]));
console.log(deepEqual(inte<|fim_suff... | fim | yangshun/tech-interview-handbook | javascript |
<|fim_suffix|>ence('a', 'abcde') === true);
<|fim_prefix|>function isSubsequence(s, t) {
if (s.length > t.length) {
return false;
}
let matchedLength = 0;
for (let i = 0; i < t.length; i++) {
if (matchedLength < s.length && s[matchedLength] === t[i]) {
matchedLength += 1;
}
}
return matche... | fim | yangshun/tech-interview-handbook | javascript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.