Skip to content

Instantly share code, notes, and snippets.

@shinaisan
shinaisan / index.js
Last active July 24, 2021 18:32
Webpack and D3 (d3.drag) Example
import * as d3 from 'd3';
var config = {
width: 640,
height: 640,
plot: {
width: 560,
height: 560,
}
};
@shinaisan
shinaisan / index.js
Last active September 13, 2018 12:07
Example of pegjs
import peg from 'pegjs';
(() => {
// Event handler
const button = document.getElementById('button-parse');
button.addEventListener('click', (evt) => {
const div = document.getElementById('div-output');
try {
// Syntax
const syntaxInput = document.getElementById('textarea-syntax');
@shinaisan
shinaisan / index.js
Last active September 11, 2018 11:05
Example of pegjs (PEG.js)
import peg from 'pegjs';
import pegSrc from './source.pegjs';
(() => {
// Event handler
const button = document.getElementById('button-parse');
button.addEventListener('click', (evt) => {
const div = document.getElementById('div-output');
try {
// Input
@shinaisan
shinaisan / index.css
Last active January 24, 2024 14:42
Example of webpack with showdown
body {
margin-top: 10px;
}
@shinaisan
shinaisan / README.md
Created September 2, 2018 04:22
Minimal Example of Logstash HTTP Input

Minimal Example of Logstash HTTP Input

Logstash

pushd $THIS_GIST_DIR
test -d data || mkdir data
test -d logs || mkdir logs
logstash --path.settings $THIS_GIST_DIR --path.logs $THIS_GIST_DIR/logs --path.data $THIS_GIST_DIR/data -f $THIS_GIST_DIR/pipeline.config
@shinaisan
shinaisan / README.md
Created September 2, 2018 04:04
Short Example of Logstash JSON Filter

Short Example of Logstash JSON Filter

Logstash

pushd $THIS_GIST_DIR
test -d data || mkdir data
test -d logs || mkdir logs
logstash --path.settings $THIS_GIST_DIR --path.logs $THIS_GIST_DIR/logs --path.data $THIS_GIST_DIR/data -f $THIS_GIST_DIR/pipeline.config
@shinaisan
shinaisan / index.js
Created September 1, 2018 13:05
Winston JSON Format Example
const { createLogger, format, transports } = require('winston');
let test = {};
test.json = (args) => {
const logger = createLogger({
format: format.combine(
format.timestamp(),
format.json()
),
@shinaisan
shinaisan / index.js
Created September 1, 2018 12:02
morgan custom format example
const express = require('express');
const fs = require('fs');
const path = require('path');
const morgan = require('morgan');
const morganFormat = (tokens, req, res) => (
JSON.stringify({
'remote-addr': tokens['remote-addr'](req),
'remote-user': tokens['remote-user'](req),
'date': tokens.date(req, res, 'iso'),
@shinaisan
shinaisan / index.js
Created August 30, 2018 00:32
Winston Custom Format Example
const { createLogger, format, transports } = require('winston');
let test = {};
const myFormat = (info) => (
JSON.stringify(info)
);
test.custom = (args) => {
const logger = createLogger({
@shinaisan
shinaisan / index.js
Created August 30, 2018 00:16
Winston transports.File Example
const { createLogger, format, transports } = require('winston');
let test = {};
test.common = (pretty, args) => {
const output = (pretty
? format.prettyPrint()
: format.simple());
const logger = createLogger({
format: format.combine(