Skip to content

Instantly share code, notes, and snippets.

View tai2's full-sized avatar
🐢

Taiju Muto tai2

🐢
View GitHub Profile
We couldn’t find that file to show.
package main
import (
"fmt"
"sync"
)
type Fetcher interface {
// Fetch returns the body of URL and
// a slice of URLs found on that page.
package main
import (
"fmt"
"golang.org/x/tour/tree"
)
//type Tree struct {
// Left *Tree
// Value int
/// <reference types="node" />
declare module 'through2-spy' {
import stream = require('stream');
function through2_spy(transform?: SpyFunction): stream.Transform;
type SpyFunction = (this: stream.Transform, chunk: any) => void;
export = through2_spy;
package main
import (
"io"
"os"
"strings"
)
type rot13Reader struct {
r io.Reader
package main
import (
"io"
"os"
"strings"
)
type rot13Reader struct {
r io.Reader
import "strings"
func WordCount(s string) map[string]int {
counts := make(map[string]int)
words := strings.Fields(s)
for _, word := range words {
count, ok := counts[word]
if ok {
counts[word] = count + 1
} else {
@tai2
tai2 / errorLoggerMiddleware.ts
Created April 4, 2019 13:51
Dump stack trace to console when FSA contains an error.
import { Dispatch } from 'redux'
type ErrorAction = { payload: Error }
function isErrorAction(action: any): action is ErrorAction {
return (<ErrorAction>action).payload instanceof Error
}
const errorLoggerMiddleware = (store: any) => (next: Dispatch) => (
action: any

2002: 出会い

エリック・レイモンドのハッカーになろうに感化されて、Pythonを使いはじめる。シンプルな構文やスライスの多機能さなどに魅了される。

2005: 遺伝的アルゴリズムによるSameGameソルバー(趣味)

大学で受講していた遺伝的アルゴリズムの講義で要求された自由課題として、Pygameを使ってSameGameを実装した上で、そのソルバーもPythonで実装した。評価関数の設計が良くなかったのか、スコアはあまり伸びなかった(ソースコード消失)。

2006: RSA公開鍵の実装(趣味)

export default function getVideoDuration(src: string): Promise<number> {
return new Promise((resolve, reject) => {
const video = document.createElement('video')
video.src = src
video.addEventListener('loadedmetadata', () => {
resolve(video.duration)
})
video.addEventListener('error', error => {
reject(error)
})