Skip to content

Instantly share code, notes, and snippets.

View stfsy's full-sized avatar
🎯
Focusing

Stefan Pfaffel stfsy

🎯
Focusing
  • Siemens
  • Nuremberg, Germany
  • 04:34 (UTC +02:00)
View GitHub Profile
variable "modules" {
type = list
default = ["ai", "payments"]
}
@stfsy
stfsy / opentelemetry-exporter-setup.js
Created July 30, 2021 19:33
Setup of an opentelemetry prometheus exporter
'use strict'
const { PrometheusExporter } = require('@opentelemetry/exporter-prometheus')
const { MeterProvider } = require('@opentelemetry/metrics')
// configuration options omitted for brevity
const exporter = new PrometheusExporter({ host, port, endpoint, appendTimestamp, prefix }, () => {
console.log('Exporter now running on port', port)
})
@stfsy
stfsy / reduce-w-output-array.js
Last active July 30, 2021 19:18
Reduce the parsed output of the w command to an object
'use strict'
module.exports = (result) => {
return result.map(({ user, 'login@': login, from }) => {
return Object.assign({}, { user, login, from })
}).reduce((context, next) => {
if (!Array.isArray(context[next.user])) {
context[next.user] = []
}
context[next.user].push(next)
@stfsy
stfsy / unix-w-output-parser.js
Last active July 30, 2021 19:21
Parses the output of unix w command into an JS array containing zero or more Objects
'use strict';
module.exports = (output) => {
const lines = output.split('\n')
const columns = lines[1].split(' ').filter(column => column).map(entry => entry.toLowerCase())
const values = lines.slice(2).map(line => line.split(' ').filter(entry => entry))
return values.slice(0, values.length - 1).reduce((context, next) => {
const line = {}
next.forEach((value, index) => {
@stfsy
stfsy / dependabot.yaml
Created July 5, 2021 16:09
Dependabot configuration file to automatic Github Actions updates
# place file in .github directory of your repository
version: 2
updates:
- package-ecosystem: github-actions
assignees:
- stfsy # add yourself or other users here as you wish
directory: /
schedule:
interval: daily
@stfsy
stfsy / ssl.yaml
Last active June 6, 2021 08:37
Spring Boot most simple ssl configuration for development
server:
port: 8443
ssl:
key-store: "file:/etc/letsencrypt/live/monitoring.blauspecht.io/keystore.p12"
key-store-password: ""
key-password: ""
@stfsy
stfsy / insecure.js
Last active June 5, 2021 20:10
ExpressJS server, that redirects traffic to https and answers Lets Encrypt acme challenge webroot requests directly
'use strict'
const spdy = require('spdy')
const express = require('express')
const port = process.env.port || 8080
const app = express()
app.use('/.well-known/acme-challenge/', express.static('./certbot/.well-known/acme-challenge/', {
dotfiles: 'allow'
@stfsy
stfsy / server.js
Last active June 5, 2021 19:57
ExpressJS configuration for SSL with Let's Encrypt certificates
'use strict'
const fs = require('fs')
const constants = require('crypto').constants
const spdy = require('spdy')
const server = require('express')
const app = express()
const port = process.env.port || 3000
@stfsy
stfsy / ssl.conf
Created June 5, 2021 19:52
NGINX ssl snippets
ssl_dhparam /etc/ssl/certs/dhparam.pem;
ssl_session_timeout 1d;
ssl_session_cache shared:SSL:10m;
ssl_session_tickets off;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
ssl_stapling on;
@stfsy
stfsy / nginx.conf
Last active June 5, 2021 19:53
NGINX configuration for lets encrypt files | certbot webroot command
include snippets/ssl.conf;
client_header_buffer_size 1k;
client_max_body_size 8m;
large_client_header_buffers 4 4k;
server_tokens off;
server {
listen 8080;