Skip to content

Instantly share code, notes, and snippets.

import { reducer, initialState } from './counter-control.reducer';
import * as CounterControlActions from './counter-control.actions';
describe('CounterControl Reducer', () => {
describe('an unknown action', () => {
it('should return the previous state', () => {
const action = {} as any;
const result = reducer(initialState, action);
@mmitou
mmitou / test.ts
Created September 27, 2020 08:11
type CheckValidFn = (v: any) => ValidationErrors | null;
const createValidatorFn = (...checkValids: CheckValidFn[]): ValidatorFn => {
const check = and(...checkValids);
const validator = (control: AbstractControl) => check(control.value);
return validator;
};
const and = (...checkValids: CheckValidFn[]): CheckValidFn => {

memo

プロジェクトを作る

ng new ngrx-example
cd ngrx-example

必要なパッケージを追加しておく

@mmitou
mmitou / gist:a9559f12fa8c9df4ff531ba34ee314b0
Created August 8, 2020 08:31
echo example: bind path param using struct tag
package main
import (
"log"
"net/http"
"reflect"
"github.com/labstack/echo/v4"
)
package main
import (
"fmt"
"github.com/go-playground/validator/v10"
)
type Foo struct {
// ID string `validate:"alphanum,len=3|len=5,excludesall=abcdefghijklmnopgrstuvwxyz"`
package main
import (
"fmt"
"reflect"
)
type ID struct {
CountryName string `hoge:"hello,foo" json:"cname"`
Index int `hoge:"world" json:"hogege"`
aws dynamodb create-table \
--table-name Music \
--attribute-definitions \
AttributeName=Artist,AttributeType=S \
AttributeName=SongTitle,AttributeType=S \
--key-schema \
AttributeName=Artist,KeyType=HASH \
AttributeName=SongTitle,KeyType=RANGE \
--provisioned-throughput \
ReadCapacityUnits=10,WriteCapacityUnits=5 \
@mmitou
mmitou / .vimrc
Created May 16, 2020 10:20
vim setting for go and typescript
set hlsearch
set tabstop=2
set shiftwidth=2
set statusline=%f
set laststatus=2
set softtabstop=2
set autowrite
call plug#begin('~/.vim/plugged')
" go
@mmitou
mmitou / main.go
Created February 17, 2020 10:20
sample: OAuth2 protected resource server
package main
import (
"fmt"
"log"
"net/http"
"strings"
jwt "github.com/dgrijalva/jwt-go"
"github.com/gorilla/mux"
@mmitou
mmitou / simple_linear_regression.py
Created November 6, 2019 07:11
シンプルな線型回帰をpytorchで書いてみた。
import torch
import torch.nn as nn
import torch.optim as optim
import numpy as np
import matplotlib.pyplot as plt
# dataset
# original: f(x) = 2x + 3
dataset_size = 100