Skip to content

Instantly share code, notes, and snippets.

@elzup
elzup / gh-pages.yml
Created October 9, 2019 02:40
GithubActions gh-pages deploy
name: GitHub Pages
on:
push:
branches:
- master
jobs:
build-deploy:
@elzup
elzup / trump.js
Created September 25, 2019 07:08
trump flowtype
// @flow
type Color = 'red' | 'black';
const RED = 'red';
const BLACK = 'black';
type Mark = {|name: string, color: Color|};
const SPADE: Mark = {name: 'S', color: BLACK};
const HEART: Mark = {name: 'H', color: RED};
const CLUB: Mark = {name: 'C', color: BLACK};
@elzup
elzup / has31.js
Created March 31, 2019 03:40
Does month have 31days
const has31 = month => Boolean((month & 1) ^ ((month >> 3) & 1))
test('1-12', () => {
expect(has31(1)).toMatchInlineSnapshot(`true`)
expect(has31(2)).toMatchInlineSnapshot(`false`)
expect(has31(3)).toMatchInlineSnapshot(`true`)
expect(has31(4)).toMatchInlineSnapshot(`false`)
expect(has31(5)).toMatchInlineSnapshot(`true`)
expect(has31(6)).toMatchInlineSnapshot(`false`)
expect(has31(7)).toMatchInlineSnapshot(`true`)
const has31 = month => Boolean((month & 1) ^ ((month >> 3) & 1))
test('1-12', () => {
expect(has31(1)).toMatchInlineSnapshot(`true`)
expect(has31(2)).toMatchInlineSnapshot(`false`)
expect(has31(3)).toMatchInlineSnapshot(`true`)
expect(has31(4)).toMatchInlineSnapshot(`false`)
expect(has31(5)).toMatchInlineSnapshot(`true`)
expect(has31(6)).toMatchInlineSnapshot(`false`)
expect(has31(7)).toMatchInlineSnapshot(`true`)
@elzup
elzup / wbgt.js
Last active March 4, 2019 08:28
Approximate wbgt: 近似暑さ指数(WBGT)計算式
function awbgt(tmp, hmd) {
return (
(hmd - 20) * (Math.pow(tmp - 40, 2) * -0.00025 + 0.185) +
(11 / 15) * (tmp - 25) +
17.8
)
}
@elzup
elzup / flow-to-ts-renamer.sh
Created January 3, 2019 01:46
.js to .ts with 75lb/renamer
n
@elzup
elzup / 付き合って
Created December 27, 2018 03:41
sudo ./付き合って
#!/bin/sh
[ $USER = "root" ] && echo "オッケー" || echo "ごめん無理"
@elzup
elzup / s2s.config-redux.js
Last active November 29, 2018 09:00
s2s.config-redux.js
// @flow
import path from 'path'
const cwd = process.cwd()
const getRootDir = (...x) => path.resolve(cwd, 'src', ...x)
const getTyepDir = x => getRootDir('types', x)
const rootReducerPath = getRootDir('reducer.js')
const rootActionPath = getTyepDir('action.js')
@elzup
elzup / common-page.js
Created October 24, 2018 07:57
Page container component
import { Grid, Paper } from '@material-ui/core'
export const Page = (props: Object) => (
<Grid container justify={'center'}>
<Grid item xs={12} sm={12} md={10}>
<Paper {...props} />
</Grid>
</Grid>
)
@elzup
elzup / lodash.test.js
Created October 7, 2018 10:40
lodash key map
// @flow
import _ from 'lodash'
test('works', () => {
const a = [{ id: 'foo', v: 100 }, { id: 'bar', v: 200 }]
expect(_.mapKeys(a, 'id')).toMatchInlineSnapshot(`
Object {
"bar": Object {