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
| 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 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
| func DecodeBase64(b64Str string) io.Reader { | |
| r := strings.NewReader(b64Str) | |
| img := base64.NewDecoder(base64.StdEncoding, r) | |
| } |
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
| 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 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 { BaseContext } from 'koa' | |
| declare module 'koa' { | |
| interface BaseContext { | |
| io: SocketIO.Server | |
| } | |
| } | |
| export default (io: SocketIO.Server) => async ( | |
| ctx: BaseContext, |
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
| 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 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 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 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 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 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
| sudo apt-get update | |
| sudo apt-get install -y libpam-google-authenticator | |
| ga_profile=$(cat << EOS | |
| #!/bin/sh | |
| if [ "$USER" != "root" ]; then | |
| if [ ! -f "$HOME/.google_authenticator" ]; then | |
| trap 'exit' SIGINT | |
| echo "Initialize google-authenticator" |
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
| module.exports = (response) => { | |
| const {headers, ...rest} = response | |
| return { | |
| ...rest, | |
| headers: { | |
| 'Access-Control-Allow-Origin': '*', | |
| ...headers | |
| } | |
| } | |
| } |
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 React, {Component} from 'react' | |
| import classNames from 'classnames' | |
| import Button from 'material-ui/Button' | |
| import Tooltip from 'material-ui/Tooltip' | |
| import { withStyles } from 'material-ui/styles' | |
| const actionMargin = 20 | |
| const actionSize = 40 |