Skip to content

Instantly share code, notes, and snippets.

@hiro08gh
hiro08gh / index.tsx
Last active June 21, 2018 08:00
ReactにTypeScriptで静的型付け
import * as React from 'react';
import * as ReactDOM from 'react-dom';
interface p {
name: string;
}
class Hello extends React.Component<p> {
render() {
return <div>Hello, {this.props.name}</div>
@hiro08gh
hiro08gh / keycode.js
Created July 22, 2018 21:15
React keycode example
import React, { Component } from 'react';
export default class App extends Component {
handleKeyEnter = (e) => {
if(e.key === 'Enter') {
alert('enter')
}
}
handleKeySpace = (e) => {
@hiro08gh
hiro08gh / draw.js
Created July 5, 2018 03:47
javascript draw exam
const canvas = document.getElementById('canvas')
const ctx = canvas.getContext('2d')
/*
ctx.fillStyle = "green";
ctx.fillRect(10, 10, 100, 100);
*/
const painting = document.getElementById('paint')
const paint_style = getComputedStyle(painting)
canvas.width = parseInt(paint_style.getPropertyValue('width'))
@hiro08gh
hiro08gh / clipboard.js
Last active September 16, 2018 23:40
react-copy-to-clipboard example
import React, { Component } from 'react';
import {CopyToClipboard} from 'react-copy-to-clipboard';
import './App.css';
export default class App extends Component {
state = {
value: '',
copied: false
}
@hiro08gh
hiro08gh / canvas.js
Created September 18, 2018 08:02
Reactでcanvas属性を扱う
class CanvasComponent extends React.Component {
componentDidMount() {
this.updateCanvas();
}
updateCanvas() {
const ctx = this.refs.canvas.getContext('2d');
ctx.fillRect(0,0, 100, 100);
}
render() {
return (
@hiro08gh
hiro08gh / nginx.conf
Last active September 18, 2018 08:06
wordpress対応のセキュアなnginx.confの設定
# author kamimura
# blog https://code-log.net
# twitter https://twitter.com/kamimura_dev
#エラーページのnginxとバージョンを隠す
server_tokens off;
#インデックスページを非表示(デフォルトでoff)
autoindex off;
@hiro08gh
hiro08gh / webpack.config.js
Last active September 20, 2018 00:27
typescriptを使うためのwebpackの設定
const webpack = require('webpack');
const path = require('path');
module.exports = {
mode: 'development',
entry: './src/index.tsx',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js'
}
@hiro08gh
hiro08gh / .pretterrc
Created September 20, 2018 08:19
prettierrcの設定
{
"printWidth": 89,
"tabWidth": 2,
"useTabs": false,
"semi": false,
"singleQuote": true,
"trailingComma": "all",
"bracketSpacing": true,
"jsxBracketSameLine": false
}
@hiro08gh
hiro08gh / tsconfig.json
Last active September 21, 2018 01:27
tsconfig.jsonの設定
{
"compilerOptions": {
"outDir": "./dist/",
"sourceMap": true,
"noImplicitAny": true,
"module": "commonjs",
"target": "es6",
"jsx": "react"
},
"include": [
@hiro08gh
hiro08gh / firebase.js
Created September 22, 2018 01:49
firebase dotenv management
import firebase from 'firebase/app';
require('dotenv').config()
const Config = {
API_KEY: process.env.API_KEY,
AUTH_DOMAIN: process.env.AUTH_DOMAIN,
DATABASE_URL: process.env.DATABASE_URL,
PROJECT_ID: process.env.PROJECT_ID,
STORAGE_BUCKET: process.env.STORAGE_BUCKET,