Skip to content

Instantly share code, notes, and snippets.

@hiro08gh
hiro08gh / index.tsx
Last active August 26, 2019 06:12
TypeScriptの型定義
type Props {
text: string;
isAuth: boolean;
status: "waiting" | "success";
obj: object;
obj2: {};
obj: {
id: string;
title: string;
}
@hiro08gh
hiro08gh / index.tsx
Created August 20, 2019 03:32
hooksのuseContextの型付け
import { createContext, useContext } from 'react';
props ITheme {
backgroundColor: string;
color: string;
}
// The standard way to create context. It takes an initial value object
const ThemeContext = createContext<ITheme>({
backgroundColor: 'black',
color: 'white',
})
@hiro08gh
hiro08gh / index.tsx
Created August 20, 2019 03:27
hooksのcontext apiの型付け
type Theme = 'light' | 'dark';
const ThemeContext = createContext<Theme>('dark');
const App = () => (
<ThemeContext.Provider value="dark">
<MyComponent />
</ThemeContext.Provider>
)
const MyComponent = () => {
@hiro08gh
hiro08gh / index.tsx
Created August 20, 2019 03:01
react hooksのデータフェッチの型付け
import React, {useState, useEffect} from 'react';
import axios from 'axios';
interface ISUB {
id: number;
title: string;
}
interface IDATA extends Array<ISUB> {}
@hiro08gh
hiro08gh / index.tsx
Created August 8, 2019 05:27
react hooks simple context component
import React from 'react';
type Theme = 'light' | 'dark';
const ThemeContext = createContext<Theme>('dark');
const App = () => (
<ThemeContext.Provider value="dark">
<MyComponent />
</ThemeContext.Provider>
)
@hiro08gh
hiro08gh / nginx.conf
Created June 23, 2019 20:45
nginxのセキュアな設定
# author kamimura
# blog https://code-log.net
# twitter https://twitter.com/kamimura_dev
#エラーページのnginxとバージョンを隠す
server_tokens off;
#インデックスページを非表示(デフォルトでoff)
autoindex off;
@hiro08gh
hiro08gh / config.yml
Created June 23, 2019 20:42
SPAをs3にデプロイする際の、circleci設定
version: 2
jobs:
build:
working_directory: ~/app
docker:
- image: circleci/node:10.7.0
steps:
- checkout
- run:
name: Install system dependencies
variable "region" {
default = "us-central1"
}
provider "google" {
credentials = "${file("account.json")}"
project = ""
region = ${var.region}
}
FROM node:8.9.1-alpine as node
FROM ruby:2.6.3-alpine
MAINTAINER hiro08
COPY --from=node /opt/yarn /opt/yarn
COPY --from=node /usr/local/bin/node /usr/local/bin/
RUN ln -s /opt/yarn/bin/yarn /usr/local/bin/yarn \
&& ln -s /opt/yarn/bin/yarn /usr/local/bin/yarnpkg
@hiro08gh
hiro08gh / firebase.js
Created June 3, 2019 23:24
firebase setting
import firebase from 'firebase/app';
import 'firebase/firestore';
import 'firebase/auth';
const prodconfig = {
apiKey: 'XXX',
authDomain: 'XXX',
databaseURL: 'XXX',
projectId: 'XXX',
storageBucket: 'XXX',