Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
🍖

Yamada Yuki yamadayuki

💭
🍖
View GitHub Profile
@yamadayuki
yamadayuki / index.js
Last active Jul 21, 2020
hard-update
View index.js
#!/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 Dec 16, 2019
How to use OpenCensus packages in Node.js
View tracing.ts
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 Apr 3, 2019
persisted queries
View index.js
#!/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 Dec 10, 2018
check npm dependencies
View index.js
#!/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 Dec 13, 2016
The round-robin scheduling.
View queue.js
// 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 Dec 12, 2016
Reverse Polish notation implementation using Stack.
View stack.js
// 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) {
View shell_sort.js
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_D
// Test Case
// Input
// 5
// 5
// 1
// 4
// 3
// 2
View stable_sort.js
// 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
View selection_sort.js
// 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