2023-04-08から1日間の記事一覧

node - sql server接続

tediousjs.github.io github.com $ node index.js db connected { deptno: 10, dname: 'ACCOUNTING', loc: 'NEW YORK' } { deptno: 20, dname: 'RESEARCH', loc: 'DALLAS' } { deptno: 30, dname: 'SALES', loc: 'CHICAGO' } { deptno: 40, dname: 'OPERATIO…

node - コマンド実行

const { exec, execSync } = require("child_process") // 非同期 exec("ls -al", (err, stdout, stedrr) => { if (err) { console.log(err) } console.log(stdout) }) // 同期 const stdout = execSync("ls -al").toString() console.log(stdout)

node - file処理

const glob = require("glob") const fs = require("fs") // ファイル一覧取得 const files = glob.sync("./work_dir/**", { nodir: true }) //console.log(files) files.forEach((f) => { console.log(`<${f}>`) console.log(fs.readFileSync(f).toString())…

jq - 条件抽出

# 抽出 $ cat sample.json | jq '.items[]' | jq 'select(.owner.type == "Organization")' or $ cat sample.json | jq '[.items[]]' | jq 'map(select(.owner.type == "Organization" or .owner.type == "User"))' or $ cat _sample.json | jq '.items[] | …

JavaScript - sample

const fs = require("fs") const data = JSON.parse(fs.readFileSync("test-data.json")) function isEqual(o, name, targets) { return targets.some((t) => { return t === o[name] }) } function isContainList(o, name, targets) { return targets.some(…