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
const findMapPromises = async <T, S> (arr: T[], predicate: (value: T, index: number, obj: T[]) => Promise<S>): Promise<S> => { | |
for (let i = 0; i < arr.length; i++) { | |
try { | |
const r = await predicate(arr[i], i, arr) | |
return r | |
} catch (e) { | |
// next. | |
} | |
} | |
return null |
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 React from 'react' | |
import { | |
Link as RouterLink, | |
LinkProps as RouterLinkProps | |
} from 'react-router-dom' | |
import MuiLink, { LinkProps as MuiLinkProps } from '@material-ui/core/Link' | |
export type LinkProps = MuiLinkProps & Pick<RouterLinkProps, 'to' | 'replace'> | |
const createLink: React.FC<LinkProps> = ({ innerRef, ...rest }) => { |
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
AWSTemplateFormatVersion: '2010-09-09' | |
Description: Static contents distribution using S3 and CloudFront with basic authentication by lambda@Edge | |
Parameters: | |
AuthUser: | |
Description: ID for basic authentication | |
Type: String | |
Default: user2018 | |
AuthPass: | |
Description: Password for basic authentication | |
Type: String |
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 { BaseContext } from 'koa' | |
declare module 'koa' { | |
interface BaseContext { | |
io: SocketIO.Server | |
} | |
} | |
export default (io: SocketIO.Server) => async ( | |
ctx: BaseContext, |
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
export const svgToPng = async (svg: SVGSVGElement) => { | |
const w = svg.getAttribute('width') | |
const h = svg.getAttribute('height') | |
if (!w || !h) { | |
throw new Error('Undefined svg size') | |
} | |
const width = parseInt(w) | |
const height = parseInt(h) |
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
func DecodeBase64(b64Str string) io.Reader { | |
r := strings.NewReader(b64Str) | |
img := base64.NewDecoder(base64.StdEncoding, r) | |
} |
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
func ConvertToJpeg(src io.Reader, dst io.Writer, quality int) error { | |
img, _, err := image.Decode(src) | |
if err != nil { | |
return err | |
} | |
opts := &jpeg.Options{Quality: quality} | |
err = jpeg.Encode(dst, img, opts) | |
if err != nil { | |
return err |
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
package test_helper | |
import ( | |
"fmt" | |
"io" | |
"net/http" | |
) | |
type BearerAuthClient struct { | |
token string |
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 React from 'react' | |
import { makeStyles } from '@material-ui/core/styles' | |
import ImageIcon from '@material-ui/icons/Image' | |
interface PlaceHolderImageProps { | |
width: number | |
height: number | |
} |
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 React, { useState, useEffect } from 'react' | |
import QRCode from 'qrcode' | |
export interface QRCodeImageProps { | |
value: string | |
} | |
const QRCodeImage: React.FC< | |
QRCodeImageProps & React.ImgHTMLAttributes<HTMLImageElement> | |
> = ({ value, ...rest }) => { | |
const [dataUrl, setDataUrl] = useState('') |