Skip to content

Instantly share code, notes, and snippets.

View borisyordanov's full-sized avatar
🥐

Boris Yordanov borisyordanov

🥐
View GitHub Profile
/*
* There are 3 key problems with the React code below. Can you find them?
* Assume fetchUserProfile exists elsewhere.
*/
import { Suspense, useState, useEffect } from 'react';
const SuspensefulUserProfile = ({ userId }) => {
const [data, setData] = useState({});
useEffect(() => {
fetchUserProfile(userId).then((profile) => setData(profile));
FOR /F "tokens=* USEBACKQ" %%F IN (`tzutil /g`) DO SET PREVIOUS_TZ=%%F
PRINT %cd%
tzutil /s "UTC"
cmd.exe /c yarn test %*
tzutil /s "%PREVIOUS_TZ%"
@borisyordanov
borisyordanov / pact-vscode-snippets.json
Last active June 26, 2020 16:13
FYI `pactMatchers` comes from a custom package I use
{
"Add id match": {
"prefix": "pact_id_match",
"body": [
"pactMatchers.id(${TM_SELECTED_TEXT})"
]
},
"Add oneOf match": {
"prefix": "pact_oneOf_match",
"body": [
import { useState, useEffect } from 'react'
import { PROFILE_PHOTO_REQUIREMENTS } from '@src/constants'
import { INITIAL_MAX_SCALE } from '../constants'
import { roundToPrecision, checkPortraitAspectRatio } from '../utils'
const {
minLandscapeWidth,
minPortraitWidth,
minHeight
gf=git fetch $*
gs=git status $*
gst=git stash $*
gp=git pull $*
gc=git commit -am $*
gcn=git commit -n -am $*
gck=git checkout $*
gps=git push $*
gcm=git checkout master $*
grh=git reset --hard $*
@borisyordanov
borisyordanov / Typography.tsx
Last active December 30, 2018 18:07
[Typography.tsx]Dynamic TypeScript interfaces for styled-components themes
// Typography.tsx
import * as React from 'react';
import styled from 'styled-components';
import theme from './theme';
interface IText extends React.HTMLAttributes<HTMLElement> {
color?: keyof typeof theme.colors;
}
@borisyordanov
borisyordanov / theme.ts
Last active December 25, 2018 12:41
[theme.ts]Dynamic TypeScript interfaces for styled-components themes
// theme.ts
const theme = {
colors: {
black: '#000',
orange: '#f89f92',
pink: '#ff96db',
purple: '#181257',
white: '#fff
},
// rest of the theme goes here
function getCookie(name: string) {
const decodedCookies = decodeURIComponent(document.cookie);
const cookieList: string[] = decodedCookies.split('; ');
const cookie: string | undefined = cookieList.find(c => c.startsWith(name));
if (cookie) {
return cookie.split('=')[1];
}
return '';
}