Skip to content

Instantly share code, notes, and snippets.

View omas-public's full-sized avatar

Omas Naohiko omas-public

View GitHub Profile
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 => 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')
const createInfo = (start, max) => {
const threads = GmailApp.getInboxThreads(start, max)
const matrix = threads.map(v => (
[
v.getId(),
v.getFirstMessageSubject(),
v.getMessageCount()
]
))
return matrix
#!/bin/sh
VERSION='90'
TUTOR_DIR="/usr/share/vim/vim$VERSION/tutor"
TUTOR_JA=$(tempfile -p 'ja')
TUTOR=$(tempfile -p 'en')
chmod +w $TUTOR
cp $TUTOR_DIR/tutor.ja.utf-8 $TUTOR_JA
cp $TUTOR_DIR/tutor $TUTOR

JangKeng App

コンピュータとじゃんけんするゲーム

  • プレイヤーは手を選択
  • コンピュータはランダムで手を選択
  • 勝敗を判定して表示

Step 1 [インターフェース表示まで]

import React, { useState, useEffect } from 'react'
const ViewForm = ({ text }) => <p>text: {text}</p>
const ActionForm = ({ fn }) => {
const [inputValue, setInputValue] = useState('')
const handleChange = (e) => {
setInputValue(e.target.value)
}
const handleClick = e => fn(inputValue)