Skip to content

Instantly share code, notes, and snippets.

View hiroppy's full-sized avatar
:octocat:
focusing on my works

Yuta Hiroto hiroppy

:octocat:
focusing on my works
View GitHub Profile
@hiroppy
hiroppy / chat.mjs
Last active March 4, 2023 12:07
communicating with chatGPT
import * as readline from 'node:readline/promises';
import { stdin as input, stdout as output } from 'node:process';
const token = "your-token";
const messages = [];
const rl = readline.createInterface({ input, output });
rl.prompt();
rl.on('line', async (line) => {
@hiroppy
hiroppy / calc.js
Created May 19, 2019 01:17
Benchmarks: Compare es5 and es2015
const { readFile } = require('fs').promises;
(async () => {
const n = 3;
/**
1 middleware
5 middleware
10 middleware
15 middleware
@hiroppy
hiroppy / permission.md
Last active May 9, 2019 17:51
list the permissions of my managed repository
@hiroppy
hiroppy / saga.md
Last active July 13, 2020 04:44
redux-saga่จญ่จˆ

ๆง‹ๆˆ่ฆ็ด 

1. ไธ€ใคใฎ่ฒฌๅ‹™ใ—ใ‹ๆŒใŸใชใ„ saga

้žๅŒๆœŸใ‚คใƒ™ใƒณใƒˆใฎๅ ดๅˆใฏใ€success ใจ failure ใ‚’ๆŒใกใพใ™ใ€‚

2. 1 ใ‚’้›†ใ‚ใฆๅ‡ฆ็†ใฎใƒ•ใƒญใƒผใ‚’ๅฎš็พฉใ™ใ‚‹ saga

ๅŸบๆœฌ็š„ใซใ“ใฎ saga ใŒ container ใ‹ใ‚‰ใ‚ณใƒผใƒซใ•ใ‚Œใพใ™ใ€‚(e.g. page ใฎใƒญใƒผใƒ‰็ญ‰)
ใ“ใ“ใงใฏ่ค‡ๆ•ฐใฎ saga ใŒๅ‡ฆ็†้ †ใซใ‹ใ‹ใ‚ŒใฆใŠใ‚Šใ€้–‹ๅง‹ใ‹ใ‚‰็ต‚ไบ†ใพใงใฎๅ‡ฆ็†ใŒๅ…จใฆๆ›ธใ‹ใ‚Œใ‚‹ใ“ใจใ‚’ๆƒณๅฎšใ—ใพใ™ใ€‚

@hiroppy
hiroppy / index.ts
Last active July 6, 2021 08:12
polling using redux-saga
import { delay } from 'redux-saga';
import { put, take, race, call, cancel, takeEvery } from 'redux-saga/effects';
import { Upload, addJob, removeJob } from '../actions/job';
function* upload(action: Upload) {
try {
const { file, jobId: id } = action.payload;
yield put(addJob({ id }));
import { Request, Response } from 'express';
import * as React from 'react';
import { Provider } from 'react-redux';
import { renderToNodeStream, renderToStaticMarkup } from 'react-dom/server';
import { StaticRouter } from 'react-router-dom';
import { ServerStyleSheet } from 'styled-components';
import { HTML } from '../HTML';
import { Router } from '../../client/Router';
import { configureStore } from '../../client/store/configureStore';
import { rootSaga } from '../../client/sagas';
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@hiroppy
hiroppy / URLSearchParams.js
Last active March 24, 2017 10:31
WHATWG URL
const { URLSearchParams } = require('url');
const params = new URLSearchParams('foo=bar&hoge=fuga&foo=baz');
// URLSearchParams { 'foo' => 'bar', 'foo' => 'baz', 'hoge' => 'fuga' }
console.log(params.toString()); // foo=bar&foo=baz&hoge=fuga
params.sort();
// URLSearchParams { 'foo' => 'bar', 'foo' => 'baz', 'hoge' => 'fuga' }
console.log(params.toString()); // foo=bar&foo=baz&hoge=fuga
@hiroppy
hiroppy / translateHumanToCat
Last active August 29, 2015 14:07
ใฒใ‚‰ใŒใชใ€่‹ฑ่ชžใ‚’็Œซ่ชžใซๅค‰ๆ›ใ™ใ‚‹
{'ใ‚':'ใซใ‚‡ใซใซใ‚ƒใใซใ‚…'},
{'ใ„':'ใซใ‚‡ใซใซใ‚ƒใใซใ‚ƒใ'},
{'ใ†':'ใซใ‚‡ใซใซใ‚ƒใใซใ‚ƒใƒผ'},
{'ใˆ':'ใซใ‚‡ใซใซใ‚ƒใใซใ‚ƒใ‚ใ‚“'},
{'ใŠ':'ใซใ‚‡ใซใซใ‚ƒใใซใ‚ƒใƒผใ‚“'},
{'ใ‹':'ใซใ‚‡ใซใซใ‚ƒใใซใ‚ƒใƒผใ”'},
{'ใ':'ใซใ‚‡ใซใซใ‚ƒใใซใ‚ƒใƒผใƒผ'},
{'ใ':'ใซใ‚‡ใซใซใ‚ƒใใ—ใ‚ƒ'},
{'ใ‘':'ใซใ‚‡ใซใซใ‚ƒใ‚ใซใ‚ƒ'},