Skip to content

Instantly share code, notes, and snippets.

@masatomix
masatomix / Group Indication.ts
Last active March 19, 2020 01:03
同じ key値のデータを、配列としてまとめる。
const re: { [key: string]: any[] } = {}
const datas = [
{ key: 'a', id: 'a_id1', value: '11' },
{ key: 'a', id: 'a_id2', value: '12' },
{ key: 'a', id: 'a_id3', value: '13' },
{ key: 'b', id: 'b_id1', value: '21' },
{ key: 'b', id: 'b_id2', value: '22' },
]
for (const row of datas) {
@masatomix
masatomix / reduce.ts
Last active March 19, 2020 01:05
Reduceのサンプル. 収集するaccumulatorと初期値を設定するのが重要
const array1 = [1, 2, 3, 4,5];
const reducer = (accumulator, currentValue,index) => {
console.log(`---`)
console.log(`Index: ${index}`)
console.log(`A: ${accumulator}`)
console.log(`C: ${currentValue}`)
return {value: accumulator.value + currentValue}
return accumulator+currentValue
}
hoge(x: number, y: number, z: number): number {
return x + y + z
}
hoge_curry(x: number): (y: number) => (z: number) => number {
return (y: number): ((z: number) => number) => {
return (z: number): number => {
return x + y + z
}
}
@masatomix
masatomix / xlsx2csvString2JSON.ts
Last active March 19, 2020 00:59
Excel → CSV文字列 → JSON。any[][] を経て csv文字列を愚直に作成。csvtojson で先頭行をPropertyにJSON化。
const XlsxPopulate = require('xlsx-populate')
const workbook: any = await XlsxPopulate.fromFileAsync(inputFullPath)
const headers: string[] = workbook
.sheet(sheetName)
.usedRange()
.value()
.shift()
@masatomix
masatomix / xlsx2csvString2JSON.ts
Last active March 19, 2020 00:58
Excel → JSON。(ヘッダ中心)。any[][] を経て、ヘッダ部とデータ部を使ってJSON化。各行ごとに、ヘッダ部を左から順次走査して、同じIndexのデータ部を取得してプロパティにする
const XlsxPopulate = require('xlsx-populate')
// 指定された場合は、一行目の文字列群を使ってプロパティを作成する
const workbook: any = await XlsxPopulate.fromFileAsync(inputFullPath)
const headers: string[] = workbook
.sheet(sheetName)
.usedRange()
.value()
.shift()
@masatomix
masatomix / xlsx2csvString2JSON.ts
Last active March 19, 2020 00:59
Excel → JSON。(データ中心)any[][] を経て、ヘッダ部とデータ部を使ってJSON化。各行ごとに、データ部を左から順次走査して、同じIndexのヘッダ部を取得してプロパティにする
const XlsxPopulate = require('xlsx-populate')
// 指定された場合は、一行目の文字列群を使ってプロパティを作成する
const workbook: any = await XlsxPopulate.fromFileAsync(inputFullPath)
const headers: string[] = workbook
.sheet(sheetName)
.usedRange()
.value()
.shift()
@masatomix
masatomix / Swagger
Created December 12, 2022 11:20
Power Automateに処理させるように少しだけ修正した、UiPath Orchestrator APIのSwaggerの定義ファイル
{
"swagger": "2.0",
"info": {
"title": "UiPath.WebApi 15.0",
"description": "Orchestrator API",
"version": "15.0"
},
"host": "cloud.uipath.com",
"basePath": "/mvpjapankino/enterpriseTenant/orchestrator_/",
"schemes": [