Skip to content

Instantly share code, notes, and snippets.

@mmitou
mmitou / decorator.ts
Created July 23, 2023 05:38
typescript decorator
export function ClassName(name: string) {
return function actualDecorator<T, U = unknown>(
constructor: new (...args: T[]) => U,
arg: ClassDecoratorContext
) {
console.log(arg);
constructor.prototype.className = name;
};
}
@mmitou
mmitou / Full.svelte
Created January 20, 2023 10:57
sveltekitでstorybookのdecolatorを使いたい時
<div class="h-80 w-full"><slot /></div>
@mmitou
mmitou / error.ts
Created July 12, 2022 09:41
型の違う関数をキーで呼び分けたい時の処理
const ErrorMessageTemplate = {
ElementNotFoundError({ elementId }: { elementId: string }) {
return `element not found: elementId=${elementId}`;
},
UserNotFoundError({ userId }: { userId: string }) {
return `user not found: userId=${userId}`;
},
};
export class AppError<
@mmitou
mmitou / init.vim
Created July 9, 2021 04:36
neovim用の設定
set hlsearch
" インデントを制御する
"" vimはインデントという概念を持っていて、以下の設定でインデントを具体化する
"" 参考: https://qiita.com/ysn/items/f4fc8f245ba50d5fb8b0
set tabstop=2 " タブ制御文字の見た目を空白2文字にする
set shiftwidth=2 " インデントの見た目を空白2文字にする
call plug#begin('~/.config/nvim/plugged')
@mmitou
mmitou / package.json
Last active June 20, 2021 09:37
ブラウザ用typescriptの設定
{
"name": "webpack-example",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
@mmitou
mmitou / index.html
Created June 1, 2021 04:52
websocketを使うwebrtc
<!DOCTYPE html>
<html>
<head>
<title>signaling</title>
</head>
<body>
<div class="video">
<video id="localVideo" width="320" height="240" style="border: 1px solid black;" autoplay></video>
<video id="remoteVideo" width="320" height="240" style="border: 1px solid black;" autoplay></video>
@mmitou
mmitou / main.go
Created May 30, 2021 06:17
不要なコードを削除
package main
import (
"context"
"errors"
"fmt"
"strings"
"time"
@mmitou
mmitou / main.go
Created May 29, 2021 09:48
redisを使うようにした
package main
import (
"context"
"errors"
"fmt"
"strings"
"time"
@mmitou
mmitou / main.go
Created May 28, 2021 04:55
部屋分けwebsocket
package main
import (
"context"
"fmt"
"time"
"github.com/gorilla/websocket"
"github.com/labstack/echo/v4"
package main
import (
"context"
"fmt"
"time"
"github.com/gorilla/websocket"
"github.com/labstack/echo/v4"