Skip to content

Instantly share code, notes, and snippets.

@Restoration
Restoration / strictNullCheck.md
Last active August 6, 2019 03:52
strictNullCheck
@Restoration
Restoration / next.js
Created August 3, 2019 11:09
NextContext
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/31125
interface ExpressNextContext extends NextContext {
req?: express.Request;
res?: express.Response;
}
class Page extends React.Component {
static getInitialProps(ctx: ExpressNextContext) {
...
@Restoration
Restoration / index.js
Last active August 2, 2019 07:33
ContextAPI + ReactHooks
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
const productsList = [
{
sku: "first_product",
title: "Fishsticks",
price: 8.99
},
{
@Restoration
Restoration / redux.jsx
Created July 31, 2019 13:27
Redux ( React Hooks + Context API )
// https://www.simplethread.com/cant-replace-redux-with-hooks/
import React, { createContext, useReducer, useContext } from 'react';
const defaultState = {
counter: 0,
};
function reducer(state = defaultState, action = {}) {
switch (action.type) {
case 'COUNTER_INC':
// https://www.sitepoint.com/replace-redux-react-hooks-context-api/
// Define the initial state of our app
const initialState = {
contacts: [
{
id: "098",
name: "Diana Prince",
email: "[email protected]"
},
useEffect(() => {
window.addEventListener('mousemove', () => {});
// returned function will be called on component unmount
return () => {
window.removeEventListener('mousemove', () => {})
}
}, [])
@Restoration
Restoration / matrix.js
Last active July 20, 2019 00:26
matrix
/*
3
11 2 4
4 5 6
10 8 -12
*/
//11 + 5 -12 = 4
//4 + 5 + 10 = 19
( async ( ) => {
await console.log("Hello");
})();
@Restoration
Restoration / style.css
Created July 2, 2019 22:59
CSS3でボックスの角にベベル(丸くないborder-radius)をかける方法
# http://webrocketsmagazine.com/entry/20120203/css3-bevel.html
/* CSS3でボックスの角にベベル(丸くないborder-radius)をかける方法 */
.bevel {
background:
linear-gradient(45deg, transparent 10px, #0099ff 10px),
linear-gradient(135deg, transparent 10px, #0099ff 10px),
linear-gradient(225deg, transparent 10px, #0099ff 10px),
linear-gradient(315deg, transparent 10px, #0099ff 10px);
background-position: bottom left, bottom right, top right, top left;
background-size: 50% 50%;
@Restoration
Restoration / docker-compose.yml
Created June 23, 2019 21:29
Docker for WordPress
# https://docs.docker.com/compose/wordpress/
version: '3.3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment: