Skip to content

Instantly share code, notes, and snippets.

@shinaisan
shinaisan / README.md
Created August 29, 2018 12:27
Winston Timestamp Example

Winston Timestamp Example

See fecha for details of timestamp formats.

Output

$ node index.js simple a b c
info: arguments: [ 'a', 'b', 'c', [length]: 3 ] {"0":"a","1":"b","2":"c","timestamp":"2018-08-29T12:26:14.844Z"}
@shinaisan
shinaisan / index.js
Created August 29, 2018 12:22
Winston simple format example
const { createLogger, format, transports } = require('winston');
let test = {};
test.simple = () => {
const logger = createLogger({
format: format.simple(),
transports: [new transports.Console()]
});
logger.info('Hello world!');
@shinaisan
shinaisan / README.md
Last active August 25, 2018 07:31
Example of morgan log file rotation
@shinaisan
shinaisan / .gitignore
Last active August 25, 2018 07:17
Example of morgan tiny, short, common and other formats
# See https://help.github.com/ignore-files/ for more about ignoring files.
# dependencies
/node_modules
# testing
/coverage
# production
/dist
@shinaisan
shinaisan / README.md
Last active June 19, 2022 14:27
Short Example of Logstash Multiple Pipelines

Short Example of Logstash Multiple Pipelines

This gist is just a personal practice record of Logstash Multiple Pipelines.

The following summary assumes that the PATH contains Logstash and Filebeat executables and they run locally on localhost.

Logstash config

@shinaisan
shinaisan / greedy_set_cover.py
Created August 18, 2018 10:22
Greedy Set Cover Sample Implementation
def greedy_set_cover(universe, subsets, costs):
covered = set()
selection = []
cover_cost = 0
while (len(covered) < universe):
# Cost effectiveness
ce = [ float('inf') if len(uncovered) == 0 else (costs[i] / len(uncovered))
for i in range(len(subsets))
for uncovered in [subsets[i].difference(covered)] ]
index = min(range(len(subsets)), key = lambda i: ce[i])
@shinaisan
shinaisan / greedy_set_cover.cpp
Last active August 18, 2018 06:20
Greedy Set Cover Sample Implementation
#include <iostream>
#include <iterator>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <cassert>
@shinaisan
shinaisan / .gitignore
Last active August 18, 2018 03:58
Webpack and D3 Example 1
# See https://help.github.com/ignore-files/ for more about ignoring files.
# dependencies
/node_modules
# testing
/coverage
# production
/dist
@shinaisan
shinaisan / README.md
Last active August 18, 2018 03:21
SVG

SVG with image syntax of MD (Does not work)

SVG

Full URL with sanitize=true

SVG

@shinaisan
shinaisan / README.md
Created April 11, 2018 12:01
Example of pthread_kill

pthread_kill Example

This short program deliberately kills a thread after pthread_join so it may cause SEGV on some targets.

Compiling

gcc -pthread thread1.c