Skip to content

Instantly share code, notes, and snippets.

View omas-public's full-sized avatar

Omas Naohiko omas-public

View GitHub Profile
import axios from "axios";
import { useState, useEffect } from "react";
const baseURL = "https://jsonplaceholder.typicode.com/users/1";
const print = JSON.stringify
const Item = ({ user }) => (
<li>{user}</li>
)
import { useEffect, useState } from "react"
import ulid from 'ulid'
import axios from 'axios'

// const Item = ({ item, role }) => (

// )
const handler = (req, res) => {
const json = {
headings: [
'日付',
'項目',
'入金',
'出金'
],
values: [
{
/*
Baseとなるjsx
*/
const MoneyBook = props => {
return (
<>
<h1>お小遣い帳</h1>
<table>
<thead>
const identity = v => v
const join = (sep = '\n') => array => array.join(sep)
const split = (sep = ' ') => string => string.split(sep)
const inputs = (file = '/dev/stdin') => {
const stream = require('fs').readFileSync(file, 'utf-8').trim()
const toArray = sep => fn => iter => Array.from(split(sep)(iter), fn)
return {
readCols: (fn = identity) => toArray(' ')(fn)(stream),
readRows: (fn = identity) => toArray('\n')(fn)(stream),
readStream: (fn = identity) => fn(stream),
const fileSync = file => {
const stream = require('fs').readFileSync(file, 'utf8').trim()
console.log(stream)
return stream
}
const fileAsync = file => {
const callback = (error, data) => data
const stream = require('fs').readFile(file, 'utf8',
callback
const fun = array => n => array.map(v => v * n)
const array = [1, 2, 3]
console.log(JSON.stringify(array.map(v => fun(array)(v))))
// 1114.js
const arr = [0, 1, 12, 24, 36]
const start = 2
const f1 = (arr, start) => {
const head = arr.slice(0, 2)
const tail = arr.slice(start + 2)
return [...head, 16, 25, ...tail]
}

標準入力は以下を使用

const stream = require('fs').readFileSync('/dev/stdin', 'utf8').trim()
// const cols = stream.split(' ')
// const lines = stream.split('\n')
// const matrix = stream.split('\n').map(line =&gt; line.split(' '))
@omas-public
omas-public / stdout_primer.md
Last active October 25, 2022 10:20
10・25のお題

【改行あり出力】1,000 行の出力

入力は以下のテンプレートを使用する

const stream = require('fs').readFileSync('/dev/stdin', 'utf8').trim()
const lines = stream.split('\n')