Skip to content

Instantly share code, notes, and snippets.

View stfsy's full-sized avatar
🎯
Focusing

Stefan Pfaffel stfsy

🎯
Focusing
View GitHub Profile
const observer = new IntersectionObserver(callback, options)
const observer = new IntersectionObserver((entries, observer) => {
for (const entry of entries) {
if (entry.isIntersecting) {
// do something after target has become visible on screen
} else {
// do something after target has been moved off screen
}
}
}, options)
@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;
@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 / 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 / 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 / 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 / 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 / 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 / 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)