Skip to content

Instantly share code, notes, and snippets.

View yamadayuki's full-sized avatar
💭
🍖

Yamada Yuki yamadayuki

💭
🍖
View GitHub Profile
@yamadayuki
yamadayuki / index.js
Last active July 21, 2020 12:16
hard-update
#!/usr/bin/env node
// @ts-check
const { execSync } = require("child_process");
const { manifest } = require("pacote");
const { join } = require("path");
const { promises } = require("fs");
function getPackageJsonFiles() {
return execSync("git ls-files | grep package.json")
@yamadayuki
yamadayuki / tracing.ts
Created December 16, 2019 04:30
How to use OpenCensus packages in Node.js
import { CoreTracer, Span, Tracer } from "@opencensus/core";
import { StackdriverTraceExporter } from "@opencensus/exporter-stackdriver";
import { TracingBase } from "@opencensus/nodejs-base";
import { TraceContextFormat } from "@opencensus/propagation-tracecontext";
import { Request } from "express";
import { ServerResponse } from "http";
function getOperationName(req: Request): string | undefined {
if (req.baseUrl === "/graphql" && req.method === "POST") {
return req.body.operationName;
@yamadayuki
yamadayuki / index.js
Last active April 3, 2019 09:33
persisted queries
#!/usr/bin/env node
const { version } = require('./package.json');
const { ExtractGQL } = require('persistgraphql/lib/src/ExtractGQL')
const { addTypenameTransformer } = require('persistgraphql/lib/src/queryTransformers')
const { parse, separateOperations } = require('graphql')
const { writeFileSync } = require('fs')
const { URLSearchParams } = require('url');
const yargs = require('yargs')
@yamadayuki
yamadayuki / index.js
Last active December 10, 2018 06:08
check npm dependencies
#!/usr/bin/env node
const fs = require("fs");
const path = require("path");
const madge = require("madge");
const { parse } = require("@babel/parser");
const traverse = require("@babel/traverse").default;
const { isImportDeclaration, isImportSpecifier } = require("@babel/types");
const chalk = require("chalk");
@yamadayuki
yamadayuki / queue.js
Last active December 13, 2016 04:24
The round-robin scheduling.
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_B
// Test Case
// Input
// 5 100
// p1 150
// p2 80
// p3 200
// p4 350
// p5 20
@yamadayuki
yamadayuki / stack.js
Created December 12, 2016 13:11
Reverse Polish notation implementation using Stack.
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_A
// Test Case
// Input
// 34 116 + 20 5 - 5 - 1 * +
// Output
// 160
var input = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split(' ').map(function(value) {
@yamadayuki
yamadayuki / shell_sort.js
Created December 8, 2016 20:20
Shell Sort
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_D
// Test Case
// Input
// 5
// 5
// 1
// 4
// 3
// 2
@yamadayuki
yamadayuki / stable_sort.js
Created December 8, 2016 19:29
Stable Sort
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_C
// Test Case
// Input
// 5
// H4 C9 S4 D2 C3
// Output
// D2 C3 H4 S4 C9
// Stable
@yamadayuki
yamadayuki / selection_sort.js
Created December 8, 2016 19:04
Selection Sort
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_B
// Test Case
// Input
// 6
// 5 2 4 6 1 3
// Output
// 1 2 3 4 5 6
// 3